FUNCTION CALL CONVENTIONS
- Registers W0-W7 are caller saved. The calling function must push these
values
onto the stack for the register values to be preserved.
- Registers W8-W14 are callee saved. The function being called must save
any of
these registers it will modify.
- Registers W0-W4 are used for function return values.
Function Parameters
- The first eight working registers (W0-W7) are used for function
parameters. Parameters are allocated to registers in left-to-right order,
and a parameter is assigned to the first available register that is suitably
aligned.
- In the following example, all parameters are passed in registers,
although not in theorder that they appear in the declaration. This format
allows the MPLAB C30 compiler to make the most efficient use of the
available parameter registers.
EXAMPLE 4-1: FUNCTION CALL MODEL
void params0(short p0, long p1, int p2, char p3, float p4, void *p5)
{
/*
** W0 p0
** W1 p2
** W3:W2 p1
** W4 p3
** W5 p5
** W7:W6 p4
*/
...
}
Return Value
- Function return values are returned in W0 for 8- or 16-bit scalars,
W1:W0 for 32-bitscalars, and W3:W2:W1:W0 for 64-bit scalars. Aggregates are
returned indirectly through W0, which is set up by the function caller to
contain the address of the
aggregate value.