I have a question about printing a floating point number and difference between a double word and quad word data. Here is my example
section .data
number dq 2.0
form db '%.2f',0
section .text
extern printf
global main:
push rbp
mov rbp,rsp
push rdi
push rsi
push rbx
movq xmm0,[number]
push qword[number]
mov rdi,form
mov rax,1
call printf
pop rbx
pop rsi
pop rdi
mov rsp,rbp
pop rbp
ret
Output is :2.0 that is ok but here is a problem if a number is double word
section .data
number dd 2.0
form db '%.2f',0
section .text
extern printf
global main:
push rbp
mov rbp,rsp
push rdi
push rsi
push rbx
movd xmm0,[number]
push qword[number]
mov rdi,form
mov rax,1
call printf
pop rbx
pop rsi
pop rdi
mov rsp,rbp
pop rbp
ret
then output is 0.00, but when I check a xmm0 register I notice that in first case the content is something like this 8_float={0x0,0x2,...},v4_double={0x2,0x0...}, and in second case is 8_float={0x2,0x0,..},v4_double={0x0,0x0,..} so that mean that printf always check a v4_double? I try to printf a double with %lf, but it is the same result 0.00, do you have some idea I try even with different move like movsd,movups,movapd,.. but that does not help me. Do you have some idea?