IDIV divides signed two's-complement numbers using the same registers as DIV: a byte divisor divides AX, giving the quotient in AL and the remainder in AH; a word divisor divides DX:AX, giving the quotient in AX and the remainder in DX.

Rounding and the remainder

The quotient is rounded toward zero, and the remainder takes the sign of the dividend. So −9 ÷ 2 gives −4 remainder −1 (not −5 remainder 1), and 9 ÷ −2 gives −4 remainder 1. In every case quotient × divisor + remainder equals the dividend.

Sign-extend first

Because the dividend is double width, a 16-bit value in AX must be widened to DX:AX before a word IDIV, and an 8-bit value in AL to AX before a byte IDIV. CWD and CBW do exactly that. Clearing DX with XOR DX, DX, the habit from DIV, is wrong here for negative numbers: −50 in AX with DX = 0 is read as 65486, and the division silently gives a wrong answer.

Prints -7.
MOV AX, -50
CWD ; DX:AX = -50 (DX = FFFFh)
MOV BX, 7
IDIV BX ; AX = -7, DX = -1
NEG AX ; AX = 7
MOV CX, AX
MOV DL, '-'
MOV AH, 02h
INT 21h
MOV AX, CX
ADD AL, '0' ; digit -> character
MOV DL, AL
MOV AH, 02h ; DOS: print DL
INT 21h
MOV AL, -9
CBW ; AX = -9
MOV BL, 2
IDIV BL ; AL = -4, AH = -1

Divide overflow

A zero divisor, or a quotient that does not fit in the signed destination, raises interrupt 0 just as with DIV. The usual surprise is −32768 ÷ −1: the answer +32768 does not fit in a signed word. On the 8086 the allowed quotients are −127..127 for a byte divide and −32767..32767 for a word divide, so a quotient of exactly −128 or −32768 also faults; the 286 and later accept it.

Flags

All six arithmetic flags are undefined after IDIV.

Later CPUs

The 386 adds IDIV ECX on EDX:EAX, prepared with the new CDQ instruction.