Writing ARM and Thumb Assembly Language
2-26 Copyright © 2000, 2001 ARM Limited. All rights reserved. ARM DUI 0068B
2.6.1 Direct loading with MOV and MVN
In ARM state, you can use the
MOV
and
MVN
instructions to load a range of 8-bit constant
values directly into a register:
•
MOV
can load any 8-bit constant value, giving a range of
0x0
to
0xFF
(0-255).
It can also rotate these values by any even number. Table 2-4 shows the range of
values that this provides.
•
MVN
can load the bitwise complement of these values. The numerical values are
-(n+1)
, where
n
are the values given in Table 2-4.
You do not need to calculate the necessary rotation. The assembler performs the
calculation for you.
You do not need to decide whether to use
MOV
or
MVN
. The assembler uses whichever is
appropriate. This is useful if the value is an assembly-time variable.
If you write an instruction with a constant that cannot be constructed, the assembler
reports the error:
Immediate n out of range for this operation
.
The range of values shown in Table 2-4 can also be used as one of the operands in
data-processing operations. You cannot use their bitwise complements as operands, and
you cannot use them as operands in multiplication operations.
Table 2-4 ARM-state immediate constants
Rotate Binary Decimal Step Hexadecimal
No rotate
000000000000000000000000xxxxxxxx
0-255 1
0-0xFF
Right, 30 bits
0000000000000000000000xxxxxxxx00
0-1020 4
0-0x3FC
Right, 28 bits
00000000000000000000xxxxxxxx0000
0-4080 16
0-0xFF0
Right, 26 bits
000000000000000000xxxxxxxx000000
0-16320 64
0-0x3FC0
... ... ... ...
Right, 8 bits
xxxxxxxx000000000000000000000000
0-255 x 2
24
2
24
0-0xFF000000
Right, 6 bits
xxxxxx000000000000000000000000xx
---
Right, 4 bits
xxxx000000000000000000000000xxxx
---
Right, 2 bits
xx000000000000000000000000xxxxxx
---