EGA and VGA Video Memory Mapping in MS-DOS 6.22
In MS-DOS 6.22, system memory is structured around the 1 MB real-mode
address limit of the x86 architecture, allocating a dedicated 128 KB
range known as the Upper Memory Area (UMA) specifically for video
display buffers. MS-DOS does not dynamically translate these memory
addresses through an operating system abstraction layer; instead, it
relies on standard PC memory map conventions established by the IBM PC
BIOS. Addresses between 0xA0000 and 0xBFFFF
map directly to the physical memory residing on EGA and VGA adapter
cards, dividing the space between bitmapped graphics, monochrome text,
and color text modes.
The Real-Mode Video Window
MS-DOS 6.22 operates primarily in real mode, addressing memory using a segment:offset model across a 20-bit address bus (0x00000 to 0xFFFFF). Conventional memory occupies the lower 640 KB (0x00000 to 0x9FFFF), which DOS uses for operating system routines, drivers, and user applications.
The region immediately following conventional memory, spanning from 640 KB to 768 KB, is reserved for video hardware:
- 0xA0000 – 0xAFFFF (Segment
A000h, 64 KB): Reserved for EGA and VGA graphics modes. - 0xB0000 – 0xB7FFF (Segment
B000h, 32 KB): Reserved for monochrome display adapters (MDA) and Hercules compatibility. - 0xB8000 – 0xBFFFF (Segment
B800h, 32 KB): Reserved for CGA color text and graphic modes, as well as standard VGA color text modes.
Video Buffer Segment Allocations
When an application in MS-DOS switches video modes—typically by
issuing software interrupt INT 10h with a specific mode
number in register AH—the video controller activates the
appropriate memory window:
- Standard VGA Graphics (
0xA0000): Modes such as Mode 13h (320x200, 256 colors) and Mode 12h (640x480, 16 colors) use base segment0xA000. In Mode 13h, memory is linear: byteA000:0000represents the top-left pixel on screen, with subsequent bytes directly representing adjacent pixels across the scanline. - Text Modes (
0xB8000): Mode 03h (the standard 80x25 16-color text mode used by the DOS command prompt) writes directly to segment0xB800. Here, memory is mapped in two-byte pairs: the first byte defines the ASCII character code, and the second byte defines the text attribute (foreground and background colors, plus blinking attributes). - Monochrome Modes (
0xB0000): Mode 07h (monochrome 80x25 text) points to segment0xB000. In systems configured exclusively with a color VGA monitor, this 32 KB block is physically unaddressed by the video adapter.
Handling Video Memory Larger than 64 KB
Standard VGA cards feature 256 KB of video RAM, while Super VGA
(SVGA) cards feature 512 KB to several megabytes. Because the CPU
real-mode aperture at segment 0xA000 is only 64 KB wide,
the hardware cannot map all video memory into the system address space
at once.
To access high-resolution modes requiring more than 64 KB, EGA and VGA controllers use planar memory architectures or banking:
- Planar Memory (EGA / 16-Color VGA): The 256 KB of
VRAM is divided into four 64 KB "planes" (Red, Green, Blue, Intensity).
All four planes share the address space
A000:0000toA000:FFFF. The CPU directs read and write operations to specific planes by sending commands to the VGA Graphics Controller I/O ports (0x3CEand0x3CF). - Bank Switching (SVGA): Video BIOS extensions define
page registers. The software changes the active memory bank via
INT 10h, AX=4F05h, swapping 64 KB chunks of VRAM in and out of the0xA0000window.
Interaction with MS-DOS 6.22 Memory Managers
MS-DOS 6.22 manages system memory via HIMEM.SYS and
EMM386.EXE. When configured in CONFIG.SYS,
EMM386.EXE switches the CPU into Virtual 8086 mode to
create Upper Memory Blocks (UMBs) and map Expanded Memory (EMS) pages
into unused regions of the UMA.
EMM386.EXE must avoid mapping RAM over active video
segments:
- By default,
EMM386.EXEexcludes0xA0000through0xAFFFFif EGA/VGA hardware is detected, preserving the graphics frame buffer. - The region
0xB8000to0xBFFFFis consistently excluded to ensure the DOS text console functions without corruption. - If a system uses a standard color VGA monitor without monochrome
hardware, the monochrome segment
0xB0000to0xB7FFFremains idle. Users running MS-DOS 6.22 can reclaim this unmapped 32 KB window by addingDEVICE=EMM386.EXE I=B000-B7FFtoCONFIG.SYS, allowing DOS to create additional UMB space for loading device drivers and TSR programs high.