rev
Reverse Bytes (32-bit)
REV <Wd>, <Wn>
Reverses the byte order in a 32-bit register (Endianness swap).
Details
Reverses the byte order of a 32-bit value in Wn and stores the result in Wd, performing endianness conversion. The upper 32 bits of the destination register are zeroed. The condition flags NZCV are not affected. This is an AArch64-only instruction available in the Base instruction set.
Pseudocode Operation
Wd ← ReverseBytes(Wn)
Xd[63:32] ← 0
Example
REV w0, w1
Encoding
Binary Layout
0
1
0
11010110
00000
0000
10
Rn
Rd
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 | ||
|---|---|---|---|---|---|
| 0x5AC00800 | REV <Wd>, <Wn> | A64 | 0 | 1 | 0 | 11010110 | 00000 | 0000 | 10 | Rn | Rd | ||
| 0xDAC00C00 | REV <Xd>, <Xn> | A64 | 1 | 1 | 0 | 11010110 | 00000 | 0000 | 11 | Rn | Rd | ||
| 0x05344000 | REV <Pd>.<T>, <Pn>.<T> | A64 | 00000101 | size | 110100010000 | 0 | Pn | 0 | Pd | ||
| 0x05383800 | REV <Zd>.<T>, <Zn>.<T> | A64 | 00000101 | size | 111000001110 | Zn | Zd |
Description
Reverse Bytes reverses the byte order in 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;