Next: 4.6.12 Functions Up: 4.6 The PIC16 port Previous: 4.6.10 Memory Models Contents Index

## 4.6.11 Stack

The stack implementation for the PIC16 port uses two indirect registers, FSR1 and FSR2.

FSR1
  is assigned as stack pointer
FSR2
  is assigned as frame pointer

The following stack models are supported by the PIC16 port

- SMALL model
- LARGE model

SMALL model means that only the FSRxL byte is used to access stack and frame, while LARGE uses both FSRxL and FSRxH registers. The following table shows the stack/frame pointers sizes according to stack model and the maximum space they can address:

Stack & Frame pointer sizes according to stack model | small | large
Stack pointer FSR1 | 8-bits | 16-bits
Frame pointer FSR2 | 8-bits | 16-bits

LARGE stack model is currently not working properly throughout the code generator. So its use is not advised. Also there are some other points that need special care:

1. Do not create stack sections with size more than one physical bank (that is 256 bytes)
2. Stack sections should no cross physical bank limits (i.e. #pragma stack 0x50 0x100)

These limitations are caused by the fact that only FSRxL is modified when using SMALL stack model, so no more than 256 bytes of stack can be used. This problem will disappear after LARGE model is fully implemented.

Next: 4.6.12 Functions Up: 4.6 The PIC16 port Previous: 4.6.10 Memory Models Contents Index