Search code examples
assemblyx86cpufpu

Loading register value to FPU stack


I'm currently working on an Assembly program that makes uses of both the CPU and FPU registers. My question concerns how it is possible to load a register value to the FPU stack (namely ecx).

mov    ecx, 10d    ; Load 10 into ECX
fldpi              ; Load Pi
fild   ecx         ; This does not work, it does however for .data variables
fmul               ; Multiply

Any help would be greatly appreciated. I'm developing using Visual Studio 2015/MASM, with .386 and .model flat, STDCALL.

Best regards, Z


Solution

  • You could do:

    mov [temp_mem],ecx
    fild dword ptr [temp_mem]
    

    or

    push ecx
    fild dword ptr [esp]
    pop ecx
    

    or you could just have the constant 10 in your data section:

    .data
    ten dd 10
    .code
    fild dword ptr [ten]