stswi
Store String Word Immediate - 7C 00 00 5A
stswi

Instruction Syntax

Mnemonic Format Flags
stswi rS,rA,NB 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
NB 16-20 Number of bytes to store
Reserved 21-29 000000000
Reserved 30-31 00

Operation

EA ← (rA)
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 the value in the base register. Starting from register rS, the specified number of bytes (NB) are stored to consecutive memory locations. The bytes are taken from consecutive registers, with each register providing 4 bytes.

Note: The stswi instruction stores a string of bytes to memory from consecutive registers. This is useful for copying data structures or strings.

Affected Registers

Memory

Examples

Basic Store String Word Immediate

# Store 16 bytes from r3 through r6 to memory
stswi r3, r4, 16    # Store 16 bytes starting at address in r4

Copy Data Structure

# Copy a 12-byte structure
li r3, source_addr  # Load source address
li r4, dest_addr    # Load destination address
stswi r3, r4, 12    # Copy 12 bytes from r3-r5 to destination

String Copy

# Copy a string of known length
li r3, string_data  # Load string data in registers
li r4, buffer       # Load buffer address
stswi r3, r4, 20    # Copy 20 bytes (5 registers worth)

Related Instructions

stswx, lswi, lswx

Back to Index