Skip to main content

IAR Embedded Workbench for Arm 9.70.x

location

In this section:
Syntax
#pragma location={address|register|NAME}
Parameters

address

The absolute address of the global or static variable or function for which you want an absolute location.

register

An identifier that corresponds to one of the Arm core registers R4–R11. This parameter cannot be used in 64-bit mode.

NAME

A user-defined section name—cannot be a section name predefined for use by the compiler and linker.

Description

Use this pragma directive to specify:

  • The location—the absolute address—of the global or static variable whose declaration follows the pragma directive.

  • An identifier specifying a register. The variable defined after the pragma directive is placed in the register. The variable must be declared as __no_init and have file scope.

A string specifying a section for placing either a variable or function whose declaration follows the pragma directive.Do not place variables that would normally be in different sections—for example, variables declared as __no_init and variables declared as const—in the same named section.

Example
#pragma location=0xFFFF0400
__no_init volatile char PORT1; /* PORT1 is located at address
                                  0xFFFF0400 */

#pragma location=R8
__no_init int TASK; /* TASK is placed in R8 */

#pragma location="FLASH"
char PORT2; /* PORT2 is located in section FLASH */

/* A better way is to use a corresponding mechanism */
#define FLASH _Pragma("location=\"FLASH\"")
/* ... */
FLASH int i; /* i is placed in the FLASH section */
See also

Controlling data and function placement in memory and Declare and place your own sections.