stwbrx
Store Word Byte-Reverse Indexed
Swaps bytes and stores a word.
Details
The stwbrx instruction stores a word from a register to memory, reversing the byte order. The effective address is calculated by adding the contents of registers RA and RB. If RA is zero, it is treated as zero; otherwise, its value is used. The data from RS is stored in reverse byte order into the memory location specified by the effective address.
Pseudocode Operation
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
Encoding
Operands
-
RS
Source -
RA
Base -
RB
Index