Chapter 25
Control Instructions
25–4
JUMP TO SUBROUTINE
SBR file number 3
Jump to Subroutine
JSR
Output Instruction
(JSR)
JSR
F1
F2
F3
F4
F5
ZOOM on JSR –(JSR)– 2.3.0.0.2
NAME: JUMP TO SUBROUTINE
FILE: 3
EDT_DAT
HHT Ladder Display:
HHT Zoom Display:
Ladder Diagrams and APS Displays:
(online monitor mode)
The Jump to Subroutine (JSR), Subroutine (SUB), and Return (RET) are
used in conjunction, as shown on the following page.
When rung conditions for a JSR instruction are true, the processor jumps to
the subroutine instruction (SBR) at the beginning of the target subroutine file
and resumes execution at that point (you cannot jump into any part of a
subroutine except the first instruction in that file).
When the processor does not jump to the subroutine (JSR rung false), the
SBR rungs are not scanned or evaluated, meaning outputs, timers, etc. are
left in their last state (if an OTE is on, it stays on). They are not
de–energized. Your main program should account for this and turn
off/reset/de–energize output instructions as required.
You must program each subroutine in its own program file by assigning a
unique file number (3–255).
Nesting Subroutine Files
Nesting subroutines allow you to direct program flow from the main program
to one subroutine and then on to another subroutine. The following rules
apply when nesting subroutines:
•
With fixed and SLC 5/01 processors, you can nest subroutines up to 4
levels.
•
With SLC 5/02 processors, you can nest subroutines up to 8 levels. If you
are using an STI subroutine, I/O event–driven interrupt subroutine, or
user fault routine, you can nest subroutines up to 3 levels from each.
Jump to Subroutine (JSR)