此反斜杠在此汇编代码中起什么作用? [英] What does this backslash do in this assembly code?
问题描述
我不确定这些推送线有什么区别. (从Linux的x86/entry/calling中删除 .h ,清除了零或零"清除.)
I am not sure what the difference is in these push lines. (trimmed down from Linux's x86/entry/calling.h, with the xor-zero clearing removed.)
.macro PUSH_AND_CLEAR_REGS rdx=%rdx rax=%rax save_ret=0
pushq \rdx
pushq \rax
pushq %r11
pushq %r12
.endm
是否都推入堆栈?还是前两条推线做些不同的事情?我在Linux上使用GNU工具链.
Do both push onto the stack? Or do the first two push lines do something different? I am on linux using the GNU toolchain.
这些行在.S
asm源文件包含的.h
文件中找到.
These lines where found in a .h
file that's included by .S
asm source files.
还有谁能告诉我这段代码的作用吗?
Also can anyone tell me what this code does?
.macro PUSH_AND_CLEAR_REGS rdx=%rdx rax=%rax save_ret=0
特别是PUSH_AND_CLEAR_REGS之后的代码.
Specifically the code after PUSH_AND_CLEAR_REGS.
推荐答案
内部 GAS .macro
,则使用\foo
引用名为foo
的宏参数.
Inside a GAS .macro
, you use \foo
to refer to a macro parameter called foo
.
您正在查看的.macro
具有3个带有默认值的参数;大概在某些用例中,他们想要保存替代值来代替RAX和RDX中的实际值.但是其余的寄存器会像平常一样保存并进行异或归零.
The .macro
you're looking at has 3 args with default values; presumably in some use-case they want to get alternate values saved in place of what's actually in RAX and RDX. But the rest of the registers get saved and xor-zeroed as normal.
因此,在宏扩展之后,是push %rdx
和push %rax
,与push %r11
和push %r12
相同.
So after macro expansion, yes it's just push %rdx
and push %rax
, same as the push %r11
and push %r12
.
IDK(如果您正在查看旧版本的Linux),但是它在其他.S
手写asm源文件中包含的.h
中,而.c
源中的不是中包含的.我为您解决了问题.
IDK if you were looking at an old version of Linux, but this is in a .h
that's included by other .S
hand-written asm source files, not by .c
sources. I fixed your question for you.
我认为关于GAS宏定义的评论对于此宏的用途非常清楚.请参阅我添加到您的问题的github链接.
I thought the comment on the GAS macro definition was was pretty clear about the purpose of this macro. See the github link I added to your question.
这篇关于此反斜杠在此汇编代码中起什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!