[comp.lang.c] Turbo C and TSR's

toma@killer.UUCP (Tom Armistead) (06/25/87)

Well, I too have just recently received a copy of Turbo C, $55 bucks
from a discount sftwr house (Nothing but praise!!!)

One complaint:
    I don't like the way the inline assembly stuff works, you must
    have MASM (3.0 or greater) to use this feature. I'll be damned
    if I'm gonna pay $80 bucks for the worst assembler on the market...

    A86 all the way!!!

One question:
    Has anyone written any TSR's in Turbo C, they give you this
    nice function called keep() for terminatiing and staying
    resident, but, you must give keep() the number of paragraphs
    of memory used by you pgm and they don't document how to get
    that value. I called Borland's tech supp. and they don't really
    have an answer yet (they are working on it), however, I was told
    of a undoc'd global variable called _brkval that is supposed to point
    first byte of the stack, so (_brkval + _stklen) should point to the
    end of data???  Sometimes it does and sometimes it doesn't???
    Any suggestions???

Tom
-----
UUCP:           ihnp4\
                      \killer!toma
  infoswx!convex!dj3b1/
Tom Armistead

guardian@laidbak.UUCP (Harry Skelton) (07/01/87)

In article <1041@killer.UUCP> toma@killer.UUCP (Tom Armistead) writes:
>
>One complaint:
>    I don't like the way the inline assembly stuff works, you must
>    have MASM (3.0 or greater) to use this feature. I'll be damned

You could download WASM to do your assembler or the new MASM.  Check a few
chicago BBS's for it (that's where I got my copy).  FREE!!


>
>One question:
>    Has anyone written any TSR's in Turbo C, they give you this
>    nice function called keep() for terminatiing and staying
>    resident, but, you must give keep() the number of paragraphs
>    of memory used by you pgm and they don't document how to get
>    that value. I called Borland's tech supp. and they don't really
>Tom Armistead

Borland has a support group to handle the calls so they could not answer you
fully.  I would first check a few things.  First, do you (m)alloc memory? If so
you'll have to just buffer your own.  You could do a malloc, get the address 
and then de-(m)alloc memory, take the address and set it to the next paragraph.
give dos the paragraph to use as a next loader and int27 or whatever out of
your program.  For now, don't trust keep.  Another thing is to make a .asm 
program to load under a system() call and exit with the paragraph point that
it was loaded (up to 255 paragraphs).  If Turbo C has the 'size' utility then
that could tell you how large your program is.  If not...download it from a 
bbs.

The other thing is to start the program as assembler with orig 100 or 0 and 
make a loader for it.

Last hack would be to system out to command.com /p and let dos worry about 
things.  

Yes I know these are HACKS to the problem, but I found that a TSR in 'C' is
best done by a system() command to the SHELL (command.com) and make it
fixed in memory.  Sort of a fork() under dos!

Don't trust Turbo 'C' untill version 5 or so..  :-)

Harry Skelton
guardian@laidbak.UUCP