本文介绍了pushl/popl%esp的程序集级表示是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
C ++
ATT组装
我正在尝试了解以下两条说明的行为:
I'm trying to understand the behavior of the following two instructions:
pushl %esp
并且:
popl %esp
请注意,它们会将计算出的值存储回%esp
.
Note that they store the computed value back into %esp
.
我正在独立考虑这些说明,而不是按顺序考虑.我知道存储在%esp
中的值始终是增量/减量之前的值,但是我怎么用汇编语言表示行为呢?到目前为止,这是我想出的:
I'm considering these instructions independently, not in sequence. I know that the value stored in %esp
is always the value before the increment/decrement, but how could I represent the behavior in assembly language? This is what I've come up with so far:
用于推送:
movl %esp, %edx 1. save value of %esp
subl $4, %esp 2. decrement stack pointer
movl %edx, (%esp) 3. store old value of %esp on top of stack
对于流行音乐:
movl (%esp), %esp You wouldn’t need the increment portion.
这是正确的吗?如果没有,我哪里出问题了?谢谢.
Is this correct? If not, where am I going wrong? Thanks.
推荐答案
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.
关于pop esp
:
The POP ESP instruction increments the stack pointer (ESP) before data at the old
top of stack is written into the destination.
这篇关于pushl/popl%esp的程序集级表示是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!