LEA汇编指令 [英] lea assembly instruction
问题描述
我只是想确保我读这个权利:
I Just want to make sure I am reading this right:
movl 12(%ebp), %edx
leal (%edx, %edx, 4), %eax
我读的第一行: EDX = [EPB + 12]
,第二行: EAX = EDX + EDX * 4
有人能澄清?
另外,如果我有以下两行:
Also, what if I had the following two lines:
leal (%edx, %edx, 4), %eax
leal (%edx, %edx, 2), %eax
一旦执行第二行,会在 EAX
寄存器被覆盖?
以及 EAX = EDX + EDX * 4
是乘以4的地址?或地址由4的内容?
And the eax = edx + edx*4
is multiplying the address by 4? Or the contents of the address by 4?
推荐答案
不正确。在AT& T公司的语法,指定 12(%EBP)
为您提供了一个内存引用包含在的%ebp
,与另外的12偏移,即从该%EDX $ C $的c>的内容(在这种情况下)将被加载的有效地址是
的%ebp + 12
。
Incorrect. In the AT&T syntax, specifying 12(%ebp)
gives you a memory reference to the address contained in %ebp
, with an additional offset of 12, i.e. the effective address from which the contents of %edx
(in this case) will be loaded is %ebp + 12
.
您说得对第二部分,虽然。在 LEA
指令用于负载()有效地址,并可以用于地址运算,有时也有普通的算术,如果你不需要标志。
You're right about the second part, though. The LEA
instruction is used to Load (the) Effective Address, and can be used for address arithmetic and sometimes also ordinary arithmetic, if you don't need the flags.
这篇关于LEA汇编指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!