Page 1 of 1

why ADD triggers a GP exception?

Posted: Fri Jan 06, 2012 12:57 pm
by harvey
Hi, everyone

I'm writing a toy os and I came across a new exception-related problem. I've constructed a dummy IDT and exception handler. The case is when a instruction "add $4, %esp " is executed, a GP exception is triggered and the dummy exception handler is invoked and the system halts. As you know, the vector is 13.
An interesting thing is before the instruction triggers the exception, it is executed properly once earlier. That is, the second time execution cases exception.
the memory contents of the instruction is like the below

<native_restore_fl + 10>: 0xc304c483 0xdae8c3fa 0xc3ffffff

=>0xc01032dc <native_restore_fl+10>: add $4, %esp
0xc01032df <native_restore_fl+13>: ret

Could anyone give me a hint?

Re: why ADD triggers a GP exception?

Posted: Fri Jan 06, 2012 4:40 pm
by Combuster
It's not the instruction that causes that interrupt. Check your error codes and PIC configuration.

Re: why ADD triggers a GP exception?

Posted: Mon Jan 09, 2012 2:47 am
by harvey
Combuster wrote:It's not the instruction that causes that interrupt. Check your error codes and PIC configuration.
you're right. It's none business of interrupts. I feel shame I spent four days solving this stupid problem...