# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# MPLAB XC16 C-Compiler

- 1
- 2
…
- 186
- 187
- 188
- 189
- 190
…
- 365
- 366

MPLAB
®
XC16 C Compiler Users Guide
DS50002071C-page 188  2012-2013 Microchip Technology Inc.
13.8 FUNCTION CALL CONVENTIONS
When calling a function:
 Registers W0-W7 are caller saved. The calling function must preserve these val-
ues before the function call if their value is required subsequently from the func-
tion call. The stack is a good place to preserve these values.
 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.
 Registers W0-W7 are used for argument transmission.
 DBRPAG/PSVPAG should be preserved if the -mconst-in-code (auto_psv)
memory model is being used.
TABLE 13-2: REGISTERS REQUIRED
Parameters are placed in the first aligned contiguous register(s) that are available. The
calling function must preserve the parameters, if required. Structures do not have any
alignment restrictions; a structure parameter will occupy registers if there are enough
registers to hold the entire structure. Function results are stored in consecutive
registers, beginning with W0.
13.8.1 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 the
order that they appear in the declaration. This format allows the compiler to make the
most efficient use of the available parameter registers.
Data Type Number of Working Registers Required
char 1
int 1
short 1
pointer 1
long 2 (contiguous  aligned to even numbered register)
float 2 (contiguous  aligned to even numbered register)
double* 2 (contiguous  aligned to even numbered register)
long double 4 (contiguous  aligned to quad numbered register)
structure 1 register per 2 bytes in structure
_Fract 1
long _Fract 2 (contiguous  aligned to even numbered register)
_Accum 3 (contiguous  aligned to quad numbered register)
* double is equivalent to long double if -fno-short-double is used.

- 1
- 2
…
- 186
- 187
- 188
- 189
- 190
…
- 365
- 366