我有这个代码,假设使用_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
我得到的输出是:
该数字为0.000000
我期望的输出是:
号码是34.250000
我的代码有什么问题,以及为获得所需的输出必须做些什么?
编辑:
解决方案是:
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
正确的输出是:
号码是34.250000
@MichaelPetch非常感谢你。我很抱歉,我的英语很糟糕。