How MS-DOS 6.22 Manages Software Interrupt Vectors

In MS-DOS 6.22, software interrupt vector management relies directly on the real-mode architecture of the x86 processor and its Interrupt Vector Table (IVT). Located in the lowest 1,024 bytes of physical memory, the IVT maps interrupt signals to specific service routines provided by the ROM BIOS, the DOS kernel, and loaded device drivers. This article details the structure of the IVT, how MS-DOS 6.22 initializes and modifies these lower memory addresses, and the mechanisms used to chain and restore interrupt vectors during program execution.

The Real-Mode Interrupt Vector Table (IVT)

The x86 architecture defines the first 1 KB of conventional memory—spanning absolute physical addresses 00000h to 003FFh—as the Interrupt Vector Table. This memory area is dedicated entirely to 256 4-byte pointers corresponding to interrupt numbers 00h through FFh.

Each vector consists of:

  • Two bytes for the Offset (IP): Stored in little-endian order at the lower memory address.
  • Two bytes for the Segment (CS): Stored in little-endian order directly following the offset.

When a software interrupt instruction (such as INT 21h) executes, the processor automatically calculates the target address by multiplying the interrupt number by four (21h * 4 = 84h). The CPU pushes the Flags register, CS, and IP onto the stack, clears the interrupt flag if required, and loads the segment and offset found at 0000:0084h to execute the routine.

Initialization at Boot

During system startup, interrupt vector allocation occurs in stages:

  1. BIOS Initialization: The system ROM BIOS configures lower interrupts (00h through 1Fh). This covers basic CPU exceptions (such as divide-by-zero on INT 00h), hardware interrupt mappings from the 8259 Programmable Interrupt Controller (PIC) (such as timer ticks on INT 08h and keyboard input on INT 09h), and primitive I/O routines like video (INT 10h) and disk services (INT 13h).
  2. DOS Kernel Loading (IO.SYS and MSDOS.SYS): As MS-DOS 6.22 initializes, it populates its reserved vector range (20h through 3Fh). The kernel hooks critical entry points, most notably INT 21h (the main DOS API), INT 20h (Program Terminate), INT 25h/26h (Absolute Disk Read/Write), and INT 2Fh (Multiplex Interrupt).
  3. Driver and CONFIG.SYS Processing: Device drivers and resident utilities (HIMEM.SYS, EMM386.EXE) alter specific vectors in this table to hook hardware services or redirect calls into upper memory blocks (UMBs) or the High Memory Area (HMA).

Vector Modification: Functions 25h and 35h

While MS-DOS 6.22 operates in real mode—meaning any application has unrestricted write access to address 0000:0000h—the operating system provides standard API calls through INT 21h to read and update vector addresses safely:

  • Get Interrupt Vector (INT 21h, Function 35h): The caller loads AL with the interrupt number and executes AH = 35h. MS-DOS returns the current handler's address as a segment:offset pair in ES:BX.
  • Set Interrupt Vector (INT 21h, Function 25h): The caller loads AL with the interrupt number, sets DS:DX to the entry point of the new routine, and executes AH = 25h.

When Function 25h executes, the DOS kernel disables hardware interrupts using the CLI instruction, writes the 4-byte address directly to (Interrupt Number * 4), and restores interrupt status with STI. This atomic write prevents a hardware interrupt from firing when only half of an address pointer has been written to the IVT.

Interrupt Chaining and TSR Management

Terminate and Stay Resident (TSR) programs hook interrupts to monitor or augment system behavior. Because MS-DOS 6.22 lacks a native multi-layered driver stack, chaining is handled manually by software:

  1. A TSR uses Function 35h to retrieve and store the original vector address in its own memory block.
  2. The TSR uses Function 25h to replace the vector with its own routine.
  3. When the interrupt occurs, the TSR executes its code and either consumes the interrupt or performs a far jump (JMP FAR) to the previously saved address, passing execution down the chain.

Context Preservation and the PSP

To prevent orphaned vectors when user applications crash or exit, MS-DOS 6.22 preserves critical vector states within each program's Program Segment Prefix (PSP):

  • PSP Offset 0Ah: Stores the exit address (INT 22h).
  • PSP Offset 0Eh: Stores the Ctrl+C handler address (INT 23h).
  • PSP Offset 12h: Stores the Critical Error handler address (INT 24h).

When a transient program starts, DOS copies the current vectors for 22h, 23h, and 24h into the new PSP. If the application overrides these vectors during execution, the kernel automatically restores the original pointers from the PSP back into lower memory at 0000:0088h, 0000:008Ch, and 0000:0090h upon termination via INT 20h or INT 21h, Function 4Ch.