Stack / base pointers in assembly
Posted
by flyingcrab
on Stack Overflow
See other posts from Stack Overflow
or by flyingcrab
Published on 2010-04-28T01:23:41Z
Indexed on
2010/04/28
1:33 UTC
Read the original article
Hit count: 465
I know this topic has been covered ad-naseum here, and other places on the internet - but hopefully the question is a simple one as I try to get my head around assembly...
So if i understand correctly the ebp (base pointer) will point to the top of the stack, and the esp (stack pointer) will point to the bottom -- since the stack grows downward. esp therefore points to the 'current location'. So on a function call, once you've saved the ebp on the stack you insert a new stack frame - for the function. So in the case of the image below, if you started from N-3 you would go to N-2 with a function call. But when you are at N-2 - is your ebp == 25 and the esp == 24 (at least initially, before any data is placed on the stack)?
Is this correct or am I of on a tangent here?
Thanks!
© Stack Overflow or respective owner