9.1.3 Return Address Stack
The return address stack allows any combination of up to 127 program
calls and interrupts to occur. The PC is pushed onto the stack when a CALL
or RCALL instruction is executed or an interrupt is Acknowledged. The PC
value is pulled off the stack on a RETURN, RETLW or a
RETFIE instruction. PCLATU and PCLATH are not affected by any of the
RETURN or CALL instructions.
The Stack Pointer is readable and writable and the address on the top of the stack is readable and writable through the Top-of-Stack (TOS) Special File registers. Data can also be pushed to or popped from the stack using these registers.
A CALL type instruction causes a push onto the
stack; the Stack Pointer is first incremented and the location pointed to by the Stack
Pointer is written with the contents of the PC (already pointing to the instruction
following the CALL). A RETURN type
instruction causes a pop from the stack; the contents of the location pointed to by the
STKPTR are transferred to the PC and then the Stack Pointer is decremented.
The Stack Pointer is initialized to 0x00 after all
Resets.
