ldbrx

Load Doubleword Byte-Reverse Indexed

ldbrx RT, RA, RB

Loads a doubleword from memory, byte-reversing it before storing in the target register.

Details

The ldbrx instruction loads a doubleword from memory and reverses its bytes before placing it into the target register RT. The effective address (EA) is calculated as the sum of 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, 8)
RT ← load_data56:63 || load_data48:55 || load_data40:47 || load_data32:39 || load_data24:31 || load_data16:23 || load_data8:15 || load_data0:7

Programming Note

The ldbrx instruction is commonly used for loading and reversing the byte order of a doubleword from memory into a register. Ensure that the base address in RA (or 0 if using an absolute address) and the offset in RB are correctly set to avoid accessing invalid memory locations. This instruction operates at user privilege level, but care must be taken to handle potential exceptions such as alignment errors or access violations. Performance may vary depending on memory alignment; optimal performance is achieved when the effective address is 8-byte aligned.

Example

ldbrx r3, r4, r5

Encoding

Binary Layout
31
0
RT
6
RA
11
RB
16
532
/
 
Format X-form
Opcode 0x7C000428
Extension Base

Operands

  • RT
    Target
  • RA
    Base
  • RB
    Index