|
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...
|