Yes, gdb
pointed you in the right direction: you are loading the arguments wrong. You used fldl
where the l
means double
when dealing with floating point instructions. I guess you thought the l
meant 4 bytes
. To load 4 byte floats you need the flds
instruction.
Furthermore, fsubr
expects a floating point number but you give it an integer. Solution: change .int 2
to .float 2
. Also change to fsubrs
for safety (although that is the default).
Finally, you are leaving 3 values on the fpu stack, which is not according to the expected calling convention and can cause problems later. You should only leave the return value there.