lswx
Load String Word Indexed
lswx RT, RA, RB
Loads N bytes from memory (N in XER).
Details
Loads a variable number of bytes from memory into a sequence of GPRs starting at RT, where the byte count is stored in XER[25:31]. Bytes are loaded from address RA|0 (or RA + RB if RA is non-zero) into consecutive 32-bit words. 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
reg[8*byte_offset:8*byte_offset+7] ← [addr + i]
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
lswx r3, r4, r5
Encoding
Binary Layout
31
0
RT
6
RA
11
RB
16
533
21
/
31
Operands
-
RT
Start Reg -
RA
Base -
RB
Index