This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

tell me about the stack frame stuff

I have a C code.

When calling function is executed first the value 75 is pushed to the stack and then value 25 is pushed to the stack. Then return address is pushed on to the stack. Return address will be the address of the next instruction after the calling function. Right? How does the return address calculated?

Then other stuff is pushed on the stack and soething copied from sp. So sp will be pointing to the top of the stack which contains what it was set with.

Then when the called function is executed, a local variable result is created on the stack and stack will be pointing to result variable.

then values of _op1 and _op2 on the stack is referenced and value for result is computed and stored in result variable on the stack.

How is the result returned to the calling function?

Where actuslly the stack frame gets created. Is it when move sp stuff is executed?
old value of sp is stored and then it is used to reference the variables on the stack but it never changes but it changes during stack operation. Finally when returning from the
function sp is assigned its old value which is in store. Right?

How value of result is returned to main function?

Is it that registers get told to returns the results?
Why other stuff is not generally pushed to the stack while entering a function call?

0