6 using register-based map and field directives – ARM VERSION 1.2 User Manual

Page 70

Advertising
background image

Writing ARM and Thumb Assembly Language

2-58

Copyright © 2000, 2001 ARM Limited. All rights reserved.

ARM DUI 0068B

2.10.6

Using register-based MAP and FIELD directives

Register-based

MAP

and

FIELD

directives define register-based symbols. There are two

main uses for register-based symbols:

defining structures similar to C structures

gaining faster access to memory sections described by non register-based

MAP

and

FIELD

directives.

Defining register-based symbols

Register-based symbols can be very useful, but you must be careful when using them.
As a general rule, use them only in the following ways:

As the location for a load or store instruction to load from or store to. If

Location

is a register-based symbol based on the register

Rb

and with numeric offset, the

assembler automatically translates, for example,

LDR Rn,Location

into

LDR

Rn,[Rb,#offset]

.

In an

ADR

or

ADRL

instruction,

ADR Rn,Location

is converted by the assembler into

ADD Rn,Rb,#offset

.

Adding an ordinary numeric expression to a register-based symbol to get another
register-based symbol.

Subtracting an ordinary numeric expression from a register-based symbol to get
another register-based symbol.

Subtracting a register-based symbol from another register-based symbol to get an
ordinary numeric expression. Do not do this unless the two register-based
symbols are based on the same register. Otherwise, you have a combination of
two registers and a numeric value. This results in an assembler error.

As the operand of a

:BASE:

or

:INDEX:

operator. These operators are mainly of

use in macros.

Other uses usually result in assembler error messages. For example, if you write

LDR

Rn,=Location

, where

Location

is register-based, you are asking the assembler to load

Rn

from a memory location that always has the current value of the register

Rb

plus offset

in it. It cannot do this, because there is no such memory location.

Similarly, if you write

ADD Rd,Rn,#expression

, and

expression

is register-based, you are

asking for a single

ADD

instruction that adds both the base register of the expression and

its offset to

Rn

. Again, the assembler cannot do this. You must use two

ADD

instructions

to perform these two additions.

Advertising