rbit
Reverse Bits (Thumb)
RBIT <Rd>, <Rm>
Reverses bits in a 32-bit register.
Details
Reverse Bits: Reverses all 32 bits in Rm and writes the result to Rd. Each bit position i is moved to position 31-i. The condition flags are not affected. This instruction is available in Thumb state (T32) and A32.
Pseudocode Operation
for i = 0 to 31
Rd[i] ← Rm[31-i]
Example
RBIT r0, r2
Encoding
Binary Layout
111110101
001
Rn
1111
Rd
10
10
Rm
Operands
-
Rd
Destination general-purpose register -
Rm
Second source / offset general-purpose register
Reference (Arm AArch32 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x06FF0F30 | RBIT{<c>}{<q>} <Rd>, <Rm> | A32 | cond | 01101 | 1 | 11 | 1 | 1 | 1 | 1 | Rd | 1 | 1 | 1 | 1 | 0 | 011 | Rm | ||
| 0xFA90F0A0 | RBIT{<c>}{<q>} <Rd>, <Rm> | T32 | 111110101 | 001 | Rn | 1111 | Rd | 10 | 10 | Rm |
Description
Reverse Bits reverses the bit order in a 32-bit register.
Operation
if ConditionPassed() then
EncodingSpecificOperations();
bits(32) result;
for i = 0 to 31
result<31-i> = R[m]<i>;
R[d] = result;