Skip to main content

IAR Embedded Workbench for RL78 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 Near 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 and pointers by explicitly specifying a memory attribute, see Using data memory attributes.

This table summarizes the data models:

Data model name

Default memory and pointer attribute

Placement of data

Near (default)

__near

The highest 64 Kbytes

Far

__far

The entire 1 Mbyte of memory

Huge

__huge

The entire 1 Mbyte of memory

Table 54. 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 Near data model

The Near data model places data in the highest 64 Kbytes of memory. This memory can be accessed using 2-byte pointers, which means that only 16 bits are needed for pointer storage. The default pointer type passed as a parameter will use one 16-bit register or 2 bytes on the stack.

The Far data model

The Far data model places data in the first 1 Mbyte of memory. This is the only memory that can be accessed using 3-byte pointers. The default pointer type passed as a parameter will use 4 bytes on the stack. By default, using this data model is faster but less flexible than the Huge data model.

The Huge data model

The Huge data model places data in the first 1 Mbyte of memory. This is the only memory that can be accessed using 3-byte pointers. The default pointer type passed as a parameter will use 4 bytes on the stack. By default, using this data model is slower but more flexible than the Far data model.