sthbrx

Store Halfword Byte-Reverse Indexed

sthbrx RS, RA, RB

Swaps bytes and stores a halfword.

Details

The sthbrx instruction stores a halfword from the source register RS to memory at an effective address calculated by adding the contents of registers RA and RB. The data is stored in byte-reversed order compared to other store instructions.

Pseudocode Operation

if RA = 0 then b ←0
else           b ←(RA)
EA ←b + (RB)
MEM(EA, 2) ←(RS)56:63 || (RS)48:55

Programming Note

The sthbrx instruction is useful for storing a halfword in memory with byte-reversed order. Ensure that the base address register (RA) and index register (RB) are correctly set to avoid incorrect memory addresses. This instruction operates at user privilege level and will raise an exception if the effective address is out of bounds or if there is a protection fault.

Example

sthbrx r3, r4, r5

Encoding

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

Operands

  • RS
    Source
  • RA
    Base
  • RB
    Index