X86 Build: Release movsd instruction

This is my problem:
I am trying to use scanf

(in msvcrt.dll

) to input a single floating point value in flat assembler

, then I write a simple "scanf program" like this (in C

):

#include <stdio.h>

int main() {
    float a;

    scanf("%f", &a);
    printf("Just input: %f", a);
    return 0;
}

      

then using cl.exe

to compile with an option /FA

to create an assembly file like this:

    lea eax, DWORD PTR _a$[ebp]
    push    eax
    push    OFFSET $SG2935
    call    _scanf
    add esp, 8
; Line 8
    cvtss2sd xmm0, DWORD PTR _a$[ebp]
    sub esp, 8
    movsd   QWORD PTR [esp], xmm0
    push    OFFSET $SG2936
    call    _printf
    add esp, 12                 ; 0000000cH

      

What I missed is the instruction movsd

. Here: http://faydoc.tripod.com/cpu/movsb.htm it Move doubleword at address DS:(E)SI to address ES:(E)DI

but I don't see any settings esi

, edi

there movsd

are two parameters here and in the generated source file, but in the document in the link it shouldn't. Can someone explain to me here?

+3


source to share


3 answers


I suspect the web page is less complete.

He talks about the code of the code A5

, but there are other options, such as F2 0F

that allow you to move between XMM registers and more arbitrary memory locations.



See here for details .

+5


source


There are two x86 instructions with the same name!

  • MOVS / MOVSB ​​/ MOVSW / MOVSD / MOVSQ-Move data from line to line
  • MOVSD - Move scalar value with two floating point


Check intel spec.

+11


source


This is another MOVSD instruction that is part of the SSE instructions. Here, it moves the double precision floating point value from xmm0 into memory.

+4


source







All Articles