Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The world is coming to an end ... SAVE YOUR BUFFERS!!!


devel / alt.lang.asm / Re: MASM/WASM .model

Re: MASM/WASM .model

<603a328f-f89b-400b-9c20-bd7b99f24347n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=298&group=alt.lang.asm#298

  copy link   Newsgroups: alt.lang.asm
X-Received: by 2002:a05:6214:1c4d:b0:473:67a4:14de with SMTP id if13-20020a0562141c4d00b0047367a414demr17839667qvb.69.1658055870548;
Sun, 17 Jul 2022 04:04:30 -0700 (PDT)
X-Received: by 2002:a25:d54:0:b0:670:322d:61c6 with SMTP id
81-20020a250d54000000b00670322d61c6mr1427093ybn.391.1658055870174; Sun, 17
Jul 2022 04:04:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: alt.lang.asm
Date: Sun, 17 Jul 2022 04:04:29 -0700 (PDT)
In-Reply-To: <2e4fb6e5-73cd-4f4c-9215-13a26760282cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=51.9.176.194; posting-account=8PoR_AoAAACGGSg3xbkDgqdI88QVi-yY
NNTP-Posting-Host: 51.9.176.194
References: <49cf90f2-c5b9-4e28-9aac-7372d4baa10cn@googlegroups.com>
<84f78dc3-06b0-4764-8250-f4d67b17d024n@googlegroups.com> <0e81e9a4-82a3-4453-846c-96c4dd7b96f8n@googlegroups.com>
<980dbde1-0efe-406d-b8fd-9af94709f9e2n@googlegroups.com> <8ffe96ea-bdbb-4478-a3dd-80d40004a918n@googlegroups.com>
<0955f624-16ed-48cf-ab11-68a1504e124bn@googlegroups.com> <5c2aec03-67c2-4dfb-b884-4410247097c2n@googlegroups.com>
<2e4fb6e5-73cd-4f4c-9215-13a26760282cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <603a328f-f89b-400b-9c20-bd7b99f24347n@googlegroups.com>
Subject: Re: MASM/WASM .model
From: robertapengelly@gmail.com (Robert Pengelly)
Injection-Date: Sun, 17 Jul 2022 11:04:30 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 165
 by: Robert Pengelly - Sun, 17 Jul 2022 11:04 UTC

On Sunday, 17 July 2022 at 05:01:48 UTC+1, Alexei A. Frounze wrote:
> On Saturday, July 16, 2022 at 7:07:45 PM UTC-7, Robert Pengelly wrote:
> > On Sunday, 17 July 2022 at 02:49:34 UTC+1, Alexei A. Frounze wrote:
> > > On Saturday, July 16, 2022 at 4:26:41 PM UTC-7, Robert Pengelly wrote:
> > > > On Saturday, 16 July 2022 at 22:33:55 UTC+1, Alexei A. Frounze wrote:
> > > > > On Saturday, July 16, 2022 at 11:43:28 AM UTC-7, Robert Pengelly wrote:
> > > > > > On Saturday, 16 July 2022 at 19:11:09 UTC+1, Alexei A. Frounze wrote:
> > > > > > > On Saturday, July 16, 2022 at 10:44:44 AM UTC-7, Robert Pengelly wrote:
> > > > > > > > Does anyone know what .model actually does in MASM? I found http://www.c-jump.com/CIS77/ASM/Directives/lecture.html#D77_0030_models which states "Small model supports one data segment and one code segment." but yet if I use .model small,c with WASM I can still create multiple segments when I use 'CODE' or 'DATA'. Have I misunderstood what ".model" does or is WASM ignoring the .model line.
> > > > > > > Are you expecting it to forbid additional segments that you may mistakenly define?
> > > > > > > Are you getting too many segments when you expect only two?
> > > > > > >
> > > > > > > As usual, what's your code and how do you assemble and link it?
> > > > > > > Alex
> > > > > > Sorry, I have the following code:
> > > > > >
> > > > > > .model small, c
> > > > > > .386p
> > > > > >
> > > > > > _DATA segment word public 'DATA'
> > > > > > data1 dw 18h
> > > > > > _DATA ends
> > > > > >
> > > > > > _DTEST segment word public 'DATA'
> > > > > > data2 dw 80h
> > > > > > _DTEST ends
> > > > > >
> > > > > > _TEXT segment word public 'CODE'
> > > > > >
> > > > > > start:
> > > > > >
> > > > > > cli
> > > > > > hlt
> > > > > >
> > > > > > _TEXT ends
> > > > > >
> > > > > > _TTEXT segment word public 'CODE'
> > > > > >
> > > > > > test:
> > > > > >
> > > > > > cli
> > > > > > hlt
> > > > > >
> > > > > > _TTEXT ends
> > > > > >
> > > > > > end
> > > > > >
> > > > > > If small only supports one code and one data segment then I don't expect the code to assemble using WASM as there's two code and two data segments but yet it does.
> > > > > Then don't define more segments than you need.
> > > > > (It's a good question of why you may think you need them!)
> > > > >
> > > > > However, if you still want somewhat (just visually?) separate segments
> > > > > for e.g. different kinds of data (constants, initialized-to-zero vars,
> > > > > other initialized vars, etc) which in the end will be part of one 64KB
> > > > > segment, you may group them. See the group directive.
> > > > >
> > > > > Also, if you only use the "Simplified segment directives" like .CODE,
> > > > > .CONST, .DATA, I bet they would be automatically grouped together
> > > > > as necessary.
> > > > >
> > > > > Alex
> > > > It's not a case of whether I define them or not, I'm just trying to understand how MASM (and MASM-compatible assemblers) work and I'm asking what .model actually does/doesn't do as from my understanding it shouldn't compile and display an error instead. If your not going to bother answering the question and instead tell me what I should and shouldn't do then why both even replying.
> > > Maybe you should state your problem/task/objective more fully when asking for help with it.
> > > What you just said did not immediately follow from the original post.
> > >
> > > Alex
> > Actually it does I did ask "Does anyone know what .model actually does in MASM?" and "Have I misunderstood what ".model" does" then you asked for code and I provided it then you tell me what I should and shouldn't be doing. How hard is it to understand that I'm trying to understand how MASM and MASM-compatible assemblers function with regards to .model. I'm under the assumption that if you use .model small, c then the assembler should fail (and before you bitch again like I originally asked) have I misunderstood what ".model" does or is WASM ignoring the .model line. Seriously how hard is it to get a simple answer to a question.
> It's not a typical question I'd expect without any prior history or larger
> context. As it turns out you're not asking about how to use the tool
> (which is a more common question), you're asking about how it's
> implemented, about its edge cases, you're almost asking how to
> reverse engineer or replicate the tool.
> This isn't the kind of question I would normally expect.
>
> Further, this may not be implemented equally in similar/compatible
> assemblers.
>
> xASM may not be ignoring the .MODEL directive, it just may not be
> doing the kind of check you're expecting from it. All it may be doing
> in response to .MODEL is generating .CODE, .DATA and other such
> special segments into two groups, which will reside in two distinct
> 64KB segments after linking. And that's it, without imposing any
> limitations on any other segments you may throw in.
> (and, of course, there's some support for subroutines, argument
> passing and such, which is also affected by .MODEL, but we
> aren't discussing subroutines here/now)
> Your linker may then either fail to link or it just may produce an
> executable with all your segments. And there isn't any problem in
> DOS .EXEs having several dozens or even a hundred of different
> segments (possibly overlapping).
>
> If you want more info, check the official documentation or
> find the answer by experimentation. But I'm guessing you already
> have your answer. The assembler doesn't limit the number of
> your segments. So, if you want to replicate this behavior, do it.
> If you still want the check that the assembler isn't doing for you,
> you need something else to do it. If you're generating code,
> you may check for it on the generator side. If you're writing the
> code by hand, either be careful or see if there's anything that
> you can use to catch undesired segments. See if there are other
> useful directives or options in the assembler or linker. See if you
> can just post-process the object file or the map file or even the
> executable...
>
> There's no need to be so rude. Explain what you're trying to do.
> Do some research yourself. You're not always going to get
> everything right away and the way you want it.
>
> Alex
I weren't being rude (not intentionally any) I just got a little annoyed by you telling me "Then don't define more segments than you need." and then "What you just said did not immediately follow from the original post. " plus it was late and I couldn't sleep due to the heat, I have a very short fuse and I tend to lash out easily and I'm sorry for that but now I have a clear head. I've tried doing research when it come to wasm but I can't seem to find anything about it from google and other search engines (some examples are https://www.google.co.uk/search?q=wasm+model give me results about webassembly whatever that is). Other than trying to understand the source code (which I have tried and failed at multiple times) I have no idea what should and shouldn't happen. For larger context, I'm a developer and I'm fascinated by assemblers at the moment and I'm trying to understand how they work from a developer perspective (how they work, how they could be implemented, etc) by using existing ones and examining the output. Microsoft's documentation about MASM directives I kind of useless as well, take https://docs.microsoft.com/en-us/cpp/assembler/masm/dot-model?view=msvc-170 it tells you about the directive, the arguments and model types but doesn't tell what the types actually do. I've also looked a JWasm to try and understand it (source code is a bit earlier to go through) but it doesn't support ".model" it does support "-ms" as a command line option but couldn't really find where it was effecting the code. Is that better or do you need more.

SubjectRepliesAuthor
o MASM/WASM .model

By: Robert Pengelly on Sat, 16 Jul 2022

35Robert Pengelly
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor