Intel 253668-032US ユーザーズマニュアル

ページ / 806
6-18   Vol. 3
INTERRUPT AND EXCEPTION HANDLING
To return from an exception- or interrupt-handler procedure, the handler must use 
the IRET (or IRETD) instruction. The IRET instruction is similar to the RET instruction 
except that it restores the saved flags into the EFLAGS register. The IOPL field of the 
EFLAGS register is restored only if the CPL is 0. The IF flag is changed only if the CPL 
is less than or equal to the IOPL. See Chapter 3, “Instruction Set Reference, A-M,” of 
the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2A
, for 
a description of the complete operation performed by the IRET instruction.
If a stack switch occurred when calling the handler procedure, the IRET instruction 
switches back to the interrupted procedure’s stack on the return.
6.12.1.1   Protection of Exception- and Interrupt-Handler Procedures
The privilege-level protection for exception- and interrupt-handler procedures is 
similar to that used for ordinary procedure calls when called through a call gate (see 
Section 5.8.4, “Accessing a Code Segment Through a Call Gate”). The processor does 
Figure 6-4.  Stack Usage on Transfers to Interrupt and Exception-Handling Routines
 CS
Error Code
EFLAGS
CS
 EIP
ESP After
Transfer to Handler
Error Code
ESP Before
Transfer to Handler
 EFLAGS
 EIP
 SS
 ESP
Stack Usage with No
Privilege-Level Change
Stack Usage with
Privilege-Level Change
Interrupted Procedure’s 
Interrupted Procedure’s
and Handler’s Stack
Handler’s Stack
ESP After
Transfer to Handler
Transfer to Handler
ESP Before
Stack