home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 3,574 of 4,675   
   sdn45478@nospicedham.gmail.com to R.Wieser   
   Re: EXE program stack setup questions   
   11 Oct 18 10:17:54   
   
   On Saturday, October 6, 2018 at 2:09:42 AM UTC-7, R.Wieser wrote:   
   > Hello all,   
   >   
   > A few days ago was creating an TINY model EXE style program, and suddenly   
   > realized that my stack setup was probably born outof a "it works, I will   
   > take a better look at it later" thought.   And now its (much!) later and I'm   
   > having some stupid(?) questions about it.    I'm using Borlands Tasm by the   
   > way (yes, *that* old :-) ).   
   >   
   > Method #1:   
   > Do not define a stack segment, causing SS = CS, but with SP far beyond the   
   > end of the program.  Moving it to directly beyond the end of an   
   > uninitialized data segment thats defined just before the end of the program   
   > is easiest.   
   >   
   > Downside: the Main procedure cannot contain stack-based references without   
   > some "clever" juggeling of the SP and BP registers, and more complex stuff   
   > to move the "uses {registers}" to inside the new stack.   
   >   
   > (The Main procedure does not have arguments and probably doesn't need to   
   > have any register preserved, but humour me please).   
   >   
   > Method #2   
   > Use a ".stack {size}" definition.  Although that would solve the "uses"   
   > problem, it than need to move SS back onto CS (to have unencumbered, easy   
   > by-pointer access to stack-based data), and adjust both SP and BP   
   > accordingly (and maybe even the saved, on-stack BP).  This adjustment could   
   > cause an overflow, which ofcourse would need to be captured.  In short, more   
   > "clever" stuff involved.   
   >   
   > Those two are the ones I'm currently aware of.    Does anyone know of a   
   > simpler, more direct way ?   Preferably one where the OS sets up SS:SP, but   
   > with SS being equal to CS.   
   >   
   > Regards,   
   > Rudy Wieser   
   >   
   Rudy,   
   If I needed a tiny program I would just use a COM file.   
   Explicitly setup segments at program entry to all the same as CS,   
   then call DOS to reduce RAM usage. I don't know what TASM is doing but   
   NASM does this very well and makes no assumptions which have to be   
   later figured out.   
   Steve   www.ml1compiler.org    (NASM stuff)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca