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,498 of 4,675    |
|    Terje Mathisen to R.Wieser    |
|    Re: error for small data model    |
|    16 Nov 22 13:09:43    |
      From: terje.mathisen@nospicedham.tmsw.no              R.Wieser wrote:       > 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. :-)              For my word count code I needed a 64 KB lookup table, so I put that in a       separate ES segment, then I could put another largish table in the SS       segment and access it with BP, leaving disk buffers etc in DS.              Terje                     --       - |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca