5.5 Stack
All devices have a 16-level by 15-bit wide hardware stack. The stack space is not part of either
program or data space. The PC is PUSHed onto the stack when the CALL
or
CALLW
instructions are executed or an interrupt causes a branch.
The stack is POPed in the event of a RETURN
, RETLW
or
a RETFIE
instruction execution. PCLATH is not affected by a PUSH or POP
operation.
The stack operates as a circular buffer if the STVREN Configuration bit is programmed to
‘0
’. This means that after the stack has been PUSHed 16 times, the
17th PUSH overwrites the value that was stored from the first PUSH. The
18th PUSH overwrites the second PUSH (and so on). The STKOVF and STKUNF
flag bits will be set on an overflow/underflow, regardless of whether the Reset is
enabled.
1
’, the device will
be reset if the stack is PUSHed beyond the 16th level or POPed beyond the
fist level, setting the appropriate bits (STKOVF or STKUNF, respectively) in the PCON
register.CALL
, CALLW
,
RETURN
, RETLW
and RETFIE
instructions or the vectoring to an interrupt address.