Re: Randall Hyde's essay "Which assembler is the best?"

From: luvr (spam-loving-criminal_at_spam-sink.net)
Date: 04/30/04


Date: Fri, 30 Apr 2004 20:35:11 +0100


"The_Sage" <theeSage@azrmci.net> wrote in message
news:2ea3905so462dgtp6i0qn3fndd6k48ttge@4ax.com...

> >Reply to article by: "Randall Hyde" <randyhyde@earthlink.net>
> >Date written: Thu, 29 Apr 2004 03:34:07 GMT
> >MsgID:<PI_jc.13688$eZ5.13479@newsread1.news.pas.earthlink.net>

> >Well, Windows (Win32), Linux, BeOs, BSD, and QNX all use
> >the flat memory model. Is that enough for you?

> Wrong again. They use protected mode, which is not the same thing as flat
mode.

Confusing terminology... I'd say that there is no such thing as "flat
mode"...
I mean, "flat" is a MODEL, not a MODE.

Apart from this linguistic detail, you're quite right: "Protected MODE" in
no way equates "Flat MODEL".

However, all of the Operating Systems listed run in "Protected MODE," and,
as far as I know, they provide any application with a "flat" (that is,
linear) view of its memory address space - In other words, as far as the
application is concerned, memory addresses start counting at 0, and count
linearly all the way up to the top of the address space. The application,
thus, doesn't even realise that it is running on a hardware architecture
that relies on memory segments by nature.

(In fact, there is one case - that I know of - where Win32 *does* explicitly
use the segmented nature of the x86 memory model: It sets up the FS segment
register so that it addresses a so-called "Thread Information Block," or
"Thread Environment Block" - I don't remember which of these terms is to be
preferred in Win32 parlance, but I think the other one was what OS/2 used to
call it. This control block plays a vital role in many thread-related
operations - e.g., at address FS:[0] there is the head of the chain of
Exception Handlers for the thread; furthermore, the block contains the
Thread-Private Storage slots, or whaterver they're called exactly; and, the
block even contains its own linear memory address... which would otherwise
be pretty hard to get at, unless you can peek into the Segment Tables...)

--Luc.



Relevant Pages

  • Re: Exe in exe
    ... Segment descriptors have a ... But only through aliasing linear memory into several logical segments. ... Using a flat memory model and protecting memory at the page ...
    (alt.comp.lang.borland-delphi)
  • Re: Exe in exe
    ... > But only through aliasing linear memory into several logical segments. ... Using a flat memory model and protecting memory at the page ... > level instead of at the segment level is just done out of laziness. ... Doing that ONLY allows a ONE TIME FIX, ...
    (alt.comp.lang.borland-delphi)
  • Re: History of far memory...?
    ... memory. ... > farmalloc, far char pointers, etc., to differentiate it from near memory. ... You could then access the segment through ... The problem with the huge memory model was that carrying aound the segment ...
    (comp.lang.c)
  • Re: Randall Hydes essay "Which assembler is the best?"
    ... done - that there is an implicit "x86" here because Randy's Webster ... flat... ... memory model has to be "lowest common denominator" - to ensure all ... conditions where the segmentation is "effectively switched off":) ...
    (alt.lang.asm)
  • Re: When is "volatile" used instead of "lock" ?
    ... with respect to the memory model. ... Where else is it violating the 335 memory ... can still write thread-safe code. ... IAsyncResult result = BeginBackgroundOperation(ref value1, ...
    (microsoft.public.dotnet.languages.csharp)