Assembly AT&;T
有人能帮我理解这个命令吗:Assembly AT&;T,assembly,Assembly,有人能帮我理解这个命令吗: mov %esp,%edi lea 0x10(%edi),%esi 首先,我将esp的地址加载到edi。 然后我将edi+10的值加载到esi,这意味着esp+10的地址。 但这对堆栈意味着什么?如果我推送,我会在堆栈上写4个字节,对吗?如果我在堆栈上跳回10字节,这一点在哪里 |______| # here? |______| |______| |______| |______| |______| |______| |___*__|
mov %esp,%edi
lea 0x10(%edi),%esi
首先,我将esp
的地址加载到edi
。
然后我将edi+10
的值加载到esi
,这意味着esp+10
的地址。
但这对堆栈意味着什么?如果我推送,我会在堆栈上写4个字节,对吗?如果我在堆栈上跳回10字节,这一点在哪里
|______| # here?
|______|
|______|
|______|
|______|
|______|
|______|
|___*__| # or at the position of the star?
|______| # 4 Byte
|______| # also 4 Byte long...
|______| <---%edi
这里?
|______|
|______|
|______|
|______|
|______|
|______|
|___*__|还是在星星的位置?
|______|#4字节
|______|#也有4字节长。。。
|______|您使用的是x86,而不是x64,对吗?我将假设这一点 “这对堆栈意味着什么?” 此代码对堆栈操作没有影响(
push
,pop
,等等)。这是因为堆栈操作在esp
寄存器上作为堆栈指针工作。上面的代码没有更改,因此就堆栈而言,没有任何更改
“如果我推送,我会在堆栈上写入4个字节,对吗?”:
不一定。x86支持对16位和32位操作数执行推送操作,因此写入堆栈的字节数取决于所推送的大小。例如:
push %ax ; will push 2 bytes on the stack (sizeof(ax) == 2)
push %eax ; will push 4 bytes on the stack (sizeof(eax) == 4)
请注意,push还通过sizeof(op1)
减去esp
“如果我在堆栈上跳回10个字节,这一点在哪里?”
esi
上的lea
命令不会更改堆栈指针。所以
nop ; 10 points back on the stack here
mov %esp,%edi
lea 0x10(%edi),%esi
nop ; will be the exact same location as here.
; relative to esi, this location is (esi - 26)
0x10==16
用于记录…而16/4是4个字节的字。。。。
nop ; 10 points back on the stack here
mov %esp,%edi
lea 0x10(%edi),%esi
nop ; will be the exact same location as here.
; relative to esi, this location is (esi - 26)