A pop-up or hardware-support program's interrupt handler receives control asynchronously—that is, whenever the user presses a key or a device generates an interrupt. To service the interrupt, the system temporarily suspends the current instruction and passes control to the interrupt handler. Since an asynchronous interrupt may occur at any time, the interrupt handler must determine the state of MS-DOS and possibly of the ROM BIOS before carrying out any operations. If a pop-up or hardware-support interrupt occurs while an MS-DOS system function or ROM BIOS routine is being carried out, the interrupt handler should ignore the interrupt and return immediately.
If the interrupt handler uses MS-DOS system functions, it must check the InDOS flag before calling a function and must check the ErrorMode flag before calling any character I/O function (Interrupt 21h Functions 01h through 0Ch).
The one-byte InDOS flag specifies whether MS-DOS is currently processing a system function. If the flag is nonzero, the interrupt handler can call only the character I/O functions; it must not call other MS-DOS system functions. A program can retrieve the address of the InDOS flag by using Get InDOS Flag Address (Interrupt 21h Function 34h).
The one-byte ErrorMode flag specifies whether MS-DOS is currently processing a critical disk error. If it is, the flag is nonzero and the interrupt handler must not call any MS-DOS system function, including the character I/O functions. The ErrorMode flag occupies the byte immediately before the InDOS flag, so a program can determine the ErrorMode flag address by subtracting 1 from the InDOS flag address.
The interrupt handler must check whether any ROM BIOS routine it calls directly has been interrupted, and it must not call an interrupted ROM BIOS routine that is not reentrant. Since MS-DOS provides no means to determine whether a ROM BIOS routine has been interrupted, a TSR must intercept these interrupts and record when control enters and leaves the routines. The interrupt handler can then check this record before making a call to the ROM BIOS. intercepted>
The interrupt handler must not continue if another hardware interrupt is being processed. To determine whether an interrupt is active, the TSR must query the system interrupt controller.