SW006012 Microchip Technology, SW006012 Datasheet - Page 83

C COMPILER FOR DSPIC30F FAMILY

SW006012

Manufacturer Part Number
SW006012
Description
C COMPILER FOR DSPIC30F FAMILY
Manufacturer
Microchip Technology
Type
MPLAB® C30 Compilerr
Series
PIC24 & DsPICr
Datasheets

Specifications of SW006012

Supported Families
PIC24, DsPIC30F And DsPIC33F
Core Architecture
PIC, DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Tool Type
Compiler
Processor Series
PIC24, dsPIC
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
dsPIC30F
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2007 Microchip Technology Inc.
MPLAB C30 C Compiler Runtime Environment
EXAMPLE 4-2:
typedef struct bar {
} bar;
void
params1(int i, bar b) {
}
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.
EXAMPLE 4-3:
typedef struct bar {
} bar;
void
params2(int i, bar b, int j) {
}
Accessing arguments that have been placed onto the stack depends upon whether or
not a Frame Pointer has been created. Generally the compiler will produce a Frame
Pointer (unless otherwise told not to do so), and stack-based parameters will be
accessed via the Frame Pointer register (W14). The above example, b will be
accessed from W14-22. The Frame Pointer offset of negative 22 has been calculated
(refer to Figure 4-6) by removing 2 bytes for the previous FP, 4 bytes for the return
address, followed by 16 bytes for b.
When no Frame Pointer is used, the assembly programmer must know how much stack
space has been used since entry to the procedure. If no further stack space is used,
the calculation is similar to the above. b would be accessed via W15-20; 4 bytes for the
return address and 16 bytes to access the start of b.
4.12.2
Function return values are returned in W0 for 8- or 16-bit scalars, W1:W0 for 32-bit
scalars, 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.
int i;
double d;
double d,e;
/*
** W0
** W1
** W5:W2
*/
/*
** W0
** stack
** W1
*/
Return Value
FUNCTION CALL MODEL, PASSING STRUCTURES
FUNCTION CALL MODEL, STACK BASED ARGUMENTS
i
b.i
b.d
i
b
j
DS51284F-page 77

Related parts for SW006012