stswx

Store String Word Indexed

stswx RT, RA, RB

Stores N bytes to memory (N in XER).

Details

Stores a variable number of bytes from a sequence of GPRs starting at RT to memory, where the byte count is stored in XER[25:31]. Bytes are stored from consecutive 32-bit words to address RA|0 (or RA + RB if RA is non-zero). This is a Base category instruction that does not affect condition registers.

Pseudocode Operation

N ← XER[25:31]
addr ← (RA == 0) ? 0 : RA + RB
reg ← RT
for i ← 0 to N-1
  byte_offset ← i mod 4
  if byte_offset == 0 and i > 0 then
    reg ← (reg + 1) mod 32
  [addr + i] ← reg[8*byte_offset:8*byte_offset+7]

Programming Note

String instructions are not pipelined on most implementations and can be very slow for large counts. Consider using byte loops or vector instructions for performance-critical paths. NB: these instructions are optional in Power ISA 3.0+ and may trap on some implementations.

Example

stswx r3, r4, r5

Encoding

Binary Layout
31
0
RT
6
RA
11
RB
16
661
21
/
31
 
Format X-form
Opcode 0x7C00052A
Extension Base
Registers Altered XER

Operands

  • RT
    Start Reg
  • RA
    Base
  • RB
    Index