pgo*_*god 8 assembly gnu-assembler
我想使用气体宏在装配函数中动态创建一组标签.我想做这样的事情:
.macro set_up_jumptab_entry prefix, from=0, to=10
.quad \prefix_\item
.if \to-\from
set_up_jumptab_entry \prefix,"(\from+1)",\to
.endif
.endm
set_up_jumptab_entry myfunc 0 10
这里\ prefix_\item就像myfunction_7.现在,我可以找到许多递归调用的例子,但我还没有找到一个涉及传入宏参数的标签连接.天然气的记录很少,所以回答这个问题对我来说很难.
像
\argA\()\argB :
应该创建一个由argA和argB组成的标签.
编辑
测试\()似乎没有必要; 测试代码是:
.file "test.c"
.macro prova argA, argB
\argA\argB :
.endm
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
movl $0, %eax
popl %ecx
popl %ebp
leal -4(%ecx), %esp
prova abc, def
jmp abcdef
ret
.size main, .-main
.ident "GCC: (GNU) 4.3.2"
.section .note.GNU-stack,"",@progbits
Run Code Online (Sandbox Code Playgroud)
这只是gcc -S test.c最小C代码的输出(懒惰:D).(prova意思test是意大利语)