Jump Instructions and
Subroutine Programming
Chapter 11
1111
Figure 11.9
Representative Subroutine Area
()
()
||
||
| / |
||
| / |
LBL
XX
( RET )
()
||
LBL
XX
( RET )
()
||
LBL
XX
( RET )
Main Program
Subroutine Area
(Subroutine #1)
(Subroutine #2)
(Subroutine #8)
End
The label is the first
instruction in each
subroutine.
Up to sixtyfour (64)
subroutines can
be programmed
if no jumps are
programmed.
The return is the
last instruction in its
subroutine.
Subroutine boundary serves
as end statement for main
program.
A subroutine may call another subroutine (Figure 11.10a) which, in turn,
may call another subroutine. This nesting process can continue until eight
levels of calls are involved.
Figure 11.10 (a) shows three levels of nested subroutines. The main
program calls Level 1 at label 01 (a). Level 1, in turn, calls Level 2 at label
02 (b). Note that Level 1 subroutine issued the command to jump to label
02 before all the steps in Level 1 were completed. Likewise, Level-2
subroutine issued the command to jump to label 03 (c) before completing
all Level-2 steps.
Level-3 subroutine, the last subroutine in the next, is executed to its return
instruction (d). Each return instruction returns processor execution to the
instruction immediately following the JSR that initiated the subroutine (e
and f). Execution continues from that point.
11.3.2
Nested Subroutines
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com