Files
2024-02-19 00:25:23 -05:00

69 lines
6.5 KiB
HTML

<html><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>80386 Programmer's Reference Manual -- Section 2.6</title>
</head>
<body>
<b>up:</b> <a href="C02.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C02.HTM">Chapter 2 -- Basic Programming Model</a><br>
<b>prev:</b> <a href="S02_05.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S02_05.HTM">2.5 Operand Selection</a><br>
<b>next:</b> <a href="C03.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C03.HTM">Chapter 3 -- Applications Instruction Set</a><br>
<p>
<hr>
<p>
<h1>2.6 Interrupts and Exceptions</h1>
The 80386 has two mechanisms for interrupting program execution:
<ol>
<li>Exceptions are synchronous events that are the responses of the CPU to certain conditions detected during the execution of an instruction.
<li>Interrupts are asynchronous events typically triggered by external devices needing attention.
</ol>
Interrupts and exceptions are alike in that both cause the processor to temporarily suspend its present program execution in order to execute a program of higher priority. The major distinction between these two kinds of interrupts is their origin. An exception is always reproducible by re-executing with the program and data that caused the exception, whereas an interrupt is generally independent of the currently executing program.
<p>Application programmers are not normally concerned with servicing interrupts. More information on interrupts for systems programmers may be found in <a href="C09.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C09.HTM">Chapter 9</a> . Certain exceptions , however, are of interest to applications programmers, and many operating systems give applications programs the opportunity to service these exceptions. However, the operating system itself defines the interface between the applications programs and the exception mechanism of the 80386.
<p>Table 2-2 highlights the exceptions that may be of interest to applications programmers.
<ul>
<li>A divide error exception results when the instruction <a href="DIV.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/DIV.HTM">DIV</a> or <a href="IDIV.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/IDIV.HTM">IDIV</a> is executed with a zero denominator or when the quotient is too large for the destination operand . (Refer to <a href="C03.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C03.HTM">Chapter 3</a> for a discussion of <a href="DIV.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/DIV.HTM">DIV</a> and <a href="IDIV.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/IDIV.HTM">IDIV</a>.)
<li>The debug exception may be reflected back to an applications program if it results from the trap flag (TF).
<li>A breakpoint exception results when the instruction <a href="INT.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/INT.HTM">INT 3</a> is executed. This instruction is used by some debuggers to stop program execution at specific points.
<li>An overflow exception results when the <a href="INT.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/INT.HTM">INTO</a> instruction is executed and the OF (overflow) flag is set (after an arithmetic operation that set the OF flag ) . (Refer to <a href="C03.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C03.HTM">Chapter 3</a> for a discussion of <a href="INT.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/INT.HTM">INTO</a>) .
<li>A bounds check exception results when the <a href="BOUND.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/BOUND.HTM">BOUND</a> instruction is executed and the array index it checks falls outside the bounds of the array . (Refer to <a href="C03.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C03.HTM">Chapter 3</a> for a discussion of the <a href="BOUND.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/BOUND.HTM">BOUND</a> instruction. )
<li>Invalid opcodes may be used by some applications to extend the instruction set. In such a case, the invalid opcode exception presents an opportunity to emulate the opcode.
<li>The &quot;coprocessor not available&quot; exception occurs if the program contains instructions for a coprocessor, but no coprocessor is present in the system.
<li>A coprocessor error is generated when a coprocessor detects an illegal operation.
</ul>
The instruction <a href="INT.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/INT.HTM">INT</a> generates an interrupt whenever it is executed; the processor treats this interrupt as an exception. The effects of this interrupt (and the effects of all other exceptions) are determined by exception handler routines provided by the application program or as part of the systems software (provided by systems programmers). The <a href="INT.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/INT.HTM">INT</a> instruction itself is discussed in <a href="C03.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C03.HTM">Chapter 3</a>. Refer to <a href="C09.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C09.HTM">Chapter 9</a> for a more complete description of exceptions.
<pre>
Table 2-2. 80386 Reserved Exceptions and Interrupts
Vector Number Description
0 Divide Error
1 Debug Exceptions
2 NMI Interrupt
3 Breakpoint
4 <a href="INT.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/INT.HTM">INTO</a> Detected Overflow
5 <a href="BOUND.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/BOUND.HTM">BOUND</a> Range Exceeded
6 Invalid Opcode
7 Coprocessor Not Available
8 Double Exception
9 Coprocessor Segment Overrun
10 Invalid Task State Segment
11 Segment Not Present
12 Stack Fault
13 General Protection
14 Page Fault
15 (reserved)
16 Coprocessor Error
17-32 (reserved)
</pre>
<p>
<hr>
<p><b>up:</b> <a href="C02.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C02.HTM">Chapter 2 -- Basic Programming Model</a><br>
<b>prev:</b> <a href="S02_05.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S02_05.HTM">2.5 Operand Selection</a><br>
<b>next:</b> <a href="C03.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C03.HTM">Chapter 3 -- Applications Instruction Set</a><br>
</body>