stwx
Store Word Indexed - 7C 00 00 2E
stwx

Instruction Syntax

Mnemonic Format Flags
stwx 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 Source register
rA 11-15 Base register
rB 16-20 Index register
Reserved 21-29 000000000
Reserved 30-31 00

Operation

EA ← (rA) + (rB)
(EA) ← (rS)

The effective address is calculated by adding the base register to the index register. The word (32-bit value) in the source register is stored at the effective address.

Note: The stwx instruction stores a 32-bit word to memory using indexed addressing. The address must be aligned to a 4-byte boundary.

Affected Registers

Memory

Examples

Basic Store Word Indexed

# Store word using indexed addressing
stwx r1, r3, r4     # Store r1 at address r3 + r4

Array of Words with Dynamic Index

# Store word in array using dynamic index
li r3, array         # Load array base address
li r4, 8             # Index = 8 (2 * 4 bytes)
stwx r1, r3, r4      # Store word at array[2]

Dynamic Addressing

# Store word using dynamic index calculation
li r3, base_addr     # Load base address
add r4, r5, r6       # Calculate index dynamically
stwx r1, r3, r4      # Store word at base_addr + index

Related Instructions

stw, stwu, stwux, lwzx

Back to Index