Category Archives: Real Mode

It’s 8086 ! It’s What Time Traveller Take

By : Antonius (sw0rdm4n)




Back again to old days, x86 architecture was introduced by intel around 1978 when they released 8086 microprocessor. 8086 introduces real mode where memory consist of segments and offsets (segmented memory).
In 1982, intel released 80286 that introduced protected mode but not used widely yet until the release of 80386. Protected virtual address mode was widely used since i386 (80386 processor) where it introduced paging and virtual address, replacing the old real mode addressing ( but on boot i386 processor still uses real mode).
Meanwhile i386 still had real mode environment via virtual 8086 mode. Nowaday modern operating system commonly uses protected mode on run time, however on boot before switched to protected mode, intel cpu still runs on real mode. The switch phase from real mode to proctected mode accomplished by real mode kernel.
Why 8086 ? because 8086 design is the basic of all intel x86 family until x86_64 processor, however intel x86_64 or amd64 cpu still runs on modified real mode on boot before real mode kernel switched to protected mode kernel.

x86 Bootstrapping phase before kernel switched to protected mode

-------------------------------------- ---------
         BIOS / BOOT ROM                       |
--------------------------------------         |
                |                              |
--------------------------------------         |
 Boot Loader(located at MBR)                  cpu runs on real mode 
--------------------------------------         |
                |                              |
--------------------------------------         |
  VBR or another stages of boot loader         |
--------------------------------------         |
                |                              |
--------------------------------------         |
         Real Mode Kernel               --------
        Protected Mode Kernel

8086 pin header schematic :

  • vcc : for 5 volt voltage(positive)
  • gnd : pin for ground (negative)
  • ad0 – ad15 : multiplexed address (address or data pins)
  • a16-a19 : high order 4 bits of the 20 bits address (address or control pins)
  • reset : to reset cpu
  • s1(dt/r) : data transmit or receive
  • s0 (den) : data bus enable
  • clk : clock
  • ale : address latch enable
  • nmi and intr : control

Intel 8086 was 16 bit cpu with 20 bit addressing. Based on it’s design , it was only capable for 16 bit addressibility. Intel engineer designed memory segmentation (segment and offset pair) in order to have ability for 20 bits addressing.
Let’s say it has 16 bit addressing capability, it means (2 ^ 16) * 1 byte = 65.536 bytes (64 kb). In order to have more 4 bit addressing capability it used segment and offset. Once segmentation used it has 20 bits addressing capability, it means
(2 ^ 20) * 1 byte = 1.048.576 bytes (1 mb). So we may conclude without segmentation and offset, intel 8086 cpu only has 64 kb addressing capability, but with the use of memory segmentation design, it has until 1 mb addressibility.

On real mode, each segment size is 65536 bytes (each size is 64 kb where 1 kb is 1024 bytes, each segment is limited by 16 bits). Memory is arranged using segment and offset pair.
Since real mode doesn’t support virtual memory mapping yet, absolute memory address that consist of segment and offset will map to a physical memory address, actually
this isn’t one to one mapping means 2 or more segment and offset may be translated to the same physical address.

Translating segment:offset to physical address is simple. As an example, we have a form of block memory with segment and offset :


Where segment is 0700h and offset is 0100h. Calculation is simple :

Physical address = (Segment * 16 decimal) + offset

Since 16 decimal is 10h : (0700h * 10h) + 0100h = 7100h