wrong value passed..
Posted: Mon Aug 18, 2003 8:43 pm
Hello,
I have the following isr:
and my interrupt handler function:
I have the following isr:
Code: Select all
_int0:
cli ; disable interrupts
push eax ; store the current state of cpu
push ebx
push ecx
push edx
push ebp
push edi
push esi
push es
push ds
push fs
push gs
mov eax, 0
mov gs, eax
mov fs, eax
mov eax, 0x10 ; LINEAR_DATA_SEL == 0x10
mov es, eax
mov ds, eax
mov eax, 0
call IntHandler ; call the interrupt handler
pop gs ; begin to restore the saved cpu state
pop fs
pop ds
pop es
pop esi
pop edi
pop ebp
pop edx
pop ecx
pop ebx
pop eax
sti ; re-enable interrupts
iretd ; return
Code: Select all
void IntHandler(unsigned int x)
{
char* msg[] = {"Divide Error Exception!", "blah", "blah2" };
kprintf("x is: %x\n", x);
// kprintf("%s\n", msg[x]);
kprintf("Halting the CPU...");
asm("cli");
asm("hlt");
}
And I do a simple: x += x / 0; to trigger the divide by 0 exception in kernel
My handler gets called but the argument that is passed to the handler is 0x10. I tried assigning 0 to eax before calling the function. Yet when I print the argument it is always 0x10... Can anyone please shed light on this ??
thanks