* remove "\r" nonsense
[mascara-docs.git] / i386 / i386.reference / DIV.htm
blob296728e978eae27563e84b4914b7ee59a34abc5a
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Opcode DIV</TITLE>
5 </HEAD>
6 <BODY>
7 <B>up:</B> <A HREF="c17.htm">
8 Chapter 17 -- 80386 Instruction Set</A><BR>
9 <B>prev:</B><A HREF="DEC.htm"> DEC Decrement by 1</A><BR>
10 <B>next:</B><A HREF="ENTER.htm"> ENTER Make Stack Frame for Procedure Parameters</A>
11 <P>
12 <HR>
13 <P>
14 <H1>DIV -- Unsigned Divide</H1>
16 <PRE>
17 Opcode Instruction Clocks Description
19 F6 /6 DIV AL,r/m8 14/17 Unsigned divide AX by r/m byte
20 (AL=Quo, AH=Rem)
21 F7 /6 DIV AX,r/m16 22/25 Unsigned divide DX:AX by r/m
22 word (AX=Quo, DX=Rem)
23 F7 /6 DIV EAX,r/m32 38/41 Unsigned divide EDX:EAX by r/m
24 dword (EAX=Quo, EDX=Rem)
25 </PRE>
27 <H2>Operation</H2>
29 <PRE>
30 temp := dividend / divisor;
31 IF temp does not fit in quotient
32 THEN Interrupt 0;
33 ELSE
34 quotient := temp;
35 remainder := dividend MOD (r/m);
36 FI;
37 </PRE>
39 <EM>
40 <H3>Note</H3>
41 Divisions are unsigned. The divisor is given by the r/m operand.
42 The dividend, quotient, and remainder use implicit registers. Refer to
43 the table under "Description"
44 </EM>
46 <H2>Description</H2>
48 DIV performs an unsigned division. The dividend is implicit; only the
49 divisor is given as an operand. The remainder is always less than the
50 divisor. The type of the divisor determines which registers to use as
51 follows:
52 <PRE>
54 Size Dividend Divisor Quotient Remainder
55 byte AX r/m8 AL AH
56 word DX:AX r/m16 AX DX
57 dword EDX:EAX r/m32 EAX EDX
58 </PRE>
60 <H2>Flags Affected</H2>
62 OF, SF, ZF, AR, PF, CF are undefined.
64 <H2>Protected Mode Exceptions</H2>
66 Interrupt 0 if the quotient is too large to fit in the designated register
67 (AL, AX, or EAX), or if the divisor is 0; #GP(0) for an illegal memory
68 operand effective address in the CS, DS, ES, FS, or GS segments; #SS(0)
69 for an illegal address in the SS segment; #PF(fault-code) for a page fault
71 <H2>Real Address Mode Exceptions</H2>
73 Interrupt 0 if the quotient is too big to fit in the designated register
74 (AL, AX, or EAX), or if the divisor is 0; Interrupt 13 if any part of the
75 operand would lie outside of the effective address space from 0 to 0FFFFH
77 <H2>Virtual 8086 Mode Exceptions</H2>
79 Same exceptions as in Real Address Mode; #PF(fault-code) for a page
80 fault
83 <P>
84 <HR>
85 <P>
86 <B>up:</B> <A HREF="c17.htm">
87 Chapter 17 -- 80386 Instruction Set</A><BR>
88 <B>prev:</B><A HREF="DEC.htm"> DEC Decrement by 1</A><BR>
89 <B>next:</B><A HREF="ENTER.htm"> ENTER Make Stack Frame for Procedure Parameters</A>
90 </BODY>