I'm new to assembly (using fasm), but pretty familiar with C. But my floating point code always return 0. I have tried using the FPU instruction set, and the SSE instruction set, but the result is always 0.0000 and I'm not sure what I'm missing. Here's what I have:
section .data
fmt db 'fv = %f',0ah,0
fv dd 5.0f
fv2 dd 2.0f
section .text
_main:
enter 0,0
; // fv*=fv2;
movss xmm0,[fv]
movss xmm1,[fv2]
mulss xmm0,xmm1
movss [fv],xmm0
push [fv]
push fmt
call _printf
However, using the Microsoft Visual C compiler and inline-assembly, the same code seems to work. Here's the applicable portion:
__asm
{
; // fv*=fv2;
movss xmm0,[fv]
movss xmm1,[fv2]
mulss xmm0,xmm1
movss [fv],xmm0
}
...printf("fv = %f\n",fv);