.data
temp real4 ?
fmtStr byte 'Result is: %d', 10, 0
fmtStr2 byte 'Result is: %f', 10, 0
i real4 ?
.code
printFloat proc
sub rsp, 20h
movsd xmm1, [temp]
lea rcx, fmtStr2
call printf
add rsp, 20h;
ret
printFloat endp
Result is always 0.0000000. How i can get value real4 like 5.3434
There are some bugs here.
tempis areal4but it should be areal8, or it can stay areal4but then we need to convert it to a double to pass it toprintf(varargs functions don't accept floats, they have to be double).The floating point argument also has to be copied in the corresponding integer argument, so
rdxin this case.Also,
20his the wrong thing to subtract fromrsp, it will leave the stack unaligned andprintfmay not like that (it didn't like that on my system). If you have that here, you may have it in other functions too, and some combinations would accidentally result in a correct alignment anyway but for the wrong reason.The code you showed never assigned a non-zero to
tempbut I assume you did that elsewhere.This code worked for me: