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,606 of 4,675   
   sdn45478@nospicedham.gmail.com to All   
   Re: EXE program stack setup questions   
   17 Oct 18 17:14:13   
   
   On Saturday, October 6, 2018 at 2:09:42 AM UTC-7, R.Wieser wrote:   
   Hi,   
   I noticed that I didn't explain this very well.   
   For RH:   
   Dos allocates all of RAM for a COM program by default.   
   When a DOS program exits properly, then RAM is the same for the next   
   program upon entry minus whatever a memory manager does to move around   
   DOS (and we need not care)   
   and drivers/tsrs. All memory upon entry for the new program is the   
   same and contiguous from an ASM viewpoint unless the previous program exited   
   incorrectly and left a memory leak.   
   For RW:   
   A. If you change SP for a tiny model program to 100H then you will overwrite   
   the PSP and corrupt your program.   
   B. The stack pointer points to the end of the stack segment which is the   
   same exact segment as every other segment register. A segment register   
   contains the lower 4 bits * 16 + the upper 4 bits as an address so if you   
   change   
   it then you must account for this. The stack pointer points to an address   
   at the end of the stack segment that points to a small exit routine in   
   in the PSP (as I recall).   
   The best way to change SS is to allocate your tiny program to 64K using DOS   
   then to ask DOS for another segment which you change SS to, (which screws   
   up your exit using RTS which you should not do anyway).   
   Steve    www.ml1compiler.org   
      
   --- 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