🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Stack Segment... Can I change it?

#2324
From: Tom Almy
Date: Fri, 21 Sep 1990 16:35
35 lines
1832 bytes
In article <31074@nigel.ee.udel.edu> shearer@cis.udel.edu (Rob Shearer) writes:

>I use TC++ version 1.0.  

>After the main() delcaration i would like to tell the system WHERE to use
>the stack..  

>can I just poing _SS = FP_SEG(newlocation);
>                 _SP = FP_OFF(newoffset);

Several considerations (generic across any compiler for the 80x86):

1. Don't use any memory model for which the compiler will assume DS=SS. 
   Check your reference manual carefully on this. You must also make sure
   that any libraries you use don't make the assumption either.

2. In the sequence you give above, you must make sure that the generated
   instruction that loads the SP immediately follows the one that loads SS.
   The mov ss,.. instruction automatically inhibits interrupts for one
   following instruction.
   If this is not the case, you will need to disable interupts while
   changing stacks.

3. Don't forget to move all local variables and parameters to the new
   stack first, and set the BP register.

4. Make sure the compiler doesn't generate stack checking code.

Good luck! Languages not designed for multitasking may contain lots of
"gotchas" for you to pull this off. The only compilers I know of that 
will guarentee success are those for Modula-2 and Forth.

Tom Almy
toma@tekgvs.labs.tek.com
Standard Disclaimers Apply
Technical Details
Message-ID: <8158@tekgvs.LABS.TEK.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!toma
References: <31074@nigel.ee.udel.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!toma
From: toma@tekgvs.LABS.TEK.COM (Tom Almy)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Stack Segment...  Can I change it?
Message-ID: <8158@tekgvs.LABS.TEK.COM>
Date: 21 Sep 90 16:35:04 GMT
References: <31074@nigel.ee.udel.edu>
Reply-To: toma@tekgvs.LABS.TEK.COM (Tom Almy)
Organization: Tektronix, Inc., Beaverton,  OR.
Lines: 35