[comp.sys.ibm.pc] TSRs in Microsoft C

chris@wbcs.UUCP (Chris Rott) (03/04/89)

I would like to know if anyone has info on how to write TSR programs using
Microsoft C (5.0).  Ie.  Can it be done ???  I am unaware of a way to create
an executable with only a single segment, which can be used for exe2bin.
Any ideas or directions in this area would be appreciated.  If this is
an over-hashed topic here, please e-mail rather than post.
	-Thanks



	Chris Rott

... US MAIL ....................... UUCP ...................................
Boeing Computer Services	...!scubed!ncr-sd!ncrwic!wbcs!chris
PO Box 7730, MS K79-32		...!bellcore!fenix!ncrlnk!ncrwic!wbcs!chris
Wichita, KS 67277-7730		...!hplabs!hp-sdd!ncr-sd!ncrwic!wbcs!chris
............................................................................

everett@hpcvlx.HP.COM (Everett Kaser) (03/07/89)

Your TSR program doesn't HAVE to be .COM, it can stay as .EXE, so you can
have multiple segments.  In the Sept 1988 issue of Microsoft Systems Journal
is an article titled "Using Microsoft C Version 5.1 to Write Terminate-and-
Stay-Resident Programs".  I'm not sure, but it may be of help to you :-).

Everett Kaser
!hplabs!hp-pcd!everett
everett%hpcvlx@hplabs.hp.com

toma@tekgvs.LABS.TEK.COM (Tom Almy) (03/09/89)

In article <101000044@hpcvlx.HP.COM> everett@hpcvlx.HP.COM (Everett Kaser) writes:
>Your TSR program doesn't HAVE to be .COM, it can stay as .EXE, so you can
>have multiple segments.  
...
Actually .COM vs .EXE has nothing to do with number of segments.  While a
.COM file starts executing with DS=CS=SS=ES, the program itself can change the
segment registers and utilize the entire memory space.  I have written many
programs (and a compiler) which do this.

The .EXE file offers four possible advantages, only the first cannot be 
avoided in assembler or within the compiler design:
1. Size of the loaded image can be greater than 64k;  .COM files are
   arbitrarily limited to 64k (is this to make them CP/M compatible? :-) )
2. The loader does a simple relocation, adding the starting segment to
   locations given in a table at the start of the file.  Thus segments
   can be treated as constants by the compiler.  But the program could do
   this itself if the loader didn't.
3. The .EXE header specifies initial values for the stack registers and the
   instruction pointer (registers CS, IP, SS, and SP).
4. The header specifies the quantity of memory to allocate beyond the end
   of the image.  In a .COM file, all memory goes to the program and any
   not needed must be freed.

Tom Almy
toma@tekgvs.labs.tek.com
Standard Disclaimers Apply