assembly - Do I have to pop the error code pushed to stack by certain exceptions before returning from the interrupt handler? -


I have loaded the IDT table with 256 entries, all pointing to the same handler:

  • For exceptions 8 and 10-14, press exception numbers (these exceptions automatically press an error code)
  • For others, a "dummy" error code And push the exception number;
  • the

So when entering common handler, the stack is aligned properly and exceptions / interval number, error code (Which can only be a dummy), Efflag, CS and EIP.

My question'm concerned returning from the interrupt handler I exception number and come back after the error code from the stack using iret , but this exception nr 8 Does not work for; If I leave the error code on the stack, then it gets cured!

Question:

  • Do I have to leave the error code on the stack for exceptions to the error code? If so, then iret determines whether to pop the error code or not?
  • As soon as I am able to middle, I always get the exception 8 (double fault), but then everything is fine (I am developing a hobby OS). Is this normal behavior or I have a bug somewhere?
  • If CPU returns a pushed error code automatically, Em> should pop it up before iret . The iret instructions do not know where you are coming from, if it is a mistake, a trap or an external obstacle, it always does this, and it assumes that there is no error code on the stack .

    Error code:

    SDM (Software Manual developer), Section 3, Chapter 5, quoted from section 5.13>

    A Dbalwrld or write error code stack (default Interrupt , Netting or work gate is based on size). To keep the stack alliance for double push, the upper part of the error code is reserved. Note that the error code is not popped up when the IRET command is executed to bring an exception handler back, so the handler must remove the error code before executing the return.

    You can find:

    Volume 3 Part 1, Chapter 5, describes the exception and puts the handling in the middle. There is a device for the iret instruction in Volume 2 Part 1.


Comments