lwbrx

Load Word Byte-Reverse Indexed

lwbrx RT, RA, RB

Loads a word and swaps bytes.

Details

Loads a word (32-bit value) from memory at address (RA|0) + RB, byte-reverses it, and stores the result in RT. No status flags are affected. This instruction is used for converting word-sized data between big-endian and little-endian formats.

Pseudocode Operation

EA ← (RA|0) + RB
RT ← byte_reverse_32([EA])

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