mullw
Multiply Low Word - 7C 00 00 96
mullw
Instruction Syntax
Mnemonic | Format | Flags |
mullw | rD,rA,rB | OE = 0, Rc = 0 |
mullw. | rD,rA,rB | OE = 0, Rc = 1 |
mullwo | rD,rA,rB | OE = 1, Rc = 0 |
mullwo. | rD,rA,rB | OE = 1, Rc = 1 |
Instruction Encoding
0
1
1
1
1
1
D
D
D
D
D
A
A
A
A
A
B
B
B
B
B
OE
0
0
0
0
0
1
0
0
1
Rc
Field | Bits | Description |
Primary Opcode | 0-5 | 011111 (0x1F) |
rD | 6-10 | Destination register |
rA | 11-15 | Source register A |
rB | 16-20 | Source register B |
OE | 21 | Overflow Exception |
XO | 22-29 | 150 (Extended opcode) |
Rc | 30-31 | Record Condition Register |
Operation
rD ← (rA × rB)[32:63]
The contents of registers rA and rB are multiplied as signed 32-bit integers, and the low-order 32 bits of the result are placed into rD.
Note: The mullw instruction performs signed multiplication and returns the low-order word of the result. This is the most commonly used multiplication instruction for 32-bit arithmetic.
Affected Registers
Condition Register (CR0 field)
(if Rc = 1)
- LT (Less Than)
- GT (Greater Than)
- EQ (Equal)
- SO (Summary Overflow)
Note: CR0 field reflects the sign of the result.
XER (Exception Register)
(if OE = 1)
- SO (Summary Overflow)
- OV (Overflow)
For more information on condition codes see Section 2.1.3, "Condition Register," and Section 2.1.5, "XER Register," in the PowerPC Microprocessor Family: The Programming Environments manual.
Examples
Basic Multiplication
mullw r3, r1, r2 # r3 = r1 * r2 mullw. r3, r1, r2 # Same as above, but also sets condition register
Array Index Calculation
# Calculate array index: index * sizeof(element) lwz r4, 0(r10) # Load array index mullw r5, r4, 4 # r5 = index * 4 (for 32-bit elements) add r6, r7, r5 # r6 = base_address + offset
Matrix Operations
# Calculate matrix element offset: row * cols + col mullw r8, r6, r5 # r8 = row * cols add r9, r8, r7 # r9 = (row * cols) + col
Overflow Detection
mullwo r3, r1, r2 # Multiply with overflow exception enabled # If overflow occurs, an exception is raised
Extended Precision Arithmetic
# Part of 64-bit multiplication using low word mullw r6, r4, r5 # Get low word of product mulhw r7, r4, r5 # Get high word of product # r7:r6 contains full 64-bit result