什么是ESP和EBP寄存器? [英] What are the ESP and the EBP registers?

查看:126
本文介绍了什么是ESP和EBP寄存器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现,ESP寄存器是当前堆栈指针和EBP是当前堆栈帧的基指针。不过,我不明白这些定义(我刚开始学习如何美元汇编C $ C)。

I found that the ESP register is the current stack pointer and EBP is the base pointer for the current stack frame. However, I don't understand these definitions (I am just starting to learn how to code in assembler).

我的理解是,ESP对栈本身EBP点朝着什么是在堆栈的顶部点。但这些都只是我的猜测,他们是最有可能不正确。否则,你会像下面这样的声明是什么意思?

What I understand is that ESP points towards the stack itself and EBP points towards whatever is on top of the stack. But these are just my guesses and they are most likely incorrect. Otherwise, what would a statement like the following mean?

MOV EBP, ESP    

编辑:我觉得上面的说法是我的书错字。我觉得应该是EBX代替EBP

EDIT : I think the statement above is a typo of my book. I think it should be EBX instead of EBP

推荐答案

ESP是栈指针,EBP是/是一个堆栈帧,这样,当你输入一个函数EBP可能在这一点上获得的ESP副本,应有尽有这种情况发生之前堆栈,返回地址,在参数传递等和事情是全球该功能(本地变量)现在将静态距离为函数的持续时间的堆栈帧指针。尤其是现在可以自由地徜徉作为编译器的欲望和嵌套到其他函数时(每个需求自然是preserve的EBP)都可以使用。

esp is the stack pointer, ebp is/was for a stack frame so that when you entered a function ebp could get a copy of esp at that point, everything on the stack before that happens, return address, passed in parameters, etc and things that are global for that function (local variables) will now be a static distance away from the stack frame pointer for the duration of the function. esp is now free to wander about as the compiler desires and can be used when nesting to other functions (each needs to preserve the ebp naturally).

这是管理堆栈一个偷懒的办法。使编译调试轻松了许多,使得了解编译器更容易产生code,但烧伤可能已经否则通用寄存器。

it is a lazy way to manage the stack. makes compiler debugging a lot easier, makes understanding the code generated by the compiler easier, but burns a register that might have been otherwise general purpose.

这篇关于什么是ESP和EBP寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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