Article View: comp.os.msdos.programmer
Article #2604Re: <20416@eagle.lerc.nasa.gov>
From: don
Date: Fri, 05 Oct 1990 13:45
Date: Fri, 05 Oct 1990 13:45
50 lines
2465 bytes
2465 bytes
>>I'm attempting to use Microsoft C's _dos_keep function but I
>>do not know how to calculate the 2'd paramter required by this
>>function. The 2'd paramter is the desired size in 16 byte paragraphs
>>of the program that you want to remain resident. Does anybody know how to
>>calculate this, or is there some function call that I can use to get
>>the desired size. Any help with my problem would be greatly appreciated.
>Well, why don't we let MICROSOFT lend an answer for a change, OK? Here's
>the Example program that popped up on my screen when I inquired about the
>_dos_keep function in Microsoft Quick C / Quick Assembler v2.51.
>void main( int argc, char **argv )
>{
> long minute, hour;
> unsigned tsrsize;
> /* Initialize stack and bottom of program. */
> _asm mov WORD PTR tsrstack[0], sp
> _asm mov WORD PTR tsrstack[2], ss
> FP_SEG( tsrbottom ) = _psp;
> FP_OFF( tsrbottom ) = 0;
> /* Program size is:
> * top of stack
> * - bottom of program (converted to paragraphs)
> * + one extra paragraph
> */
> tsrsize = ((tsrstack - tsrbottom) >> 4) + 1;
Although the code executes correctly as written, there are some points in it
which may not work under all circumstances. In picking up the top of the
stack, it is using the current stack location. This occurs after main()
has already pushed its local parameters on the stack. What this means is
1) you cannot return from main()
2) after you TSR, you cannot use the input or local parameters
in main().
Although neither of these cases are likely to occur in a well-written high-
level TSR program, I think the person who uses this code should be aware
of that fact.
---------------------------------------------------------------------
The more you drive, the less intelligent you are.
-- _Repo Man_
Don Subt The opinions expressed above are
Tandy Corp. strictly mine, not my employer's.
817-390-2923 don%trsvax@rwsys.lonestar.org...
Technical Details
Message-ID:
<25600004@trsvax>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!evax!utacfd!merch!cpe!hal6000!trsvax!donReferences:
<20416@eagle.lerc.nasa.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!evax!utacfd!merch!cpe!hal6000!trsvax!don From: don@trsvax.UUCP Newsgroups: comp.os.msdos.programmer Subject: Re: <20416@eagle.lerc.nasa.gov> Message-ID: <25600004@trsvax> Date: 5 Oct 90 13:45:00 GMT References: <20416@eagle.lerc.nasa.gov> Lines: 50 Nf-ID: #R:eagle.lerc.nasa.gov:20416:trsvax:25600004:000:1982 Nf-From: trsvax.UUCP!don Oct 5 08:45:00 1990