Here is the C code for a TSR that I have used in the past.
It was written and compiled with Borland turbo C.
You just put your code in the 'popup' function in the 'popup.c' file.
'Resident.c' does most of the work and stays the same for all tsr's.
I need to write a DOS-based program to capture the time & date info
from serial port and update the system clock while other DOS-based application is running.
If you could find the book 'Turbo C (Memory-Resident utilities, Screen I/O and Programming Techniques)' by Al Stevens, first published in 1987,
ISBN 0-943518-35-0.
In the days of DOS, this book was my bible! The guys a C guru. The code I posted above I copied from his book. He understands, and describes in great detail all you need to know about TSR's.
This book opened my eyes to the power and elegance of the c programming language!