GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

X86 memory models

In computing, the x86 memory models are a set of six different memory models of the x86 CPU operating in real mode which control how the segment registers are used and the default size of pointers. Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

In computing, the x86 memory models are a set of six different memory models of the x86 CPU operating in real mode which control how the segment registers are used and the default size of pointers. mov bx, word [reg] mov ax, word [bx] mov dx, word [bx+2] Far pointers are 32-bit pointers containing a segment and an offset. To use them the segment register ES is used by using the instruction LES Reg, dword ptr [mem] . They may reference up to 1024 KiB of memory. Note that pointer arithmetic (addition and subtraction) does not modify the segment portion of the pointer, only its offset. Operations which exceed the bounds of zero or 65535 (0xFFFF) will undergo modulo 64K operation just as any normal 16-bit operation. For example, if the segment register is set to 0x5000 and the offset is being incremented, the moment this counter offset becomes (0x10000), the resulting absolute address will roll over to 0x5000:0000. les bx,dword [reg] mov ax,word [es:bx] mov dx,word [es:bx+2] Huge pointers are essentially far pointers, but are (mostly) normalized every time they are modified so that they have the highest possible segment for that address. This is very slow but allows the pointer to point to multiple segments (i.e. to span more than 64 KB), and allows for accurate pointer comparisons, as if the platform were a flat memory model: It forbids the aliasing of memory as described above, so two huge pointers that reference the same memory location are always equal. les bx,dword [reg] mov ax,word [es:bx] add bx,2 test bx,0xfff0 jz lbl sub bx,0x10 mov dx,es inc dx mov es,dx lbl: mov dx,word [es:bx] In reality, a compiler may optimize the above Huge pointer code using no branches. This version decrements the segment unconditionally and to compensate, a segment length (0x10) is added to BX. Unlike the previous Huge example, this version does not require the segment:offset to be normalized. les bx,dword [reg] mov ax,word [es:bx] mov dx,es dec dx mov es,dx mov dx,word [es:bx+(2+0x10)] ===x86-64=== On the x86-64 platform, a total of seven memory models exist, as the majority of symbol references are only 32 bits wide, and if the addresses are known at link time (as opposed to position-independent code). This does not affect the pointers used, which are always flat 64-bit pointers, but only how values that have to be accessed via symbols can be placed. ==See also== Protected mode ==References==

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"X86 memory models". 1789134598. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1374365108

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·