For each function call during run-time, the implementation has to ...
• Pass parameters from the calling function to the called function;
• Determine the return address within the caller's code;
• Save the caller's return address, stack and memory segments;
• Jump to execute the called function;
For each function return during run-time. the implementation has to...
• Return to the caller the value computed by the called function;
• Recycle the memory resources used by the called function;
• Reinstate the caller's stack and memory segments;
• Jump to the return address in the caller's code.
courtesy of http://www.onlineocr.net/. Note that bullet one above for the function (callee) means you HAVE to push a value onto the stack before returning..
VM Implementation of Call and Return
No comments:
Post a Comment