lwax
Load Word Algebraic Indexed - 7C 00 00 4D
lwax
Instruction Syntax
Mnemonic | Format | Flags |
lwax | rD,rA,rB | None |
Instruction Encoding
0
1
1
1
1
1
D
D
D
D
D
A
A
A
A
A
B
B
B
B
B
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
1
0
0
1
0
Field | Bits | Description |
Primary Opcode | 0-5 | 011111 (0x1F) |
rD | 6-10 | Destination register |
rA | 11-15 | Base register (can be 0) |
rB | 16-20 | Index register |
XO | 21-30 | 0000000001 (1) - Extended opcode |
Rc | 31 | Record bit (0) |
Operation
if rA = 0 then EA ← (rB) else EA ← (rA) + (rB) rD ← EXTS(MEM(EA, 4))
A word (32 bits) is loaded from memory, sign-extended to 64 bits, and placed in register rD. The effective address is computed by adding the contents of registers rA and rB, or just rB if rA is 0.
Note: This indexed form is essential for array access and dynamic addressing with signed 32-bit data in 64-bit environments. The sign extension preserves the sign of signed word values, making it ideal for processing signed integer arrays and data structures. If rA=0, it is treated as the value 0, not the contents of register r0.
Affected Registers
- rD: Loaded with sign-extended word value
- rA: Used as base register (if not 0)
- rB: Used as index register
Examples
Example 1: Load signed word from array
# Load signed word from array using indexed addressing
lwax r3, r4, r5 # r3 = sign-extended word from address r4 + r5
Example 2: Load with zero base register
# Load from absolute address
lwax r6, r0, r7 # r6 = sign-extended word from address r7
Example 3: Array element access
# Access signed integer array element
slwi r8, r9, 2 # Multiply index by 4 (word size)
lwax r10, r11, r8 # Load signed word from array[r9]