User`s manual

UPS25 37 RTD Embedded Technologies, Inc
The second major concern when writing ISRs is to make them as short as possible
in term of execution time. Spending long times in interrupt service routines may
mean that other important interrupts are not serviced. Also, if you spend too long
in your ISR, it may be called again before you have exited. This will lead to your
computer hanging up and will require a reboot.
Your ISR should have the following structure:
Push any processor registers used in your ISR. Most C compiler do this automatically
Put the body of your routine here
Clear the interrupt bit by writing to the UPS25 status register
Issue the EOI command to the 8259 by writing 20h to address 20h
Pop all registers. Most C compilers do this automatically
The following C example shows what the shell of your ISR should be like:
/*-------------------------------------------------------------------------------
| Function: new_IRQ_handler
| Inputs: Nothing
| Returns: Nothing
|-------------------------------------------------------------------------------*/
void interrupt far new_IRQ_handler(void)
{
IRQ_flag = 1; // Indicate to main process interrupt has occurred
{
// Your program code to shut down should be here
}
outp(BASE+0x01,0x00); // Clear interrupt on UPS25
outp(0x20, 0x20); // Acknowledge the interrupt controller
}
Saving the Startup Interrupt Mask Register (IMR) and interrupt vector
The next step after writing the ISR is to save the start up state of the interrupt
mask register, and the original interrupt vector you are using. The IMR is located in
address 21h. The interrupt vector you will be using is located in the interrupt vector
table (an array of pointers or addresses) and it is located in the first 1024 bytes of
the memory (Segment 0 offset 0). You can read this value directly, but it is better
practice to use DOS function 35h (get interrupt vector) to do this. Most C compilers
have a special function available for doing this. The vectors for the hardware
interrupts on the XT - bus are vectors 8-15, where IRQ0 uses vector 8 and IRQ7
uses vector 15. Thus if your UPS25 is using IRQ5 it corresponds to vector number
13.