mul
Unsigned multiply
Multiplies unsigned integers into the full implicit product in the one-operand form.
8086 and later
Used in
- Arithmetic, logic and bitsx86-64 assembly
- Multiply and divide, with the remainderx86-64 assembly
CFPFAFZFSFDFOF ●????–●
- ● depends on the result
- ? undefined (do not rely on it)
- – not changed
Forms
Operands
r/m- A general-purpose register or memory location matching the operation’s size, for example
raxorqword [rbp-8]. reg- A general-purpose register matching the operation’s size, for example
al,ax,eaxorrax. imm- An immediate value: a constant written in the instruction as a number, a character or a label, for example
10,0x1f,'a'ormsg. Open a row to see the size it has in each form, such asimm8orimm32.
Its explicit source width selects the implicit other factor and full product: 8 bits uses al and produces ax; 16 bits uses ax and produces dx:ax; 32 bits uses eax and produces edx:eax; 64 bits uses rax and produces rdx:rax. The register before the colon holds the high half. CF and OF are set when that high half is nonzero.
NASM also accepts two- and three-operand mul spellings as aliases of the corresponding imul forms. These keep only the destination-width low product; their overflow flags follow signed imul rules. Use the one-operand form when you need the full unsigned product.
global _start
section .text
_start:
mov rax, 12
mov rbx, 5
mov rcx, 3
mov rsi, 9
mul rax
mov rax, 60 ; syscall 60: exit
xor rdi, rdi
syscall