Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

The less time planning, the more time programming.


devel / comp.lang.asm.x86 / Re: error for small data model

SubjectAuthor
* error for small data modelPaul Edwards
`* error for small data modelR.Wieser
 `* error for small data modelPaul Edwards
  `* error for small data modelR.Wieser
   `* error for small data modelPaul Edwards
    `* error for small data modelR.Wieser
     +* error for small data modelPaul Edwards
     |`* error for small data modelR.Wieser
     | `* error for small data modelPaul Edwards
     |  +- error for small data modelR.Wieser
     |  `* error for small data modelGeorge Neuner
     |   `* error for small data modelPaul Edwards
     |    `* error for small data modelTerje Mathisen
     |     `- error for small data modelPaul Edwards
     `- error for small data modelTerje Mathisen

1
error for small data model

<b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=816&group=comp.lang.asm.x86#816

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: error for small data model
Date: Sun, 13 Nov 2022 18:30:52 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 21
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Mon, 14 Nov 2022 02:30:52 +0000
Injection-Info: reader01.eternal-september.org; posting-host="bb597b607c70ed199e0e486d54bd302b";
logging-data="1769038"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/580rM+sV5QbHg2PgO3iPvxuArEGevuEc="
User-Agent: G2/1.0
Cancel-Lock: sha1:FFbEcmsgh0jFMQxzHX8UzIElpYc=
 by: Paul Edwards - Mon, 14 Nov 2022 02:30 UTC

What is the best way of producing an error here?

; push the psp now, ready for calling start

if @DataSize
push ds
else
error you must use a model with far data pointers
endif

Also, is there something like:

if not @DataSize
error ...
endif

???

Thanks. Paul.

Re: error for small data model

<tksso8$1fir$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=817&group=comp.lang.asm.x86#817

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: address@nospicedham.not.available (R.Wieser)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Mon, 14 Nov 2022 09:03:17 +0100
Organization: Aioe.org NNTP Server
Lines: 26
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <tksso8$1fir$1@gioia.aioe.org>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="bb597b607c70ed199e0e486d54bd302b";
logging-data="1816600"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188hyQLEA9ydFJTUubZaIhk11SrJOSAbag="
Cancel-Lock: sha1:yLXFDEe93VpCAHmOn+/0pDnVXUY=
 by: R.Wieser - Mon, 14 Nov 2022 08:03 UTC

Paul,

> What is the best way of producing an error here?

That depends on 1) what kind of error you want (run or assmble time) 2) the
assembler you're using.

Looking at the example code it looks to me you want #2. In that case you
could check if your assember has something like "@err" (for errors) and
"@out" (for warnings).

And a suggestion : when one of the blocks contains an program (error) exit
than you do not need to use an "else". Just make sure that the error-exit
is in the first, main block :
- - - - - - - - - -
if not @DataSize
error you must use a model with far data pointers
endif
push ds
- - - - - - - - - -
notice the "not" after the "if"

Regards,
Rudy Wieser

Re: error for small data model

<d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=818&group=comp.lang.asm.x86#818

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Mon, 14 Nov 2022 21:45:26 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 48
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com> <tksso8$1fir$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Tue, 15 Nov 2022 05:45:26 +0000
Injection-Info: reader01.eternal-september.org; posting-host="6e3d1c0a0277330236a4563ef5e7a953";
logging-data="2117649"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18L7U3HQaZs/t2LwzLSrnpGSSqWGmyY4TM="
User-Agent: G2/1.0
Cancel-Lock: sha1:D7MRYdOqdRsOPhXJXmRgUYQk2rI=
 by: Paul Edwards - Tue, 15 Nov 2022 05:45 UTC

On Monday, November 14, 2022 at 4:13:11 PM UTC+8, R.Wieser wrote:
> Paul,
> > What is the best way of producing an error here?
> That depends on 1) what kind of error you want (run or assmble time) 2) the
> assembler you're using.
>
> Looking at the example code it looks to me you want #2. In that case you
> could check if your assember has something like "@err" (for errors) and
> "@out" (for warnings).
>
> And a suggestion : when one of the blocks contains an program (error) exit
> than you do not need to use an "else". Just make sure that the error-exit
> is in the first, main block :
> - - - - - - - - - -
> if not @DataSize
> error you must use a model with far data pointers
> endif
> push ds
> - - - - - - - - - -
> notice the "not" after the "if"

Hi Rudy, thanks for your reply.

Yes, I am after an assembly error.

But neither @err nor not seem to work on masm or wasm.

@err gives an error and "not" seems to be used as a variable
which is false.

However, I now accept small data pointers so I no longer
need to produce an error so it doesn't matter any more.

On the subject of small and medium memory model -
how is it possible for them to work? Functions can
accept pointers that originated from either the stack
or the data segment, or potentially even the code
section if literals are stored there.

Those are different address spaces. How did DOS compiler
vendors manage to get a sensible result?

Did they define the buffer in fwrite etc to be "far" to force
an override? That would work for the C library, but fall down
when it comes to user code.

Thanks. Paul.

Re: error for small data model

<tkvkkc$18sf$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=819&group=comp.lang.asm.x86#819

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: address@nospicedham.not.available (R.Wieser)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Tue, 15 Nov 2022 10:03:03 +0100
Organization: Aioe.org NNTP Server
Lines: 37
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <tkvkkc$18sf$1@gioia.aioe.org>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com> <tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="6e3d1c0a0277330236a4563ef5e7a953";
logging-data="2146586"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+a8Ff9YKz7PyefdX81kGVj0RTHBWOxz9o="
Cancel-Lock: sha1:xqf5y2J7NX6ko3D5VscdzWfDmZU=
 by: R.Wieser - Tue, 15 Nov 2022 09:03 UTC

Paul,

> Yes, I am after an assembly error.
>
> But neither @err nor not seem to work on masm or wasm.
>
> @err gives an error and "not" seems to be used as a variable
> which is false.

My suggestions where based on Borlands Tasm32 (yeah I know, ancient). But
now you've specified which assembler you're using you stand a chance that
someone here uses the same and knows the answer to all three of the above.

Though you could try using "ifn" instead of "if not". Bottom line, take a
peek at your assemblers documentation.

> On the subject of small and medium memory model -
> how is it possible for them to work?
....
> Those are different address spaces.

I had the same thoughts/problem. Its almost impossible to use stack-based
structures/strings when DS and SS are not the same. As such they are most
always (made) the same.

If you want to store data in / retrieve from the code segment of your
program (you should not, but its your choice) than you have no other option
than to make sure that all three segment registers are the same (locking you
into the smaller memory models).

That, or special functions that override the pointers default segment with
one of your own choice (for example, mov al,[cs:si] ).

Regards,
Rudy Wieser

Re: error for small data model

<cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=820&group=comp.lang.asm.x86#820

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Tue, 15 Nov 2022 18:01:29 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 33
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>
<tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>
<tkvkkc$18sf$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Wed, 16 Nov 2022 02:01:30 +0000
Injection-Info: reader01.eternal-september.org; posting-host="080424488f2a97c6f0cd81689c5eba9c";
logging-data="2303606"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kEkruTeJC1KMldAck7CwFNzYbtI/PDIE="
User-Agent: G2/1.0
Cancel-Lock: sha1:PL3wkkkcFRi/zBgR63VChajQq6k=
 by: Paul Edwards - Wed, 16 Nov 2022 02:01 UTC

On Tuesday, November 15, 2022 at 5:17:47 PM UTC+8, R.Wieser wrote:

> > On the subject of small and medium memory model -
> > how is it possible for them to work?
> ...
> > Those are different address spaces.

> I had the same thoughts/problem. Its almost impossible to use stack-based
> structures/strings when DS and SS are not the same. As such they are most
> always (made) the same.
>
> If you want to store data in / retrieve from the code segment of your
> program (you should not, but its your choice) than you have no other option
> than to make sure that all three segment registers are the same (locking you
> into the smaller memory models).

What do you mean by "smaller memory models"?

The only ones that conceivably work are tiny, compact,
large and huge.

The ones that don't are small and medium.

> That, or special functions that override the pointers default segment with
> one of your own choice (for example, mov al,[cs:si] ).

But from memory small was the default memory model for
DOS C compilers.

How did they manage to make it work?

Thanks. Paul.

Re: error for small data model

<tl24sf$nh2$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=821&group=comp.lang.asm.x86#821

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: address@nospicedham.not.available (R.Wieser)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Wed, 16 Nov 2022 08:52:35 +0100
Organization: Aioe.org NNTP Server
Lines: 42
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <tl24sf$nh2$1@gioia.aioe.org>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com> <tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com> <tkvkkc$18sf$1@gioia.aioe.org> <cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="080424488f2a97c6f0cd81689c5eba9c";
logging-data="2442148"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ozf9qZ2T97nGvuSAxJkTUBGVI21RJQtQ="
Cancel-Lock: sha1:je6+UwUqP2Yj87X7EmWteqXuryc=
 by: R.Wieser - Wed, 16 Nov 2022 07:52 UTC

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

Re: error for small data model

<35fa491e-d38d-4c08-a221-df3b6d452738n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=822&group=comp.lang.asm.x86#822

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Wed, 16 Nov 2022 00:46:44 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 18
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <35fa491e-d38d-4c08-a221-df3b6d452738n@googlegroups.com>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>
<tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>
<tkvkkc$18sf$1@gioia.aioe.org> <cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com>
<tl24sf$nh2$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Wed, 16 Nov 2022 08:46:44 +0000
Injection-Info: reader01.eternal-september.org; posting-host="080424488f2a97c6f0cd81689c5eba9c";
logging-data="2448100"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XnC7flayCB8emrYp2CnOPFmI72eB/r6M="
User-Agent: G2/1.0
Cancel-Lock: sha1:kwdtyquRPOkA5S3VhLNlWLUtHb8=
 by: Paul Edwards - Wed, 16 Nov 2022 08:46 UTC

On Wednesday, November 16, 2022 at 4:04:02 PM UTC+8, R.Wieser wrote:
> Paul,
> > What do you mean by "smaller memory models"?
> The ones that keep DS and SS (and possibly CS) the same.

There is no choice in that case - tiny is the only one.

> 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. :-)

So long as you use far data pointers, ie compact, large and
huge, it should all be fine. Otherwise you only have the one
choice, above.

Unless I'm missing something.

BFN. Paul.

Re: error for small data model

<tl2bgl$1doh$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=823&group=comp.lang.asm.x86#823

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: address@nospicedham.not.available (R.Wieser)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Wed, 16 Nov 2022 10:45:50 +0100
Organization: Aioe.org NNTP Server
Lines: 20
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <tl2bgl$1doh$1@gioia.aioe.org>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com> <tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com> <tkvkkc$18sf$1@gioia.aioe.org> <cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com> <tl24sf$nh2$1@gioia.aioe.org> <35fa491e-d38d-4c08-a221-df3b6d452738n@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="080424488f2a97c6f0cd81689c5eba9c";
logging-data="2456211"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184bcMONbO4WyImy90Gdw9cXtMyuN+FEzw="
Cancel-Lock: sha1:SkHoMAzEb7M6UmDLb/arOwby5fs=
 by: R.Wieser - Wed, 16 Nov 2022 09:45 UTC

Paul,

> There is no choice in that case - tiny is the only one.

As you have not mentioned anything about your requirements there is no way
for me to agree or disagree with the above I'm afraid ...

> So long as you use far data pointers, ie compact, large and
> huge, it should all be fine.

And create the replacement or wrapper functions for INT 21h (and other) "one
segment only" calls.

As I said, its not rocket science. But you might find programming Assembly
in those models becoming tiresome rather quickly.

Regards,
Rudy Wieser

Re: error for small data model

<tl2ju1$1ado$2@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=824&group=comp.lang.asm.x86#824

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: terje.mathisen@nospicedham.tmsw.no (Terje Mathisen)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Wed, 16 Nov 2022 13:09:43 +0100
Organization: Aioe.org NNTP Server
Lines: 50
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <tl2ju1$1ado$2@gioia.aioe.org>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>
<tksso8$1fir$1@gioia.aioe.org>
<d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>
<tkvkkc$18sf$1@gioia.aioe.org>
<cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com>
<tl24sf$nh2$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="080424488f2a97c6f0cd81689c5eba9c";
logging-data="2479537"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NqfptFto9qnZU+QozlyrNEZExGLwJE24="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.14
Cancel-Lock: sha1:fy6cOhauTKvDAmIarPry5/ulTnE=
 by: Terje Mathisen - Wed, 16 Nov 2022 12:09 UTC

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

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: error for small data model

<74b2d6f1-540b-4521-92f4-6cedc6a58c55n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=825&group=comp.lang.asm.x86#825

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Wed, 16 Nov 2022 05:33:51 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 34
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <74b2d6f1-540b-4521-92f4-6cedc6a58c55n@googlegroups.com>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>
<tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>
<tkvkkc$18sf$1@gioia.aioe.org> <cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com>
<tl24sf$nh2$1@gioia.aioe.org> <35fa491e-d38d-4c08-a221-df3b6d452738n@googlegroups.com>
<tl2bgl$1doh$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Wed, 16 Nov 2022 13:33:51 +0000
Injection-Info: reader01.eternal-september.org; posting-host="080424488f2a97c6f0cd81689c5eba9c";
logging-data="2492231"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SiPKW1XtfmseHSamRdKPgr9U1OPSWekc="
User-Agent: G2/1.0
Cancel-Lock: sha1:/OIMIKlpihTn4qw1FV798H2cdkM=
 by: Paul Edwards - Wed, 16 Nov 2022 13:33 UTC

On Wednesday, November 16, 2022 at 5:49:12 PM UTC+8, R.Wieser wrote:
> Paul,
> > There is no choice in that case - tiny is the only one.
> As you have not mentioned anything about your requirements there is no way
> for me to agree or disagree with the above I'm afraid ...

I was trying to implement my C library (PDPCLIB) for MSDOS
when I encountered this issue.

> > So long as you use far data pointers, ie compact, large and
> > huge, it should all be fine.
> And create the replacement or wrapper functions for INT 21h (and other) "one
> segment only" calls.
>
> As I said, its not rocket science. But you might find programming Assembly
> in those models becoming tiresome rather quickly.

I'm not trying to program in assembly, except for the minimal
wrappers.

I'm wondering how a C "hello world" could have worked in small
memory model C compiler (any vendor) when the "hello world"
string could come from either a buffer on the stack or a data
variable.

It somehow magically worked.

I didn't need to stuff around in my hello world application program -
someone else magically dealt with that.

Now I'm trying to understand magic.

Thanks. Paul.

Re: error for small data model

<tl32ce$m1h$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=826&group=comp.lang.asm.x86#826

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: address@nospicedham.not.available (R.Wieser)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Wed, 16 Nov 2022 17:16:07 +0100
Organization: Aioe.org NNTP Server
Lines: 22
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <tl32ce$m1h$1@gioia.aioe.org>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com> <tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com> <tkvkkc$18sf$1@gioia.aioe.org> <cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com> <tl24sf$nh2$1@gioia.aioe.org> <35fa491e-d38d-4c08-a221-df3b6d452738n@googlegroups.com> <tl2bgl$1doh$1@gioia.aioe.org> <74b2d6f1-540b-4521-92f4-6cedc6a58c55n@googlegroups.com>
Injection-Info: reader01.eternal-september.org; posting-host="080424488f2a97c6f0cd81689c5eba9c";
logging-data="2521420"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vBF2u+LWNIIpc3yPPsTKzF4MsdEJ8RtE="
Cancel-Lock: sha1:xzocoQRp4wVQJoTHTw9ScFzLD80=
 by: R.Wieser - Wed, 16 Nov 2022 16:16 UTC

Paul,

> I'm wondering how a C "hello world" could have worked in small
> memory model C compiler (any vendor) when the "hello world"
> string could come from either a buffer on the stack or a data
> variable.
>
> It somehow magically worked.

:-) Thats the problem when you use a compiler, it hides a lot of the "magic"
from you.

When using a compiler it just silently switches to the library matching the
chosen memory model and "upgrades" your involved pointers accordingly.

Maybe you can tell your compiler to generate an assembly listing of the
program you're compiling, and see how it works ?

Regards,
Rudy Wieser

Re: error for small data model

<k36anhpurljh220kp25cdos0shh1kagbbt@4ax.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=827&group=comp.lang.asm.x86#827

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: gneuner2@nospicedham.comcast.net (George Neuner)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Wed, 16 Nov 2022 12:14:03 -0500
Organization: A noiseless patient Spider
Lines: 31
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <k36anhpurljh220kp25cdos0shh1kagbbt@4ax.com>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com> <tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com> <tkvkkc$18sf$1@gioia.aioe.org> <cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com> <tl24sf$nh2$1@gioia.aioe.org> <35fa491e-d38d-4c08-a221-df3b6d452738n@googlegroups.com> <tl2bgl$1doh$1@gioia.aioe.org> <74b2d6f1-540b-4521-92f4-6cedc6a58c55n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="080424488f2a97c6f0cd81689c5eba9c";
logging-data="2533967"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BcrF+F/YdPJwfs84qGC0DMTzSKybIyM4="
User-Agent: ForteAgent/8.00.32.1272
Cancel-Lock: sha1:rbr2q9t4g3joUispBwdEvwEfE3Y=
 by: George Neuner - Wed, 16 Nov 2022 17:14 UTC

On Wed, 16 Nov 2022 05:33:51 -0800 (PST), Paul Edwards
<mutazilah@nospicedham.gmail.com> wrote:

>I'm wondering how a C "hello world" could have worked in small
>memory model C compiler (any vendor) when the "hello world"
>string could come from either a buffer on the stack or a data
>variable.
>
>It somehow magically worked.

I may be mis-remembering [it has been a long time], but I believe the
"small" model was 64K code, 64K data, DS = SS.

"tiny" was 64K code + data, CS = DS = SS.
"compact" was 64K code, 1MB data, DS != SS
"medium" was 1MB code, 64K data, DS = SS
"large" was 1MB code, 1MB data, DS != SS, 4:16 pointers
"huge" was 1MB code, 1MB data, DS != SS, 16:4 pointers

>I didn't need to stuff around in my hello world application program -
>someone else magically dealt with that.
>
>Now I'm trying to understand magic.

No magic, just either saving/restoring the segment register around
code that messes with it. Or liberal use of segment overrides.

>Thanks. Paul.
George

Re: error for small data model

<956b57a9-275f-4ecf-8820-5e359f594c4an@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=828&group=comp.lang.asm.x86#828

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Thu, 17 Nov 2022 17:36:24 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 67
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <956b57a9-275f-4ecf-8820-5e359f594c4an@googlegroups.com>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>
<tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>
<tkvkkc$18sf$1@gioia.aioe.org> <cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com>
<tl24sf$nh2$1@gioia.aioe.org> <35fa491e-d38d-4c08-a221-df3b6d452738n@googlegroups.com>
<tl2bgl$1doh$1@gioia.aioe.org> <74b2d6f1-540b-4521-92f4-6cedc6a58c55n@googlegroups.com>
<k36anhpurljh220kp25cdos0shh1kagbbt@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Fri, 18 Nov 2022 01:36:25 +0000
Injection-Info: reader01.eternal-september.org; posting-host="97c8fa8b35318cd5ab19136d61cc1b74";
logging-data="2914471"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RQ6L32yHpabkRIpJExdmI8QXEBOSJl3Y="
User-Agent: G2/1.0
Cancel-Lock: sha1:YMT0vHZ1EQG7HLn/GA0Wn05/uHY=
 by: Paul Edwards - Fri, 18 Nov 2022 01:36 UTC

On Thursday, November 17, 2022 at 1:34:48 AM UTC+8, George Neuner wrote:

> >I'm wondering how a C "hello world" could have worked in small
> >memory model C compiler (any vendor) when the "hello world"
> >string could come from either a buffer on the stack or a data
> >variable.
> >
> >It somehow magically worked.

> I may be mis-remembering [it has been a long time], but I believe the
> "small" model was 64K code, 64K data, DS = SS.

Thanks, that was the secret!

Does this code look right to you (it is working, but that
doesn't necessarily mean I have adjusted sp correctly):

(btw, "ifn @DataSize" didn't work)

https://sourceforge.net/p/pdos/gitcode/ci/master/tree/pdpclib/dosstart.asm#l70

; It appears that in the tiny memory model, you are still required
; to set ds to the same as cs yourself, presumably because ds is
; pointing to the PSP while cs is probably pointing to the beginning
; of the executable. DGROUP may also get the correct value, presumably
; zero. es is set to ds a bit later. And you need to set ss to that
; value too

if @Model eq 1
mov dx, cs
else
mov dx,DGROUP
endif

mov ds,dx

; In tiny, small and medium memory models, you need to set
; ss to ds (MSDOS will have set them to different values
; when it loaded the executable).
; ds and ss are the same so that
; near pointers can refer to either stack or data and still work

if @DataSize
else

mov bx,ss
mov ax,ds
sub bx,ax
mov cl,4
shl bx,cl

mov bp, sp
sub bp, bx
mov ss, dx
mov sp, bp
; And that null PSP thing needs to be redone
mov ax, 0
push ax

endif

My testing suggests that there is a problem with tiny memory
model, but the other memory models seem to work.

Thanks. Paul.

Re: error for small data model

<tlasea$1vs6$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=829&group=comp.lang.asm.x86#829

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: terje.mathisen@nospicedham.tmsw.no (Terje Mathisen)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Sat, 19 Nov 2022 16:24:02 +0100
Organization: Aioe.org NNTP Server
Lines: 81
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <tlasea$1vs6$1@gioia.aioe.org>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>
<tksso8$1fir$1@gioia.aioe.org>
<d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>
<tkvkkc$18sf$1@gioia.aioe.org>
<cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com>
<tl24sf$nh2$1@gioia.aioe.org>
<35fa491e-d38d-4c08-a221-df3b6d452738n@googlegroups.com>
<tl2bgl$1doh$1@gioia.aioe.org>
<74b2d6f1-540b-4521-92f4-6cedc6a58c55n@googlegroups.com>
<k36anhpurljh220kp25cdos0shh1kagbbt@4ax.com>
<956b57a9-275f-4ecf-8820-5e359f594c4an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="df5986395ad149a27958751bc0d35b2f";
logging-data="3423588"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Zw2fDwyhIrW29fJTX5NkH7B6OGlkdD5E="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.14
Cancel-Lock: sha1:m5GBELMTaexk4O35YyrIOhMvs4g=
 by: Terje Mathisen - Sat, 19 Nov 2022 15:24 UTC

Paul Edwards wrote:
> On Thursday, November 17, 2022 at 1:34:48 AM UTC+8, George Neuner wrote:
>
>>> I'm wondering how a C "hello world" could have worked in small
>>> memory model C compiler (any vendor) when the "hello world"
>>> string could come from either a buffer on the stack or a data
>>> variable.
>>>
>>> It somehow magically worked.
>
>> I may be mis-remembering [it has been a long time], but I believe the
>> "small" model was 64K code, 64K data, DS = SS.
>
> Thanks, that was the secret!
>
> Does this code look right to you (it is working, but that
> doesn't necessarily mean I have adjusted sp correctly):
>
> (btw, "ifn @DataSize" didn't work)
>
> https://sourceforge.net/p/pdos/gitcode/ci/master/tree/pdpclib/dosstart.asm#l70
>
> ; It appears that in the tiny memory model, you are still required
> ; to set ds to the same as cs yourself, presumably because ds is
> ; pointing to the PSP while cs is probably pointing to the beginning
> ; of the executable. DGROUP may also get the correct value, presumably
> ; zero. es is set to ds a bit later. And you need to set ss to that
> ; value too
>
> if @Model eq 1
> mov dx, cs
> else
> mov dx,DGROUP
> endif
>
> mov ds,dx
>
> ; In tiny, small and medium memory models, you need to set
> ; ss to ds (MSDOS will have set them to different values
> ; when it loaded the executable).
> ; ds and ss are the same so that
> ; near pointers can refer to either stack or data and still work
>
> if @DataSize
> else
>
> mov bx,ss
> mov ax,ds
> sub bx,ax
> mov cl,4
> shl bx,cl
>
> mov bp, sp
> sub bp, bx
> mov ss, dx
> mov sp, bp
> ; And that null PSP thing needs to be redone
> mov ax, 0
> push ax
>
> endif
>
>
> My testing suggests that there is a problem with tiny memory
> model, but the other memory models seem to work.

Tiny is the one used by all .COM files, in those the binary has no
relocation info, it is just block copied into a newly allocated 64KB
block of memory, at offset 100h, and with those first 256 bytes (the
PSP) initialized by the OS.

In this model all segment registers are the same, i.e. CS=DS=ES=SS
because the OS and CPU are pretending to be a Z80 with no support for
extended/segmented memory addressing.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: error for small data model

<4e9abdeb-90ac-4c66-bae9-c1658d391fcfn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=830&group=comp.lang.asm.x86#830

  copy link   Newsgroups: comp.lang.asm.x86
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mutazilah@nospicedham.gmail.com (Paul Edwards)
Newsgroups: comp.lang.asm.x86
Subject: Re: error for small data model
Date: Sat, 19 Nov 2022 08:32:58 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 72
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <4e9abdeb-90ac-4c66-bae9-c1658d391fcfn@googlegroups.com>
References: <b1863970-566d-439a-9d0f-d7ce43878580n@googlegroups.com>
<tksso8$1fir$1@gioia.aioe.org> <d228345e-8018-4c65-b88a-0b7f063298ddn@googlegroups.com>
<tkvkkc$18sf$1@gioia.aioe.org> <cfce65a5-dbc0-4e15-9b2b-81990741eb79n@googlegroups.com>
<tl24sf$nh2$1@gioia.aioe.org> <35fa491e-d38d-4c08-a221-df3b6d452738n@googlegroups.com>
<tl2bgl$1doh$1@gioia.aioe.org> <74b2d6f1-540b-4521-92f4-6cedc6a58c55n@googlegroups.com>
<k36anhpurljh220kp25cdos0shh1kagbbt@4ax.com> <956b57a9-275f-4ecf-8820-5e359f594c4an@googlegroups.com>
<tlasea$1vs6$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Sat, 19 Nov 2022 16:32:58 +0000
Injection-Info: reader01.eternal-september.org; posting-host="df5986395ad149a27958751bc0d35b2f";
logging-data="3433318"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kc3ZbndmQgJu/ZU0+kvJlldc8KGp2piU="
User-Agent: G2/1.0
Cancel-Lock: sha1:fjn7lQJs2dRqm3PF8laqA75JAwU=
 by: Paul Edwards - Sat, 19 Nov 2022 16:32 UTC

On Saturday, November 19, 2022 at 11:37:49 PM UTC+8, Terje Mathisen wrote:

> > if @DataSize
> > else
> >
> > mov bx,ss
> > mov ax,ds
> > sub bx,ax
> > mov cl,4
> > shl bx,cl
> >
> > mov bp, sp
> > sub bp, bx

This should have been an add, not a subtract. :-)

> > mov ss, dx
> > mov sp, bp
> > ; And that null PSP thing needs to be redone
> > mov ax, 0
> > push ax
> >
> > endif
> >
> >
> > My testing suggests that there is a problem with tiny memory
> > model, but the other memory models seem to work.

> Tiny is the one used by all .COM files, in those the binary has no
> relocation info, it is just block copied into a newly allocated 64KB
> block of memory, at offset 100h, and with those first 256 bytes (the
> PSP) initialized by the OS.
>
> In this model all segment registers are the same, i.e. CS=DS=ES=SS
> because the OS and CPU are pretending to be a Z80 with no support for
> extended/segmented memory addressing.

That's only if you deliberately choose to produce a COM file,
and also you need an org 100h in the startup code.

Otherwise, tiny memory model produces a perfectly fine
normal MSDOS executable, and the entry point can be
anywhere.

My hello world program, linking in the whole C library
in tiny memory model is this size:

Memory size: e110 (57616.)

_TEXT CODE DGROUP 0000:0000 000053c6
CONST DATA DGROUP 053c:0006 000002be
CONST2 DATA DGROUP 0568:0004 00000000
_DATA DATA DGROUP 0569:0000 00000668
_BSS BSS DGROUP 05cf:0008 00006412
STACK STACK DGROUP 0c11:0000 00002000

Entry point address: 0000:02fa

Which is cool.

I have a lot of BSS because of 6144-byte buffers for files which
gave a great speedup on a real XT in the 1990s.

My tiny mode doesn't support malloc though, so you can't
do much. Doesn't support parameters either. :-) Large is
fine though. It was interesting to see.

PDOS/86 now has INT 3 and INT 1 support as a result of
debugging that.

BFN. Paul.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor