DOS API

The DOS API (Application Programming Interface) is a collection of system services originally introduced with 86‑DOS and subsequently employed by MS‑DOS, PC‑DOS, and other DOS‑compatible operating systems. The API is accessed primarily through software interrupt 21h (INT 21h); a program invokes a service by loading a subfunction number into the AH register and supplying additional parameters in other CPU registers. Through this mechanism applications can perform tasks such as keyboard input, video output, file manipulation, program execution, memory management, and device control.

History

  • 86‑DOS and MS‑DOS 1.0 – The initial API was designed for functional compatibility with CP/M and used file control blocks (FCBs) for file access.
  • MS‑DOS 2.0 – Major extensions introduced Unix‑like concepts: file handles, hierarchical directories, and device I/O control.
  • MS‑DOS 3.1 – Added support for network redirectors.
  • MS‑DOS 3.31 – Enhanced INT 25h/26h functions to handle hard disks larger than 32 MiB.
  • MS‑DOS 5 – Introduced upper‑memory blocks (UMBs). Subsequent releases up to MS‑DOS 6.x retained the API unchanged.

Integration with Windows

  • Windows 9x (95/98/ME) – DOS runs as a virtual DOS machine (VDM) or can be booted directly in real mode (MS‑DOS 7.0/7.1). The API was extended with internationalisation, long‑filename (LFN) support, and FAT32 handling.
  • Windows NT family – Uses the NT Virtual DOS Machine (NTVDM) to emulate the DOS API for 16‑bit DOS programs, supporting the DOS 5.0 API.
  • Linux (DOSEMU) – Provides a similar emulation layer for DOS applications.

Interrupt Vectors

The DOS API uses several interrupt vectors, the most important being:

Vector Description Introduced
20h Program termination 1.0+
21h Main DOS API services 1.0+
22h Program termination address 1.0+
23h Control‑C handler address 1.0+
24h Critical‑error handler address 1.0+
25h/26h Absolute disk read/write 1.0+ (enhanced in 3.31)
27h Terminate and stay resident (TSR) 1.0+
2Fh Multiplex services (e.g., PRINT, MSCDEX) 3.0+
Additional vectors for networking, idle callout, etc. Various

INT 21h Services

INT 21h provides a large set of functions, identified by the value placed in AH. Representative groups include:

  • File I/O – Open (0Fh), Create (3Ch), Read (3Fh), Write (40h), Close (3Eh), Delete (41h), Seek (42h), Get/Set attributes (43h).
  • Directory Management – Change directory (3Bh), Create subdirectory (39h), Remove subdirectory (3Ah), Get current directory (47h).
  • Device I/O – Character input/output (01h/02h), Buffered keyboard input (0Ah), Direct console I/O (06h).
  • Memory Management – Allocate (48h), Release (49h), Reallocate (4Ah).
  • Program Control – Execute program (4Bh), Terminate with return code (4Ch), Get DOS version (30h).
  • Extended Services – Long‑filename handling, network functions (5Eh‑5Fh), extended error information (59h), file sharing (5Dh), code‑page management (66h).

Implementations and Variants

The DOS API is implemented in a variety of operating systems and clones, including:

  • MS‑DOS (most widespread) and PC‑DOS (IBM’s OEM version)
  • OS/2 1.x, DR‑DOS, ROM‑DOS, FreeDOS, ReactOS, Embedded DOS, SISNE plus, PTSDOS, among others

These systems maintain compatibility with the original INT 21h service set, often adding proprietary extensions while preserving the core API contract.

Legacy and Influence

The DOS API established a de‑facto standard for low‑level system interaction on early personal computers. Its design—simple register‑based calls via software interrupts—served as a model for later protected‑mode interfaces such as the DOS Protected Mode Interface (DPMI) and influenced the development of early Windows subsystem architectures.

References: Wikipedia article “DOS API”, historical documentation of MS‑DOS releases.

Browse

More topics to explore