Subroutine Instructions; Subroutine Enter - Sbs(91) - Omron CPM1 Programming Manual

Hide thumbs Also See for CPM1:
Table of Contents

Advertisement

Subroutine Instructions

5-25 Subroutine Instructions

5-25-1 SUBROUTINE ENTER – SBS(91)
Limitations
Description
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).
Ladder Symbol
SBS(91) N
The CQM1-CPU11/21-E supports only subroutine numbers 000 through 127.
The CPM1/CPM1A/SRM1 support only subroutine numbers 000 through 049.
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) 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
returning to the main program. Nesting is possible to up to sixteen levels. A
subroutine cannot call itself (e.g., SBS(91) 000 cannot be programmed within
Definer Data Areas
N: Subroutine number
000 to 255
Main program
SBS(91) 00
Main program
SBN(92) 00
Subroutine
RET(93)
END(01)
Section 5-25
321

Advertisement

Table of Contents
loading

Table of Contents