15
15 – 84
MISC
STACK CONTROL
Note that once any Stack Overflow occurs, the corresponding stack overflow bit is
set in SSTAT, and this bit stays set indicating there has been loss of information.
Once set, the stack overflow bit can only be cleared by resetting the processor.
Instruction Format:
Stack Control, Instruction Type 26:
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Pp Lp Cp Spp
Pp:
PC Stack Control
Lp:
Loop Stack Control
Cp:
Counter Stack Control
Spp:
Status Stack Control
Syntax:
[ PUSH STS ] [ , POP CNTR] [ , POP PC] [ , POP LOOP] ;
POP
Example:
POP CNTR, POP PC, POP LOOP;
Description:
Stack Control pushes or pops the designated stack(s). The entire
instruction executes in one cycle regardless of how many stacks are specified.
The PUSH STS (Push Status Stack) instruction increments the status stack pointer by
one to point to the next available status stack location; and pushes the arithmetic
status (ASTAT), mode status (MSTAT), and interrupt mask register (IMASK) onto
the processor’s status stack. Note that the PUSH STS operation is executed
automatically whenever an interrupt service routine is entered.
Any POP pops the value on the top of the designated stack and decrements the same
stack pointer to point to the next lowest location in the stack. POP STS causes the
arithmetic status (ASTAT), mode status (MSTAT), and interrupt mask (IMASK) to be
popped into these same registers. This also happens automatically whenever a
return from interrupt (RTI) is executed.
POP CNTR causes the counter stack to be popped into the down counter. When the
loop stack or PC stack is popped (with POP LOOP or POP PC, respectively), the
information is lost. Returning from an interrupt (RTI) or subroutine (RTS) also pops
the PC stack automatically.
Status Generated:
SSTAT:
7
6
5
4
3
2
1
0
LSO
LSE SSO SSE
CSO CSE PSO PSE
–
*
*
*
–
*
–
*
PSE
PC Stack Empty: set if a pop results in an empty program counter stack; cleared otherwise.
CSE
Counter Stack Empty: set if a pop results in an empty counter stack; cleared otherwise.
SSE
Status Stack Empty: for PUSH STS, this bit is always cleared (indicating status stack not empty).
For POP STS, SSE is set if the pop results in an empty status stack; cleared otherwise.
SSO
Status Stack Overflow: for PUSH STS set if the status stack overflows; otherwise not affected.
LSE
Loop Stack Empty: set if a pop results in an empty loop stack; cleared otherwise.