# `mul`

[MIPS Documentation](https://asm-editor.specy.app/documentation/mips.md) › [Instructions](https://asm-editor.specy.app/documentation/mips/instruction.md)

Web page: https://asm-editor.specy.app/documentation/mips/instruction/mul

**Multiply (low 32-bit result to register)**

Category: Arithmetic

Multiplies the second register by the third, or an immediate, as signed values and stores the low 32 bits of the product in the first.

Used in: [Arrays and strings](https://asm-editor.specy.app/learn/courses/mips/think-in-assembly/arrays-and-strings.md) (MIPS assembly), [jal, jr, and the course calling convention](https://asm-editor.specy.app/learn/courses/mips/think-in-assembly/jal-jr-and-the-calling-convention.md) (MIPS assembly), [syscall in the Playground](https://asm-editor.specy.app/learn/courses/mips/talking-to-the-outside-world/syscall.md) (MIPS assembly), [Multiply and divide with hi and lo](https://asm-editor.specy.app/learn/courses/mips/examples/multiply-and-divide.md) (MIPS assembly), [Stack arguments and a stack frame](https://asm-editor.specy.app/learn/courses/mips/examples/subroutine-with-stack-arguments.md) (MIPS assembly), [Recursion: factorial and Fibonacci](https://asm-editor.specy.app/learn/courses/mips/examples/factorial-and-fibonacci.md) (MIPS assembly), [A jump table](https://asm-editor.specy.app/learn/courses/mips/examples/jump-table.md) (MIPS assembly), [A 2D array](https://asm-editor.specy.app/learn/courses/mips/examples/two-dimensional-array.md) (MIPS assembly), [Drawing shapes on the screen](https://asm-editor.specy.app/learn/courses/mips/examples/drawing-on-the-screen.md) (MIPS assembly), [Flappy ASM](https://asm-editor.specy.app/learn/courses/mips/examples/flappy-asm.md) (MIPS assembly)

## Forms

- `mul $t1, $t2, $t3`

## Pseudo-instructions

The processor does not have these forms. The assembler replaces each of them with one or more real instructions. Open a row to see them.

- `mul $t1, $t2, imm`
  - `mul $t1,$t2,-100`: Set HI to high-order 32 bits, LO and $t1 to low-order 32 bits of the product of $t2 and 16-bit signed immediate (use mfhi to access HI, mflo to access LO) → `addi $at, $zero, imm`; `mul $t1, $t2, $at`
  - `mul $t1,$t2,100000`: Set HI to high-order 32 bits, LO and $t1 to low-order 32 bits of the product of $t2 and 32-bit immediate (use mfhi to access HI, mflo to access LO) → `lui $at, hi(imm)`; `ori $at, $at, lo(imm)`; `mul $t1, $t2, $at`

## Operands

- `$t1`: Any general-purpose register, `$0` to `$31`, using its numeric or named spelling, such as `$8` or `$t0` (`$zero` is `$0`; `$ra` is `$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 (`-32768` to `32767`) or a 32-bit value (`-2147483648` to `4294967295`). The size your value needs decides which real instructions the assembler uses. Open the row to see them for each size.

## Description

No overflow exception is raised. HI is updated with the upper 32 bits.

## Example

```mips
# Initialize both inputs, then execute mul with initialized inputs. Inspect $t2: 21.
li $t0, 7
li $t1, 3
mul $t2, $t0, $t1
```
