Interrupt Vector Table

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
killedbydeath

Interrupt Vector Table

Post by killedbydeath »

Hi all,

Im still programming in real mode and as i've read from the intel manuals in real mode theres an IDT like structure for handling interrupts. My question is how can i program it (is it similar to the IDT in means of assigning interrupt handlers?).Do i make an idt similar strucure and then issue lidt?
Best Regards
Habbit

Re:Interrupt Vector Table

Post by Habbit »

The real-mode exception handling structure is indeed called IVT, interrupt vector table. In the 386 and later, you can execute LIDT to set its base and limit, just like the IDT, but for the sake of compatibility, you should work with it the way the 8086 expects, which is:

* Base (start of table) at 0000:0000
* Last used byte (aka limit?): 0000:03FF
* That gives you 1024 bytes, split in 256 interrupt vectors like this:
0000:0000 Offset for entry 0 ---------| INTERRUPT
0000:0002 Segment for entry 0 ------------| VECTOR #0
0000:0004 Offset for entry 1
0000:0008 Segment for entry 1
...
0000:03FB Offset for entry 255
0000:03FE Segment for entry 255

So invoking INT #x is like doing a far call to the prodecure pointed by the #x vector in the IVT, with the additional things pushed in the stack by the processor in the case of exceptions.

EDIT: order of segment and offset was reversed. sorry
Post Reply