Slide 15.5: DIV instruction
Slide 15.7: IDIV instruction (cont.)
Home

IDIV Instruction


The IDIV (signed divide) instruction performs signed integer division, using the same operands as the DIV 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, AX is divided by “src” and the quotient is stored in AL and the remainder in AH. If source is a word value, DX:AX is divided by “src”, and the quotient is stored in AL and the remainder in DX.
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 
 .data
 x  SWORD  2001h
 y  SBYTE  80h
 .code
 movsx  eax, x
 idiv   y
 call   WriteHex
 .data
   x  SWORD  -101h
   y  SBYTE  10h
 .code
   mov    eax, 0
   mov    ax, x
   test   y, 0FFh
   jz     ABORT
   idiv   y
   call   WriteHex
 ABORT:   exit
 .data
 x  SWORD  -1010h
 y  SBYTE  10h
 .code
 mov    eax, 0
 mov    ax, x
 idiv   y
 call   WriteHex
 Output   Output   Output 
  AL =   AH =

 

  AL =   AH =

 

  AL =   AH =