小编3la*_*210的帖子

在x86中调用printf来打印整数

我试图调用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)

x86 assembly printf call nasm

5
推荐指数
2
解决办法
3万
查看次数

标签 统计

assembly ×1

call ×1

nasm ×1

printf ×1

x86 ×1