📄 s02_06.htm
字号:
<!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">Chapter 2 -- Basic Programming Model</A><BR><B>prev:</B> <A HREF="s02_05.htm">2.5 Operand Selection</A><BR><B>next:</B> <A HREF="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 CPUto certain conditions detected during the execution of an instruction.<LI>Interrupts are asynchronous events typically triggered by externaldevices needing attention.</OL>Interrupts and exceptions are alike in that both cause the processor totemporarily suspend its present program execution in order to execute aprogram of higher priority. The major distinction between these two kinds ofinterrupts is their origin. An exception is always reproducible byre-executing with the program and data that caused the exception, whereas aninterrupt is generally independent of the currently executing program.<P>Application programmers are not normally concerned with servicinginterrupts. More information on interrupts for systems programmers may befound in <A HREF="c09.htm">Chapter 9</A> . Certain exceptions , however, are of interest toapplications programmers, and many operating systems give applicationsprograms the opportunity to service these exceptions. However, the operatingsystem itself defines the interface between the applications programs andthe exception mechanism of the 80386.<P>Table 2-2 highlights the exceptions that may be of interest to applicationsprogrammers.<UL><LI> A divide error exception results when the instruction <A HREF="DIV.htm">DIV</A> or <A HREF="IDIV.htm">IDIV</A> isexecuted with a zero denominator or when the quotient is too large forthe destination operand . (Refer to <A HREF="c03.htm">Chapter 3</A>for a discussion of <A HREF="DIV.htm">DIV</A> and <A HREF="IDIV.htm">IDIV</A>.)<LI> The debug exception may be reflected back to an applications programif it results from the trap flag (TF).<LI> A breakpoint exception results when the instruction <A HREF="INT.htm">INT 3</A> is executed.This instruction is used by some debuggers to stop program execution atspecific points.<LI> An overflow exception results when the <A HREF="INT.htm">INTO</A> instruction is executedand the OF (overflow) flag is set (after an arithmetic operation thatset the OF flag ) . (Refer to <A HREF="c03.htm">Chapter 3</A> for a discussion of <A HREF="INT.htm">INTO</A>) .<LI> A bounds check exception results when the <A HREF="BOUND.htm">BOUND</A> instruction isexecuted and the array index it checks falls outside the bounds of thearray . (Refer to <A HREF="c03.htm">Chapter 3</A> for a discussion of the <A HREF="BOUND.htm">BOUND</A> instruction. )<LI> Invalid opcodes may be used by some applications to extend theinstruction set. In such a case, the invalid opcode exception presentsan opportunity to emulate the opcode.<LI> The "coprocessor not available" exception occurs if the programcontains instructions for a coprocessor, but no coprocessor is presentin the system.<LI> A coprocessor error is generated when a coprocessor detects an illegaloperation.</UL>The instruction <A HREF="INT.htm">INT</A> generates an interrupt whenever it is executed; theprocessor treats this interrupt as an exception. The effects of thisinterrupt (and the effects of all other exceptions) are determined byexception handler routines provided by the application program or as part ofthe systems software (provided by systems programmers). The <A HREF="INT.htm">INT</A> instructionitself is discussed in <A HREF="c03.htm">Chapter 3</A>. Refer to <A HREF="c09.htm">Chapter 9</A> for a more completedescription of exceptions.<PRE>Table 2-2. 80386 Reserved Exceptions and InterruptsVector Number Description0 Divide Error1 Debug Exceptions2 NMI Interrupt3 Breakpoint4 <A HREF="INT.htm">INTO</A> Detected Overflow5 <A HREF="BOUND.htm">BOUND</A> Range Exceeded6 Invalid Opcode7 Coprocessor Not Available8 Double Exception9 Coprocessor Segment Overrun10 Invalid Task State Segment11 Segment Not Present12 Stack Fault13 General Protection14 Page Fault15 (reserved)16 Coprocessor Error17-32 (reserved)</PRE><P><HR><P><B>up:</B> <A HREF="c02.htm">Chapter 2 -- Basic Programming Model</A><BR><B>prev:</B> <A HREF="s02_05.htm">2.5 Operand Selection</A><BR><B>next:</B><A HREF="c03.htm">Chapter 3 -- Applications Instruction Set</A><BR></BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -