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
 INCLUDE Irvine32.inc
 .data
  x  SBYTE  -02h
  y  SBYTE  40h
 .code
 main PROC
  mov   al, x
  imul  y
  call  DumpRegs
  exit
 main ENDP
 END main

 INCLUDE Irvine32.inc
 .data
  x  SBYTE  -03h
  y  SBYTE  40h
 .code
 main PROC
  mov   al, x
  imul  y
  call  DumpRegs
  exit
 main ENDP
 END main

 INCLUDE Irvine32.inc
 .data
  x  SWORD  20h
 .code
 main PROC
  imul  bx, x, 400h
  call  DumpRegs
  exit
 main ENDP
 END main
Output Output Output

AX =  

CF =   OF =

 


AX =  

CF =   OF =

 




BX =  

CF =   OF =

 



3-Operand Multiplication 2-Operand Multiplication 32-Bit Signed Multiplication
 INCLUDE Irvine32.inc
 .data
  x  SWORD  -200h
 .code
 main PROC
  movsx  eax, x
  imul   ebx, eax, 0400h
  call   DumpRegs
  exit
 main ENDP
 END main

 INCLUDE Irvine32.inc
 .data
  x  SDWORD  200h
  y  SDWORD  400h
 .code
 main PROC
  mov   ecx, x
  mov   ebx, y
  imul  ecx, ebx
  call  DumpRegs
  exit
 main ENDP
 END main

 INCLUDE Irvine32.inc
 .data
  x  SDWORD  -200h
  y  SDWORD   400h
 .code
 main PROC
  mov   eax, x
  mov   ebx, y
  imul  ebx
  call  DumpRegs
  exit
 main ENDP
 END main
Output Output Output

EBX =  

CF =   OF =

 


ECX =  

CF =   OF =

 


EDX:EAX =

   

CF =   OF =

 







      Dogs can’t operate MRI machines. But catscan.