Chapter 25
Control Instructions
25–5
The example below illustrates jumping to successive subroutines, then
returning in reverse order.
JSR
90
JSR
91
SBR
RET
SBR
SBR
JSR
92
RET
RET
Example of Nesting Subroutine to Level 3
Program
Main
Subroutine File 90
Level 1
Subroutine File 91
Level 2
Subroutine File 92
Level 3
Note: Runtime errors (error codes 0025, 0026, 0027, and 0030) occur if
more than the allowable levels of subroutines are called (subroutine stack
overflow) or if more returns are executed than there are call levels
(subroutine stack underflow). Also, do not execute a JSR to a subroutine that
is already active in the subroutine stack.
Update critical I/O in subroutines using immediate input (IIM) and/or
immediate output (IOM) instructions, especially if your application calls for
nested or relatively long subroutines. Otherwise, the processor does not
update I/O until it reaches the end of the main program after executing
subroutines.
Entering Parameters
File – This is the SBR (subroutine) file number. Assign a decimal number
from 3 to 255.