IDIV Instruction


The (signed divide) instruction performs signed integer division, using the same operands as the instruction.

IDIV — Signed Integer Division

Usage: IDIV src

Flag O D I S Z A P C
Result ?     ? ? ? ? ?

Signed binary division of accumulator by source. If source is a byte value, is divided by “src” and the quotient is stored in and the remainder in . If source is a word value, is divided by “src”, and the quotient is stored in and the remainder in .
Clocks
Operands 286 386 486 Size Bytes
reg8 17 19 19 2
reg16 25 27 27 2
reg32   43 43 2
mem8 22 22 20 2-4
mem16 38 30 28 2-4
mem32   46 44 2-4


8-Bit Signed Division Divided by Zero Divide Overflow
 INCLUDE Irvine32.inc 
 .data
  x  SWORD  2001h
  y  SBYTE  80h
 .code
 main PROC
  movsx  eax, x
  idiv   y
  call   WriteHex
  exit
 main ENDP
 END main

 INCLUDE Irvine32.inc
 .data
  x  SWORD  -101h
  y  SBYTE  10h
 .code
 main PROC
  mov    eax, 0
  mov    ax, x
  test   y, 0FFh
  jz     ABORT
  idiv   y
  call   WriteHex
 ABORT:  exit
 main ENDP
 END main

 INCLUDE Irvine32.inc
 .data
  x  SWORD  -1010h
  y  SBYTE  10h
 .code
 main PROC
  mov    eax, 0
  mov    ax, x
  idiv   y
  call   WriteHex
  exit
 main ENDP
 END main
Output Output Output

AL =  

AH =  




AL =  

AH =  




AL =  

AH =  









      “Argued that winning a silver medal is the worst,    
      as it means being the top loser.”    
      ― Jerry Seinfeld