assembly - 在 Assembly 中描述 pop

标签 assembly x86 cpu-registers

<分区>

我正在研究 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/

相关文章:

assembly - 无效的有效地址计算

linux - int 0x80 是 linux 汇编程序中唯一使用的中断号吗?

linux - dmidecode 从哪里获取 SMBIOS 表?

delphi - 在程序集中获取ThreadID

linux - 汇编 - 编译器看不到我的内联更改?

c - 海湾合作委员会错误 : "unable to find a register to spill" (problems with OS's dev's inline assembly)

c++ - 在 qt whit C++ 代码中不显示汇编代码

assembly - 实现 ARMv5TE 和 VFPv1 的 ARM 处理器?

x86 - 包含x86 ARM x64二进制文件的单个NuGet软件包

assembly - 将值存储在 MIPS 的 HI 和 LO 寄存器中