SLAA534A June 2013 – June 2020
Some MSP family devices support multiple data and code memory models. These models differ by the allowed size of objects and pointers. The compiler uses different instructions and relocations to implement these models. Section 1.10 provides an overview of the code and data models supported by the MSP family. For information about how pointers differ depending on the memory model, see Section 2.5.
The MSP family does not have a distinction between "near" and "far" addresses.
In addition to the models affecting the size of pointers, the data model affects the types of size_t and ptrdiff_t, and thus dictates the maximum allowable object size.
For the MSP430 and the MSP430X with the small data model, all memory locations are accessible with 16-bit addresses.
For the MSP430X with the restricted and large data models, most addresses are still accessible with a 16-bit address and all bits are zero above the 16th bit. Some instructions (such as CALL) handle only 16-bit pointers, so these instructions can only be used in the lower 64 KB of memory space; they ignore the upper 4 bits of the 20-bit pointers. Other instructions (such as CALLA) make use of the full 20-bit address; these instructions can reach the entire memory space.
MSP430X devices do not have any writeable memory above the 64 KB boundary. For these devices, even when the restricted or large data models are used, only constant data will be placed above 64 KB. The compiler can take advantage of this knowledge to produce more efficient code. This is controlled by the --near_data compiler option. If --near_data=globals is specified, it tells the compiler that all global read/write data must be located in the first 64 KB of memory. This is the default behavior. If --near_data=none is specified, the compiler cannot rely on this assumption to generate more efficient code.
In the cases where the designation depends on toolchain-specific aspects like command-line options or language extensions, the onus is on the programmer to use these constructs consistently wherever the variable is declared, but on the linker to catch errors .
The ABI establishes conventional assignments of variables to sections. A variable's assignment is a function of its initialization category, as determined by the first matching condition from the following list.
The conventional section assignment is given by Table 4-2:
Initialization category | |||
---|---|---|---|
Uninitialized | Initialized | Const | |
.bss | .data | .const |
The conventional assignments may be overridden in toolchain-specific ways. For example, variables may be assigned to user-defined sections.