The A20 or addressing line 20 is one of the plethora of electrical lines that make up the system bus of an x86-based computer system. The A20 line in particular is used to transmit the 21st bit on the address bus.
A microprocessor will typically have a number of addressing lines equal to the base-two logarithm of its physical addressing space. For example a processor with 4 GiB of physical addressing space requires 32 lines, which are named A0 through A31. The lines are named after the number of the bit in the address they are transmitting. Thus, A0 will transmit the least significant bit, which is bit 0. A20 transmits bit 21 and will become active once addresses reach 1 MiB or 220.
The early Intel 8086, Intel 8088, and Intel 80186 processors had 20 address lines, numbered A0 to A19, with these the processor can access 220 bytes or 1 MiB. The processors were designed to access only blocks ("segments") of 64 KiB directly (64KiB = 216 - 16-bit offset). Which chunk of physical memory this offset actually pointed to, was pre-selected with a 16-bit "segment-register" which could be moved in steps of 16 byte. The resulting address is equal to Segment * 16 + Offset.
In consequence there were various ways to address the same byte in memory. Exemplary, four of 4096 different segment:offset combinations, all referencing the byte whose physical address is 0x000FFFFF (the last byte in 1 MiB-memory space), are:
Referenced the last way, an increase of one in the offset yields F800:8000, which is a proper address for the processor, but since it translates to the physical address 0x00100000 (the first byte over 1 MiB) the processor would need another address-line to actually access this byte. Since such a line doesn't exist on the 8086 line of processors, the 21st bit above, while set, gets dropped, causing the address F800:8000 to "wrap around" and to actually point to the physical address 0x0000000.
Because loading segment registers was very slow on early processors, this trick was used by some DOS programmers, for example, to have one segment that has access to program data (e.g. from F800:0000 to F800:7FFF, pointing to the physical addresses 0x000F8000 - 0x000FFFFF) as well as the I/O data (e.g. keyboard buffer) that was located in the first memory segment (with addresses F800:8000 to F800:FFFF pointing to the physical addresses 0x00000000 to 0x00007FFF).
When IBM designed the IBM PC AT machine, they decided to use the new higher-performance Intel 80286 microprocessor. The 80286 could address up to 16 MiB of system memory, thus removing the ability for memory addresses to wrap around: Since the required address line now existed, the combination F800:8000 would no longer point to the physical address 0x0000000 but the correct address 0x00100000. As a result some DOS programs would no longer work. In order to remain compatible with these programs, IBM decided to fix the problem themselves, on the motherboard.
Full article ▸