P
ar
t
2: C
omman
d
s
Moog Animatics SmartMotor™ Developer's Guide, Rev. L
Page 722 of 909
STACK
Stack Pointer Register, Clear
APPLICATION:
Program execution and flow control
DESCRIPTION:
Reset user program subroutine return stack
EXECUTION:
Immediate
CONDITIONAL TO:
N/A
LIMITATIONS:
N/A
REPORT VALUE:
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 STACK command empties the queue of pending (GOSUB) RETURN addresses, resets any
pending interrupts, and resets any PAUSE statements.
In order to execute the RETURN program statement, the processor needs to be able to recall
the program address point where it should return. The "stack" is a region where these
addresses are stored.
A maximum of nine address locations can be stored within the stack. This means that if a
tenth GOSUB is called before any intervening RETURN statements, the stack will overflow and
the program execution may fail. The stack region is managed using a pointer to the currently
effective return address storage location. The STACK command directly resets this pointer to
its initial (starting) condition. By doing this, the STACK command clears all RETURN addresses
in the stack queue.
NOTE:
Care should be taken when the STACK command is used. Issuing STACK will
cause any following RETURN command to be ignored. Therefore, proper program
flow, with GOTO commands or otherwise, should be used to prevent a memory
mapping error.
Because the GOSUB command may be issued serially to the SmartMotor, it may be possible to
overflow the stack regardless of the downloaded program code. The STACK command could
also be issued through serial communications to clear the stack and prevent overflow.
However, that method is not recommended because it would be difficult to know what line of
code the motor may be running at that time.
Part 2: Commands: STACK