x86简单mov指令
这是一个简单的问题,但我在谷歌上找不到可靠的答案。
该指令的含义是什么:
movl %eax, (%esi, %ecx, 4)
它是否将寄存器eax
中的值移动到(%esi, %ecx, 4)
也指向的内存中的值?
(%esi, %ecx, 4)
用于数组。所以它意味着 Array[Xs + 4i],其中 Xs 是数组在内存中的起点,i 只是整数数组中的偏移量。
This is a simple question but I can't find reliable answers on google.
What does this instruction mean:
movl %eax, (%esi, %ecx, 4)
Is it move the value at register eax
to the value in memory that (%esi, %ecx, 4)
is pointing too?
(%esi, %ecx, 4)
is for an array. So it means Array[Xs + 4i] where Xs is the starting point in memory for the Array and i is just an offset in the integer array.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
完全正确。这是 AT&T 语法,因此首先是源,然后是目的地。因此,它将
eax
寄存器的内容存储到内存位置esi + 4*ecx
。如果您喜欢将其视为一个数组,它会将
eax
存储到基于esi
的 4 字节对象数组的第ecx
条目>。Exactly correct. This is AT&T syntax, so the source comes first, then the destination. Thus, it stores the contents of the
eax
register to the memory locationesi + 4*ecx
.If you like to think of this as an array, it stores
eax
to theecx
th entry of an array of 4-byte objects based atesi
.是的,就是这样。在 AT&T 语法中,内存寻址写为:
offset
是一个有符号常量,指定距base
的偏移量,base
是一个寄存器,其中首先,index
是寄存器,指定在乘以multiplier
(可以是 1、2、4 或 8)后从数组开始后查看的距离 。您必须至少指定其中之一
偏移量
、基数
和索引
。要使用不带base
的index
,您需要在其前面添加一个逗号 ((, index)
)。如果您不指定multiplier
,则默认为 1。在 Intel 语法中,这写为:
这更容易理解,因为它只是一个数学问题。
Yes, that's exactly what it is. In AT&T syntax, memory addressing is written as:
offset
is a signed constant specifying the offset frombase
,base
is a register of where to start at,index
is the register specifying how far after the start of the array to look, after multiplying bymultiplier
, which can be 1, 2, 4, or 8.You must specify at least one of
offset
,base
, andindex
. To useindex
withoutbase
, you need to precede it with a comma ((, index)
). If you don't specifymultiplier
, it defaults to 1.In Intel syntax, this is written as:
This is easier to understand, since it is simply a math problem.