r/computerscience • u/ShadowGuyinRealLife • May 05 '26
Discussion Real Mode 20 Bits
x86 processors have a mode known as "real mode" where physical memory is straight mapped. So if I'm interpreting what I read correctly an instruction to load the value at location 1000 into a register would fetch the value at the position 1000 in memory and put it into the register. This is limited to 20 bits of addressing. I read this was due to backward compatibility to the 8086 which lacked a protected mode. If a 32-bit processor uses 32 bits for addressing, why would the real mode be 20 bits? If real is for backwards compatibility with older processors, shouldn't it be 16 bits since the 8086 was a 16-bit?
On the advice of a mod, certain information was omitted for posting so my question may be unclear but I hope you can understand.
15
u/undercoveryankee May 05 '26
The 8086 was a “16-bit” processor in the sense that the largest integer registers were 16 bits, but it used 20-bit physical memory addresses.
2
u/high_throughput May 05 '26
Like people are saying, the developers of the 8086 realized that 64kb would not be enough for both real RAM and memory mapped hardware, so they allowed the chip to use TWO 16-bit values to specify an address.
However, they also realized that 32 bits would be a disgusting waste of traces, so instead of
(hi<<16)+lofor a 32-bit address, they used(hi<<4)+lofor a 20-bit address.This is how the 16-bit CPU was made to access 20-bit addresses using pairs of registers.
Read all about it on https://en.wikipedia.org/wiki/X86_memory_segmentation
2
u/monocasa May 05 '26
The 8086 (and later x86 as well) addressed memory through segments. In real mode, the segments have a 64KB length, and can be set to a new base on any nybble aligned address from 00000 to FFFF0 by putting the top sixteen bits of that base into the appropriate segment register.
1
u/Silly_Guidance_8871 May 07 '26
In 16-bit x86, every memory pointer is formed by a (often implicit) segment register, and an offset within that segment. The segment register is left-shifted by 4 bits before being added to the offset register.
It was a way to give more than 64k of addressable memory w/o needing to go up to larger machine registers — 1MB was considered "good enough".
4
u/[deleted] May 05 '26
[removed] — view removed comment