pgubook-readers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pgubook-readers] [Chapter 4] what is "Old %ebp" for and what is it?


From: Justis Durkee
Subject: Re: [Pgubook-readers] [Chapter 4] what is "Old %ebp" for and what is it?
Date: Thu, 7 Apr 2011 14:58:40 -0700

From the book:

"Copying the stack pointer into the base pointer at the beginning of a function
allows you to always know where your parameters are (and as we will see, local
variables too), even while you may be pushing things on and off the stack.
%ebp will always be where the stack pointer was at the beginning of the function,
so it is more or less a constant reference to the stack frame (the stack frame
consists of all of the stack variables used within a function, including parameters,
local variables, and the return address)."

So it serves as a anchor into the stack, to allow for base pointer addressing. Think of the case of nested functions, you always want an entry into the stack within the current function's context.

On Sat, Mar 19, 2011 at 6:47 PM, 김태윤 <address@hidden> wrote:
hello
I am reading programming from the ground up chapter 4, 40page
there is stack figuration which is
Parameter #N
...
Parameter 2
Parameter 1
Return Address
Old %ebp
Local Variable 1
Local Variable 2

I have no idea what "Old %ebp" for.
if %ebp is used for accessing return address and parameters, then why
don't %ebp point just return address rather than "Old %ebp"?
is it for future uses?

my question is this
Q1. what is "Old %ebp" for and what is it?
Q2. why %ebp point Old %ebp not just return address?

_______________________________________________
Pgubook-readers mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/pgubook-readers


reply via email to

[Prev in Thread] Current Thread [Next in Thread]