Subroutine Linkage - GE DATANET-30 Programming Reference Manual

Hide thumbs Also See for DATANET-30:
Table of Contents

Advertisement

Subroutine Linkage
Indirect addressing and a special Branch Subroutine (BRS) instruction provide a means for
getting to and from subroutines and program banks. The BRS command is a 3-word-time in-
struction which, during the first execution cycle, stores P+l (the address of the word following
the BRS) in memory location M and during the second cycle loads the contents of (M+l) into
the P- counter, as follows:
ALPHA
SUBRN
SUBRNl
BRS
LDA
IND
IND
LDB
BRU
SUB RN
0
0
SUBRNl
SUB RN
SUB RN
x
When the BRS at location ALPHA is executed:
1.
The P-counter + 1 is stored in SUBRN.
Transfer to Subroutine
Continue
Subroutine linkage
Start of subroutine
Exit from subroutine
2.
The program branches to location contained in SUBRN+l.
3.
The subroutine is executed.
This subroutine may be located anywhere in memory.
4.
The exit from the subroutine via the BRU SUBRN X causes the contents of SUBRN
(location ALPHA+l) to be loaded into P.
5.
The LDA instruction following the BRS is executed after execution of the subroutine.
Thus, 1 instruction (BRS), 2 words in memory (SUBRN and SUBRN+l), and 5 word times (BRS
and BRU X) are needed for the general subroutine linkage, since the two linkage words are
normally in the common data bank and can be accessed from anywhere in memory.
This technique of subroutine linkage has these advantages:
1.
Only 1 instruction is needed in the main program to call a subroutine.
2.
The subroutine may be located anywhere in memory at no sacrifice in time or memory.
3.
The subroutine may be called from anywhere in memory at no sacrifice in time or
memory.
[ID/A\ll/A\~~11~ ~@------------
III-7

Advertisement

Table of Contents
loading

Table of Contents