NASM显示与printf的一个DWORD [英] nasm displaying a dword with printf
本文介绍了NASM显示与printf的一个DWORD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的code(TEST.ASM)
this is my code (test.asm)
预计数= 1337
输出:NUM = 4199373
output: "num = 4199373"
问题:我该如何解决这个问题。
question: How do I fix it.
意图:好奇心走向汇编语言,不分配
intent: curiosity towards assembly language, not assignment.
; nasm -fwin32 test.asm
; gcc test.obj -o test
extern _printf
global _main
section .text
_main:
push num
push msg
call _printf
add esp, 8
ret
msg db 'num = %i', 0xa, 0
num dd 1337
改变推NUM
到推DWORD [NUM]
固定它。
推荐答案
推NUM
推 NUM
地址(类似推味精
),而不是值包含在那里。
push num
pushes the address of num
(similar to push msg
), but not the value contained there.
您需要推DWORD [NUM]
代替。
这篇关于NASM显示与printf的一个DWORD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文