_chain_intr

Description

Chains an interrupt from one handler to another.

#include <dos.h>

void _chain_intr( void( __cdecl __interrupt __far *target )());

target Target interrupt routine  

Remarks

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:

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 */

}

Call the interrupt routine (after casting it to an interrupt function if necessary). Do this 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 __interrupt. The __interrupt declaration ensures that the procedure's entry/exit sequence is appropriate for an interrupt handler.

Return Value

The _chain_intr function does not return to the caller.

Compatibility

Standards:None

16-Bit:DOS

32-Bit:None

See Also

_dos_getvect, _dos_keep, _dos_setvect