AT& T语法中(%eax)的含义? [英] Meaning of (%eax) in AT&T syntax?

查看:147
本文介绍了AT& T语法中(%eax)的含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您必须原谅我,我是x86组装和一般组装的新手。

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是一个保存指向某个整数的指针的寄存器。我们称它为xp

%eax is a register which holds a pointer to some integer. Let's call it xp

这是否表示: * xp = * xp +%edx ? (%edx 是整数)

Does this mean that it's saying: *xp = *xp + %edx? (%edx is an integer)

我只是迷惑在addl存储结果的位置。如果%eax 是一个指向int的指针,则(%eax)应该是该int的实际值。因此, addl 会将%edx +(%eax)的结果存储在 * xp ?我真的很希望有人向我解释一下!

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!

我非常感谢您的帮助!

推荐答案

是的,此指令完全按照您的想法做。

Yes, this instruction is doing exactly what you think it's doing.

大多数x86算术指令采用两个操作数:源和目标。在AT& T语法(在此使用)中,目的地总是正确的操作数。因此,使用以下指令:

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:

addl %edx, %eax

edx eax 中的值相加并将结果存储在 eax 中。但是,在您的示例中,(%eax)是一个内存操作数;这就是AT& T语法中括号的含义(就像NASM语法中的方括号一样)。

the values in edx and eax are added together and the result is stored in eax. However, in your example, (%eax) is a memory operand; that's what parentheses mean in AT&T syntax (like square-brackets in NASM syntax).

这意味着 eax 被视为指针,因此从 eax 指向的地址中获取正确的操作数,并将结果存储到相同的地址。

This means that eax is treated as a pointer, so the right operand is taken from the address pointed to by eax, and the result is stored to the same address.

这篇关于AT& T语法中(%eax)的含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆