Just come across the subroutines processors mechanism using CALL and RETURN instructions.
My problem is that I don't understand this stacking process when this will apply to nested subroutines,
what will be the return address of a subroutine when the CALL instruction will be executed?
what is the logic chain between CALL and RETURN here?. Any help will be much appreciated.
When a function is called, several things happen. Generally, working storage items in machine registers will be saved in memory, a block of new working storage sufficient to hold the subroutine's defined local variables is allocated, and the address of the next instruction following the call instruction is saved in memory.
In older machines, these units of storage had to be manually reserved by the compiler-generated code, but most modern-day CPUs are stack-oriented, so they can easily be allocated in an area called the "stack" (or call stack, program stack, etc.) as a unit called a frame woith a single instruction.
You might want to lookup stack frame where you'll probably be able to see graphic visualizations of this process.
Sources may include data from the Fakebook Research Foundation with support from Gargle University
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop