P
ar
t
2: C
omman
d
s
Moog Animatics SmartMotor™ Developer's Guide, Rev. L
Page 674 of 909
RETURN
Return From Subroutine
APPLICATION:
Program execution and flow control
DESCRIPTION:
Return program execution to next statement following current
subroutine call
EXECUTION:
Immediate
CONDITIONAL TO:
A previous GOSUBn program statement was performed
LIMITATIONS:
Up to nine nested GOSUB or interrupt subroutines may occur at
one time
READ/REPORT:
N/A
WRITE:
N/A
LANGUAGE ACCESS:
N/A
UNITS:
N/A
RANGE OF VALUES:
N/A
TYPICAL VALUES:
N/A
DEFAULT VALUE:
N/A
FIRMWARE VERSION:
5.x and later
COMBITRONIC:
N/A
DETAILED DESCRIPTION:
The RETURN command is used to terminate a subroutine within a user program.
NOTE:
Subroutines present a great opportunity to partition and organize your code.
When the RETURN command is invoked, program execution continues immediately after the
GOSUB that initiated the subroutine call. RETURN is normally executed from within a
program, but with care, the HOST terminal may also be used to issue a RETURN instruction.
In order to execute the RETURN program statement, the processor needs to be able to recall
(from the stack) the program address point where it should return. The "stack" is a memory
region where these addresses are stored. A maximum of nine address locations can be stored
within the stack. Therefore, do not use more than nine nested subroutines; otherwise, it may
cause a stack overflow and crash the program.
NOTE:
RETURNI must be used to return from interrupt subroutines; RETURN must
always be used to return from GOSUB subroutines.
Part 2: Commands: RETURN