283
• Use the I/O REFRESH instruction in interrupt subroutines to refresh required
I/O from Special I/O Units and mask interrupts in the main program while read-
ing/writing Special I/O Unit words.
5-23-3 SUBROUTINE ENTER – SBS(91)
N: Subroutine number
000 to 255
Ladder Symbol Definer Data Areas
SBS(91) N
Limitations Subroutine numbers 000 through 015 are used with input interrupts and subrou-
tine number 099 is used for the scheduled interrupt.
Description A subroutine can be executed by placing SBS(91) in the main program at the
point where the subroutine is desired. The subroutine number used in SBS(91)
indicates the desired subroutine. When SBS(91) is executed (i.e., when the
execution condition for it is ON), the instructions between the SBN(92) with the
same subroutine number and the first RET(93) after it are executed before
execution returns to the instruction following the SBS(91) that made the call.
SBS(91) 000
SBN(92) 000
RET(93)
END(01)
Main program
Subroutine
Main program
SBS(91) may be used as many times as desired in the program, i.e., the same
subroutine may be called from different places in the program).
SBS(91) may also be placed into a subroutine to shift program execution from
one subroutine to another, i.e., subroutines may be nested. When the second
subroutine has been completed (i.e., RET(93) has been reached), program
execution returns to the original subroutine which is then completed before re-
turning to the main program. There is no limit to the number of nesting levels,
unlike the C200HS PCs in which nesting is limited to 16 levels.
A subroutine cannot call itself (e.g., SBS(91) 000 cannot be programmed within
the subroutine defined with SBN(92) 000). The following diagram illustrates two
levels of nesting.
SBN(92) 010 SBN(92) 011 SBN(92) 012
SBS(91) 011
RET(93)
SBS(91) 010 SBS(91) 012
RET(93) RET(93)
Subroutines and Interrupt Control Section 5-23