Microchip Technology SW006022-1N Data Sheet
Memory Allocation and Access
2012 Microchip Technology Inc.
DS52071B-page 143
7.12.1
Near or Far Data
If variables are allocated in the near data space, the compiler is often able to generate
better (more compact) code than if the variables are not allocated in near data. If all
variables for an application can fit within the 8 KB of near data, then the compiler can
be requested to place them there by using the default -msmall-data command line
option when compiling each module. If the amount of data consumed by scalar types
(no arrays or structures) totals less than 8 KB, the default -msmall-scalar, com-
bined with -mlarge-data, may be used. This requests that the compiler arrange to
have just the scalars for an application allocated in the near data space.
better (more compact) code than if the variables are not allocated in near data. If all
variables for an application can fit within the 8 KB of near data, then the compiler can
be requested to place them there by using the default -msmall-data command line
option when compiling each module. If the amount of data consumed by scalar types
(no arrays or structures) totals less than 8 KB, the default -msmall-scalar, com-
bined with -mlarge-data, may be used. This requests that the compiler arrange to
have just the scalars for an application allocated in the near data space.
If neither of these global options is suitable, then the following alternatives are
available.
available.
1.
It is possible to compile some modules of an application using the
-mlarge-data
-mlarge-data
or -mlarge-scalar command line options. In this case, only
the variables used by those modules will be allocated in the far data section. If
this alternative is used, then care must be taken when using externally defined
variables. If a variable that is used by modules compiled using one of these
options is defined externally, then the module in which it is defined must also be
compiled using the same option, or the variable declaration and definition must
be tagged with the far attribute.
this alternative is used, then care must be taken when using externally defined
variables. If a variable that is used by modules compiled using one of these
options is defined externally, then the module in which it is defined must also be
compiled using the same option, or the variable declaration and definition must
be tagged with the far attribute.
2.
If the command line options -mlarge-data or -mlarge-scalar have been
used, then an individual variable may be excluded from the far data space by
tagging it with the near attribute.
used, then an individual variable may be excluded from the far data space by
tagging it with the near attribute.
3.
Instead of using command-line options, which have module scope, individual
variables may be placed in the far data section by tagging them with the far
attribute.
variables may be placed in the far data section by tagging them with the far
attribute.
The linker will produce an error message if all near variables for an application cannot
fit in the 8K near data space.
fit in the 8K near data space.