stswx
Store String Word Indexed - 7C 00 00 5B
stswx
Instruction Syntax
Mnemonic | Format | Flags |
stswx | rS,rA,rB | None |
Instruction Encoding
0
1
1
1
1
1
S
S
S
S
S
A
A
A
A
A
B
B
B
B
B
0
0
0
0
0
0
0
0
0
0
0
Field | Bits | Description |
Primary Opcode | 0-5 | 011111 (0x1F) |
rS | 6-10 | Starting source register |
rA | 11-15 | Base register |
rB | 16-20 | Index register (contains byte count) |
Reserved | 21-29 | 000000000 |
Reserved | 30-31 | 00 |
Operation
EA ← (rA) + (rB) NB ← (rB)[0:31] for i = 0 to NB-1 do if i mod 4 = 0 then r ← (rS + i/4) endif (EA + i) ← (r)[(3 - (i mod 4)) * 8 : (3 - (i mod 4)) * 8 + 7] endfor
The effective address is calculated by adding the base register to the index register. The number of bytes to store (NB) is taken from the index register. Starting from register rS, NB bytes are stored to consecutive memory locations starting at the effective address.
Note: The stswx instruction stores a string of bytes to memory from consecutive registers, with the byte count specified in a register. This is useful for copying data structures or strings of variable length.
Affected Registers
Memory
- NB bytes starting at effective address (EA)
- NB is the value in rB
Examples
Basic Store String Word Indexed
# Store bytes from r3 with count in r4 to address in r5 stswx r3, r5, r4 # Store (r4) bytes starting at r5
Copy Variable Length Data
# Copy data with variable length li r3, source_data # Load source data in registers li r4, 12 # Load byte count li r5, dest_addr # Load destination address stswx r3, r5, r4 # Copy 12 bytes to destination
String Copy with Length
# Copy string with length in register li r3, string_data # Load string data in registers li r4, string_len # Load string length li r5, buffer # Load buffer address stswx r3, r5, r4 # Copy string to buffer