2-291
2 Instructions
CP1E CPU Unit Instructions Reference Manual(W483)
Subroutines Instructions
2
SBS
Function
SBS(091) calls the subroutine with the
specified subroutine number. The subrou-
tine is the program section between
SBN(092) and RET(093). When the sub-
routine is completed, program execution
continues with the next instruction after
SBS(091).
A subroutine can be called more than
once in a program.
Subroutines can be nested up to 16 lev-
els. Nesting is when another subroutine is
called from within a subroutine program,
such as shown in the following example,
which is nested to 3 levels.
B
SBS
n
A
B
A
SBN
n
RET
END
Main program
Subroutine
program
(SBN(092) to
RET(093))
Program end
Execution condition ON
SBN 10
to to
to
to
to
SBS 11
RET
SBN 11
SBS 12
RET RET
SBN 12
D
SBS
n
C
D
A
SBN
n
RET
A
SBS
m
B
SBN
m
RET
END
Main program
Subroutine
program n
Execution condition ON
Execution condition ON
C
B
Subroutine
program m
Program end
Two-level
nesting