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
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.
Help me out of this problem
Re:Help me out of this problem
I presume you've loaded handler addresses into the IDT structure before the lidt instruction.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Help me out of this problem
I guess i'm just repeating what Pete said, but the code you showed just creates an IDT which makes every handler to be located at 0x08:0x0000 ... you need to have something like "setup_handler" function which would install function X as handler for interrupt Y.
for instance:
btw, as your so-called "int_0 handler" does nothing but returning, your code will be halting on "div" instruction, continuously calling the DIV_BY_0 exception and returning to the faulty instruction :-/
for instance:
Code: Select all
;; expects eax=handler and edx=interrupt number.
;; no register modified
setup_idt_handler:
mov [idt+edx*8],ax
rol eax,16
mov [idt+6+edx*8],ax
rol eax,16
ret
setup_idt:
...
mov eax,int_0
xor edx,edx
call setup_idt_handler;
...
lidt[...]