rev16
Reverse Bytes in Halfwords
REV16 <Wd>, <Wn>
Reverses bytes in each 16-bit halfword.
Pseudocode Operation
result[7:0] ← Wn[15:8]
result[15:8] ← Wn[7:0]
result[23:16] ← Wn[31:24]
result[31:24] ← Wn[23:16]
Wd ← result
Example
REV16 w0, w1
Encoding
Binary Layout
0
31
1
30
0
29
11010110
28:21
00000
20:16
0000
15:12
01
11:10
Rn
9:5
Rd
4:0
Operands
-
Wd
Destination 32-bit integer register -
Wn
First source / base 32-bit integer register
Related
Other forms of rev16
Across architectures
Byte Swap (Endianness Reversal) : how x86, ARM, RISC-V, and PowerISA each do this.
More in Base
Reference
View in Arm A64 ISA Reference ↗
Arm A64 ISA
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x0E201800 | REV16 <Vd>.<T>, <Vn>.<T> | A64 | 0 | Q | 0 | 01110 | size | 100000000 | 1 | 10 | Rn | Rd | ||
| 0x5AC00400 | REV16 <Wd>, <Wn> | A64 | 0 | 1 | 0 | 11010110 | 00000 | 0000 | 01 | Rn | Rd | ||
| 0xDAC00400 | REV16 <Xd>, <Xn> | A64 | 1 | 1 | 0 | 11010110 | 00000 | 0000 | 01 | Rn | Rd |
Description
Reverse bytes in 16-bit halfwords reverses the byte order in each 16-bit halfword 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;