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

49 lines
5.1 KiB
HTML

<html><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>80386 Programmer's Reference Manual -- Section 9.2</title>
</head>
<body>
<b>up:</b> <a href="C09.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C09.HTM">Chapter 9 -- Exceptions and Interrupts</a><br>
<b>prev:</b> <a href="S09_01.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S09_01.HTM">9.1 Identifying Interrupts</a><br>
<b>next:</b> <a href="S09_03.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S09_03.HTM">9.3 Priority Among Simultaneous Interrupts and Exceptions</a>
<p>
<hr>
<p>
<h1>9.2 Enabling and Disabling Interrupts</h1>
The processor services interrupts and exceptions only between the end of one instruction and the beginning of the next. When the repeat prefix is used to repeat a string instruction, interrupts and exceptions may occur between repetitions. Thus, operations on long strings do not delay interrupt response.
<p>Certain conditions and flag settings cause the processor to inhibit certain interrupts and exceptions at instruction boundaries.
<h2>9.2.1 NMI Masks Further NMIs</h2>
While an NMI handler is executing, the processor ignores further interrupt signals at the NMI pin until the next <a href="IRET.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/IRET.HTM">IRET</a> instruction is executed.
<h2>9.2.2 IF Masks INTR</h2>
The IF (interrupt-enable flag) controls the acceptance of external interrupts signalled via the INTR pin. When IF=0, INTR interrupts are inhibited; when IF=1, INTR interrupts are enabled. As with the other flag bits, the processor clears IF in response to a RESET signal. The instructions <a href="CLI.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/CLI.HTM">CLI</a> and <a href="STI.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/STI.HTM">STI</a> alter the setting of IF.
<p><a href="CLI.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/CLI.HTM">CLI</a> (Clear Interrupt-Enable Flag) and <a href="STI.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/STI.HTM">STI</a> (Set Interrupt-Enable Flag) explicitly alter IF (bit 9 in the flag register). These instructions may be executed only if CPL &lt;= IOPL. A protection exception occurs if they are executed when CPL &gt; IOPL.
<p>The IF is also affected implicitly by the following operations:
<ul>
<li>The instruction <a href="PUSHF.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/PUSHF.HTM">PUSHF</a> stores all flags, including IF, in the stack where they can be examined.
<li>Task switches and the instructions <a href="POPF.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/POPF.HTM">POPF</a> and <a href="IRET.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/IRET.HTM">IRET</a> load the flags register; therefore, they can be used to modify IF.
<li>Interrupts through interrupt gates automatically reset IF, disabling interrupts. (Interrupt gates are explained later in this chapter.)
</ul>
<h2>9.2.3 RF Masks Debug Faults</h2>
The RF bit in EFLAGS controls the recognition of debug faults. This permits debug faults to be raised for a given instruction at most once, no matter how many times the instruction is restarted . (Refer to <a href="C12.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C12.HTM">Chapter 12</a> for more information on debugging.)
<h2>9.2.4 MOV or POP to SS Masks Some Interrupts and Exceptions</h2>
Software that needs to change stack segments often uses a pair of instructions; for example:
<pre>
<a href="MOV.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/MOV.HTM">MOV</a> SS, AX
<a href="MOV.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/MOV.HTM">MOV</a> ESP, StackTop
</pre>
If an interrupt or exception is processed after SS has been changed but before ESP has received the corresponding change, the two parts of the stack pointer SS:ESP are inconsistent for the duration of the interrupt handler or exception handler.
<p>To prevent this situation, the 80386, after both a <a href="MOV.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/MOV.HTM">MOV</a> to SS and a <a href="POP.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/POP.HTM">POP</a> to SS instruction, inhibits NMI, INTR, debug exceptions, and single-step traps at the instruction boundary following the instruction that changes SS. Some exceptions may still occur; namely, page fault and general protection fault. Always use the 80386 <a href="LGS.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/LGS.HTM">LSS</a> instruction, and the problem will not occur.
<p>
<hr>
<p><b>up:</b> <a href="C09.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C09.HTM">Chapter 9 -- Exceptions and Interrupts</a><br>
<b>prev:</b> <a href="S09_01.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S09_01.HTM">9.1 Identifying Interrupts</a><br>
<b>next:</b> <a href="S09_03.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/S09_03.HTM">9.3 Priority Among Simultaneous Interrupts and Exceptions</a>
</body>