Writing ARM and Thumb Assembly Language

Example 2-23 on page 2-60 contains separate LDR pseudo-instructions to load the address of each of the data items. Each LDR pseudo-instruction is converted to a separate instruction by the assembler. However, it is possible to access the entire data section with a single LDR pseudo-instruction. Example 2-24 shows how to do this. Both speed and code size are improved.

Example 2-24

 

AREA

data, DATA

StartOfData

EQU

0x1000

EndOfData

EQU

0x2000

DataAreaBase

RN

r11

 

MAP

0,DataAreaBase

StartOfUsedData

FIELD

0

Integer

FIELD

4

String

FIELD

MaxStrLen

Array

FIELD

ArrayLen*8

BitMask

FIELD

4

EndOfUsedData

FIELD

0

UsedDataLen

EQU

EndOfUsedData - StartOfUsedData

 

ASSERT

UsedDataLen <= (EndOfData - StartOfData)

 

AREA

code, CODE

 

LDR

DataAreaBase,=StartOfData

 

MOV

r0,#1

 

STR

r0,Integer

 

MOV

r0,#0

 

STRB

r0,String

 

MOV

r0,#0xA000000A

 

STRB

r0,BitMask

 

 

 

Note

In this example, the MAP directive is:

MAP 0, DataAreaBase

not:

MAP StartOfData,DataAreaBase

The MAP and FIELD directives give the position of the data relative to the DataAreaBase register, not the absolute position. The LDR DataAreaBase,=StartOfData statement provides the absolute position of the entire data section.

ARM DUI 0068B

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

2-61

Page 73
Image 73
ARM VERSION 1.2 manual This example, the MAP directive is, Not