Thread: stack query
View Single Post
Old Sep 16th, 2005, 6:38 AM   #1
aloksave
Programmer
 
aloksave's Avatar
 
Join Date: Sep 2005
Posts: 33
Rep Power: 0 aloksave is on a distinguished road
stack query

can anyone explain how the local variables are acessed from a stack frame of that particular function..since stacks can only push or pop values and stack pointer always points to top of the stack and the frame pointer always points to the end of the previous stack frame..how local variables are acessed?
for eg:
suppose for func temp
int temp(int a,int b);
{
int d=10;
int e,f,g;
e = d;
g = e+d;
f=g;
return(1);
}

first b will be pushed then a then the return address and the then stack frame for the func temp will start..and d,ef,g will be pushed in..but then how are these local variables acesses for assignment when only way they can come out by popping..
may be im not able to explain in proper way but can anyone if possible explain this...
aloksave is offline   Reply With Quote