Slide 15.3: IMUL instruction
Slide 15.5: DIV instruction
Home

IMUL Instruction (Cont.)

Two- and three- operand formats truncate the product to the length of the destination. If significant digits are lost, the Overflow and Carry flags are set.

 8-Bit Signed Multiplication   8-Bit Signed Multiplication   3-Operand Multiplication 
 .data
 x  SBYTE  -02h
 y  SBYTE  40h
 .code
 mov   al, x
 imul  y
 call  DumpRegs
 .data
 x  SBYTE  -03h
 y  SBYTE  40h
 .code
 mov   al, x
 imul  y
 call  DumpRegs
 .data
 x  SWORD  20h
 .code
 imul  bx, x, 400h
 call  DumpRegs
 Output   Output   Output 
  AX=
  CF=   OF=



  AX=
  CF=   OF=



  BX=
  CF=   OF=



 3-Operand Multiplication   2-Operand Multiplication   32-Bit Signed Multiplication 
 .data
 x  SWORD  -200h
 .code
 movsx  eax, x
 imul   ebx, eax, 0400h
 call   DumpRegs
 .data
 x  SDWORD  200h
 y  SDWORD  400h
 .code
 mov   ecx, x
 mov   ebx, y
 imul  ecx, ebx
 call  DumpRegs
 .data
 x  SDWORD  -200h
 y  SDWORD   400h
 .code
 mov   eax, x
 mov   ebx, y
 imul  ebx
 call  DumpRegs
 Output   Output   Output 
  EBX=
  CF=   OF=



  ECX=
  CF=   OF=



  EDX:EAX=
  CF=   OF=