IMUL-MUL

By Vesper Vei
2 minutes read

Table of Contents

  1. IMUL-MUL (imul / mul)
    1. Basic purpose
    2. IMUL instruction formats
    3. MUL instruction format (unsigned)
    4. Behavioral characteristics
    5. Example
    6. Common uses

IMUL-MUL (imul / mul)

Basic purpose

IMUL → signed multiplication
MUL → unsigned multiplication Both may involve a double-register result (EDX:EAX or RDX:RAX).

IMUL instruction formats

There are three forms:

  1. Implicit form (result stored in edx:eax)
imul r/m32
; EDX:EAX = EAX * r/m32(有符号)
  1. Explicit two-operand form
imul reg, r/m32
reg = reg * r/m32
  1. Three-operand form
imul reg, r/m32, imm
reg = r/m32 * imm

MUL instruction format (unsigned)

mul r/m32 ; EDX:EAX = EAX * r/m32

MUL does not have an explicit reg = reg × x form.

Behavioral characteristics

Example

mov eax, 5
imul eax, 3 ; eax = 15
mov eax, -10
imul eax, -4 ; eax = 40(有符号乘法)

Implicit form:

mov eax, 0x10000
imul dword ptr [rbp-4] ; rdx:rax = rax * [rbp-4]

Common uses



Relationship Graph

Loading graph...