brh

Byte-Reverse Halfword

brh RA,RS

Reverses the byte order of a halfword in a register.

Encoding

Binary Layout
0
0:5
RS
6:10
RA
11:15
6
16:20
11
21:25
16
26:30
21
31
 
Format X-form
Opcode 0x7C0001B6
Extension Base

Operands

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

Example

brh r4, r3

Related

More in Base

Reference

Description

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.

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.