707
3. Instructions
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Subroutines
3
GSBN/GRET
• Place the global subroutine region (GSBN(751) to GRET(752)) in interrupt task 0 just before the
END(001) instruction. When two or more global subroutines are being used, group them together in
interrupt task 0 after the end of the main program. If part of the main program is placed after the
global subroutine region, that program section will be ignored.
Example Programming
• The step instructions, STEP(008) and
SNXT(009) cannot be used in global
subroutines.
When CIO 0.00 is ON in the following
example, global subroutine 10 is executed
and program execution returns to the next
instruction after the GSBS(750) instruction
that called the subroutine.
GSBN
SNXT
STEP
GRET
Not allowed
GSBN
n
GRET
END
Global
subroutine
region
This part of the
program will not
be executed.
Interrupt task 0
Note : The input method for the global
subroutine number, N, is different
for the CX-Programmer and a
Programming Console. Input #0
to #1023 on the CX-Programmer
and 0 to 1023 on a Programming
Console.
GSBS
#10
0.00
GSBN
#10
GRET
END
Global subroutine
region
Cyclic or interrupt task
Interrupt task 0