Mail Archives: djgpp/1997/08/05/12:50:16
Hello !
I was trying out the FPU instructions (just FLD, FMUL and FST/FSTP). It
appeared that everything worked fine when I used FST but when I used FSTP,
the result went wrong, in the sense that the result is meaningless, although
sometimes it appears to have the same value as the first argument. The code
(corrected) appears below.
Also, it appears that I can't use FMUL without operands in NASM.
I would greatly appreciate any assistance.
Thanks in advance.
Chan Tze Yi
csgcty AT singnet DOT com DOT sg
PS : Please reply by email because I no longer subscribe to the mailing list.
***start of asm file***
[BITS 32]
[GLOBAL _fp]
[SECTION .text]
;extern float fp(float a,float b)
fp_a equ 8
fp_b equ 12
_fp:
push ebp
mov ebp,esp
fld dword [ebp+fp_a]
fmul dword [ebp+fp_b]
fstp dword [result] <------ this is the line
mov eax,[result]
mov esp,ebp
pop ebp
ret
[SECTION .data]
result dd 0.0
***start of cpp file***
#include <stdio.h>
extern "C" float fp(float a,float b);
void main()
{ float a=1,b;
while(a!=0)
{ scanf("%f %f",&a,&b);
printf("%f\n",fp(a,b));
}
}
- Raw text -