

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


We now begin discussion of subroutine linkages for simple subroutines without large argument blocks. With the mechanisms discussed in this lecture, one can use either global variables or general purpose registers to pass addresses, values, and results. The idea behind this discussion in the textbook is to call a subroutine for side effect only. An example would be to manage all tasks associated with printing a new page. As the textbook notes, subroutines may be written to facilitate repetitive tasks. Indeed, the “Wheeler Jump” (EDSAC, 1952) was developed for just this purpose. Early operating systems began as collection of subroutines to facilitate handling of input and output devices, mainly line printers. When batch programming became common, the computer needed a control program to automate the processing of a sequence of jobs, read and processed one after another. This control program was merged with a set of subroutines for Input/Output handling and routines for standard mathematical functions to create the first operating system.
The language requires two instructions associated with subroutines: one to call the subroutine and one to effect a return from the subroutine. Calling the subroutine The instruction used is BAL (Branch and Link) The format of the instruction is BAL Reg,Address An example of such an instruction is BAL 8,P10PAGE The first argument is a register number to be used for subroutine linkage. We explain this more fully in just a bit. The second argument is the address of the first instruction in the subroutine. There are other standards for this argument, but this is the one that IBM uses. Returning from the subroutine This instruction is used to return from execution of the subroutine. It is an unconditional jump to an address contained in the register. The format of the instruction is BR Reg An example of such an instruction is BR 8