🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #4693

TSR's in TurboC 2.0 and TurboC++ 1.0

#4693
From: charles spell
Date: Thu, 14 Feb 1991 20:44
53 lines
2349 bytes
TurboC++ Professional gives an example program gives a short
TSR program in the Reference guide under the keep() function.

I try compiling:

	 tcc -mt -lt -k- -I../include keep.c 

And get the error message:
     Cannot generate .COM file: segment-relocatable items present.

Must TSR's be .COM files?

I comment out the setvect() statement and it links fine. In TC 2.0
it links fine. How do I get around this? Here is a one-page TSR that
is very similar (DO NOT EXECUTE IT!!!! IT CAN DESTROY YOUR DISK!!):

#include <dos.h>
#define DISK_VECT 0x13           /* This program was intended to flash the */
extern unsigned int _heaplen;    /* upper right-hand corner during ANY disk*/
extern unsigned int _stklen;     /* operation...DO NOT RUN THIS PROGRAM!!! */
void interrupt new_disk(void);
void interrupt (*old_disk)();
#error This statement added to warn all not to run this program!!!
void new_disk(void)
{
static unsigned int far *screen = MK_FP(0xB800, 0000);

screen[80] ^= 0x00ff;  /* this line DESTROYS certain registers for int 13h */
(*old_disk)();
screen[80] ^= 0x00ff;
}

main(void)
{
old_disk = getvect(DISK_INT);
setvect(DISK_INT, &new_disk); /* comment this line and TC++ 1.0 produces    */
_heaplen = 512;               /* .COM ok. TC 2.0 works in both cases...     */
_stklen  = 0x1000;
keep(0, 0x1000);
}

How do I get the registers as they were on entry to new_disk() (they are
destroyed by the screen[80] ^= 0x00ff;) before calling old_disk?

uunet!mcnc!unccvax!cs00chs

uunet!decvax!pyrdc!clt2!jjr
-- 
 .--------------------------.  ...  |On the border of your mind lies a place
 |uunet!mcnc!unccvax!cs00chs|  (")  |where dreams and reality are one...I will 
 `--------------------------'-w-U-w-|take you there, for I am the subject...
 \%\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%\|the subject of your imagination. -Aldo Nova
Technical Details
Message-ID: <3187@unccvax.uncc.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!dog.ee.lbl.gov!ucbvax!decwrl!mcnc!unccvax!cs00chs

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!dog.ee.lbl.gov!ucbvax!decwrl!mcnc!unccvax!cs00chs
From: cs00chs@unccvax.uncc.edu (charles spell)
Newsgroups: comp.os.msdos.programmer
Subject: TSR's in TurboC 2.0 and TurboC++ 1.0
Keywords: converting to .COM
Message-ID: <3187@unccvax.uncc.edu>
Date: 14 Feb 91 20:44:07 GMT
Followup-To: comp.os.msdos.programmer
Organization: University of NC at Charlotte
Lines: 53