Reference Manual

Turbo PMAC/PMAC2 Software Reference
Turbo PMAC Program Command Specification 436
subroutines by following the G-Code with one or more sets of {letter}{data}, as in CALL and
READ statements.
Most users will have G-codes only in the range 0-99, which permits the use of PROG 1000 only and
allows {data’} to equal {data} for direct specification of the line label.
Example:
G01 jumps to N1000 of PROG 1000
G12 jumps to N12000 of PROG 1000
G115 jumps to N15000 of PROG 1010
See Also:
Program commands CALL{data}, D{data}, M{data}, T{data}, RETURN
GOSUB
Function: Unconditional Jump With Return
Type: Motion program (PROG only)
Syntax: GOSUB{data}
where:
{data} is a constant or expression representing the line label to jump to
This command causes the motion program execution to jump to the line label (N or O) of the same motion
program specified in {data}, with a jump back to the commands immediately following the GOSUB
upon encountering the next RETURN command.
If {data} is a constant, the path to the subroutine will have been linked before program run time, so the
jump is very quick. If {data} is a variable expression, it must be evaluated at run time, and the
appropriate label then searched for. The search starts downward in the program to the end, then continues
(if necessary) from the top of the program down.
A variable GOSUB command permits the equivalent structure to the CASE statement found in many high-
level languages.
If the specified line label is not found, the GOSUB command will be ignored, and the program will
continue as if the command had not occurred.
The CALL command is similar, except that it can jump to another motion program.
Examples:
GOSUB300 jumps to N300 of this program, to jump back on RETURN
GOSUB8743 jumps to N8743 of this program, to jump back on RETURN
GOSUB(P17) jumps to the line label of this program whose number matches the current value of P17, to jump back
on RETURN
See Also:
Writing and Executing Motion Programs
Program commands CALL, GOTO, N, O, RETURN
GOTO
Function: Unconditional Jump without Return
Type: Motion program (PROG only)
Syntax: GOTO{data}
where:
{data} is an integer constant or expression with a value from 0 to 99,999.
This command causes the motion program execution to jump to the line label (N or O) specified in
{data}, with no jump back.