views:

114

answers:

2
+1  Q: 

x86 architecture

I'm studying x86 and Real Time Systems, and I have a question, that is:

Which steps x86 follows to handle any interrupt ?

+1  A: 

Start here with the Interrupt Descriptor Table. Basically, when an interrupt occurs, flow control jumps to this table and then on to whatever is in this table. Also, I believe all registers are pushed as soon as the interrupt occurs, but I'm not 100% certain of this as it's been a long, long time since I've dealt with this.

Michael Dorgan
All the registers and the flags ar pushed before the interrupt occurs and are popped after the interrupt-handling code is over.
nc3b
Yep, kinda what I thought. On some of the stuff I've worked on, you've had to do the pushing and popping yourself. Was pretty sure that x86 did this for you.
Michael Dorgan
The processor flags are pushed automatically, but the other registers aren't; when it's dispatched, the ISR should explicitly preserve any/all registers which it intends to alter.
ChrisW
+2  A: 

When an interrupt occurs, the CPU does the following:

  • Push the current address (contents of the Instruction Pointer) onto the stack; also, push the processor flags (but not all the other processor registers)
  • Jump to the address of the ISR (Interrupt Service Routine), which is specified in the Interrupt Descriptor Table.

The ISR should do the following:

  • Push any registers which it intends to alter (or, push all registers)
  • Handle the interrupt
  • Reenable interrupts
  • Pop any registers which it pushed
  • Use the IRET instructions, which pops the CPU flags and Instruction Pointer value from the stack (and thus returns to whatever was executing when the interrupt occured).
ChrisW