Assigning Interrupt handler address

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
The_Pro

Assigning Interrupt handler address

Post by The_Pro »

I'm writing a protected mode os. I've jumped into the protected mode. I have planned to write the interrupts now. I have written an interrupt handler and i'm struck with how to assign the address of the handler in the IDT, since, the offset0_15 and offset16_31 are to be assigned seperately. I have given the coding.

idt:

offset0_15 dw ?
selector0_15 dw 08h
zero_byte db 0
iflags db 8eh
offset16_31 dw ? ; how to assign

idt_end:


     Consider this as an interrupt handler.

demo_int:
mov ax, 10h
mov ds, ax
mov ss, ax
mov esp, 090000h
mov byte [0xb8000], 'A'
mov byte [0xb8001], 1Bh
iretd


And another question is what is the second word selector0_15 called ? Please help me out of this two problems.

Thank  you.
Xenos

RE:Assigning Interrupt handler address

Post by Xenos »

Your OS will probably crash if you change the stack pointer in an interrupt routine, since it holds the return address...

Just put the high and low word of the interrupt handlers offset into the IDT. You can do this at assembly time using something like

offset0_15 dw (demo_int & 0ffffh)
...
offset16_31 dw (demo_int >> 16)

or at runtime by simple calculation.
Post Reply