AT&T 语法中 (%eax) 的含义?
抱歉,我对 x86 汇编以及一般汇编是全新的。
所以我的问题是,我有类似的东西:
addl %edx,(%eax)
%eax 是一个寄存器,它保存指向某个整数的指针。我们称之为 xp
这是否意味着它在说:*xp = *xp + %edx
? (%edx
是一个整数)
我只是很困惑 addl 将在哪里存储结果。如果 %eax
是指向 int 的指针,则 (%eax)
应该是该 int 的实际值。那么addl
会将%edx+(%eax)
的结果存储在*xp
中吗?我真的很希望有人向我解释这一点!
我真的很感谢任何帮助!
You'll have to excuse me, I'm brand new to x86 assembly, and assembly in general.
So my question is, I have something like:
addl %edx,(%eax)
%eax is a register which holds a pointer to some integer. Let's call it xp
Does this mean that it's saying: *xp = *xp + %edx
? (%edx
is an integer)
I'm just confused where addl will store the result. If %eax
is a pointer to an int, then (%eax)
should be the actual value of that int. So would addl
store the result of %edx+(%eax)
in *xp
? I would really love for someone to explain this to me!
I really appreciate any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这条指令正在做你认为它正在做的事情。
大多数 x86 算术指令采用两个操作数:源和目标。在 AT&T 语法(此处使用)中,目标始终是正确的操作数。因此,使用如下指令:
将
edx
和eax
中的值相加,并将结果存储在eax
中。但是,在您的示例中,(%eax)
是一个内存操作数;这就是 AT&T 语法中括号的含义(就像 NASM 语法中的方括号)。这意味着
eax
被视为指针,因此从eax
指向的地址中取出右操作数,并将结果存储到同一地址。Yes, this instruction is doing exactly what you think it's doing.
Most x86 arithmetic instructions take two operands: a source and a destination. In AT&T syntax (used here), the destination is always the right operand. So with an instruction like:
the values in
edx
andeax
are added together and the result is stored ineax
. However, in your example,(%eax)
is a memory operand; that's what parentheses mean in AT&T syntax (like square-brackets in NASM syntax).This means that
eax
is treated as a pointer, so the right operand is taken from the address pointed to byeax
, and the result is stored to the same address.