>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, 김태윤 <[email protected]> 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 > [email protected] > http://lists.nongnu.org/mailman/listinfo/pgubook-readers >
_______________________________________________ Pgubook-readers mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/pgubook-readers
