Content deleted Content added
→Real mode: Since it's plural both times, saying bytes twice seems redundant. Also, post-script to previous edit summary: Upon further consideration, I actually think that erroneous "1" (instead of "16") may quite possibly also just have been a simple typo. |
→Real mode: OMG, turns out, per en.wikipedia.org/w/index.php?title=X86_memory_segmentation&diff=prev&oldid=441344024 the 1 byte was NOT a typo. So that's where Joh got it from? I CAN actually understand what OR made the OP think 1 byte, but that's not a real (mode) segment size, it's sectionable! Just bc you're not USING all 16 bytes doesn't mean the segment wasn't 16 bytes. If every "1-byte segment" MUST be followed by a 15-byte gap before the next starts, THAT'S ACTUALLY A 16-BYTE SEGMENT! |
||
Line 12:
[[Image:Overlapping realmode segments.svg|thumb|right|300px|Three segments in [[real mode]] memory (click on image to enlarge). There is an overlap between segment 2 and segment 3; the bytes in the turquoise area can be used from both segment selectors.]]
In [[real mode]] or [[Virtual 8086 mode|V86 mode]], the size of a ''segment'' can range from 16 through 65,536 [[byte]]s, in 16-byte steps, with individual bytes being addressed
The 16-bit segment selector in the segment register is interpreted as the most significant 16 bits of a linear 20-bit address, called a segment address, of which the remaining four least significant bits are all zeros. The segment address is always added to a 16-bit offset in the instruction to yield a ''linear'' address, which is the same as [[physical address]] in this mode. For instance, the segmented address 06EFh:1234h (here the suffix "h" means [[hexadecimal]]) has a segment selector of 06EFh, representing a segment address of 06EF0h, to which the offset is added, yielding the linear address 06EF0h + 1234h = 08124h.
Line 35:
Because of the way the segment address and offset are added, a single linear address can be mapped to up to 2<sup>12</sup> = 4096 distinct segment:offset pairs. For example, the linear address 08124h can have the segmented addresses 06EFh:1234h, 0812h:0004h, 0000h:8124h, etc.
This could be confusing to programmers accustomed to unique addressing schemes, but it can also be used to advantage, for example when addressing multiple nested data structures. While real mode segments are technically always 64 [[Kilobyte|KB]] long, the practical effect is only that no segment can be ''longer'' than 64 KB, rather than that every segment ''must'' be 64 KB long. Because there is no protection or privilege limitation in real mode, even if a segment
(The leading zeros of the linear address, segmented addresses, and the segment and offset fields are shown here for clarity. They are usually omitted.)
|