10.8 Memory Models
MPLAB XC32 C/C++ Compiler does not use fixed memory models to alter allocation of variables to memory.
The -G option (see Options Specific to PIC32M Devices),
which controls the gp-relative addressing threshold, is similar to the
small-data/large-data/scalar-data memory models offered by the Microchip compilers for
the 8- and 16-bit architectures. The value specified with this option indicates the
maximum size of objects that will be allocated to the small data sections, for example,
sbss, sdata, etc. Variables allocated to the
small-data sections require fewer instructions to access than variables allocated to the
other data sections. For example:
xc32-gcc -G128 -mprocessor=32MX795F512L main.c
In this example, data objects up to 128 bytes in size will be located in the efficient small-data or small-bss section.
In general larger -G values result in more efficient code. However,
gp-relative addressing is limited to 64-KB of small data.
