<分区>
我正在研究 IA32。当我想到 popl DEST
指令在做什么时,我想到以下几点:
movl (%esp), DEST
addl $4, %esp
但是当我想到 popl %esp
时,我开始怀疑自己。尽管这可能是一条毫无意义的指令,但我认为可能有更好的方法来考虑一般性地描述 popl DEST
指令。你会如何描述它?
<分区>
我正在研究 IA32。当我想到 popl DEST
指令在做什么时,我想到以下几点:
movl (%esp), DEST
addl $4, %esp
但是当我想到 popl %esp
时,我开始怀疑自己。尽管这可能是一条毫无意义的指令,但我认为可能有更好的方法来考虑一般性地描述 popl DEST
指令。你会如何描述它?
最佳答案
以下是 Intel 文档中 POP 指令的一小部分伪代码:
IF StackAddrSize = 32
THEN
IF OperandSize = 32
THEN
DEST ← SS:ESP; (* Copy a doubleword *)
ESP ← ESP + 4;
ELSE (* OperandSize = 16*)
...
FI;
...
但这里是关于 POP xSP
的具体说明:
The POP ESP instruction increments the stack pointer (ESP) before data at the old top of stack is written into the destination.
这意味着顺序
PUSH ESP
POP ESP
没有做任何不寻常的事情,就像这个:
PUSH EAX
POP EAX
类似地,PUSH xSP
上有一些文字:
The PUSH ESP instruction pushes the value of the ESP register as it existed before the instruction was executed. If a PUSH instruction uses a memory operand in which the ESP register is used for computing the operand address, the address of the operand is computed before the ESP register is decremented.
关于assembly - 在 Assembly 中描述 pop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14918663/