A good answer might be:

Yes. Subroutines typically call other subroutines which call other subroutines.... and so on.

But, even if it calls another subroutine, it eventually gets control back again. Then, after it finishes, it returns to its caller.

Many Calls but One Return

The problem is illustrated at right. The main routine is written to call a useful subroutine sub at several locations in the code. But sub is written to return to only one location. Usually this will not work.

In the past, before the concept was completely understood, hardware support for subroutines was missing. Various nasty tricks were used to implement the idea.

What is needed is a method that sends the return address to the subroutine. When the subroutine finishes, it passes control to that return address.

Of course, "passing control to a return address" means to load the PC (program counter) with the return address. The next instruction fetch of the machine cycle will get the instruction from that address.


 

QUESTION 3:

(Hardware Design Question: ) How should the return address be passed to the subroutine? (i) By placing in in main memory somewhere, or (ii) By placing it in a register designated for this purpose.