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,597 of 4,675   
   Terje Mathisen to R.Wieser   
   Re: EXE program stack setup questions   
   16 Oct 18 11:44:43   
   
   From: terje.mathisen@nospicedham.tmsw.no   
      
   R.Wieser wrote:   
   > Martin,   
   >   
   >> I thuoght you said you wanted the tiny model.   
   >   
   > Correct.   
   >   
   >> SS==CS, SP==0 is the tiny model, isn't it?   
   >   
   > Among 65535 possible other values of SP, yes.   
   >   
   >> I you expect more than almost 64kB of code and data, the tiny   
   >> model is not what you want.   
   >   
   > No, its the other way around.   I expect my programs to take quite a   
   > bit less than 64 KB, including uninitialized data and stack space.   
   > I do not want my 16 KB program to occupy a 64 KB block of memory.   
      
   For a Tiny model program, i.e. COM file, you cannot control this, you   
   will effectively always get a single 64K segment with SP pointing at a   
   16-bit word == 0000. This is required so that a COM file consisting of   
   just a single RET instruction will pop that word into IP and start   
   executing the code at offset zero of the segment, i.e.  the beginning of   
   the PSP.   
      
   At this address you will find an INT 20h instruction which is the Exit   
   Program code, i.e. return to the OS.   
      
   If you, in your startup code, modify SP to point anywhere else, that is   
   also OK as long as the resulting stack area is big enough (100-200 bytes?)   
      
   For TSRs we would usually relocate the resident code so that it would   
   overlap as much of the PSP as possible, since this would easily save   
   over 150 bytes, and in the interrupt handler(s) we would make sure that   
   SP would point at a local stack area.   
      
   My most popular hack was a sub-700 byte (resident size) replacement for   
   the Norwegian keyboard and screen font drivers, this compared nicely   
   with the 20-60 KB required for the various IBM/MS supplied OS drivers   
   with less functionality.   
      
   The result was that HP/Compaq here in Norway stole my program and handed   
   it out to all their major corporate customers. When we caught them   
   red-handed they refused to pay any restitution and promized never to so   
   it again.   
      
   A year later we caught them again, and this time my bosses had such a   
   good relationship with the HP folks that they once again stopped me from   
   suing HP. :-(   
      
   Terje   
      
   --   
   -    
   "almost all programming can be viewed as an exercise in caching"   
      
   --- 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