How MS-DOS 6.22 Manages XMS 3.0 Extended Memory
MS-DOS 6.22 manages Extended Memory Specification version 3.0 (XMS
3.0) through its default extended memory manager,
HIMEM.SYS. By implementing the XMS 3.0 specification,
MS-DOS 6.22 allows 16-bit real-mode software to access memory above the
1 MB barrier, manage the High Memory Area (HMA), control the A20 line,
and allocate large continuous Extended Memory Blocks (EMBs) exceeding
the previous 64 MB limitation of XMS 2.0.
The Role of HIMEM.SYS
MS-DOS 6.22 does not natively manage extended memory in the operating
system kernel. Instead, it delegates this task to
HIMEM.SYS, which is loaded via the CONFIG.SYS
file (DEVICE=C:\DOS\HIMEM.SYS). Upon initialization,
HIMEM.SYS queries system BIOS routines (specifically INT
15h, Function E801h, Function 88h, or CMOS registers) to map available
physical RAM beyond 1 MB. It then organizes this space according to XMS
3.0 rules and exposes a consistent interface to applications.
Interface Access and Function Calls
Programs interact with XMS 3.0 via an indirect call vector rather than direct software interrupts:
- An application calls software interrupt
INT 2Fhwith registerAX=4300hto verify if an XMS driver is installed. - The application requests the driver’s entry-point address using
INT 2FhwithAX=4310h. - The driver returns a far call address (
ES:BX). - Programs access XMS functions by placing the desired function code
in
AHand executing a far call to this address.
Core XMS 3.0 Capabilities in MS-DOS 6.22
1. 32-Bit Addressing Beyond 64 MB
The primary distinction of XMS 3.0 over XMS 2.0 is support for memory
capacities exceeding 64 MB (up to 4 GB). HIMEM.SYS in DOS
6.22 introduces 32-bit functions alongside standard 16-bit
functions:
- Function 88h (Query Any Free Extended Memory):
Returns the largest free block and total free extended memory in
kilobytes as 32-bit values in
EAXandEDX. - Function 89h (Allocate Any Extended Memory Block):
Accepts 32-bit allocation requests in
EDX, allowing allocations greater than 65,535 KB. - Function 8Eh (Get Extended EMB Handle Information): Returns 32-bit block base addresses and sizes for any allocated handle.
2. High Memory Area (HMA) Control
The HMA is the first 64 KB minus 16 bytes of memory immediately above
the 1 MB threshold (addresses 100000h to
10FFEFh), addressable in real mode when the A20 line is
enabled.
HIMEM.SYSmanages exclusive reservation of the HMA (Function 01h and 02h).- When configured with
DOS=HIGHinCONFIG.SYS, MS-DOS 6.22 requests the HMA fromHIMEM.SYSat boot and relocates roughly 40 KB of its kernel code, buffers, and internal tables into it, freeing an equivalent amount of conventional memory below 640 KB.
3. A20 Line Management
To prevent memory addresses from wrapping around to zero at the 1 MB
mark, HIMEM.SYS controls the processor's A20 gate. It
provides functions to enable (Function 05h), disable (Function 06h), or
query (Function 07h) the state of the A20 line. In MS-DOS 6.22,
HIMEM.SYS automatically detects the machine's hardware
architecture to select the appropriate switching mechanism (such as via
the keyboard controller, fast A20 lines, or BIOS calls), which can also
be manually forced using the /MACHINE: switch.
4. Extended Memory Block (EMB) Data Transfers
Because real-mode DOS applications cannot directly read or write to
addresses above 1 MB, HIMEM.SYS implements a protected-mode
memory move service (Function 0Bh). Programs populate an Extended Memory
Move Structure containing:
- Length of data in bytes (must be an even number).
- Source handle and 32-bit source offset.
- Destination handle and 32-bit destination offset.
When invoked, the driver temporarily enters protected mode (or utilizes processor block-copy instructions), transfers the payload between conventional memory and extended memory (or between two extended memory blocks), and returns the CPU to real mode.
Interaction with EMM386.EXE
When Upper Memory Blocks (UMBs) or Expanded Memory (EMS) are
required, MS-DOS 6.22 loads EMM386.EXE after
HIMEM.SYS. In this configuration, EMM386.EXE
acts as an XMS client, requesting raw extended memory from
HIMEM.SYS via XMS 3.0 calls and utilizing the processor's
Virtual 8086 mode to map those blocks into unused physical addresses
between 640 KB and 1024 KB.