DOS API

API of the MS-DOS operating system


title: "DOS API" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["dos-technology", "operating-system-apis", "x86-architecture", "interrupts"] description: "API of the MS-DOS operating system" topic_path: "arts" source: "https://en.wikipedia.org/wiki/DOS_API" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

::summary API of the MS-DOS operating system ::

The DOS API is an API which originated with 86-DOS and is used in MS-DOS/PC DOS and other DOS-compatible operating systems. Most calls to the DOS API are invoked using software interrupt 21h (INT 21h). By calling INT 21h with a subfunction number in the AH processor register and other parameters in other registers, various DOS services can be invoked. These include handling keyboard input, video output, disk file access, program execution, memory allocation, and various other activities. In the late 1980s, DOS extenders along with the DOS Protected Mode Interface (DPMI) allow the programs to run in either 16-bit or 32-bit protected mode and still have access to the DOS API.

History of the DOS API

The original DOS API in 86-DOS and MS-DOS 1.0 was designed to be functionally compatible with CP/M. Files were accessed using file control blocks (FCBs). The DOS API was greatly extended in MS-DOS 2.0 with several Unix concepts, including file access using file handles, hierarchical directories and device I/O control. In DOS 3.1, network redirector support was added. In MS-DOS 3.31, the INT 25h/26h functions were enhanced to support hard disks greater than 32 MB. MS-DOS 5 added support for using upper memory blocks (UMBs). After MS-DOS 5, the DOS API was unchanged for the successive standalone releases of DOS.

The DOS API and Windows

In Windows 9x, DOS loaded the protected-mode system and graphical shell. DOS was usually accessed from a virtual DOS machine (VDM) but it was also possible to boot directly to real mode MS-DOS 7.0 without loading Windows. The DOS API was extended with enhanced internationalization support and long filename support, though the long filename support was only available in a VDM. With Windows 95 OSR2, DOS was updated to 7.1, which added FAT32 support, and functions were added to the DOS API to support this. Windows 98 and Windows Me also implement the MS-DOS 7.1 API, though Windows Me reports itself as MS-DOS 8.0.

Windows NT and the systems based on it (e.g. Windows XP and Windows Vista) are not based on MS-DOS, but use a virtual machine, NTVDM, to handle the DOS API. NTVDM works by running a DOS program in virtual 8086 mode (an emulation of real mode within protected mode available on 80386 and higher processors). NTVDM supports the DOS 5.0 API. DOSEMU for Linux uses a similar approach.

Interrupt vectors used by DOS

The following is the list of interrupt vectors used by programs to invoke the DOS API functions.

::data[format=table]

Interrupt vectorDescriptionVersionNotes
Terminate program1.0+Implemented in DOS kernel
Main DOS API1.0+Implemented in DOS kernel
Program terminate address1.0+Return address in calling program
Control-C handler address1.0+Default handler is in the command shell (usually COMMAND.COM)
Critical error handler address1.0+Default handler is in the command shell (usually COMMAND.COM)
Absolute disk read1.0+Implemented in DOS kernel, enhanced in DOS 3.31 to support up to 2 GB partitions
Absolute disk write1.0+Implemented in DOS kernel, enhanced in DOS 3.31 to support up to 2 GB partitions
Terminate and stay resident1.0+Implemented in COMMAND.COM in DOS 1.0, DOS kernel in DOS 2.0+
Idle callout2.0+Called by DOS kernel when waiting for input
Fast console output2.0+Implemented by the built-in console device driver or a replacement driver like ANSI.SYS
Networking and critical section3.0+Called by DOS kernel to interface with networking software
Unused
Unused
Unused
Reload transient2.0+Implemented in COMMAND.COM
Multiplex3.0+Implemented in DOS kernel and various programs (PRINT, MSCDEX, DOSKEY, APPEND, etc.) depending on subfunction number
::

DOS INT 21h services

The following is the list of functions provided via the DOS API primary software interrupt vector.

::data[format=table]

DescriptionVersion
Program terminate
Character input
Character output
Auxiliary input
Auxiliary output
Printer output
Direct console I/O
Direct console input without echo
Console input without echo
Display string
Buffered keyboard input
Get input status
Flush input buffer and input
Disk reset
Set default drive
Open file
Close file
Find first file
Find next file
Delete file
Sequential read
Sequential write
Create or truncate file
Rename file
Reserved
Get default drive
Set disk transfer address
Get allocation info for default drive
Get allocation info for specified drive
Reserved
Reserved
Get disk parameter block for default drive
Reserved
Random read
Random write
Get file size in records
Set random record number
Set interrupt vector
Create PSP
Random block read
Random block write
Parse filename
Get date
Set date
Get time
Set time
Set verify flag
Get disk transfer address
Get DOS version
Terminate and stay resident
Get disk parameter block for specified drive
Get or set Ctrl-Break
Get InDOS flag pointer
Get interrupt vector
Get free disk space
Get or set switch character
Get or set country info
Create subdirectory
Remove subdirectory
Change current directory
Create or truncate file
Open file
Close file
Read file or device
Write file or device
Delete file
Move file pointer
Get or set file attributes
I/O control for devices
Duplicate handle
Redirect handle
Get current directory
Allocate memory
Release memory
Reallocate memory
Execute program
Terminate with return code
Get program return code
Find first file
Find next file
Set current PSP
Get current PSP
Get DOS internal pointers (SYSVARS)
Create disk parameter block
Get verify flag
Create program PSP
Rename file
Get or set file date and time
Get or set allocation strategy
Get extended error info
Create unique file
Create new file
Lock or unlock file
File sharing functions
Network functions
Network redirection functions
Qualify filename
Reserved
Get current PSP
Get DBCS lead byte table pointer
Set wait for external event flag
Get extended country info
Get or set code page
Set handle count
Commit file
Get or set media id
Commit file
Reserved
Extended open/create file
::

Operating systems with native support

Operating systems with DOS emulation layer

Other emulators

References

References

  1. Ray Duncan. (1988). "Advanced MS-DOS Programming: The Microsoft Guide for Assembly Language and C Programmers". Microsoft Press.

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

dos-technologyoperating-system-apisx86-architectureinterrupts