shearer@cis.udel.edu (Rob Shearer) (09/20/90)
Hello... This is my first attempt at posting to the net... I use TC++ version 1.0. After the main() delcaration i would like to tell the system WHERE to use the stack.. in actuality, I would like to have several different stacks depending on circumstances... I am willing to go through the headache of the overhead to take care of it... but can someone tell me HOW to tell the system I want a different stack?? can I just poing _SS = FP_SEG(newlocation); _SP = FP_OFF(newoffset); will this work?? Thanks.. Robb Shearer
toma@tekgvs.LABS.TEK.COM (Tom Almy) (09/21/90)
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
Ralf.Brown@B.GP.CS.CMU.EDU (09/22/90)
In article <8158@tekgvs.LABS.TEK.COM>, toma@tekgvs.LABS.TEK.COM (Tom Almy) wrote: }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): } }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. You will also need to disable interrupts if the code can be run on an 8088, as early versions of that chip have a microcode bug which results in interrupts not being disabled for the instruction after a change to SS. -- UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=- 412-268-3053 (school) -=- FAX: ask ARPA: ralf@cs.cmu.edu BIT: ralf%cs.cmu.edu@CMUCCVMA FIDO: 1:129/3.1 Disclaimer? | I was gratified to be able to answer promptly, and I did. What's that? | I said I didn't know. --Mark Twain