xxbrh

VSX Vector Byte-Reverse Halfword

xxbrh XT,XB

Reverses the bytes of each halfword in a vector register.

Details

The xxbrh instruction reverses the bytes of each halfword element in the source vector register VSR[XB] and stores the result in the target vector register VSR[XT].

Pseudocode Operation

if MSR.VSX=0 then VSX_Unavailable()
do i = 0 to 7
    vsrc ← VSR[32×BX+B].hword[i]
    do j = 0 to 1
        VSR[32×TX+T].hword[i].byte[j] ← vsrc.byte[1-j]
    end
end

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