我试图调用printf来打印一个整数,把它打不到正确的值:
section .data
an: db 1
format: db "num: %d" , 10, 0
section .text
global main
extern printf
main:
push ebp
mov ebp,esp
mov eax, [an]
push eax
push dword format
call printf
add esp, 8
mov esp,ebp
pop ebp
mov eax, 0
ret
Run Code Online (Sandbox Code Playgroud)
此代码打印"num:1836412417"
当我尝试打印一个它有效的字符时!
section .data
an: db 'a'
format: db "num: %c" , 10, 0
section .text
global main
extern printf
main:
push ebp
mov ebp,esp
mov eax, [an]
push eax
push dword format
call printf …Run Code Online (Sandbox Code Playgroud)