[英]How to concatenate GNU GAS macro arguments with other tokens to make single label?
I would like to dynamically create a set of labels in an assembly function using a gas macro.我想使用 gas 宏在汇编函数中动态创建一组标签。 I would like to do something like this:我想做这样的事情:
.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
Here \\prefix_\\item would be something like myfunction_7.这里的 \\prefix_\\item 类似于 myfunction_7。 Now, I can find lots of examples of recursive invocation, but I haven't found one of just label concatenation involving passed-in macro arguments.现在,我可以找到很多递归调用的例子,但我还没有找到一个涉及传入宏参数的标签串联。 Gas is quite poorly documented, so answering this question is difficult for me. Gas 的记录很差,所以回答这个问题对我来说很困难。
things like像
\argA\()\argB :
should create a label composed by argA and argB.应该创建一个由 argA 和 argB 组成的标签。
EDIT编辑
Testing, \\()
seems to be not necessary;测试, \\()
似乎没有必要; the test code was:测试代码是:
.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
which is just gcc -S test.c
output (lazyness:D) of a minimal C code.这只是最小 C 代码的gcc -S test.c
输出(懒惰:D)。 ( prova
means test
in italian) (意大利语prova
均值test
)
What's your favorite gas assembler reference?您最喜欢的气体组装商参考是什么?
The docs cover this one quite well https://sourceware.org/binutils/docs/as/Macro.html文档很好地涵盖了这一点https://sourceware.org/binutils/docs/as/Macro.html
The string `()' can be used to separate the end of a macro argument from the following text.字符串“()”可用于将宏参数的结尾与以下文本分开。 eg:例如:
.macro opcode base length \\base\\().\\length .endm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.