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 ●????–●
- ● set from the result
- ? undefined afterwards
- – not changed
Forms
Operands
r/m- A general-purpose register or memory location matching the operation’s size, for example
raxorqword [rbp-8]. The byte registersah,bh,chanddhcannot be used with a REX prefix, including when the memory address usesr8–r15. reg- A general-purpose register matching the operation’s size, for example
al,ax,eaxorrax. The byte registersah,bh,chanddhcannot be used with a REX prefix, which is required byspl,bpl,sil,dilandr8–r15. imm- An immediate value encoded in the instruction, written as a number, character or label. Its encoded width and any sign extension depend on the instruction; arithmetic immediates may be sign-extended, while shift counts are used without sign extension.
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