MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Run Time Environment<br />
1. It is possible to compile some modules of an application using the<br />
-mlarge-data or -mlarge-scalar comm<strong>and</strong> line options. In this case, only<br />
the variables used by those modules will be allocated in the far data section. If<br />
this alternative is used, then care must be taken when using externally defined<br />
variables. If a variable that is used by modules compiled using one of these<br />
options is defined externally, then the module in which it is defined must also be<br />
compiled using the same option, or the variable declaration <strong>and</strong> definition must<br />
be tagged with the far attribute.<br />
2. If the comm<strong>and</strong> line options -mlarge-data or -mlarge-scalar have been<br />
used, then an individual variable may be excluded from the far data space by<br />
tagging it with the near attribute.<br />
3. Instead of using comm<strong>and</strong>-line options, which have module scope, individual<br />
variables may be placed in the far data section by tagging them with the far<br />
attribute.<br />
The linker will produce an error message if all near variables <strong>for</strong> an application cannot<br />
fit in the 8K near data space.<br />
4.6.2 Near <strong>and</strong> Far Code<br />
Functions that are near (within a radius of 32 Kwords of each other) may call each other<br />
more efficiently that those which are not. If it is known that all functions in an application<br />
are near, then the default -msmall-code comm<strong>and</strong> line option can be used when<br />
compiling each module to direct the compiler to use a more efficient <strong>for</strong>m of the function<br />
call.<br />
If this default option is not suitable, then the following alternatives are available:<br />
1. It is possible to compile some modules of an application using the<br />
-msmall-code comm<strong>and</strong> line option. In this case, only function calls in those<br />
modules will use a more efficient <strong>for</strong>m of the function call.<br />
2. If the -msmall-code comm<strong>and</strong>-line option has been used, then the compiler<br />
may be directed to use the long <strong>for</strong>m of the function call <strong>for</strong> an individual function<br />
by tagging it with the far attribute.<br />
3. Instead of using comm<strong>and</strong>-line options, which have module scope, the compiler<br />
may be directed to call individual functions using a more efficient <strong>for</strong>m of the<br />
function call by tagging their declaration <strong>and</strong> definition with the near attribute.<br />
The -msmall-code comm<strong>and</strong>-line option differs from the -msmall-data<br />
comm<strong>and</strong>-line option in that in the <strong>for</strong>mer case, the compiler does nothing special to<br />
ensure that functions are allocated near one another, whereas in the latter case, the<br />
compiler will allocate variables in a special section.<br />
The linker will produce an error message if the function declared to be near cannot be<br />
reached by one of its callers using a more efficient <strong>for</strong>m of the function call.<br />
© 2008 <strong>Microchip</strong> Technology Inc. DS51284H-page 67