![background image](http://html1.mh-extra.com/html/omron/srm1-programing-02-2001/srm1-programing-02-2001_programming-manual_742414502.webp)
7-26
Section
Subroutine Instructions
484
7-26 Subroutine Instructions
Subroutines break large control tasks into smaller ones and enable you to reuse
a given set of instructions. When the main program calls a subroutine, control is
transferred to the subroutine and the subroutine instructions are executed. The
instructions within a subroutine are written in the same way as main program
code. When all the subroutine instructions have been executed, control returns
to the main program to the point just after the point from which the subroutine
was entered (unless otherwise specified in the subroutine).
7-26-1 SUBROUTINE ENTER – SBS(91)
N
: Subroutine number
000 to 049
Ladder Symbol
Definer Data Areas
SBS(91) N
Limitations
The subroutine number must be between 000 and 049.
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).