TSR's with TC

John Birchfield jb at CSUStan.EDU
Tue Aug 29 08:24:02 AEST 1989


In article <69 at tor.nhh.no> edb_tom at tor.nhh.no (Tom Ivar Helbekkmo) writes:
>In article <3723 at ncsuvx.ncsu.edu>, sherman at csclea.ncsu.edu (Chris Sherman) writes:
>> _chain_intr, which is usually used in an interrupt handler, accepts the
>> address of another interrupt handler, and jumps (not calls) over to it.
>> It is as if the first handler was never called.
>> 
>No, you certainly can't do it that way.  ...
>Correct me if I'm wrong, someone, but unless Turbo C has explicit
>support for writing interrupt handlers in C ...

Turbo C allows writing interrupt handlers directly in C using
pretty much the same mechanism as Microsoft.  The following C
program is provided as a very succinct example.
------------------------------------------------------------------------
/*
 *              Turbo C Interrupt Handler Chaining Example
 *
 * You may easily see what your compiler thinks you mean for it to
 * do by compiling with the -S -c options and then looking at the
 * assembly code.
 *                            ---   jb   ---
 *                             Aug 28, 1989
 
#include <dos.h>

void interrupt (*ticker_save) ();
void interrupt ticker ();

int count = 0;
main ()
{
	ticker_save = getvect (8);
	setvect (8, ticker);
	while (count < 30);
	setvect (8, ticker_save);
}

void interrupt ticker ()
{
	count++;
	(ticker_save) ();
}

/*
 * The following is the pertinent assembly code generated by the
 * compiler inside ticker. Note that since the compiler knows about
 * the interrupt characteristics  of the pointer ticker_save,
 * he pushes the flags before calling him.  The only penalty you
 * have is the xtra registers pushed on the stack.  Turbo C also
 * provides meta variables _AX _DX ... so that you can directly
 * manipulate the registers in the function.
 *
 * 	mov	ds,bp
 * ; Line 17
 * 	inc	word ptr DGROUP:_count
 * ; Line 18
 * 	pushf	
 * 	call	dword ptr DGROUP:_ticker_save
 * ; Line 19
 */
------------------------------------------------------------------------
-                                                                      -
===                                                                  ===
John Birchfield                                       1575 Quail Ct.
jb at koko.csustan.edu                                   Turlock, CA  95380
                                                      (209) 634-6243



More information about the Comp.lang.c mailing list