|
HOLD Compiler Directive
Abbreviation | HL |
Arguments |
Numeric size limits for global variables placed in data,
near, and xdata memory. These numbers must be separated
by commas and enclosed in parentheses. The HOLD directive has
the following format:
HOLD (data_limit [, near_limit [,
xdata_limit]])
where:
data_limit |
is the maximum size for global variables
stored in data memory. This parameter specifies the object
size limit for data memory. If data_limit is
2, only variables of type char and int and arrays
with 2 bytes or less are placed into data memory. If
data_limit is 0, data memory is not used for
implicit variable declarations. |
near_limit |
is the maximum size for global variables
stored in near memory. This parameter specifies the object
size limit for the near memory. If
near_limit is 10, variables that are less than 10
bytes long are stored in near memory. If
near_limit is 0, near memory is not used for
implicit variable declarations. Since near_limit is
checked after data_limit, it must be larger than
data_limit. |
xdata_limit |
is the maximum size for global variables
stored in xdata memory. This parameter specifies the
object size limit for xdata memory. If
xdata_limit is 1000, variables that are 1000 bytes
long or less are stored in xdata memory and variables that
are larger are stored in far memory. If
xdata_limit is 0, xdata memory is not used for
implicit variable declarations. Since xdata_limit
is checked after data_limit and
near_limit, it must be larger than these
parameters. |
|
Default |
HOLD (0, 0, 0)
|
µVision |
Options — C251 Compiler — Memory Model — Data Allocation
Limits.
|
Description |
Use the HOLD directive to specify size limits that the C251
compiler uses when locating global variables that are declared
without explicit memory types.
Normally, the C251 compiler locates all variables in the default
memory areas defined by the SMALL, LARGE, TINY,
XSMALL and XTINY directives. You may use the
HOLD directive to store global variables in different memory
areas based on the size of the variable.
For example, HOLD(2,4,6) places variables that are 1 or 2
bytes long into data memory, 3 or 4 bytes long into
near memory, and 5 or 6 bytes long into xdata memory.
Variables that are larger than 6 bytes are stored in far
memory. Refer to “251 Memory Areas” 251 Memory Types on page 90 for
more information.
Note
-
The HOLD directive does not influence the location of
automatic variables and static variables declared within a
function. When the HOLD directive is active, the default
memory type depends on the size of the variable.
When all three HOLD parameters (data_limit,
near_limit, xdata_limit) are zero, the
C251 compiler uses the default memory type defined by the memory
model. Refer to “Memory Models” on page 94 for more information.
Note
-
The HOLD directive affects extern definitions. In
order for the C251 compiler to determine the location of external
variables, you must compile all files in a project with the same
HOLD settings. Furthermore, you should explicitly specify
array dimensions for extern arrays. Avoid array definitions with
empty brackets, for example:
extern int table []; /* Array size unknown */
/* at compile time */
|
See Also | LARGE, SMALL, TINY, XSMALL, XTINY |
Example |
C251 SAMPLE.C HOLD (2, 10, 0x2000)
In this example, variables with an object size less than or equal
to 2 bytes are stored in data memory, variables with an object
size less than or equal to 10 bytes are stored in near memory,
and variables with an object size less than or equal to 0x2000 bytes
are stored in xdata memory. Objects with larger sizes are
stored in the memory model based default memory.
C251 SAMPLE.C HOLD (0, 20)
In this example, variables with an object size 20 bytes and
smaller are stored in near data memory. All other variables
are stored in far memory.
|
|