3 Subroutine invocation and returning
When a subroutine is invoked, two operations occur:
- First, the left-most un-allocated column is allocated and labeled as a “return line number”, or abbreviated to
“retline#”. This column then gets a value that is the number of the line that logically follows the invocation.
The purpose of this column is to remember where to continue execution when the subroutine is finished.
- Second, execution continues on the first action line in the invoked subroutine.
When execution reaches the end of the a subroutine, marked “end define sub” in pseudocode, the following two operations
occur:
- First, the right-most allocated column labeled “retline#” is looked up. This column indicates where to continue
execution. Write the number in the next row of the trace (in the “line#” column).
- Second, the “retline#” that was just utilized is marked deallocated. Do so by using a series of “XXXXXXX”
characters where the column is deallocated. To be more clear, you can also use a strike-out font, such as
“retline#” to indicate the column is deallocated.