Here is a code.
I want to know what happens in the stack when it is executed?Code:void f1(int,int); int main(void) { int i,j=8; f1(i,j); return 0; } void f1(int k,int l) { int k=l+5; printf("%d",k); }
Will the steps be as follows:
1. i,j will be pushed into the stack.
2. Since f1 is called return address will be pushed into the stack.
3. Local parameters k,l will be pushed into the stack.
4. The value of k will be stored in some register.
5. Everything will be popped i.e the k,l and the stack pointer will now point to the return address.
I'm confused in 2,3 and 4 points above, will parameters k and l be pushed before return address or after the return address? Also the value of k will be stored in register or on the stack? Actually I read an article on wikipedia and that made me to think about it.
Or if someone elaborate the steps, that will be of great help.