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 4,492 of 4,675   
   R.Wieser to All   
   Re: error for small data model   
   16 Nov 22 08:52:35   
   
   From: address@nospicedham.not.available   
      
   Paul,   
      
   > What do you mean by "smaller memory models"?   
      
   The ones that keep DS and SS (and possibly CS) the same.   
      
   > But from memory small was the default memory model for   
   > DOS C compilers.   
   >   
   > How did they manage to make it work?   
      
   As long as they kept SS the same as DS that one is easy - as long as you do   
   not put (directly accessed) data in the CS segment.   No extra work is   
   needed   
      
   If not ?  Well, they would have to use segment-register overrides a lot.   
      
   Assume that SS differs from DS and you have some "local string variable" (on   
   the stack) which you want to display.  You can't use INT 21h AH=09h   
   directly, as it expects the string to be in the data segment.   
      
   So, you have to either write funtions which grab a byte a time while   
   overriding the default segment for that register (mov dl,[ss:dx]), or wrap   
   the call into a bit of code which sets DS to be the same as SS and   
   afterwards restores it. (push ds | mov ax,ss | mov ds,ax | .... | pop ds).   
      
   Ofcourse, if you have DS different from CS and put strings into the code   
   segment which you want to display you would have the same problem.  Heck,   
   the same happens when you allocate memory and want to access it : you mostly   
   have to juggle DS and ES around to get the "movs" instruction to do its   
   thing. :-)   
      
   In other words : Its not a rocket science needing problem, but its solution   
   is one that needs to be applied rigorously and correctly *all the time*.   
      
   Which is the reason that, when I'm writing Assembly, I seldom (if ever) feel   
   the need to pick a memory model where SS is different from DS.   :-)   
      
   Regards,   
   Rudy Wieser   
      
   --- 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