723
Subroutines
Section 3-19
Flags
Precautions
SBS(091) and the corresponding SBN(092) must be programmed in the same
task. An error will occur if the corresponding SBN(092) isn’t in the task.
SBS(091) will be treated as NOP(000) when it is within a program section
interlocked by IL(002) and ILC(003).
When SBS(091) is executed in the following cases, the subroutine won’t actu-
ally be called and the Error Flag will be turned ON:
1,2,3...
1.
The specified subroutine is not defined within the current task.
2.
The subroutine is calling itself.
3.
Subroutine nesting exceeds 16 levels.
4.
The specified subroutine is being executed.
Examples
Example 1: Sequential (Non-nested) Subroutines
When CIO 000000 is ON in the following example, subroutine 1 is executed
and program execution returns to the next instruction after SBS(091). The
remainder of the main program (through the instruction just before SBN(092)
1) is then executed.
Example 2: Sequential (Non-nested) Subroutines
When CIO 000000 is ON in the following example, subroutine 1 is executed
and program execution returns to the next instruction after SBS(091) 1. When
CIO 000001 is ON, subroutine 2 is executed and program execution returns
to the next instruction after SBS(091) 2.
Name
Label
Operation
Error Flag
ER
ON if nesting exceeds 16 levels.
ON if the specified subroutine number doesn’t exist.
ON if a subroutine calls itself.
ON if a subroutine being executed is called.
ON if the specified subroutine isn’t defined in the current
task.
OFF in all other cases.
1
3
2
A
→
S
→
B
A
→
B
Main program
Subroutine 1
CIO 000000 ON
Order of execution
Subroutine program:
S
Summary of Contents for CJ1G-CPUxx
Page 3: ...iv N o t i c e ...
Page 5: ...vi ...
Page 21: ...xxii Conformance to EC Directives 6 ...
Page 35: ......
Page 1131: ...1110 CJ series Instruction Execution Times and Number of Steps Section 4 2 ...