I have loaded an idt table with 256 entries, all pointing to similar handlers:
- for exceptions 8 and 10-14, push the exception number (these exceptions push an error code automatically)
- for the others, push a "dummy" error code and the exception number;
- then jump to a common handler
So when the common handler enters, the stack is properly aligned and contains the exception/interrupt number, error code (which may just be a dummy), eflags, cs and eip.
My question regards returning from the interrupt handler. I use iret
to return after taking out the exception number and the error code from the stack, but this doesn't work for exception nr 8; if I leave the error code on the stack, then it returns fine!
Questions:
- do I have to leave the error code on the stack for exceptions that put the error code there? If so, how does
iret
determine whether it has to pop an error code or not? - as soon as I enable interrupts I always get exception 8 (double fault), but then everything runs fine (I'm developing a hobby OS). Is this normal behavior or do I have a bug somewhere?