lwbrx

Load Word Byte-Reverse Indexed

lwbrx RT, RA, RB

Loads a word and swaps bytes.

Details

The lwbrx instruction loads a word from memory and reverses its byte order before storing it in the target register. The effective address is calculated by adding the contents of registers RA and RB.

Pseudocode Operation

if RA = 0 then b ←0
else           b ←(RA)
EA ←b + (RB)
load_data ←MEM(EA, 4)
RT ←320 || load_data24:31 || load_data16:23 || load_data8:15 || load_data0:7

Programming Note

The lwbrx instruction is commonly used to load a word from memory and reverse its byte order, which can be useful for handling data in big-endian or little-endian formats. Ensure that the base address (RA) and index (RB) registers are correctly set to avoid incorrect memory access. This instruction operates at user privilege level and will raise an exception if it accesses invalid memory addresses.

Example

lwbrx r3, r4, r5

Encoding

Binary Layout
31
0
RT
6
RA
11
RB
16
534
21
/
31
 
Format X-form
Opcode 0x7C00042C
Extension Base

Operands

  • RT
    Target
  • RA
    Base
  • RB
    Index