Operation:
(temp) - (NUMR)
if (temp) I (DIVR) >0 and (temp)
I(DIVR) > MAX
or (temp) I (DIVR) <0 and (temp)
I(DIVR) <0 - MAX -1 then (QUO), (REM) undefined
(SP) - (SP) - 2
((SP) + 1:(SP)) - FLAGS (IF) - 0
(TF) - 0
(SP) - (SP) - 2
((SP) +1:(SP)) - (CS) (CS) - (2)
(SP) - (SP) - 2 ((SP) + 1:(SP)) - (IP) (lP) - (0)
else
(QUO) - (temp) I (DIVR), where I is signed division
(REM) - (temp) % (DIVR) where
%is signed modulo
Description:
IDIV source
IDIV (Integer Divide) performs a signed divi- sion of the accumulator (and its extension) by the source operand. If the source operand is a byte, it is divided into the double-length divi- dend assumed to be in registers AL and AH; the single-length quotient is returned in AL, and the single-length remainder is returned in AH. For byte integer division, the maximum positive quotient is +127 (7FH) and the minimum negative quotient is -127 (S1H). If the source operand is a word, it is divided into the double-length dividend in registers AX and DX; the single-length quotient is returned in
Flags Affected:
AF,.CF, OF, PF, SF, ZF undefined
AX, and the single-length remainder is returned in DX. For word integer division, the maximum positive quotient is +32,767 (7FFFH) and the minimum negative quotient is -32,767 (S001H). If the quotient is positive and exceeds the maximum, or is negative and is less than the minimum, the quotient and remainder are undefined, and a type 0 inter- rupt is generated. In particular, this occurs if division by 0 is attempted. Nonintegral quo- tients are truncated (toward 0) to integers, and the remainder has the same sign as the divi- dend. The content of AF, CF, OF, PF, SF and ZF is undefined following IDIV.