Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
X86 assembly language
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Segmented addressing== The [[x86 architecture]] in [[real mode|real]] and [[virtual 8086 mode]] uses a process known as '''segmentation''' to address memory, not the '''flat memory model''' used in many other environments. Segmentation involves composing a memory address from two parts, a ''segment'' and an ''offset''; the segment points to the beginning of a 64 KiB (64Γ2<sup>10</sup>) group of addresses and the offset determines how far from this beginning address the desired address is. In segmented addressing, two registers are required for a complete memory address. One to hold the segment, the other to hold the offset. In order to translate back into a flat address, the segment value is shifted four bits left (equivalent to multiplication by 2<sup>4</sup> or 16) then added to the offset to form the full address, which allows breaking the [[64k barrier]] through clever choice of addresses, though it makes programming considerably more complex. In [[real mode]]/protected only, for example, if DS contains the [[hexadecimal]] number {{mono|0xDEAD}} and DX contains the number {{mono|0xCAFE}} they would together point to the memory address {{code|1=0xDEAD * 0x10 + 0xCAFE == 0xEB5CE}}. Therefore, the CPU can address up to 1,048,576 bytes (1 MB) in real mode. By combining ''segment'' and ''offset'' values we find a 20-bit address. The original IBM PC restricted programs to 640 KB but an [[expanded memory]] specification was used to implement a bank switching scheme that fell out of use when later operating systems, such as Windows, used the larger address ranges of newer processors and implemented their own virtual memory schemes. Protected mode, starting with the Intel 80286, was utilized by [[OS/2]].<!--ref name="Memory usage"/--> Several shortcomings, such as the inability to access the BIOS and the inability to switch back to real mode without resetting the processor, prevented widespread usage.<ref name="286 failings">{{cite book|url=https://archive.org/details/upgradingrepairi0000muel_17thedition|title=Upgrading and Repairing PCs, 17th Edition|last=Mueller|first=Scott|date=March 24, 2006|publisher=Que|isbn=0-7897-3404-4|edition=17|chapter=P2 (286) Second-Generation Processors|format=Book|access-date=2017-12-06|chapter-url=http://www.informit.com/articles/article.aspx?p=481859&seqNum=13|url-access=registration}} </ref> The 80286 was also still limited to addressing memory in 16-bit segments, meaning only 2<sup>16</sup> bytes (64 [[kilobyte]]s) could be accessed at a time.<!--ref name="Memory usage"/--> To access the extended functionality of the 80286, the operating system would set the processor into protected mode, enabling 24-bit addressing and thus 2<sup>24</sup> bytes of memory (16 [[megabyte]]s).<!--ref name="Address bus"/--> In [[protected mode]], the segment selector can be broken down into three parts: a 13-bit index, a ''Table Indicator'' bit that determines whether the entry is in the [[Global Descriptor Table|GDT]] or [[Local Descriptor Table|LDT]] and a 2-bit ''Requested Privilege Level''; see [[x86 memory segmentation]]. When referring to an address with a segment and an offset the notation of ''segment:offset'' is used, so in the above example the ''flat address'' 0xEB5CE can be written as 0xDEAD:0xCAFE or as a segment and offset register pair; DS:DX. There are some special combinations of segment registers and general registers that point to important addresses: *CS:IP (CS is ''Code Segment'', IP is ''Instruction Pointer'') points to the address where the processor will fetch the next byte of code. *SS:SP (SS is ''Stack Segment'', SP is ''Stack Pointer'') points to the address of the top of the stack, i.e. the most recently pushed byte. *SS:BP (SS is ''Stack Segment'', BP is ''Stack Frame Pointer'') points to the address of the top of the stack frame, i.e. the base of the data area in the [[call stack]] for the currently active subprogram. *DS:SI (DS is ''Data Segment'', SI is ''Source Index'') is often used to point to string data that is about to be copied to ES:DI. *ES:DI (ES is ''Extra Segment'', DI is ''Destination Index'') is typically used to point to the destination for a string copy, as mentioned above. The Intel [[80386]] featured three operating modes: real mode, protected mode and virtual mode. The [[protected mode]] which debuted in the 80286 was extended to allow the 80386 to address up to 4 [[Gigabyte|GB]] of memory, the all new virtual 8086 mode (''VM86'') made it possible to run one or more real mode programs in a protected environment which largely emulated real mode, though some programs were not compatible (typically as a result of memory addressing tricks or using unspecified op-codes). The 32-bit [[flat memory model]] of the [[80386]]'s extended protected mode may be the most important feature change for the x86 processor family until [[AMD]] released [[x86-64]] in 2003, as it helped drive large scale adoption of Windows 3.1 (which relied on protected mode) since Windows could now run many applications at once, including DOS applications, by using virtual memory and simple multitasking.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)