Hello all,
As an assembly programmer I never needed to write *big* programs, and therefore always used the "tiny" memory model where CS = DS = SS.
Though at some point I realized that not having SS equal to DS
creates its own problems - when trying to access stack-based data
(strings).
A "lea dx,[Stack-based item]" will work, but, for example, using it
with "mov ah,09h", "int 21h" will ofcourse fail, as DX is not
pointing into DS.
My question :
Does anyone know how this is solved ? Other than (manually!)
wrapping all such calls in a "push ds", "mov ax,ss", "mov ds,ax" ....
"pop ds" sequences I mean.
No, sorry. Why would I put strings in the stack space?
John,
No, sorry. Why would I put strings in the stack space?
Lol ! Go troll someone else, will you.
A "lea dx,[Stack-based item]" will work, but, for example, using it
with "mov ah,09h", "int 21h" will ofcourse fail, as DX is not
pointing into DS.
Lol ! Go troll someone else, will you.I'm sorry, it wasn't meant as a troll.
If ss<>ds then to load /dx/ with a saved string pointer
I'd use the 'pop' instruction.
I presume you're after something like /mov dx,[ss:stack+offset]/
John,
Lol ! Go troll someone else, will you.I'm sorry, it wasn't meant as a troll.
Phew ! Thank {deity} for that.
If ss<>ds then to load /dx/ with a saved string pointer
I'm sorry, are you /sure/ you aren't trolling ? Since when does
"lea" load something that was saved ?
I'd use the 'pop' instruction.
No you wouldn't.
I can ofcourse explain to you how "lea" works, but I always got the
idea you knew more about programming than I ever will. IOW, whats
going on here ?
I presume you're after something like /mov dx,[ss:stack+offset]/
Definitily not.
Hello all,
As an assembly programmer I never needed to write *big* programs, and therefore always used the "tiny" memory model where CS = DS = SS.
Though at some point I realized that not having SS equal to DS creates its own problems - when trying to access stack-based data (strings).
A "lea dx,[Stack-based item]" will work, but, for example, using it with "mov ah,09h", "int 21h" will ofcourse fail, as DX is not pointing into DS.
My question :
Does anyone know how this is solved ? Other than (manually!) wrapping all such calls in a "push ds", "mov ax,ss", "mov ds,ax" .... "pop ds" sequences I mean.
Regards,
Rudy Wieser
OTOH I rarely use /lea/.
OK I'll bow out, I'm clearly not understanding your requirement.
Than again, I think I painted myself in a corner. :-|
Although I was thinking of some code which would allocate a stack segment and initialise SS:SP to it (causing SS to become different from DS), when I this morning looked at the different memory models Borlands Tasm offers I could only find one which /doesn't/ set up SS equal to DS. and that one, "TPASCAL", isn't even a standard one. I wonder why that is. :-)
Its like having 20/20 vision looking back. If only I had something like that beforehand ...
As for general use... Is segment override not applicable? e.g.
I think that's it; the answer is "don't do that" (Sebastian!);
It still seems to me you were trying to use stack space to store strings.
John,
I think that's it; the answer is "don't do that" (Sebastian!);
:-) Yep. Not because it cannot work, but because it just costs too much work.
The thing is that I knew a way to deal with it (the wrapper code I mentioned in my first post), but wanted to know if there would be a simpler approach, making a SS <> DS setup feasable to use.
It still seems to me you were trying to use stack space to store strings.
:-) Not only trying, but have done so for quite a number of years now.
Are you trying to tell me that you have never used procedure-local variables ?
Are you trying to tell me that you have never used procedure-local
variables ?
Yes. I'm not the whizz programmer you thought I was!
Hello all,
As an assembly programmer I never needed to write *big* programs, and therefore always used the "tiny" memory model where CS = DS = SS.
Though at some point I realized that not having SS equal to DS creates its own problems - when trying to access stack-based data (strings).
A "lea dx,[Stack-based item]" will work, but, for example, using it with "mov ah,09h", "int 21h" will ofcourse fail, as DX is not pointing into DS.
My question :
Does anyone know how this is solved ? Other than (manually!) wrapping all such calls in a "push ds", "mov ax,ss", "mov ds,ax" .... "pop ds" sequences I mean.
Lastly, perhaps you should be using segmented memory or you could
generate code by some means other than the assembler and more higher
level.
I'd advise looking into some kind of macro assembly.
If your assembler can tell you where (in what segment) a variable
is allocated
(assuming it can actually allocate a variable on the stack just like in
the data segment)
and if the assembler can conditionally assemble code based on that,
then you can eliminate some unnecessary segment manipulation.
Lastly, perhaps you should be using segmented memory
or you could generate code by some means other than the
assembler and more higher level.
:-) I like Assembly because it /doesn't/ hide all kinds of stuff from me.
But nearly no PC can execute 16 bit code directly these days.
So what sense does it make to still write 16 bit code?
And 32 bit code also has the advantage, that you don't have to
mess around with segments.
But nearly no PC can execute 16 bit code directly these days.
For starters, why including a restriction like "directly" ? How does that matter ?
And for seconds, how does "nearly no PC" matter as long as mine does ?
So what sense does it make to still write 16 bit code?
What sense does it make for anyone to have a hobby ? Its a waste of time, not bringing any money on the table.
And 32 bit code also has the advantage, that you don't have to
mess around with segments.
True. But why "mess around" with it /at all/ ? I'm sure there are lots of well-payed professional programmers which can deliver much better quality in a much shorter time.
But a question : why are you (still?) in this newsgroup, which is all about an OS that has been obsolete for over 20 years and, listening to you, likely won't even be able to run on any of your computers ...
Alexei,
I'd advise looking into some kind of macro assembly.Borlands Tasm does support macros. But alas, they do not measure up to the inbuild method of calling procedures and its checking of the (ammount and type of) provided arguments.
If your assembler can tell you where (in what segment) a variableNope. That "lea dx,[bp-xxxx]" implicitily uses SS as its base. There is no way to tell by looking at DX itself.
is allocated
(assuming it can actually allocate a variable on the stack just like in the data segment)<huh?> You're the second one who doubts that, even though procedure-local variables are a thing in most any language ...
and if the assembler can conditionally assemble code based on that,I'm not at all sure I can override build-in menemonics to execute a macro ... Otherwise I would need to add pseudo(?) code around pretty-much everything.
then you can eliminate some unnecessary segment manipulation.
Lastly, perhaps you should be using segmented memoryIsn't that what is what started my problem ? Putting DS into a different segment than SS ?
or you could generate code by some means other than the:-) I like Assembly because it /doesn't/ hide all kinds of stuff from me.
assembler and more higher level.
A program is written in order to be executed. To write a program
which can be executed on nearly none of the current computers
(without first installing additional software like DOSBox) doesn't
make much sense.
Because normally a program is not only executed once. And if the
code still can be useful in a few years, it shouldn't be written
for a system which is obsolete already now.
Even if done as a hobby, the result should be something useful.
And therefore it doesn't also make much sense for a "starter" to start
with 16 bit coding instead of the much easier 32 bit coding.
Because normally a program is not only executed once.
Even if done as a hobby, the result should be something useful.
Why mess around to make pictures with a camera.
but many programs written for MSDOS can still be executed in the current
32 bit Windows version.
The problem is, that AMD removed v86 mode in 64 bit mode
Microsoft didn't add a software DOS emulator in 64 bit Windows.
I'm thinking more of declaring a symbol for each string and deducing
the segment from that symbol (or it maybe a pair of symbols, one
for the offset, the other for the segment).
I don't remember the details and they are important.
I'm afraid that's unavoidable.
Lastly, perhaps you should be using segmented memoryIsn't that what is what started my problem ? Putting DS into a different
segment than SS ?
Sorry, it should've been "should NOT be using segmented memory".
Then embrace it. Write all of the plumbing by hand. :)
A program is written in order to be executed. To write a program
which can be executed on nearly none of the current computers
(without first installing additional software like DOSBox) doesn't
make much sense. And therefore it doesn't also make much sense for a "starter" to start with 16 bit coding instead of the much easier
32 bit coding.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 01:46:10 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
10 files (20,373K bytes) |
| Messages: | 264,210 |