ARM VERSION 1.2 User Manual

Page 74

Advertising
background image

Writing ARM and Thumb Assembly Language

2-62

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

ARM DUI 0068B

If you use the same technique for a section of memory containing memory-mapped I/O
(or whose absolute addresses must not change for other reasons), you must take care to
keep the code maintainable.

One method is to add comments to the code warning maintainers to take care when
modifying the definitions. A better method is to use definitions of the absolute addresses
to control the register-based definitions.

Using

MAP offset,reg

followed by

label FIELD 0

makes

label

into a register-based

symbol with register part

reg

and numeric part

offset

. Example 2-25 shows this.

Example 2-25

StartOfIOArea EQU 0x1000000
SendFlag_Abs EQU 0x1000000
SendData_Abs EQU 0x1000004
RcvFlag_Abs EQU 0x1000008
RcvData_Abs EQU 0x100000C
IOAreaBase RN r11
MAP (SendFlag_Abs-StartOfIOArea),IOAreaBase
SendFlag FIELD 0
MAP (SendData_Abs-StartOfIOArea),IOAreaBase
SendData FIELD 0
MAP (RcvFlag_Abs-StartOfIOArea),IOAreaBase
RcvFlag FIELD 0
MAP (RcvData_Abs-StartOfIOArea),IOAreaBase
RcvData FIELD 0

Load the base address with

LDR IOAreaBase,=StartOfIOArea

. This allows the individual

locations to be accessed with statements like

LDR R0,RcvFlag

and

STR R4,SendData

.

Advertising