The 8086 can address 1MB of memory, requiring 20 bits to specify the address of any particular byte. Since the 8086's registers only hold 16 bits, the segment model was developed which gives each of those 1M addresses many different names. Just as the number 4
can be named as 0+4
, 1+3
, 2+2
, etc., the address 12345
can be expressed as 1234:0005
, 1233:0015
, 1230:0045
, and so on.
In other words, each physical address has 64k different logical addresses. This means that if one program is accessing 1234:0005
and another program is accessing 1233:0015
, those two programs will be accessing the exact same memory address.
So how do we prevent different programs from "colliding" with each other? First of all, recognize that modern computers do not use 8086es anymore. If you have multiple programs running on an actual 8086, they are probably cooperating with each other, sharing the address space knowingly.
Modern CPUs do not run in the 1MB segmented mode (called "real mode") anymore. If you run an OS like Windows or Linux, the CPU uses something called virtual memory, where each program has its own mapping of logical addresses to physical addresses. In this mode, the programs typically use logical addresses that are 32 or 64 bits, and the programs have no knowledge of how a given logical address maps to a physical address. Any number of programs can use the same set of logical addresses and there will be no overlap of physical addresses unless the programs specifically arrange to do so.