Writing ARM and Thumb Assembly Language
ARM DUI 0068B
Copyright © 2000, 2001 ARM Limited. All rights reserved.
2-27
Direct loading with MOV in Thumb state
In Thumb state you can use the
MOV
instruction to load constants in the range 0-255. You
cannot generate constants outside this range because:
•
The Thumb
MOV
instruction does not provide inline access to the barrel shifter.
Constants cannot be right-rotated as they can in ARM state.
•
The Thumb
MVN
instruction can act only on registers and not on constant values.
Bitwise complements cannot be directly loaded as they can in ARM state.
If you attempt to use a
MOV
instruction with a value outside the range 0-255, the
assembler reports the error:
Immediate
n
out of range for this operation
.
2.6.2
Loading with LDR Rd, =const
The
LDR Rd,=
const
pseudo-instruction can construct any 32-bit numeric constant in a
single instruction. Use this pseudo-instruction to generate constants that are out of range
of the
MOV
and
MVN
instructions.
The
LDR
pseudo-instruction generates the most efficient code for a specific constant:
•
If the constant can be constructed with a
MOV
or
MVN
instruction, the assembler
generates the appropriate instruction.
•
If the constant cannot be constructed with a
MOV
or
MVN
instruction, the assembler:
—
places the value in a
literal pool
(a portion of memory embedded in the code
to hold constant values)
—
generates an
LDR
instruction with a program-relative address that reads the
constant from the literal pool.
For example:
LDR r
n
, [pc, #offset to literal pool]
; load register
n
with one word
; from the address [pc + offset]
You must ensure that there is a literal pool within range of the
LDR
instruction
generated by the assembler. Refer to
Placing literal pools
on page 2-28 for more
information.
Refer to
LDR ARM pseudo-instruction
on page 4-82 for a description of the syntax of
the
LDR
pseudo-instruction.
Содержание Developer Suite
Страница 10: ...Preface x Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 110: ...Assembler Reference 3 32 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 185: ...ARM Instruction Reference ARM DUI 0068B Copyright 2000 2001 ARM Limited All rights reserved 4 75 Example MSR CPSR_f r5 ...
Страница 238: ...Thumb Instruction Reference 5 44 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 282: ...Vector Floating point Programming 6 44 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 360: ...Index Index 6 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...