lam*_*kie 3 x86 assembly gcc gnu-assembler
我目前正在尝试理解汇编语言中宏的概念.我大学的幻灯片说明如下:
# How to define a macro:
.macro write string
movl string, %esi
call printstr
.endm
# How to use a macro:
write aString
Run Code Online (Sandbox Code Playgroud)
但是,这对我不起作用.我正在使用gcc编译我的代码.
.data
msg: .string "The result is %d.\n"
.text
.global main
.macro add_3 n
movl n, %eax
addl $3, %eax
.endm
main:
add_3 $39
pushl %eax
pushl $msg
call printf
popl %eax
popl %eax
movl $1, %eax
int $0x80
Run Code Online (Sandbox Code Playgroud)
当我尝试编译它时,我收到以下错误:
undefined reference to `n'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
| 归档时间: |
|
| 查看次数: |
3305 次 |
| 最近记录: |