Floating point 浮点错误

Floating point 浮点错误,floating-point,x86-64,nasm,x87,Floating Point,X86 64,Nasm,X87,正在处理浮点堆栈上的操作: fld qword [perResult] ;load st0 with perimeter fsub qword [firstSide] ;take st0 and minus firstSide, st0= perimeter - firstSide fmul qword [perResult] ;take st0 and multiply by perimeter, st0 = difference of

正在处理浮点堆栈上的操作:

fld     qword [perResult]       ;load st0 with perimeter
fsub    qword [firstSide]       ;take st0 and minus firstSide, st0= perimeter - firstSide
fmul    qword [perResult]       ;take st0 and multiply by perimeter, st0 = difference of first equation * perimeter
fstp    qword [res1]            ;take the result off of st0 and place them into variable equation1

;setting up to take perimeter minus second side
fld     qword [perResult]       ;load up perimeter into st0
fsub    qword [secondSide]      ;take st0 and minus secondSide, st0 = perimeter - secondSide
fstp    qword [eq2]
出于某种原因,如果我注释掉方程得到eq2,我将得到上一个方程中的正确输出得到res1

但是如果我不注释等式2,我将得到一个0作为输出

对于下一个方程也是一样,出于某种原因,如果在上一个方程之后有一个函数,它会把它归零

以前有人遇到过这个问题吗

这里是打印功能

mov rdi, areaMsg    
call    print_string
xor r14,r14
movsd   xmm0,  [eq2]    ;move sumResult into xmm0 for printing
mov qword rax, 1
mov r14, [eq2]  ;move result into r14 register for printing float
call    print_float
call    print_nl
jmp Decision

我认为上面的代码没有问题。我在Windows XP下编译并运行了此文件:

bits 16
org 0x100

fld     qword [perResult]       ;load st0 with perimeter
fsub    qword [firstSide]       ;take st0 and minus firstSide, st0= perimeter - firstSide
fmul    qword [perResult]       ;take st0 and multiply by perimeter, st0 = difference of first equation * perimeter
fstp    qword [res1]            ;take the result off of st0 and place them into variable equation1

;setting up to take perimeter minus second side
fld     qword [perResult]       ;load up perimeter into st0
fsub    qword [secondSide]      ;take st0 and minus secondSide, st0 = perimeter - secondSide
fstp    qword [eq2]

ret

align 8

perResult       dq 11.0
firstSide       dq 1.0
res1            dq 0.0 ; (perResult - firstSide) * perResult = (11-1)*11 = 110
secondSide      dq 2.0
eq2             dq 0.0 ; perResult - secondSide = 11-2 = 9
在调试器中正确地计算了110和9

如果有问题,那就是代码中没有显示的问题