DOS Days

DOS Memory Management

Throughout the DOS era, one of the most challenging and frustrating things was making sure applications and games had the right memory configuration. The problem stemmed from limitations in the original IBM PC's architecture, where it was thought no PC would ever require more than 640 KB of RAM!

Indeed, the Intel 8088 and 8086 CPUs could only physically access up to 1 MB of memory via their 20 address lines. With the arrival of the 80286 CPU, up to 16 MB could be addressed, but in order to retain full backward-compatibility with the original IBM PC, memory allocation was still limited to the first 640 KB - this was referred to as Conventional Memory or Base Memory.

Upper Memory

In the original IBM PC architecture the area of memory between 640 KB and 1 MB was called Upper Memory. This was supposed to be reserved for a combination of video screen memory, video BIOS memory, option ROMs for certain devices, and Cassette BASIC. In reality, a lot of this 384 KB upper memory area (UMA) was unused.

From MS-DOS 5.0, launched in June 1991, device drivers and TSRs could be loaded into unused locations within the 384 KB of UMA via the loading of EMM386.EXE (a device driver that opened up access to the UMA). This helped keep conventional memory free for running programs. These locations were called Upper Memory Blocks (UMBs).

Extended Memory and the High Memory Area

All memory above 1 MB was referred to generically as Extended Memory. Within this, a small 64 KB area just above the 1 MB mark is called the High Memory Area (HMA).

Again from MS-DOS 5.0, a new device driver was provided called HIMEM.SYS which would allow parts of the operating system to be loaded into the HMA. This meant that up to 46 KB of conventional memory could be freed up for programs instead of storing part of the operating system.

On 80286-based systems and above, CPUs would need to be put into what was called "Protected" mode in order to access this Extended Memory. The default mode on startup for 286 and higher processors was called "Real" mode, which was essentially the same as the only mode the 8088 and 8086 CPUs could run in.

Expanded Memory

Due to the fact that no 100% IBM PC-compatible DOS software could support the 286's Protected mode, there was an opportunity for some other mechanism to be created in order to provide access to memory above 1 MB.

The solution was to have the ability to move a "window" of accessible memory around the extended memory space in what was known as bank switching. By swapping out chunks of the extended memory area (everything above 1 MB) into a 64 KB region of the UMA, the full amount of extended memory could be accessed, just one chunk at a time. This method of accessing more memory grew and eventually became a standard known as LIM EMS (Lotus/Intel/Microsoft Expanded Memory Specification), named after the consortium of companies that worked on and ratified the specification.

It was at this point where Extended Memory got the label XMS, and Expanded Memory got the label EMS to help differentiate between the two. Both access memory above the 1 MB mark, but do so in different ways.

In order to make use of EMS, DOS 4.01 (released in 1989) came bundled with an Expanded Memory Manager called EMM386.SYS. In 1991 a more flexible version called EMM386.EXE was released with DOS 5.0. EMM386 made use of a mode found in 80386 CPUs and above: "Virtual 8086" mode.

 

**More to follow shortly**