xxbrh

VSX Vector Byte-Reverse Halfword

xxbrh XT,XB

Reverses the bytes of each halfword in a vector register.

Details

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.

Pseudocode 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.

Example

xxbrh vs1, vs3

Encoding

Binary Layout
T
0
B
11
475
16
BX
21
TX
30 31
 
Format XX2-form
Opcode 0xF007076C
Extension VSX
Registers Altered MSR

Operands

  • XT
    Target Vector Register
  • XB
    Source Vector Register