brh

Byte-Reverse Halfword

brh RA,RS

Reverses the byte order of a halfword in a register.

Details

The contents of bits 0:15 of register RS are placed into bits 0:15 of register RA in byte-reversed order. The contents of bits 16:31 of register RS are placed into bits 16:31 of register RA in byte-reversed order.

Pseudocode Operation

RA ← (RS)8:15 || (RS)0:7
         (RS)24:31 || (RS)16:23

Programming Note

The brh instruction is useful for reversing the byte order of 16-bit halves within a 32-bit register. Ensure that the source and destination registers are correctly specified to avoid data corruption. This operation does not require any special privileges or alignment considerations.

Example

brh r4, r3

Encoding

Binary Layout
0
0
RS
6
RA
11
6
16
11
21
16
26
21
31
 
Format X-form
Opcode 0x7C0001B6
Extension Base
Registers Altered None

Operands

  • RA
    Target General Purpose Register
  • RS
    Source General Purpose Register