[comp.sys.ibm.pc] Need help writting Turbo C TSR

n9bh@cbnewsc.ATT.COM (Bruce Corbett) (02/22/90)

I'm *TRYING* to learn how to write a TSR in Turbo C.
A short program follows:



#include <stdio.h>
#include <dos.h>

void interrupt (*oldfunc)();
void interrupt myfunc();
int flag = 0;

main()
{

	oldfunc = getvect(0x1C);
	setvect(0x1C, myfunc);
	keep(0, 10000 / 16);
}

void interrupt myfunc()
{
	extern  int flag;

	(oldfunc)();
	if(flag == 0)
	{
		flag = 1;
		putchar('X');
		flag = 0;
	}
}

As it stands this code prints a $, then a prompt, then about 5 $'s on the
same line, then it hangs and I have to boot.  If the putchar() is removed
it will go resident and I see no ill effects.

Please send help/suggestions to me at:  att!nwgpb!n9bh or att!cbnewsc!n9bh

Thanks in advance,
Bruce Corbett