4-15
PROCEDURE CALLS, INTERRUPTS, AND EXCEPTIONS
If no stack switch occurs, the processor does the following when calling an interrupt or excep-
tion handler (refer to Figure 4-5):
1.Pushes the current contents of the EFLAGS, CS, and EIP registers (in that order) on the
stack.
2.Pushes an error code (if appropriate) on the stack.
3.Loads the segment selector for the new code segment and the new instruction pointer
(from the interrupt gate or trap gate) into the CS and EIP registers, respectively.
4.If the call is through an interrupt gate, clears the IF flag in the EFLAGS register.
5.Begins execution of the handler procedure at the new privilege level.
Figure 4-5. 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 Procedures
Interrupted Procedures
and Handlers Stack
Handlers Stack
ESP After
Transfer to Handler
Transfer to Handler
ESP Before
Stack