 RealView Assembler User's Guide |
|
| Direct loading with MOV and MVN2.5.1. Direct loading with MOV and MVNIn ARM and Thumb‑2, you can use the 32‑bit MOV and MVN instructions to load a wide range of constant values directly into a register. The 16‑bit Thumb MOV instruction can load any constant in the range 0‑255. You cannot use the 16‑bit MVN instruction to load a constant. ARM state immediate constants shows the range of values that can be loaded in a single instruction in ARM. Thumb‑2 immediate constants shows the range of values that can be loaded in a single instruction in Thumb‑2. You do not have 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 is not available, the assembler reports the error: Immediate n out of range for this operation. ARM state immediate constantsIn ARM state: MOV can load any 8‑bit constant value, giving a range of 0x0‑0xFF (0‑255).
It can also rotate these values by any even number. These values are also available as immediate operands in many data processing operations, without being loaded in a separate instruction. MVN can load the bitwise complements of these values. The numerical values are ‑(n+1), where n is the value available in MOV.
In ARMv6T2 and above, MOV can load any 16‑bit number, giving a range of 0x0‑0xFFFF (0‑65535).
Table 2.5 shows the range of 8‑bit values that this provides (for data processing operations). Table 2.6 shows the range of 16‑bit values that this provides (for MOV instructions only). Table 2.5. ARM state immediate constants (8‑bit) | Binary | Decimal | Step | Hexadecimal | MVN valuea | Notes |
|---|
000000000000000000000000abcdefgh | 0‑255 | 1 | 0‑0xFF | –1 to –256 | ‑ | 0000000000000000000000abcdefgh00 | 0‑1020 | 4 | 0‑0x3FC | –4 to –1024 | ‑ | 00000000000000000000abcdefgh0000 | 0‑4080 | 16 | 0‑0xFF0 | –16 to –4096 | ‑ | 000000000000000000abcdefgh000000 | 0‑16320 | 64 | 0‑0x3FC0 | –64 to –16384 | ‑ | | | ... | ... | ... | ... | ‑ | abcdefgh000000000000000000000000 | 0‑255 x 224 | 224 | 0‑0xFF000000 | 1‑256 x –224 | ‑ | cdefgh000000000000000000000000ab | (bit pattern) | ‑ | ‑ | (bit pattern) | See b in Notes | efgh000000000000000000000000abcd | (bit pattern) | ‑ | ‑ | (bit pattern) | See b in Notes | gh000000000000000000000000abcdef | (bit pattern) | ‑ | ‑ | (bit pattern) | See b in Notes |
Table 2.6. ARM state immediate constants in MOV instructions | Binary | Decimal | Step | Hexadecimal | MVN value | Notes |
|---|
0000000000000000abcdefghijklmnop | 0‑65535 | 1 | 0‑0xFFFF | ‑ | See c in Notes |
These notes give extra information on Table 2.5 and Table 2.6. - a
The MVN values are not available directly as operands in other, non data processing, instructions. - b
These values are available in ARM state only. All the other values in this table are also available in Thumb‑2, except where noted. - c
These values are only available in ARMv6T2 and above. They are not available directly as operands in other instructions.
Thumb‑2 immediate constantsIn Thumb state, in ARMv6T2 and above: the 32‑bit MOV instruction can load: any 8‑bit constant value, giving a range of 0x0‑0xFF (0‑255) any 8‑bit constant value, shifted left by any number any 8‑bit bit pattern duplicated in all four bytes of a register any 8‑bit bit pattern duplicated in bytes 0 and 2, with bytes 1 and 3 set to 0 any 8‑bit bit pattern duplicated in bytes 1 and 3, with bytes 0 and 2 set to 0.
These values are also available as immediate operands in many data processing operations, without being loaded in a separate instruction. the 32‑bit MVN instruction can load the bitwise complements of these values. The numerical values are ‑(n+1), where n is the value available in MOV. the 32‑bit MOV instruction can load any 16‑bit number, giving a range of 0x0‑0xFFFF (0‑65535). These values are not available as immediate operands in data processing operations.
Table 2.7 shows the range of values that this provides (for data processing operations). Table 2.8 shows the range of 16‑bit values that this provides (for MOV instructions only). Table 2.7. Thumb state immediate constants | Binary | Decimal | Step | Hexadecimal | MVN valuea | Notes |
|---|
000000000000000000000000abcdefgh | 0‑255 | 1 | 0‑0xFF | –1 to –256 | ‑ | 00000000000000000000000abcdefgh0 | 0‑510 | 2 | 0‑0x1FE | –2 to –512 | ‑ | 0000000000000000000000abcdefgh00 | 0‑1020 | 4 | 0‑0x3FC | –4 to –1024 | ‑ | | | ... | ... | ... | ... | ‑ | 0abcdefgh00000000000000000000000 | 0‑255 x 223 | 223 | 0‑0x7F800000 | 1‑256 x –223 | ‑ | abcdefgh000000000000000000000000 | 0‑255 x 224 | 224 | 0‑0xFF000000 | 1‑256 x –224 | ‑ | abcdefghabcdefghabcdefghabcdefgh | (bit pattern) | ‑ | 0xXYXYXYXY | 0xXYXYXYXY | ‑ | 00000000abcdefgh00000000abcdefgh | (bit pattern) | ‑ | 0x00XY00XY | 0xFFXYFFXY | ‑ | abcdefgh00000000abcdefgh00000000 | (bit pattern) | ‑ | 0xXY00XY00 | 0xXYFFXYFF | ‑ | 00000000000000000000abcdefghijkl | 0‑4095 | 1 | 0‑0xFFF | ‑ | See b in Notes |
Table 2.8. Thumb state immediate constants in MOV instructions | Binary | Decimal | Step | Hexadecimal | MVN value | Notes |
|---|
0000000000000000abcdefghijklmnop | 0‑65535 | 1 | 0‑0xFFFF | ‑ | See c in Notes |
These notes give extra information on Table 2.7 and Table 2.8. - a
The MVN values are not available directly as operands in other instructions. - b
These values are available directly as operands in ADD, SUB, and MOV instructions, but not in MVN or any other data processing instructions. - c
These values are only available in MOV instructions.
|
|