High memory area


In DOS memory management, the high memory area is the RAM area consisting of the first 65520 bytes above the one megabyte in an IBM AT or compatible computer.
In real mode, the segmentation architecture of the Intel 80286 and subsequent processors identifies memory locations with a 16-bit segment and a 16-bit offset, which is resolved into a physical address via × 16 +. Although intended to address only 1 Megabyte of memory, segment:offset addresses at FFFF:0010 and beyond reference memory beyond 1 MB. So this mode can actually address the first 65520 bytes of extended memory as part of the 64 KB range starting 16 bytes before the 1 MB mark—FFFF:0000 to FFFF:FFFF . The Intel 8086 and Intel 8088 processors, with only 1 MB of memory and only 20 address lines, wrapped around at the 20th bit, so that address FFFF:0010 was equivalent to 0000:0000.
To allow running existing DOS programs which relied on this feature to access low memory on their newer IBM PC AT computers, IBM added special circuitry on the motherboard to simulate the wrapping around. This circuit was a simple logic gate which could disconnect the microprocessor's 21st addressing line, A20, from the rest of the motherboard. This gate could be controlled, initially through the keyboard controller, to allow running programs which wanted to access the entire RAM.
So-called A20 handlers could control the addressing mode dynamically, thereby allowing programs to load themselves into the 1024–1088 KB region and run in real mode. The first user of the HMA among Microsoft products was Windows/286 2.1 in 1988, which introduced the HIMEM.SYS device driver. Starting in 1990 with DR DOS 5.0 and since 1991 with MS-DOS 5.0, parts of the operating system's BIOS and kernel could be loaded into the HMA as well, freeing up to 46 KB of conventional memory. Other components, such as device drivers and TSRs, could at least be loaded into the upper memory area, but not into the HMA. Under DOS 5.0 and higher, with DOS=HIGH, the system additionally attempted to move the disk buffers into the HMA. Under DR DOS 6.0 and higher, the disk buffers, parts of the command processor COMMAND.COM as well as several special self-relocating drivers like KEYB, NLSFUNC and SHARE could load into the HMA as well, thereby freeing up even more conventional memory and upper memory for conventional DOS software to work with. TASKMAX seems to have relocated parts of itself into the HMA as well. Under MS-DOS/PC DOS, a ca. 2 KB shared portion of COMMAND.COM can be relocated into the HMA, as well as DISPLAY.SYS bitmaps for prepared codepages. Under MS-DOS 6.2 and higher, a ca. 5 KB portion of DBLSPACE.BIN/DRVSPACE.BIN can coexist with DOS in the HMA. Under PC DOS 7.0 and 2000, DOSKEY loads into the HMA, and SHARE can be loaded into the HMA as well. Under MS-DOS 7.0 to 8.0, parts of the HMA are also used as a scratchpad to hold a growing data structure recording various properties of the loaded real-mode drivers.