Hi,
OSMAN wrote:Bochs doesn't reset or anything. It just does nothing ; prints "hello" to the screen and stays in an while ( true ) - loop. My exception 0 isn't coming whatever I try. I guess the problem is in my IDT, would you have a clue?
( I haven't called "sti" , because before main it crashes the kernel and in main asm ( "sti" ) does nothing. )
The CLI and STI instructions only control maskable IRQs, not exceptions, so STI isn't why your not getting the exception.
Are you doing something like:
Or perhaps:
If you are, then the first thing I'd do is make sure the compiler hasn't optimized it. If the variable "a" isn't used later on, then most compilers won't generate the code for the division. In this case (IIRC) the "volatile" keyword would fix it, for example "volatile int a;" instead of just "int a;".
If the division is definately in your binary, then it's either not being run at all (e.g. CPU never reaches it) or it's being run and not doing whatever you expect.
In either case, just before the division I'd put something like:
Code: Select all
push ecx
mov ecx,0
.wait:
jexcz .wait
pop ecx
Then you'd be able to run the OS using Bochs debugger. After running it for a while, stop it (with control+C) and then type in 's' a few times to see if you're in the little loop above or not. This will tell you if the division would have been executed or not.
If the division would've been run then Bochs will be stuck in the little loop. In this case, type in "set$ecx=1" to change ECX and break out of the loop. Then type in 's' until the division instruction is about to be executed, check the CPU's registers (with "infor"), and then type in 's' once more to see where the CPU goes.
Cheers,
Brendan