Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
3
3945374
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 94
    • Issues 94
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
  • Analytics
    • Analytics
    • CI / CD
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Create a new issue
  • Jobs
  • Issue Boards
  • Bennie Tan
  • 3945374
  • Issues
  • #89

Closed
Open
Opened Nov 12, 2025 by Bennie Tan@bennietan84532Maintainer
  • Report abuse
  • New issue
Report abuse New issue

X86 Memory Segmentation


The x86 structure has supported Memory Wave segmentation since the original Intel 8086 (1978), however x86 memory segmentation is a plainly descriptive retronym. Sixty four KB of memory (16,384 or 65,536 bytes), and whose directions and registers were optimised for the latter. Coping with larger addresses and extra memory was thus comparably slower, as that functionality was somewhat grafted-on within the Intel 8086. Memory segmentation may keep programs appropriate, relocatable in Memory Wave, and by confining significant elements of a program's operation to 64 KB segments, the program could still run quicker. In 1982, the Intel 80286 added help for virtual memory and memory safety; the original mode was renamed real mode, and the new model was named protected mode. The x86-64 architecture, introduced in 2003, has largely dropped support for segmentation in 64-bit mode. In both real and protected modes, the system uses 16-bit phase registers to derive the precise memory address. In actual mode, the registers CS, DS, SS, and ES point to the currently used program code segment (CS), the present data phase (DS), the current stack segment (SS), and one further segment determined by the system programmer (ES).


The Intel 80386, introduced in 1985, adds two extra segment registers, FS and GS, with no particular makes use of outlined by the hardware. The best way during which the section registers are used differs between the two modes. The selection of segment is generally defaulted by the processor in keeping with the function being executed. Instructions are at all times fetched from the code section. Any knowledge reference to the stack, together with any stack push or pop, uses the stack section; data references indirected by the BP register usually refer to the stack and so that they default to the stack phase. The additional section is the necessary destination for string operations (for example MOVS or CMPS); for this one objective only, the robotically selected phase register cannot be overridden. All different references to information use the information section by default. The info section is the default supply for string operations, but it can be overridden. FS and GS haven't any hardware-assigned makes use of. The instruction format permits an elective phase prefix byte which can be used to override the default phase for selected instructions if desired.


In actual mode or V86 mode, the elemental measurement of a segment is 65,536 bytes, with individual bytes being addressed using 16-bit offsets. The 16-bit segment selector within the phase register is interpreted because the most important sixteen bits of a linear 20-bit deal with, known as a phase tackle, of which the remaining four least important bits are all zeros. The section handle is always added to a 16-bit offset in the instruction to yield a linear handle, which is identical as bodily handle in this mode. The main zeros of the linear handle, segmented addresses, and the phase and offset fields are shown here for clarity. 4096 distinct section:offset pairs. For example, the linear address 08124h can have the segmented addresses 06EFh:1234h, 0812h:0004h, 0000h:8124h, and so on. This might be complicated to programmers accustomed to distinctive addressing schemes, but it surely will also be used to advantage, for example when addressing multiple nested knowledge structures.


Whereas real mode segments are technically always 64 KB lengthy, the practical effect is barely that no section will be longer than 64 KB, moderately than that every section as actually used in a program have to be handled as 64 KB lengthy - dealing with successfully smaller segments is possible: usable sizes vary from sixteen via 65,536 bytes, in 16-byte steps. As a result of there is no protection or privilege limitation in real mode, it continues to be completely up to this system to coordinate and keep inside the bounds of any segments. That is true each when a segment is programmatically treated as smaller than, or the full sixty four KB, but it is also true that any program can all the time entry any memory by just altering segments, since it will possibly arbitrarily set segment selectors to vary section addresses with completely no supervision. Therefore, while actual mode will be regarded as permitting different phase lengths, and as allowing segments to be overlapping or non-overlapping as desired, none of this is restrictively enforced by the CPU.


The effective 20-bit deal with house of Pc/XT-generation CPUs limits the addressable memory to 220 bytes, or 1,048,576 bytes (1 MB). This derived immediately from the hardware design of the Intel 8086 (and, subsequently, cognitive enhancement tool the intently related 8088), which had precisely 20 address pins. That is, at sixteen byte intervals. Since all segments are technically 64 KB long, this explains how overlap can occur between segments and why any location within the linear memory tackle area might be accessed with many segment:offset pairs. The precise location of the start of a section within the linear handle space may be calculated with phase × 16. Such handle translations are carried out by the segmentation unit of the CPU. The final segment, FFFFh (65535), begins at linear address FFFF0h (1048560), 16 bytes before the tip of the 20-bit tackle house, and thus can access, with an offset of up to 65,536 bytes, up to 65,520 (65536−16) bytes previous the end of the 20-bit deal with area of the 8086 or 8088 CPU.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: bennietan84532/3945374#89