5.8.13. AREA directive

The AREA directive instructs the assembler to assemble a new code or data area. Areas are independent, named, indivisible chunks of code or data that are manipulated by the linker. Refer to Chapter 5 Basic Assembly Language Programming in the ARM Software Development Toolkit User Guide and Chapter 6 Linker in the ARM Software Development Toolkit Reference Guide for more information.

Syntax

The syntax of the AREA directive is:

AREA name{,attr}{,attr}...

where:

name

is the name that the area is to be given.

You can choose any name for your areas. However, names startingwith a digit must be enclosed in bars or a missing area name error is generated. For example, |1_DataArea|.

Certain names are conventional. For example, |C$$code| is used for code areas produced by the C compiler, or for code areas otherwise associated with the C library.

attr

are one or more comma-delimited area attributes. Valid attributes are:

ALIGN=expression

By default, AOF areas are aligned on a 4-byte boundary.

expression can have any integer value between 2 and 31. The area is aligned on a 2expression-byte boundary. For example, if expression is 10, the area is aligned on a 1KB boundary.

CODE

Contains machine instructions. READONLY is the default.

COMDEF

Is a common area definition. This AOF area may contain code or data. It must be identical to any other area of the same name in other source files.

Identical AOF areas with the same name are overlaid in the same area of memory by the linker. If any are different, the linker generates a warning and does not overlay the areas.

COMMON

Is a common data area. You must not define any code or data in it. It is initialized to zeroes by the linker. All common areas with the same name are overlaid in the same area of memory by the linker. They do not all need to be the same size. The linker allocates as much space as is required by the largest common area of each name.

DATA

Contains data, not instructions. READWRITE is the default.

INTERWORK

Indicates that the code area is suitable for ARM/Thumb interworking.

NOINIT

Indicates that the data area is initialized to zero. It contains only space reservation directives, with no initialized values.

PIC

Indicates position-independent code. It can execute at any address without modification.

READONLY

Indicates that this area should not be written to.

READWRITE

Indicates that this area may be read from and written to.

Usage

There must be at least one AREA directive for an assembly.

Use the AREA directive to subdivide your source file into AOF areas. You must use a different name for each area within the same source file.

You should normally use separate AOF areas for code and data. Large programs can usually be conveniently divided into several code areas. Large independent data sets are also usually best placed in separate areas.

The scope of local labels is defined by AOF areas, optionally subdivided by ROUT directives. See Local labels and ROUT directive.

If no AREA directive is specified, the assembler generates an AOF area with the name |$$$$$$$|, and produces a diagnostic message. This limits the number of error messages caused by the missing directive, but does not lead to a successful assembly.

Example

The following example defines a read-only code area named Example.

		AREA		Example,CODE,READONLY 						; An example code area.
		; code
Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0041C
Non-Confidential