# `mulu`

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

Web page: https://asm-editor.specy.app/documentation/m68k/instruction/mulu

**Unsigned multiply**

Category: Arithmetic

The default word form multiplies two unsigned 16-bit values and stores the 32-bit product in a data register.

Used in: [Arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/m68k/think-in-assembly/arithmetic-logic-and-bits.md) (M68K assembly), [bsr, rts, link and unlk](https://asm-editor.specy.app/learn/courses/m68k/think-in-assembly/bsr-rts-link-and-unlk.md) (M68K assembly), [trap #15 and its tasks](https://asm-editor.specy.app/learn/courses/m68k/talking-to-the-outside-world/trap-15-and-its-tasks.md) (M68K assembly), [Multiply and divide, with the remainder](https://asm-editor.specy.app/learn/courses/m68k/examples/multiply-and-divide.md) (M68K assembly), [Stack arguments and a stack frame](https://asm-editor.specy.app/learn/courses/m68k/examples/subroutine-with-stack-arguments.md) (M68K assembly), [Recursion: factorial and Fibonacci](https://asm-editor.specy.app/learn/courses/m68k/examples/factorial-and-fibonacci.md) (M68K assembly), [A jump table](https://asm-editor.specy.app/learn/courses/m68k/examples/jump-table.md) (M68K assembly), [A 2D array](https://asm-editor.specy.app/learn/courses/m68k/examples/two-dimensional-array.md) (M68K assembly), [The snake game](https://asm-editor.specy.app/learn/courses/m68k/examples/snake.md) (M68K assembly), [Flappy ASM](https://asm-editor.specy.app/learn/courses/m68k/examples/flappy-asm.md) (M68K assembly)

## Flags

| Flag | Effect |
| --- | --- |
| X | not changed |
| N | depends on the result |
| Z | depends on the result |
| V | depends on the result |
| C | always 0 |

## Forms

- `mulu <ea>, Dn` · Size .w
  - Source: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs, d(PC), d(PC,Xn), #imm (data)

## 68020 only

These forms require the 68020. Select `opt p=68020` before any code or data.

- `mulu <ea>, Dn` · Size .l
  - Source: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs, d(PC), d(PC,Xn), #imm (data)
- `mulu <ea>, Dh:Dl` · Size .l
  - Source: Dn, (An), (An)+, -(An), d(An), d(An,Xn), abs, d(PC), d(PC,Xn), #imm (data)

## Operands

- [`<ea>`](https://asm-editor.specy.app/documentation/m68k/addressing-mode.md): An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With `opt p=68020`, an allowed `d(An,Xn)` or `d(PC,Xn)` mode also permits the corresponding 68020 indexed and memory indirect forms. See [68020 addressing](https://asm-editor.specy.app/documentation/m68k/addressing-mode/68020.md).
- [`Dn`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/direct.md): A data register, `d0` to `d7`.
- [`Dh:Dl`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/register-pairs.md): Two data registers for a 64-bit product, for example `d2:d1`. `Dl` supplies the 32-bit multiplicand. The result’s high long replaces `Dh`, and its low long replaces `Dl`. Use different registers for the two halves.
- [`#imm`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/immediate.md): An immediate value written after `#`: a number, character or label, such as `#10`, `#$FF` or `#'a'`. It must fit the operation’s size: byte `-128` to `255`, word `-32768` to `65535`, or long `-2147483648` to `4294967295`; signed and unsigned spellings are accepted.

## Description

The source and the destination’s low word supply the inputs; the destination’s old upper word is ignored. Word multiplication clears V.

On the 68020, `mulu.l` multiplies two 32-bit values. In both `mulu.l d0, d1` and `mulu.l d0, d2:d1`, the inputs are `d0` and `d1`. The old value of `d2` is not used. The single-register form keeps the low 32 bits in `d1` and sets V if the product does not fit in an unsigned 32-bit result. The pair form keeps all 64 bits, with the high long in `d2` and the low long in `d1`, and clears V. Use different registers for the high and low halves.

N and Z describe the result kept: 32 bits for word multiplication or a single-register long result, and 64 bits for a register-pair result. C is cleared and X is unchanged.

## Example

```m68k
move.l #2, d0
mulu #4, d0 ; d0 = 8

* --- Word operands, long result ---
move.l #$FFFF, d1
mulu #$FFFF, d1 ; d1 = $FFFE0001
```
