Microchip Technology SW006022-1N データシート
MPLAB
®
XC16 C Compiler User’s Guide
DS52071B-page 162
2012 Microchip Technology Inc.
}
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.
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 10-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.
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.
is too large. However, this does not prevent the next parameter from using a register
spot.