coltoff@PRC.Unisys.COM (Chilly Willy) (02/19/88)
This has probably been covered here hundreds of times in the past 6 months but since I'm not a regular reader of this group I don't have the data I need. I need to write a TSR in C. Actually I want to write it in C since assembler is a royal pain in the posterior end. It is actually a very simple task that I need to do but I'm a PC novice and don't know about all the little gotchas hiding hither and yon. What I want the TSR to do is modify interrupt vector 0xA and print out a message when this interrupt occurs. I'll install the TSR (I really don't care if multiple copies exist) and then use a debug to get the other board to generate the interrupt. What things should I be concerned about checking? How do I make just the interrupt handler stay memory resident? Any advice you can offer would be greatly appreciated. Thanks in advance. -- - Joel {psuvax1,sdcrdcf}!burdvax!coltoff (UUCP) coltoff@burdvax.prc.unisys.com (ARPA)
Devin_E_Ben-Hur@cup.portal.com (02/21/88)
The February'88 issue of Computer Language has an article entitled, "Writting TSRs in Turbo C." This should get you going.
dave@westmark.UUCP (Dave Levenson) (02/26/88)
In article <5527@burdvax.PRC.Unisys.COM>, coltoff@PRC.Unisys.COM (Chilly Willy) writes: > I need to write a TSR in C. Actually I want to write it in C > since assembler is a royal pain in the posterior end. It is > actually a very simple task that I need to do but I'm a PC > novice and don't know about all the little gotchas hiding > hither and yon. Joel: In Microsoft C Release 5.0 (the latest, as of this date) you can code a function as: interrupt void foo() { ... } The code generated for such a function saves the machine state, and upon reaching the return (or final } of the code) generates an iret rather than a subroutine return. This means that you can write your interrupt service routine in C. They also supply runtime library calls to several MS-DOS system functions that are helpful here: Terminate and stay resident (aka keep process) and set vector. If your main() function sets a the interrupt vector to be a pointer to another function of type interrupt, and then calls the keep process function, you've installed your code. The gotchas begin when your interrupt service function issues dos system calls. If dos was executing when the interrupt happened, you may run into the lack of re-entrancy in the dos kernel. There are arcane and poorly-documented ways of handling this, depending on what your interrupt function has to do. -- Dave Levenson Westmark, Inc. A node for news. Warren, NJ USA {rutgers | clyde | mtune | ihnp4}!westmark!dave