Try to solve this

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
x_man

Try to solve this

Post by x_man »

hello all,
   i'm developing out a protected-mode os. I've jumped into the pmode and now i've started writing interrupts. I heard that interrupts 0h-1fh are exceptions and 20h-2fh are for hardware interrupts. I've written a procedure to install the interrupts. The idt structure is:

idt:

%rep  0x1f
dw 0
dw 08h   ; code segment
db 0
db 8eh
dw 0
%endrep

idt_end:

idt_descriptor:
size dw idt_end - idt - 1
dd idt

------------------------------------


I've written a simple interrupt handler for the divide by 0 exception. But, when i write a code as:

mov ax, 20h
mov bl, 0h
div bl
   i get the error message as "3rd (13) exception with no resolution". The interrupt handler is below:

int_0:
pusha
push ss
push gs
push ds
push fs

pop fs
pop ds
pop gs
pop ss
popa
iretd

The gdt structure for the code segment is :

code_descriptor:

dw 0xFFFF
dw 0
db 0
db 0x9A
db 0xCF
db 0



Please help me out of this problem.

Thanks in advance.
Adek336

RE:Try to solve this

Post by Adek336 »

1) IDT.offset == 0, but should point at the exception handler

%rep  0x1f
dw 0       <- IDT.offset low word
dw 08h   ; code segment
db 0
db 8eh
dw 0       <- IDT.offset high word
%endrep

2) Your exception handler should not return back to the faulting code:
int_0:
pusha
push ss
push gs
push ds
push fs

pop fs
pop ds
pop gs
pop ss
popa
iretd

instead try:

int_0:
cli
hlt
which will hand the comp.

Cheers
x_man

RE:Try to solve this

Post by x_man »

Actually, i've written a procedure to assign the low-word and high-word of the interrupt handler. But, still i get the triple fault when i call the interrupt.
Post Reply