Paul,
Post by Paul EdwardsWhat do you mean by "smaller memory models"?
The ones that keep DS and SS (and possibly CS) the same.
Post by Paul EdwardsBut 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