[comp.sys.ibm.pc] MSC 5.0 Local Stacks In TSRs

elliott@optilink.UUCP (Paul Elliott x225) (05/03/88)

I am doing some TSR stuff using Microsoft C 5.0, and would like to
get access to the SS and SP registers (to set up a local stack).
TurboC has psuedo-variables for all the registers, and it is pretty
simple to read and write to these and do what I want (in TutboC).

Does anyone know of a Microsoft equivalent to the psuedo-variables
(I can't find anything even close in my manuals), or know of a work-around?

Any help or pointers will be MOST appreciated.

Paul M. Elliott: My opinions (if any) are probably not shared by Optilink.
..!hplabs!pyramid!kontron!optilin!elliott

jrv@siemens.UUCP (James R Vallino) (05/03/88)

In article <2045@optilink.UUCP> elliott@optilink.UUCP (Paul Elliott x225) writes:
>I am doing some TSR stuff using Microsoft C 5.0, and would like to
>get access to the SS and SP registers (to set up a local stack).
>TurboC has psuedo-variables for all the registers, and it is pretty
>simple to read and write to these and do what I want (in TutboC).

I had the same wish and could not find a way to set up a local stack short
of some assembly code. I punted and took the risk of using whatever stack
is active when the TSR is entered. So far that has worked but I would be
wary of not putting in the stack swap for a general use TSR.

If you don't swap stacks be careful of passing pointers to local or automatic
variables as parameters when working with a small data model. The offset
passed is based on the value in SS but the code will access this data in
another function using DS with the obvious problems. This can cause problems
in unexpected places. One work around is to use only global variables and never
use the address of a function parameter. But by the time you figure out all
gotchas here you might as well have written the TSR in assembly.


-- 
Jim Vallino	Siemens Research and Technology Lab.,Princeton, NJ
CSNET: jrv@siemens.siemens.com
UUCP: {ihnp4,philabs,seismo}!princeton!siemens!jrv