High Memory Area: How DOS Used the First 64 KB Above 1 MB
- Conventional memory freed (KB)
- KB
- Result
- Total memory above 1 MB (KB)
- 64 KB
- You entered
The High Memory Area (HMA) is the first 64 kilobytes of memory above the 1 MB boundary, and DOS used it as a way to free up conventional memory by loading parts of itself there. This article explains the technical mechanism, why it mattered, and how it worked in practice.
Background: The 640 KB Barrier and the Need for More Memory
In the early 1980s, the IBM PC used the Intel 8088 processor, which had a 20-bit address bus. This meant it could address 2^20 = 1,048,576 bytes, or exactly 1 MB of memory. Of that 1 MB, the lower 640 KB was reserved for user programs (conventional memory), and the upper 384 KB was reserved for system hardware like video memory, ROM BIOS, and expansion card I/O. This left DOS applications with only 640 KB, which became a severe limitation as software grew more complex.
The 80286 processor, introduced in 1982, had a 24-bit address bus, allowing up to 16 MB of memory. However, DOS was designed for the 8088 and could not natively use memory beyond 1 MB because its memory model was based on 16-bit segment:offset addressing, which could only reach 1 MB plus 64 KB minus 16 bytes. The HMA was that tiny sliver of memory just above 1 MB that DOS could access with a quirk of the segment:offset scheme.
How the HMA Works: The Segment:Offset Quirk
In real mode, a memory address is formed by combining a 16-bit segment and a 16-bit offset. The physical address is calculated as segment * 16 + offset. The maximum segment is 0xFFFF and the maximum offset is 0xFFFF, so the maximum physical address is 0xFFFF * 16 + 0xFFFF = 0x10FFEF. This is 1,114,095 bytes, which is 65,520 bytes above the 1 MB mark (0x100000). That 64 KB minus 16 bytes region is the HMA.
On an 80286 or later processor, the address line A20 (the 21st address line) must be enabled to access this region. If A20 is disabled, the address wraps around to 0x00000, causing a system hang. The keyboard controller (or a dedicated A20 gate) controls this line. DOS could enable A20 and then use the HMA as a contiguous block of memory.
What DOS Put in the HMA
The primary use of the HMA was to move the DOS kernel itself out of conventional memory. In DOS 5.0 and later, the command DOS=HIGH in the CONFIG.SYS file instructed DOS to load its core components—the file system handlers, buffer management, and other resident code—into the HMA. This freed up roughly 45 to 60 KB of conventional memory for applications, which was a significant gain at the time.
Other programs, such as certain device drivers and TSRs (terminate-and-stay-resident programs), could also be loaded into the HMA using the DEVICEHIGH command in DOS 6.x. However, the HMA is only 64 KB, so only the smallest drivers could fit. The rest of the upper memory area (UMA) between 640 KB and 1 MB was managed separately using EMM386.EXE and DOS=UMB.
How to Enable the HMA: A20 and DOS Commands
To use the HMA, three things had to be in place:
- An 80286 or later CPU (the 8088 could not access it).
- An A20 gate that could be enabled by software (most BIOSes did this automatically).
- DOS 5.0 or later, or a third-party memory manager like QEMM.
The typical configuration in CONFIG.SYS was:
DEVICE=C:\DOS\HIMEM.SYS– loads the extended memory manager that provides the HMA and manages A20.DOS=HIGH,UMB– tells DOS to load itself into the HMA and to manage upper memory blocks.
After booting, the command MEM would show MS-DOS resident in High Memory Area if it worked.
Common Problems and Misconceptions
One common issue was the A20 gate not being enabled, causing the system to hang on boot. This was often due to a BIOS bug or a conflict with a hardware card. The solution was to use the /A20CONTROL:OFF switch on HIMEM.SYS to force the BIOS to manage A20.
Another misconception is that the HMA is the same as the Upper Memory Area (UMA). They are different: the UMA is the 384 KB region between 640 KB and 1 MB, while the HMA is the 64 KB just above 1 MB. The UMA is used for hardware and can be remapped for drivers, while the HMA is purely for DOS itself or a single program.
Some users thought that loading DOS high would make all of conventional memory available, but it only freed about 45–60 KB, not the full 640 KB. The rest was still used by device drivers, buffers, and the file system.
Comparison with Other Memory Areas
To understand the HMA’s role, it helps to compare it with other memory regions:
- Conventional memory (0–640 KB): Used by DOS and applications. The HMA freed a portion of this.
- Upper Memory Area (640 KB–1 MB): Reserved for hardware, but unused holes could be used for drivers via
EMM386.EXE. - Extended Memory (above 1 MB): The HMA is the first 64 KB of this, but the rest required protected mode or a memory manager like HIMEM.SYS.
- Expanded Memory (EMS): A bank-switched scheme that allowed up to 32 MB on 8088 systems, but slower than extended memory.
The HMA was unique because it was the only part of extended memory that could be accessed in real mode without switching to protected mode, making it ideal for DOS.
Why It Became Obsolete
With the arrival of 32-bit processors and operating systems like Windows 95 and later, DOS was no longer the primary environment. Windows could run DOS programs in a virtual DOS machine that simulated the HMA, but there was no need to load DOS itself into it. The HMA became a historical curiosity, though the A20 gate still exists for compatibility in modern PCs.
In modern systems, the HMA is largely unused, but the concept remains important for understanding the evolution of PC memory management and the clever tricks that allowed software to squeeze more usable memory out of limited hardware.
Frequently Asked Questions
How much memory did DOS=HIGH actually free?
Typically, loading DOS into the HMA freed about 45 to 60 KB of conventional memory. The exact amount varied by DOS version and configuration. In DOS 6.22, it was around 46 KB, while earlier versions freed slightly less.
Can I still use the HMA on a modern PC?
Modern PCs with a BIOS or UEFI that supports real mode can still enable the A20 gate, but DOS itself is rarely used. If you run DOS in a virtual machine, the HMA is emulated, and you can still load DOS high.
What is the A20 gate and why does it matter?
The A20 gate is a hardware switch that controls the 21st address line. When disabled, memory addresses above 1 MB wrap around to zero. It was needed to allow the CPU to access the HMA, and it is still present in modern CPUs for backward compatibility.
Did Windows use the HMA?
Windows 3.x and Windows 9x could use the HMA for its own purposes, but they primarily ran in protected mode and used extended memory directly. The HMA was mainly a DOS feature.
Why is the HMA exactly 64 KB minus 16 bytes?
Because the maximum segment:offset address is 0xFFFF:0xFFFF, which is 1,114,095 bytes. Subtracting the 1 MB base (1,048,576) gives 65,519 bytes, which is 64 KB (65,536) minus 17 bytes. The exact usable size is 65,520 bytes (0xFFFF0 to 0x10FFEF).
Related
Formula used
in t | Total memory above 1 MB (KB) | KB | 64 | 0 out hma | Usable HMA (KB) | KB | t - 1 | 0 out conventional | Conventional memory freed (KB) | KB | 64 - (64 - hma) | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.