mul
Multiply (low 32-bit result to register)
Multiplies $t2 by $t3, or an immediate, as signed values and puts the low 32 bits of the product in $t1.
Used in
- Arrays and stringsMIPS assembly
- jal, jr, and the course calling conventionMIPS assembly
- syscall in the PlaygroundMIPS assembly
- Multiply and divide with hi and loMIPS assembly
- Stack arguments and a stack frameMIPS assembly
- Recursion: factorial and FibonacciMIPS assembly
- A jump tableMIPS assembly
- A 2D arrayMIPS assembly
- Drawing shapes on the screenMIPS assembly
Forms
mul , ,
Pseudo-instructions
The assembler turns these into one or more real instructions.
Operands
$t1- Any general-purpose register,
$0to$31, using its numeric or named spelling, such as$8or$t0($zerois$0;$rais$31). $t2- A general-purpose register. It may be the same register as
$t1. $t3- A general-purpose register. It may be the same register as
$t1. imm- An immediate value: a signed 16-bit value (
-32768to32767) or a 32-bit value (-2147483648to4294967295). The assembler chooses a supported encoding for the value and other operands; a pseudoinstruction may expand into several instructions.
No overflow exception is raised. HI is updated with the upper 32 bits.
# Initialize both inputs, then execute mul with initialized inputs. Inspect $t2: 21.
li $t0, 7
li $t1, 3
mul $t2, $t0, $t1