07.04.2013 Views

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

16-Bit C <strong>Compiler</strong> User’s Guide<br />

4.6 MEMORY MODELS<br />

The compiler supports several memory models. Comm<strong>and</strong>-line options are available<br />

<strong>for</strong> selecting the optimum memory model <strong>for</strong> your application, based on the specific<br />

<strong>dsPIC</strong> DSC device part that you are using <strong>and</strong> the type of memory usage.<br />

TABLE 4-1: MEMORY MODEL COMMAND LINE OPTIONS<br />

Option Memory Definition Description<br />

-msmall-data Up to 8 KB of data memory. Permits use of PIC18 like instructions<br />

This is the default.<br />

<strong>for</strong> accessing data memory.<br />

-msmall-scalar Up to 8 KB of data memory. Permits use of PIC18 like instructions<br />

This is the default.<br />

<strong>for</strong> accessing scalars in data memory.<br />

-mlarge-data Greater than 8 KB of data<br />

memory.<br />

Uses indirection <strong>for</strong> data references.<br />

-msmall-code Up to 32 Kwords of program Function pointers will not go through a<br />

memory. This is the default. jump table. Function calls use RCALL<br />

instruction.<br />

-mlarge-code Greater than 32 Kwords of Function pointers might go through a<br />

program memory.<br />

jump table. Function calls use CALL<br />

instruction.<br />

-mconst-in-data Constants located in data Values copied from program memory<br />

memory.<br />

by startup code.<br />

-mconst-in-code Constants located in program Values are accessed via Program<br />

memory. This is the default. Space Visibility (PSV) data window.<br />

The comm<strong>and</strong>-line options apply globally to the modules being compiled. Individual<br />

variables <strong>and</strong> functions can be declared as near or far to better control the code<br />

generation. For in<strong>for</strong>mation on setting individual variable or function attributes, see<br />

Section 2.3.1 “Specifying Attributes of Variables” <strong>and</strong> Section 2.3.2 “Specifying<br />

Attributes of Functions”.<br />

4.6.1 Near <strong>and</strong> Far Data<br />

If variables are allocated in the near data section, the compiler is often able to generate<br />

better (more compact) code than if the variables are not allocated in the near data<br />

section. If all variables <strong>for</strong> an application can fit within the 8 KB of near data, then the<br />

compiler can be requested to place them there by using the default -msmall-data<br />

comm<strong>and</strong> line option when compiling each module. If the amount of data consumed<br />

by scalar types (no arrays or structures) totals less than 8 KB, the default<br />

-msmall-scalar may be used. This requests that the compiler arrange to have just<br />

the scalars <strong>for</strong> an application allocated in the near data section.<br />

If neither of these global options is suitable, then the following alternatives are<br />

available.<br />

DS51284H-page 66 © 2008 <strong>Microchip</strong> Technology Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!