2 register-based maps – ARM VERSION 1.2 User Manual

Page 65

Advertising
background image

Writing ARM and Thumb Assembly Language

ARM DUI 0068B

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

2-53

2.10.2

Register-based maps

In many cases, you can use the same register as the base register every time you access
a data structure. You can include the name of the register in the base address of the map.
Example 2-17 shows such a register-based map. The labels defined in the map include
the register.

Example 2-17

MAP 0,r9
consta FIELD 4 ; consta uses four bytes, located at offset 0 (from r9)
constb FIELD 4 ; constb uses four bytes, located at offset 4
x FIELD 8 ; x uses eight bytes, located at offset 8
y FIELD 8 ; y uses eight bytes, located at offset 16
string FIELD 256 ; string is up to 256 bytes long, starting at offset 24

Using the map in Example 2-17, you can access the data structure wherever it is:

ADR r9,datastart
LDR r4,constb ; => LDR r4,[r9,#4]

constb

contains the offset of the data item from the start of the data structure, and also

includes the base register. In this case the base register is r9, defined in the

MAP

directive.

Advertising