i'm writing my kernel in C++ and i got the GDT and IDT working and when i tested the 0 interrupt with "int 0" right after the "lidt" , it works just fine and my handler is called , but when i write "int i = 5/0;" in C++ , nothing happens.
what's the problem ? i thought the CPU automatically does "int 0" when trying to divide by zero.
handler is called only with "int 0" not with "int i = 5/0"
Re: handler is called only with "int 0" not with "int i = 5/
I had the same problem, it's because the optimizer.
Do this instead:
What the optimizer is doing is trying to calculate the result of the operation and assign the correct value. Since it's not possible to divide by 0, nothing is done.
For example, if you do this:
No 100 and no 4 will be part of the executable. Instead, the optimizer will convert it to this:
And the i variable may or may not be modified. For example: if it's going to be used only once, it's value will only be in some register while calculating it, and it may not be saved anywhere.
Do this instead:
Code: Select all
volatile int i=5;
volatile int j=0;
i=i/j;
For example, if you do this:
Code: Select all
int i=100/4;
Code: Select all
int i=25;