Skip to main content

IAR Embedded Workbench for RX 5.20

Specifying a data model

In this section:

Three data models are implemented: Near, Far, and Huge. These models are controlled by the --data_model option. Each model has a default memory type. If you do not specify a data model option, the compiler will use the Far data model.

Your project can only use one data model at a time, and the same model must be used by all user modules and all library modules. However, you can override the default memory type for individual data objects by explicitly specifying a memory attribute, see Using data memory attributes.

This table summarizes the data models:

Data model name

Default memory attribute

Pointer attribute

Placement of data

Near

__data16

__data32

Low 32 Kbytes or high 32 Kbytes

Far (default)

__data24

__data32

Low 8 Mbytes or high 8 Mbytes

Huge

__data32

__data32

The entire 4 Gbytes of memory

Table 55. Data model characteristics  


Caution

See the IDE Project Management and Building documentation for information about setting options in the IDE.

Danger

Use the ‑‑data_model option to specify the data model for your project; see --data_model.

The impact of the different data models on the code size depends on the amount of data with static duration. There is no principal difference in the generated code. On higher optimization levels the difference is even smaller, because of the global clustering optimization.

The RXmicrocontroller has no mode for direct addressing. This means that addresses of static objects must be loaded into a register before the data can be read from memory. The size of these address loads will increase if you change to a larger data model. However, on high optimization levels, the compiler will use a base address to all objects with static duration data in the module, and use relative addressing to access them.

For this reason, the size of the generated code does not depend very much on your choice of data model, but you should nevertheless always use the smallest data model that you need.