Question

I use masm assembler for 8086 programs. I want to implement user defined interrupts but could not find a way to do it. I only know how to implement dos interrupts(INT 21H) and bios interrupts (INT 10H). I have studied that 8086 has space for user defined interrupts(from 32 to 255 in the interrupt vector table)

How do I make use of these interrupts in masm?

Was it helpful?

Solution

The 8086 processor (and subsequent Intel processors running in real mode) uses an interrupt pointer table to figure out what to do when an interrupt is thrown. This table resides in the first 1k of low memory (0000:0000 - 0000:03ff) and contains a table of CS:IP values - one for each of 256 possible interrupts - to load when an interrupt occurs.

When your program starts, it needs to populate the entries in this table corresponding to the interrupts it wants to use, with the corresponding function pointers in (I think) little-endian encoding. Take care not to clash with any other interrupts already defined. After you've done this, and if interrupts are enabled, your interrupt handler should be called automatically whenever the corresponding interrupt is thrown. Remember to IRET at the end of your interrupt handlers, to restore the state of CS:IP and FLAGS, which are pushed to the stack as soon as an interrupt is triggered.

(I don't know if you can remap e.g. INT 21h to do something else, having not tried this myself, but I don't imagine the results of doing this by accident would be pretty.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top