I have this code that is suppose to print out a floating point value using _printf
:
extern _printf
global _main
section .data
mensaje: db 'The number is %f', 10, 0
numero1: db 34.25
_main:
push numero1
push mensaje
call _printf
add esp, 8
ret
The output I get is:
The number is 0.000000
The output I expect is:
The number is 34.250000
What is wrong with my code, and what must be done to get the desired output?
EDITED:
The solution is:
extern _printf
global _main
section .data
mensaje: db 'The number is %f', 10, 0
numero1: dd 34.25
section .text
_main:
sub esp, 8
fld dword [numero1]
mov ebx, numero1
fstp qword [esp]
push mensaje
call _printf
add esp, 12
ret
The correct output is:
The number is 34.250000
@MichaelPetch Thank you very much. I am sorry to everybody, my english is bad.