focus on linux, c/c++, lua

ESP和EBP的概念

最近一段时间在研究dbg方面的细节技术,最终也想排除困扰自己已久的一些寄存器概念。在寄存器中最重要的3个指针概念就是EIP(指令指针),EBP(frame pointer),和ESP(stack pointer)。其中,eip的概念很好理解,就是指向将要执行的指令,比如函数地址等。但ebp和esp理解起来经常会有些混淆。说实话到现在我还是没有彻底理解,不过我好像记住了一句话:

The stack pointer always points to the top (or bottom, if you prefer)of the stack. The frame pointer always points to the frame. Stack operations (e.g., push, pop, call) do not modify the frame (in a properly operating system) or the frame pointer (ever).
大概理解起来就是esp指向是栈顶的地址,而ebp指向当前动作帧,比如当前执行的函数帧,这里面用帧来理解再确切不过了。

下面转载一篇文章,有助于更深一步的加深理解。

http://lazyflai.blogspot.com/2008/07/cfunction-callstack-frame.html

另:我发现台湾的一些bloger写的技术水平要比大陆稍微高一些。早上找到两篇有用的文章均是来自台湾同胞。同一个世界,同一个中国。

posted on 2010-10-20 10:25 zuhd 阅读(1497) 评论(0)  编辑 收藏 引用 所属分类: my tips


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理