Basic Instructions
2 − 86
Outline CALL: Executes the specified subroutine program.
12
SUB: Indicates the start of the subroutine program.
RET: Indicates the end of the subroutine program.
Program example
Boolean
Ladder Diagram
Address Instruction
(CALL 1 )
(ED )
(SUB 1 )
(RET )
21
Subroutine program number
X0
10
20
30
Subroutine
10
11
20
21
30
.... ....
ST X 0
CALL 1
ED
SUB 1
RET
.... ....
Description
When the execution condition (trigger) turns on, the CALL instruction is executed and the subroutine
program of the specified number is executed starting with the SUB instruction.
When the subroutine reaches the RET instruction, the program returns to the address after the CALL
instruction of the main program and the execution of the main program resumes.
ED
SUB n
RET
CALL n
X0
Main program
Main program
Subroutine program
1
2
3
When CALLn is executed, the program is executed in the order
1
,
2
,
3
shown above.
Subroutine Program Syntax
The subroutine program n is the program from the SUBn instruction to the RET instruction. Always place the
address (subroutine) after the ED instruction.
The CALL instruction can be programmed in the main program area, interrupt program area, or subroutine
program area.
Two or more CALL instructions with the same program number can be specified in a program.
CALL
SUB
RET
Subroutine call
Subroutine entry
Subroutine return