xxbrh
VSX Vector Byte-Reverse Halfword
xxbrh XT,XB
Reverses the bytes of each halfword in a vector register.
Encoding
Binary Layout
T
0
B
11
475
16
BX
21
TX
30 31
Operands
-
XT
Target Vector Register -
XB
Source Vector Register
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
Reverses the byte order within each 16-bit (halfword) element in XB and stores the result in XT. This is a VSX instruction commonly used for endianness conversion on 16-bit data granules. No condition registers or status fields are affected.
Operation
for i in 0 to 7 do
hw ← XB[i*16:(i+1)*16-1]
XT[i*16:(i+1)*16-1] ← REVERSE_BYTES(hw, 2)
end for
Programming Note
The xxbrh instruction is useful for reversing the byte order of each halfword in a vector, which can be necessary for data format conversion or compatibility. Ensure that the VSX (Vector Scalar Extensions) are enabled by checking and setting the appropriate bit in the MSR register. This instruction operates on 128-bit vectors and requires proper alignment of the source and target registers. Be cautious of endianness issues when using this instruction, as it directly manipulates byte order.