Skip to main content

IAR Embedded Workbench for RL78 5.20

Controlling data and function placement in memory

In this section:

The compiler provides different mechanisms for controlling placement of functions and data objects in memory. To use memory efficiently, you should be familiar with these mechanisms and know which one is best suited for different situations. You can use:

  • Code models

    By selecting a code model, you can control the default memory placement of functions. For more information, see Code models and memory attributes for function storage.

  • Data models

    By selecting a data model, you can control the default memory placement of variables and constants. For more information, see Data models.

  • Data memory attributes

    Using IAR-specific keywords or pragma directives, you can override the default placement of functions, variables, and constants. For more information, see Using function memory attributes and Using data memory attributes, respectively.

  • The @ operator and the #pragma location directive for absolute placement.

    Using the @ operator or the #pragma location directive, you can place individual global and static variables at absolute addresses. Note that it is not possible to use this notation for absolute placement of individual functions. For more information, see Data placement at an absolute location.

  • The @ operator and the #pragmalocation directive for section placement.

    Using the @ operator or the #pragmalocation directive, you can place individual functions, variables, and constants in named sections. The placement of these sections can then be controlled by linker directives. For more information, see Data and function placement in sections.

  • The ‑‑code_section option

    Use the ‑‑code_section option to place functions in named sections, which is useful, for example, if you want to direct them to different fast or slow memories. To read more about the ‑‑code_section option, see --code_section.