The code generated by cpik uses two stacks:
This stack is part of the PIC-18 architecture. It is only used to save the return addresses before subroutines calls. 31 levels of nested calls are generally largely sufficient for most applications.
However, recursive routines may provoke an overflow of the return stack, this point being under the responsability of the programmer.
This stack is used to store local variables, function parameters and temporary results during expression evaluation.
Due to the availability of address registers FSRx
, and indirect, auto-incremented, and indexed addressing mode, the stack manipulation is very efficient.
FSR0
is used as the software stack pointer.
The stack grows upward and is used in a pre-incremented manner: pushing a byte onto the stack uses a movxx source,PREINC0
instruction. Symetrically, a
movxx POSTDEC0,dest
is used to pop the data back.