A32 Rotated Immediate Utility

ARM Immediate Encoder & Decoder

Encode a 32-bit constant into the classic ARM A32 rotated-immediate Operand2 format, or decode a 12-bit immediate field into its resulting 32-bit value. Inspect imm8, rotate_imm, rotation amount, binary fields and alternative valid representations.

✓ imm8 ✓ rotate_imm ✓ Operand2 ✓ ROR32 ✓ All Valid Encodings
IMM
ARM A32 Immediate
● Ready
Enter an unsigned 32-bit constant in hexadecimal, decimal or binary.
Auto recognizes 0x hexadecimal and 0b binary prefixes.
Enter the 12-bit rotate_imm:imm8 field, range 0x000–0xFFF.
The upper four bits are rotate_imm and the lower eight bits are imm8.
ARM A32 rule: the 12-bit immediate field is not a normal 12-bit integer. It contains an 8-bit value and a 4-bit rotation count. The 32-bit constant is produced by rotating the zero-extended imm8 value right by 2 × rotate_imm bits.
ARM Immediate Result Calculated
Encoded Immediate
32-Bit Constant
Operand2
imm8
rotate_imm
Actual Rotation
Encodable
Decimal Constant
Valid Encodings
Bit Layout
# Operand2 rotate_imm Rotation imm8 Decoded Constant
Calculation Breakdown

What Is the ARM Immediate Encoder & Decoder?

The ARM Immediate Encoder & Decoder analyzes the rotated immediate constant format used by many classic ARM A32 data-processing instructions. It can test whether a 32-bit integer can be represented directly in this format and, when possible, calculate the required imm8 and rotate_imm fields.

The reverse mode accepts the 12-bit immediate Operand2 field and reconstructs the exact 32-bit constant represented by those bits.

ARM A32 Rotated Immediate Format

For a data-processing instruction with the immediate bit set, the 12-bit Operand2 field contains two components rather than a normal unsigned 12-bit number.

Operand2 bits: 11 8 7 0 +-------------------+---------------------------+ | rotate_imm | imm8 | +-------------------+---------------------------+ 4 bits 8 bits

The eight-bit value is zero-extended to 32 bits and rotated right by an even number of positions.

ARM Immediate Decode Formula

rotation = 2 × rotate_imm constant = ROR32(ZeroExtend(imm8), rotation)

Because rotate_imm contains four bits, its possible values are 0 through 15. The corresponding rotations are therefore 0, 2, 4, 6 and so on through 30 bits.

Why ARM Uses an 8-Bit Value Plus Rotation

A 32-bit ARM instruction has limited space for operands after allocating bits to the condition code, instruction class, opcode, registers and control flags. The rotated immediate design allows many useful constants to be represented while retaining a compact 12-bit field.

This is especially useful for constants containing a compact group of set bits positioned at different locations within a 32-bit word.

Example: Encode 0x000000FF

The value 255 fits directly in eight bits, so no rotation is required.

Constant = 0x000000FF imm8 = 0xFF rotate_imm = 0 rotation = 0 bits Operand2 = 0x0FF ROR32(0x000000FF, 0) = 0x000000FF

Example: Encode 0xFF000000

This constant does not fit directly into an eight-bit value at bit positions 7 through 0, but it can be generated by rotating an eight-bit value.

imm8 = 0xFF rotate_imm = 4 rotation = 8 bits ROR32(0x000000FF, 8) = 0xFF000000 Operand2: 0100 11111111 = 0x4FF

Example: Decode Operand2 0x4FF

Operand2 = 0x4FF rotate_imm = 0x4 imm8 = 0xFF Rotation: 4 × 2 = 8 bits ROR32(0x000000FF, 8) Result: 0xFF000000

Not Every 32-Bit Constant Is Encodable

Only constants obtainable from an eight-bit value rotated right by an even number of bit positions can use this immediate format. A value such as 0x12345678 cannot be represented as one classic A32 rotated immediate.

If the constant is not encodable, this calculator reports that result instead of generating a false imm8 or rotation field.

Why Can One Constant Have Multiple Encodings?

The ARM rotated immediate representation is not unique for every representable constant. Some values can be generated from multiple imm8 and rotation combinations.

For this reason, the encoder searches all 16 rotation fields and lists every valid representation rather than assuming the first representation is the only possible one.

What Is rotate_imm?

rotate_imm is the four-bit field stored in bits 11 through 8 of the immediate Operand2. It is not the rotation amount itself. The actual number of right rotation positions is twice the field value.

rotate_imm = 0 → ROR #0 rotate_imm = 1 → ROR #2 rotate_imm = 2 → ROR #4 rotate_imm = 3 → ROR #6 ... rotate_imm = 15 → ROR #30

What Is imm8?

imm8 is the lower eight bits of the immediate Operand2 field. Before the rotation is applied, this byte is treated as an unsigned value and zero-extended to 32 bits.

imm8 = 0x80 Zero extended: 0x00000080 Then apply: ROR32(0x00000080, 2 × rotate_imm)

ARM Immediate Operand2 Bit Layout

11 8 7 0 rrrr iiiiiiii rrrr = rotate_imm iiiiiiii = imm8 12-bit encoded value: Operand2 = (rotate_imm << 8) | imm8

Encoder vs Decoder Mode

Constant → Immediate Encoding

Use encoder mode when you know the 32-bit constant and want to determine whether an A32 data-processing instruction can represent it directly.

Immediate Encoding → Constant

Use decoder mode when examining an instruction's Operand2 bits and you want to calculate the actual 32-bit immediate value.

ARM Immediate Encoding and MOV

The rotated immediate format is commonly encountered while decoding instructions such as MOV, ADD, SUB, CMP, AND, ORR and other A32 data-processing operations when their immediate control bit is set.

MOV r0, #constant Data-processing immediate Operand2: rotate_imm : imm8

Whether a particular constant can appear directly in such an instruction depends on whether it has a valid rotated immediate representation.

ARM Immediate vs Normal 12-Bit Immediate

A common decoding mistake is treating the entire Operand2 field as a normal 12-bit integer. For classic ARM data-processing immediate instructions, that interpretation is incorrect.

Operand2 = 0x4FF Incorrect: constant = 0x4FF Correct: rotate_imm = 4 imm8 = 0xFF ROR32(0xFF, 8) = 0xFF000000

ARM Immediate Encoder & Decoder FAQs

How many bits are in an ARM A32 immediate Operand2?
The encoded immediate Operand2 contains 12 bits: four rotate bits and eight immediate-value bits.
Is the ARM immediate field a normal 12-bit integer?
No. In classic A32 data-processing immediate instructions, it contains an 8-bit value plus a 4-bit rotation field.
What is the ARM immediate rotation formula?
The rotation amount is two times rotate_imm, and the final constant is the 32-bit rotate-right result of the zero-extended imm8 value.
What range can rotate_imm have?
rotate_imm is four bits wide and therefore ranges from 0 through 15.
What rotations are possible?
The format supports even rotations from 0 through 30 bits.
What range can imm8 have?
imm8 is an unsigned eight-bit value ranging from 0x00 through 0xFF.
Can every 32-bit number be encoded?
No. Only constants obtainable by rotating a zero-extended eight-bit value right by an even number of positions are directly representable.
Can a constant have more than one valid encoding?
Yes. Some constants have multiple imm8 and rotate_imm combinations that produce exactly the same 32-bit result.
What does Operand2 0x4FF represent?
It contains rotate_imm 4 and imm8 0xFF. The actual rotation is eight bits, producing 0xFF000000.
Is 0x12345678 directly encodable?
No. It cannot be produced from one eight-bit value using an even rotate-right operation in this classic A32 immediate format.
Does this calculator handle Thumb immediates?
No. This tool specifically handles the classic ARM A32 data-processing rotated immediate format.
Does it decode AArch64 logical immediates?
No. AArch64 uses different immediate encoding schemes and should be decoded with an A64-specific calculator.

Encode or Decode ARM A32 Immediate Constants

Check whether a 32-bit constant fits the classic ARM rotated immediate format, calculate imm8 and rotate_imm, decode Operand2 fields and inspect every valid encoding for the selected value.

Scroll to Top