gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 10:53:36 25 4
gpt4 key购买 nike

C++

ATT组装

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

pushl %esp

和:
popl %esp

请注意,他们将计算出的值存储回 %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

对于流行:
movl (%esp), %esp   You wouldn’t need the increment portion. 

这样对吗?如果没有,我哪里出错了?谢谢。

最佳答案

正如它所说的push espIntel® 64 and IA-32 Architectures Developer's Manual: Combined Volumes :

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.

关于assembly - pushl/popl %esp 的汇编级表示是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14968824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com