5.9.4. Program-relative maps

You can use the program counter (r15) as the base register for a map. In this case, each STM or LDM instruction must be within 4KB of the data item it addresses, because the offset is limited to 4KB. The data structure must be in the same area as the instructions, because otherwise there is no guarantee that the data items will be within range after linking.

Example 5.18 shows a program fragment with such a map. It includes a directive which allocates space in memory for the data structure, and an instruction which accesses it.

Example 5.18. 

datastruc			%		280			; reserves 280 bytes of memory for datastruc
			MAP		datastruc
consta			#		4
constb			#		4
x			#		8
y			#		8
string			#		256
code			LDR		r2,constb			; => LDR r2,[pc,offset]

In this case, there is no need to load the base register before loading the data as the program counter already holds the correct address. (This is not actually the same as the address of the LDR instruction, because of pipelining in the processor. However, the assembler takes care of this for you.)

Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0040D