rev32

Reverse Bytes in Words

REV32 <Xd>, <Xn>

Reverses bytes in each 32-bit word (64-bit op).

Details

Reverses the byte order within each 32-bit word of a 64-bit register independently, leaving word boundaries intact. Condition flags are not affected by this instruction. This operation is performed on 64-bit registers (X-registers) and processes two 32-bit words in parallel.

Pseudocode Operation

result[7:0] ← Xn[39:32]
result[15:8] ← Xn[31:24]
result[23:16] ← Xn[23:16]
result[31:24] ← Xn[15:8]
result[39:32] ← Xn[7:0]
result[47:40] ← Xn[63:56]
result[55:48] ← Xn[55:48]
result[63:56] ← Xn[47:40]
Xd ← result

Example

REV32 x0, x1

Encoding

Binary Layout
1
1
0
11010110
00000
0000
10
Rn
Rd
 
Format Data Processing
Opcode 0xDAC00800
Extension Base

Operands

  • Xd
    Destination 64-bit integer register
  • Xn
    First source / base 64-bit integer register

Reference (Arm A64 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x2E200800 REV32 <Vd>.<T>, <Vn>.<T> A64 0 | Q | 1 | 01110 | size | 100000000 | 0 | 10 | Rn | Rd
0xDAC00800 REV32 <Xd>, <Xn> A64 1 | 1 | 0 | 11010110 | 00000 | 0000 | 10 | Rn | Rd

Description

Reverse bytes in 32-bit words reverses the byte order in each 32-bit word of a register.

Operation

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

constant integer containers = datasize DIV container_size;
for c = 0 to containers-1
    bits(container_size) container = Elem[operand, c, container_size];
    Elem[result, c, container_size] = Reverse(container, 8);

X[d, datasize] = result;