vrev16
Vector Reverse 16
VREV16<c>.<dt> <Qd>, <Qm>
Reverses bytes within 16-bit halfwords.
Details
Reverses the byte order within each 16-bit halfword element in the source register. For example, bytes [1,0] become [0,1] within each 16-bit element. Condition flags (N, Z, C, V) are not affected. Executes in A32/T32 with NEON extension; operates on integer data types.
Pseudocode Operation
for i = 0 to 127 by 16:
for j = 0 to 15 by 8:
Qd[i+j+7:i+j] ← Qm[i+15-j:i+8-j]
Example
VREV16.dt q0, q2
Encoding
Binary Layout
111100111
D
11
size
00
Vd
0
00
10
0
M
0
Vm
Operands
-
Qd
Destination 128-bit SIMD register -
Qm
Second source 128-bit SIMD register
Reference (Arm AArch32 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0xF3B00100 | VREV16{<c>}{<q>}.<dt> <Dd>, <Dm> | A32 | 111100111 | D | 11 | size | 00 | Vd | 0 | 00 | 10 | 0 | M | 0 | Vm | ||
| 0xF3B00140 | VREV16{<c>}{<q>}.<dt> <Qd>, <Qm> | A32 | 111100111 | D | 11 | size | 00 | Vd | 0 | 00 | 10 | 1 | M | 0 | Vm | ||
| 0xFFB00100 | VREV16{<c>}{<q>}.<dt> <Dd>, <Dm> | T32 | 111111111 | D | 11 | size | 00 | Vd | 0 | 00 | 10 | 0 | M | 0 | Vm | ||
| 0xFFB00140 | VREV16{<c>}{<q>}.<dt> <Qd>, <Qm> | T32 | 111111111 | D | 11 | size | 00 | Vd | 0 | 00 | 10 | 1 | M | 0 | Vm |
Description
Vector Reverse in halfwords reverses the order of 8-bit elements in each halfword of the vector, and places the result in the corresponding destination vector.
There is no distinction between data types, other than size.
Depending on settings in the CPACR, NSACR, and HCPTR registers, and the Security state and PE mode in which the instruction is executed, an attempt to execute the instruction might be undefined, or trapped to Hyp mode. For more information see Enabling Advanced SIMD and floating-point support.
Operation
if ConditionPassed() then
EncodingSpecificOperations(); CheckAdvSIMDEnabled();
bits(64) result;
integer element;
integer rev_element;
for r = 0 to regs-1
element = 0;
for c = 0 to containers-1
rev_element = (element + elements_per_container) - 1;
for e = 0 to elements_per_container-1
Elem[result, rev_element, esize] = Elem[D[m+r], element, esize];
element = element + 1;
rev_element = rev_element - 1;
D[d+r] = result;