Vault 7: Projects

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

Functions
2012-2013 Microchip Technology Inc. DS50002071C-page 189
EXAMPLE 13-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
*/
...
}
The next example demonstrates how structures are passed to functions. If the
complete structure can fit in the available registers, then the structure is passed via
registers; otherwise the structure argument will be placed onto the stack.
EXAMPLE 13-2: FUNCTION CALL MODEL, PASSING STRUCTURES
typedef struct bar {
int i;
double d;
} bar;
void
params1(int i, bar b) {
/*
** W0 i
** W1 b.i
** W5:W2 b.d
*/
}
Parameters corresponding to the ellipses (...) of a variable-length argument list are not
allocated to registers. Any parameter not allocated to registers is pushed onto the
stack, in right-to-left order.
In the next example, the structure parameter cannot be placed in registers because it
is too large. However, this does not prevent the next parameter from using a register
spot.

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh