rbit

Reverse Bits

RBIT <Wd>, <Wn>

Reverses the bit order in a register.

Details

Reverses the order of all bits in a 32-bit register, placing the least-significant bit in the most-significant position and vice versa. Condition flags are not affected by this instruction. This is a pure bit-reversal operation with no side effects.

Pseudocode Operation

result ← BitReverse(Wn)
Wd ← result

Example

RBIT w0, w1

Encoding

Binary Layout
0
1
0
11010110
00000
000000
Rn
Rd
 
Format Data Processing
Opcode 0x5AC00000
Extension Base

Operands

  • Wd
    Destination 32-bit integer register
  • Wn
    First source / base 32-bit integer register

Reference (Arm A64 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x2E605800 RBIT <Vd>.<T>, <Vn>.<T> A64 0 | Q | 1 | 01110 | 01 | 10000 | 00101 | 10 | Rn | Rd
0x5AC00000 RBIT <Wd>, <Wn> A64 0 | 1 | 0 | 11010110 | 00000 | 000000 | Rn | Rd
0xDAC00000 RBIT <Xd>, <Xn> A64 1 | 1 | 0 | 11010110 | 00000 | 000000 | Rn | Rd
0x05278000 RBIT <Zd>.<T>, <Pg>/M, <Zn>.<T> A64 00000101 | size | 1001 | 1 | 1 | 100 | Pg | Zn | Zd

Description

Reverse Bits reverses the bit order in a register.

Operation

bits(datasize) operand = X[n, datasize];
bits(datasize) result;

for i = 0 to datasize-1
    result<(datasize-1)-i> = operand<i>;

X[d, datasize] = result;