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.
Assigning Interrupt handler address
RE:Assigning Interrupt handler address
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.
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.