stwbrx

Store Word Byte-Reverse Indexed

stwbrx RS, RA, RB

Swaps bytes and stores a word.

Details

Byte-reverses the low 32 bits of RS and stores the result as a word in memory at address (RA|0) + RB. No status flags are affected. This instruction is used for writing word-sized data in reversed byte order.

Pseudocode Operation

EA ← (RA|0) + RB
[EA] ← byte_reverse_32(RS[32:63])

Programming Note

The stwbrx instruction is useful for storing a word in memory with its byte order reversed, which can be necessary for compatibility with systems that use different endianness. Ensure that the effective address (EA) calculated from registers RA and RB is properly aligned to avoid alignment exceptions. This instruction operates at user privilege level but will raise an exception if the EA is out of bounds or if there are insufficient permissions.

Example

stwbrx r3, r4, r5

Encoding

Binary Layout
31
0
RS
6
RA
11
RB
16
662
21
/
31
 
Format X-form
Opcode 0x7C00052C
Extension Base

Operands

  • RS
    Source
  • RA
    Base
  • RB
    Index