Non-Confidential | PDF version | ARM DUI0473M | ||

| ||||

Home > ARM and Thumb Instructions > Syntax of Operand2 as a constant |

An Operand2 constant in an instruction has a limited range of values.

`#`

`constant`

where

is an expression evaluating to a numeric
value.`constant`

In ARM instructions,

can have any value that can be produced by rotating an
8-bit value right by any even number of bits within a 32-bit word.`constant`

In Thumb instructions,

can be:`constant`

- Any constant that can be produced by shifting an 8-bit value left by any number of bits within a 32-bit word.
- Any constant of the form
`0x00XY00XY`

. - Any constant of the form
`0xXY00XY00`

. - Any constant of the form
`0xXYXYXYXY`

.

`X`

and `Y`

are
hexadecimal digits.
In addition, in a small number of instructions,

can
take a wider range of values. These are listed in the individual
instruction descriptions.`constant`

When an Operand2 constant is used with the instructions `MOVS`

, `MVNS`

, `ANDS`

, `ORRS`

, `ORNS`

, `EORS`

, `BICS`

, `TEQ`

or `TST`

,
the carry flag is updated to bit[31] of the constant, if the constant
is greater than 255 and can be produced by shifting an 8-bit value.
These instructions do not affect the carry flag if Operand2 is any
other constant.

If the value of an Operand2 constant is not available, but its logical inverse or negation is available, then the assembler produces an equivalent instruction and inverts or negates the constant.

For example, an assembler might assemble the instruction `CMP`

`Rd`

, #0xFFFFFFFE as the equivalent instruction
`CMN`

`Rd`

, #0x2.

Be aware of this when comparing disassembly listings with source code.

You can use the `--diag_warning 1645`

assembler command line option to check
when an instruction substitution occurs.