Thumb Instruction Reference

5.6.2LDR Thumb pseudo-instruction

The LDR pseudo-instruction loads a low register with either:

a 32-bit constant value

an address.

Note

This section describes the LDR pseudo-instruction only. See Thumb memory access instructions on page 5-4 for information on the LDR instruction.

Syntax

LDR register, =[expr label-exp]

where:

 

 

register

is the register to be loaded. LDR can access the low registers (r0-r7) only.

expr

evaluates to a numeric constant:

 

if the value of expr is within range of a MOV instruction, the

 

 

assembler generates the instruction

 

if the value of expr is not within range of a MOV instruction, the

 

 

assembler places the constant in a literal pool and generates a

 

 

program-relative LDR instruction that reads the constant from the

 

 

literal pool.

label-exp

is a program-relative or external expression. The assembler places the

 

value of label-expin a literal pool and generates a program-relative LDR

 

instruction that loads the value from the literal pool.

If label-expis an external expression, or is not contained in the current section, the assembler places a linker relocation directive in the object file. The linker ensures that the correct address is generated at link time.

The offset from the pc to the value in the literal pool must be positive and less than 1KB. You are responsible for ensuring that there is a literal pool within range. See LTORG on page 7-14 for more information.

Usage

The LDR pseudo-instruction is used for two main purposes:

To generate literal constants when an immediate value cannot be moved into a register because it is out of range of the MOV instruction.

ARM DUI 0068B

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

5-41

Page 235
Image 235
ARM VERSION 1.2 manual LDR Thumb pseudo-instruction, If the value of expr is within range of a MOV instruction