C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
_chain_intr
 Summary Example                         Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
     The _chain_intr routine passes control from one interrupt handler
     to another. The stack and the registers of the first routine are
     passed to the second, allowing the second routine to return as if
     it had been called directly.
 
     The _chain_intr routine is generally used when a user-defined
     interrupt handler begins processing, then chains to the original
     interrupt handler to finish processing.
 
     Chaining is one of two techniques, listed below, that can be used
     to transfer control from a new interrupt routine to an old one:
 
       1. Call _chain_intr with the interrupt routine as an argument.
          Do this if your routine is finished and you want the second
          interrupt routine to terminate the interrupt call.
 
               void __interrupt new_int( unsigned _es,
                                         unsigned _ds,
                                         unsigned _di,
                                         unsigned _si,... )
               {
                  ++_di;                  // Initial processing here
                  _chain_intr( old_int ); // New DI passed to old_int
                  --_di;                  // This is never executed
               }
 
       2. Call the interrupt routine (after casting it to an interrupt
          function if necessary) if you need to do further processing
          after the second interrupt routine finishes.
 
               void __interrupt new_int( unsigned _es,
                                         unsigned _ds,
                                         unsigned _di,
                                         unsigned _si,... )
               {
                  ++_di;                  // Initial processing here
                  (*old_int)();           // New DI passed to old_int
                  __asm mov _di, di       // Put real DI from old_int
                                          //   into _di for return
               }
 
          Note that the real registers set by the old interrupt
          function are not automatically set to the pseudoregisters of
          the new routine.
 
     Use the _chain_intr function when you do not want to replace the
     default interrupt handler, but you do need to see its input. An
     example is a TSR (terminate-and-stay-resident) program that checks
     all keyboard input for a particular "hot key" sequence.
 
     The _chain_intr function should be used only with C functions that
     have been declared with type __interrupt. The __interrupt
     declaration ensures that the procedure's entry/exit sequence is
     appropriate for an interrupt handler.
 
     Return Value
 
     None.
                                    -♦-