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,548 of 4,675    |
|    R.Wieser to All    |
|    EXE program stack setup questions    |
|    06 Oct 18 11:08:10    |
   
   From: address@nospicedham.not.available   
      
   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   
      
   P.s.   
   If someone knows of a website that talks about the different possible   
   methods I'd like to have a link. I did some searching to it, but somehow   
   this kind of triviality seems to be skipped (I found nothing).   
      
   --- 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