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:

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

No rotate000000000000000000000000xxxxxxxx0-25510-0xFF
Right, 30 bits0000000000000000000000xxxxxxxx000-102040-0x3FC
Right, 28 bits00000000000000000000xxxxxxxx00000-4080160-0xFF0
Right, 26 bits000000000000000000xxxxxxxx0000000-16320640-0x3FC0
... .........
Right, 8 bitsxxxxxxxx0000000000000000000000000-255 x 2242240-0xFF000000
Right, 6 bitsxxxxxx000000000000000000000000xx---
Right, 4 bitsxxxx000000000000000000000000xxxx---
Right, 2 bitsxx000000000000000000000000xxxxxx---

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.

Copyright © 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B