什么是pushl/popl%esp的汇编级表示?

amo*_*luc 7 x86 assembly stack att

C++

ATT大会

我试图理解以下两条指令的行为:

pushl %esp
Run Code Online (Sandbox Code Playgroud)

和:

popl %esp
Run Code Online (Sandbox Code Playgroud)

请注意,它们将计算出的值存储回来%esp.

我正在独立地考虑这些指令,而不是按顺序.我知道存储的值%esp总是递增/递减之前的值,但是我怎么能用汇编语言表示行为呢?这是我到目前为止所提出的:

推送:

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
Run Code Online (Sandbox Code Playgroud)

对于pop:

movl (%esp), %esp   You wouldn’t need the increment portion. 
Run Code Online (Sandbox Code Playgroud)

它是否正确?如果没有,我哪里错了?谢谢.

nrz*_*nrz 10

正如它push esp英特尔®64和IA-32架构开发人员手册中所述:组合卷:

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.
Run Code Online (Sandbox Code Playgroud)

至于pop esp:

The POP ESP instruction increments the stack pointer (ESP) before data at the old
top of stack is written into the destination.
Run Code Online (Sandbox Code Playgroud)