0

MASM Version 6.1 Programmer's Guide says the following in its page number 12:

Segmented addressing refers to the internal mechanism that combines a segment value and an offset value to form a complete memory address. The two parts of an address are represented as

segment:offset

The segment portion always consists of a 16-bit value. The offset portion is a 16-bit value in 16-bit mode or a 32-bit value in 32-bit mode.

I don't think the highlighted text above is correct for Windows NT, a 32-bit system.

Edit:

As can be seen from the comments below, there are currently two opposing positions held by @Cody Gray and @Raymond Chen, which certainly weren't even addressed in the other 3 questions, from which mine was considered a duplicate.

João Afonso
  • 1,934
  • 13
  • 19
  • No, segment:offset addressing does not apply to 32-bit flat mode. – Cody Gray - on strike Nov 19 '21 at 19:28
  • @CodyGray See the last row on Table 1.2 in page 10 of the book. It mentions "Segment selectors" for Windows NT. Is this also wrong? – João Afonso Nov 19 '21 at 19:35
  • 2
    The sentence is correct, but is not useful in Windows NT because all the selectors set their base address to 0. – Raymond Chen Nov 19 '21 at 19:37
  • Quoting from the paragraph in that same section: *"Windows NT uses the so-called “flat model” of 80386/486 processors. This model places the processor’s entire address space within one 32-bit segment. The section “Defining Basic Attributes with .MODEL” in Chapter 2 explains how to use the flat model. In flat model, your program can (in theory) access up to 4 gigabytes of virtual memory. Since code, data, and stack reside in the same segment, each segment register can hold the same value, which need never change. "* – Cody Gray - on strike Nov 19 '21 at 19:47
  • @CodyGray Thanks for your replies. I'll assume that the sentence highlighted above and the use of the expression "Segment selectors" in Table 1.2 referring to Windows NT are both wrong. – João Afonso Nov 19 '21 at 20:03
  • 2
    The sentences are not wrong. They are still correct, but not particularly useful since most segments are flat. However, it is still important when dealing with the `fs` selector register. – Raymond Chen Nov 20 '21 at 05:24
  • 1
    Cody's comment is an oversimplification. x86 memory addressing is *always* seg:off, but the mapping to linear is usually trivial outside of 16-bit mode. – Peter Cordes Nov 20 '21 at 19:33
  • @PeterCordes Can you tell me how the "segment portion always consists of a 16-bit value" in 32-bit mode? – João Afonso Nov 20 '21 at 22:06
  • 1
    Segment registers are 16 bits wide, always, regardless of mode. (Their meaning is completely different in protected mode vs. real mode, though: indexes into the GDT / LDT instead of being a shifted segment-base directly.) https://en.wikipedia.org/wiki/I386#Architecture has a diagram of the registers. I think [How did offset of an array come to mean the starting address of an array](https://stackoverflow.com/q/68002064) is a better duplicate. – Peter Cordes Nov 20 '21 at 22:41
  • @JoãoAfonso See the definition of pointer [here](https://en.wikipedia.org/wiki/I386#Data_types) – Alexander Nov 26 '21 at 22:38
  • 1
    @CodyGray, I think this Q&A https://stackoverflow.com/q/10810203/2945027 should be added in duplicates list to fully address the issue of "flat model, but FS is still there" – Alex Guteniev Nov 27 '21 at 16:47

0 Answers0