Assembly PUSH/popl%esp的程序集级表示是什么?
C++ 附件总成 我试图理解以下两条指令的行为:Assembly PUSH/popl%esp的程序集级表示是什么?,assembly,x86,stack,att,Assembly,X86,Stack,Att,C++ 附件总成 我试图理解以下两条指令的行为: pushl %esp 以及: 请注意,它们将计算值存储回%esp 我在独立考虑这些说明,而不是按顺序考虑。我知道%esp中存储的值始终是递增/递减之前的值,但我如何用汇编语言表示该行为?这就是我到目前为止的想法: 对于推送: movl %esp, %edx 1. save value of %esp subl $4, %esp 2. decrement stack pointer movl %edx, (%esp) 3.
pushl %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.
这是正确的吗?如果不是,我会错在哪里?谢谢。正如它所说的
将esp推入:
关于pop esp
:
The POP ESP instruction increments the stack pointer (ESP) before data at the old
top of stack is written into the destination.
正如它所说的,将esp推入:
关于pop esp
:
The POP ESP instruction increments the stack pointer (ESP) before data at the old
top of stack is written into the destination.
我已经用x86汇编语言编写代码几十年了。我从来没有机会使用这些。我肯定它们是有定义的,但这在实践中真的很重要吗?不,我的教科书提到它从未在实践中使用过,但这是理解教学惯例的一个很好的练习。可能是。但我会花时间考虑诸如“enter”、“leave”、“cmpsd”、“lea”之类的指令,所有这些指令都会做一些明显奇怪的事情,在适当的情况下非常有用。pushl%esp
在您希望将指向堆栈缓冲区的指针传递给具有堆栈args调用约定的函数时可能非常有用。e、 g.您可以使用sub$8,%esp
/push%esp
/push$fmt
/调用scanf
从stdin读取32位代码的double
。是的,pop%esp
=mov(%esp),%esp
我已经在x86汇编程序中编写了几十年了。我从来没有机会使用这些。我肯定它们是有定义的,但这在实践中真的很重要吗?不,我的教科书提到它从未在实践中使用过,但这是理解教学惯例的一个很好的练习。可能是。但我会花时间考虑诸如“enter”、“leave”、“cmpsd”、“lea”之类的指令,所有这些指令都会做一些明显奇怪的事情,在适当的情况下非常有用。pushl%esp
在您希望将指向堆栈缓冲区的指针传递给具有堆栈args调用约定的函数时可能非常有用。e、 g.您可以使用sub$8,%esp
/push%esp
/push$fmt
/调用scanf
以32位代码从stdin读取double
。是的,pop%esp
=mov(%esp),%esp
好的,谢谢nrz。您认为我编写的程序集行为正确吗?@amorimluc您的代码在我看来是正确的,因为它与英特尔文档相匹配。好的,谢谢nrz。您认为我编写的程序集行为正确吗?@amorimluc您的代码在我看来是正确的,因为它与英特尔文档相匹配。
The POP ESP instruction increments the stack pointer (ESP) before data at the old
top of stack is written into the destination.