INSTRUCTION SET DESCRIPTIONS

Table C-4. Instruction Set (Continued)

Name

Description

Operation

Flags

Affected

 

 

 

 

 

 

 

IDIV

Integer Divide:

When Source Operand is a Byte:

AF ?

 

IDIV src

(temp) (byte-src)

CF ?

 

Performs a signed division of the

if

DF –

 

IF –

 

(temp) / (AX) > 0 and

 

accumulator (and its extension) by the

 

OF ?

 

(temp) / (AX) > 7FH or

 

source operand. If the source operand

 

PF ?

 

(temp) / (AX) < 0 and

 

is a byte, it is divided into the double-

 

SF ?

 

(temp) / (AX) < 0 – 7FH – 1

 

length dividend assumed to be in

 

TF –

 

then (type 0 interrupt is generated)

 

registers AL and AH; the single-length

 

ZF ?

 

(SP) (SP) – 2

 

quotient is returned in AL, and the

 

((SP) + 1:(SP)) FLAGS

 

 

single-length remainder is returned in

 

 

(IF) 0

 

 

AH. For byte integer division, the

 

 

(TF) 0

 

 

maximum positive quotient is +127

 

 

(SP) (SP) – 2

 

 

(7FH) and the minimum negative

 

 

((SP) + 1:(SP)) (CS)

 

 

quotient is –127 (81H).

 

 

(CS) (2)

 

 

If the source operand is a word, it is

 

 

(SP) (SP) – 2

 

 

divided into the double-length dividend

 

 

((SP) + 1:(SP)) (IP)

 

 

in registers AX and DX; the single-

 

 

(IP) (0)

 

 

length quotient is returned in AX, and

 

 

else

 

 

the single-length remainder is returned

 

 

(AL) (temp) / (AX)

 

 

in DX. For word integer division, the

 

 

(AH) (temp) % (AX)

 

 

maximum positive quotient is +32,767

 

 

When Source Operand is a Word:

 

 

(7FFFH) and the minimum negative

 

 

 

 

 

quotient is –32,767 (8001H).

(temp) (word-src)

 

 

If the quotient is positive and exceeds

if

 

 

(temp) / (DX:AX) > 0 and

 

 

the maximum, or is negative and is

 

 

(temp) / (DX:AX) > 7FFFH or

 

 

less than the minimum, the quotient

 

 

(temp) / (DX:AX) < 0 and

 

 

and remainder are undefined, and a

 

 

(temp) / (DX:AX) < 0 – 7FFFH – 1

 

 

type 0 interrupt is generated. In

 

 

then (type 0 interrupt is generated)

 

 

particular, this occurs if division by 0 is

 

 

(SP) (SP) – 2

 

 

attempted. Nonintegral quotients are

 

 

((SP) + 1:(SP)) FLAGS

 

 

truncated (toward 0) to integers, and

 

 

(IF) 0

 

 

the remainder has the same sign as

 

 

(TF) 0

 

 

the dividend.

 

 

(SP) (SP) – 2

 

 

Instruction Operands:

 

 

((SP) + 1:(SP)) (CS)

 

 

IDIV reg

 

 

(CS) (2)

 

 

IDIV mem

(SP) (SP) – 2

 

 

 

((SP) + 1:(SP)) (IP)

 

 

 

(IP) (0)

 

 

 

else

 

 

 

(AX) (temp) / (DX:AX)

 

 

 

(DX) (temp) % (DX:AX)

 

 

 

 

 

NOTE: The three symbols used in the Flags Affected column are defined as follows:

the contents of the flag remain unchanged after the instruction is executed ¸? the contents of the flag is undefined after the instruction is executed

the flag is updated after the instruction is executed

C-16

Page 339
Image 339
Intel 80C186XL, 80C188XL user manual Idiv, Integer Divide When Source Operand is a Byte