什么是组装中的堆栈框架? [英] What is stack frame in assembly?

查看:31
本文介绍了什么是组装中的堆栈框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

堆栈帧的结构是什么,在汇编中调用函数时如何使用它?

What is the structure of a stack frame and how is it used while calling functions in assembly?

推荐答案

x86-32 栈帧是通过执行创建的

The x86-32 stack frame is created by executing

function_start:
    push ebp
    mov ebp, esp

所以它可以通过 ebp 访问,看起来像

so it's accessible through ebp and looks like

ebp+00 (current_frame) : prev_frame
ebp+04                 : return_address
                         ....
prev_frame             : prev_prev_frame
prev_frame+04          : prev_return_address

通过汇编指令设计将 ebp 用于堆栈帧有一些优点,因此通常使用 ebp 寄存器访问参数和局部变量.

There is some advantages of using ebp for stack frames by assembly instruction design, so arguments and locals usually are accessed using ebp register.

这篇关于什么是组装中的堆栈框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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