next up previous contents index
Next: 4.6.13 Function return values Up: 4.6 The PIC16 port Previous: 4.6.11 Stack   Contents   Index

4.6.12 Functions

In addition to the standard SDCC function keywords, PIC16 port makes available two more:

wparam
Use the WREG to pass one byte of the first function argument. This improves speed but you may not use this for functions with arguments that are called via function pointers, otherwise the first byte of the first parameter will get lost. Usage:
void func_wparam(int a) wparam

{

    /* WREG hold the lower part of a */

    /* the high part of a is stored in FSR2+2 (or +3 for large stack model) */

...

}

shadowregs
When entering/exiting an ISR, it is possible to take advantage of the PIC18F hardware shadow registers which hold the values of WREG, STATUS and BSR registers. This can be done by adding the keyword shadowregs before the interrupt keyword in the function's header.
void isr_shadow(void) shadowregs interrupt 1

{

...

}

shadowregs instructs the code generator not to store/restore WREG, STATUS, BSR when entering/exiting the ISR.



2008-12-05