pushl/popl%esp的程序集级表示是什么? [英] What is an assembly-level representation of pushl/popl %esp?

查看:182
本文介绍了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.

推荐答案

关于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的程序集级表示是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆