stb
Store Byte - 98 00 00 00
stb
Instruction Syntax
Mnemonic | Format | Flags |
stb | rS,d(rA) | None |
Instruction Encoding
1
0
0
1
1
0
S
S
S
S
S
A
A
A
A
A
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
Field | Bits | Description |
Primary Opcode | 0-5 | 100110 (0x26) |
rS | 6-10 | Source register |
rA | 11-15 | Base register |
SIMM | 16-31 | Signed immediate offset |
Operation
EA ← (rA) + SIMM (EA) ← (rS)[24:31]
The effective address is calculated by adding the signed immediate offset to the base register. The least significant byte of the source register is stored at the effective address.
Note: The stb instruction stores the least significant byte (bits 24-31) of the source register to memory.
Affected Registers
Memory
- Byte at effective address (EA)
Examples
Basic Store Byte
# Store byte from r3 to address in r4 stb r3, 0(r4) # Store byte at address in r4 stb r3, 4(r4) # Store byte at address r4 + 4
Array Access
# Store byte in array li r4, 0 # Array index slwi r4, r4, 0 # Multiply by 1 (byte size) add r5, r3, r4 # Calculate address stb r6, 0(r5) # Store byte
Character Storage
# Store character in string li r3, 'A' # Load character 'A' stb r3, 0(r4) # Store at string address li r3, 0 # Null terminator stb r3, 1(r4) # Store null terminator