MS-DOS API
Encyclopedia
The MS-DOS API is an API
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

 used originally in MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

/PC-DOS
PC-DOS
IBM PC DOS is a DOS system for the IBM Personal Computer and compatibles, manufactured and sold by IBM from the 1980s to the 2000s....

, and later by other DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

 systems. Most calls to the DOS API invoke software interrupt 21h (INT
INT (x86 instruction)
INT is an assembly language instruction for x86 processors that generates a software interrupt. It takes the interrupt number formatted as a byte value.When written in assembly language, the instruction is written like this:...

 21h). By calling INT 21h with a subfunction number in the AH processor register
Processor register
In computer architecture, a processor register is a small amount of storage available as part of a CPU or other digital processor. Such registers are addressed by mechanisms other than main memory and can be accessed more quickly...

 and other parameters in other registers, one invokes various DOS services. DOS services include keyboard input, video output, disk file access, executing programs, memory allocation, and various other things. The subfunctions provided in the first release of MS-DOS in 1981 were strongly oriented to compatibility with CP/M
CP/M
CP/M was a mass-market operating system created for Intel 8080/85 based microcomputers by Gary Kildall of Digital Research, Inc...

. A major revamp of the DOS API (partially influenced by certain Unix concepts) was undertaken for the release of MS-DOS 2.0 in 1983, adding numerous new subfunctions to deal with file I/O using abstract "handles" and support for subdirectories. In these new subfunctions, strings are usually terminated by a NUL byte (ASCIIZ). In MS-DOS version 3.1 (released in 1985), several subfunctions were added for dealing with networks. In MS-DOS version 4, calls were introduced to manage expanded memory
Expanded memory
In DOS memory management, expanded memory is a system of bank switching introduced April 24, 1985 that provided additional memory to DOS programs beyond the limit of conventional memory. Expanded memory uses parts of the address space normally dedicated to communication with peripherals for program...

 according to the Lotus-Intel-Microsoft specification.

There are various implementations of the DOS API, including PC-DOS
PC-DOS
IBM PC DOS is a DOS system for the IBM Personal Computer and compatibles, manufactured and sold by IBM from the 1980s to the 2000s....

, MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

, DR-DOS
DR-DOS
DR-DOS is an MS-DOS-compatible operating system for IBM PC-compatible personal computers, originally developed by Gary Kildall's Digital Research and derived from Concurrent PC DOS 6.0, which was an advanced successor of CP/M-86...

, FreeDOS
FreeDOS
FreeDOS is an operating system for IBM PC compatible computers. FreeDOS is made up of many different, separate programs that act as "packages" to the overall FreeDOS Project...

, PTS-DOS
PTS-DOS
PTS-DOS is a disk operating system, a DOS clone, developed in Russia by PhysTechSoft.- History and versions :PhysTechSoft was formed in 1991 in Moscow, Russia by graduates and members of MIPT, informally known as PhysTech. At the end of 1993, PhysTechSoft released the first commercially available...

, and others. The DOS API is based on the BIOS
BIOS
In IBM PC compatible computers, the basic input/output system , also known as the System BIOS or ROM BIOS , is a de facto standard defining a firmware interface....

, and DOS routines often internally access BIOS interrupt call
BIOS interrupt call
BIOS interrupt calls are a facility that DOS programs and some other software, such as boot loaders, use to invoke the facilities of the Basic Input/Output System...

s.

DOS extender
DOS extender
A DOS extender is a computer software program which enables software to run under a protected mode environment even though the host operating system is only capable of operating in real mode....

s along with the DOS Protected Mode Interface
DOS Protected Mode Interface
In computing, the DOS Protected Mode Interface is a specification introduced in 1989 which allows a DOS program to run in protected mode, giving access to many features of the processor not available in real mode...

 (DPMI) extend the DOS API to either 16-bit or 32-bit protected mode. The MS-DOS API is partially dependent on x86 code, hence DOS cannot be ported to other processor architectures.

The MS-DOS API and Windows

Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 versions 1.0 through 3.1 were graphical shells that ran on MS-DOS and relied on the MS-DOS API (though using its own API
Windows API
The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces available in the Microsoft Windows operating systems. It was formerly called the Win32 API; however, the name "Windows API" more accurately reflects its roots in 16-bit Windows and its support on...

 for Windows programs). Windows 9x
Windows 9x
Windows 9x is a generic term referring to a series of Microsoft Windows computer operating systems produced since 1995, which were based on the original and later modified Windows 95 kernel...

 was also DOS-based, but used a custom version of MS-DOS, mainly as a bootloader. It did not use the MS-DOS API much after booting. However, Windows 9x provided the DOS API to programs running within a command shell window. Earlier Windows 9x versions (at least through the first edition of Windows 98) also can be booted into plain CLI
CLI
-Computing:* Command-line interface, sending commands to a computer by text typed into a command-line interpreter .* Call Level Interface, an SQL database management API...

 "DOS mode" with no GUI and no Windows system services, for running pure DOS programs. The Windows 9x DOS versions (numbered 7.0 and above) include several new service subfunctions for dealing with long filenames (LFN
Long filename
Long filenames , are Microsoft's way of implementing filenames longer than the 8.3 filename, or short-filename, naming scheme used in Microsoft DOS in their modern FAT and NTFS filesystems. Because these filenames can be longer than an 8.3 filename, they can be more descriptive...

s).

Windows NT
Windows NT
Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...

 and the systems based on it (e.g. Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...

 and Windows Vista
Windows Vista
Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...

) are not based on MS-DOS, but use a virtual machine
Virtual machine
A virtual machine is a "completely isolated guest operating system installation within a normal host operating system". Modern virtual machines are implemented with either software emulation or hardware virtualization or both together.-VM Definitions:A virtual machine is a software...

, NTVDM, to handle the DOS API. NTVDM works by running a DOS program in virtual 8086 mode
Virtual 8086 mode
In the 80386 microprocessor and later, virtual 8086 mode allows the execution of real mode applications that are incapable of running directly in protected mode while the processor is running a protected mode operating system.VM86 mode uses a segmentation scheme identical to that of real mode In...

 (an emulation of real mode
Real mode
Real mode, also called real address mode, is an operating mode of 80286 and later x86-compatible CPUs. Real mode is characterized by a 20 bit segmented memory address space and unlimited direct software access to all memory, I/O addresses and peripheral hardware...

 within protected mode
Protected mode
In computing, protected mode, also called protected virtual address mode, is an operational mode of x86-compatible central processing units...

 available on 80386 and higher processors). DOSEMU
DOSEMU
DOSEMU, alternatively rendered dosemu, is a compatibility layer software package that enables MS-DOS systems, DOS clones such as FreeDOS, and DOS software to run under Linux on x86-based PCs ....

 for Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 uses a similar approach.

Common DOS services

Some basic INT 21h function calls present since DOS version 2.0:
Subfunction
(hex)
Service Parameters Returns
AH = 00 DOS 1+
Never
AH = 01 DOS 1+
AL=character read
AH = 02 DOS 1+
DL=character
AH = 09 DOS 1+
DS:DX=pointer to '$' terminated string
AH = 3C DOS 2+
Create or truncate file
CX=file attributes ; CF
Carry flag
In computer processors the carry flag is a single bit in a system status register used to indicate when an arithmetic carry or borrow has been generated out of the most significant ALU bit position...

=1 on error ; AX=error code ;
AH = 3D DOS 2+
Open existing file
AL=access and sharing modes ; DS:DX->ASCIIZ ; CF=1 on error ; AX=error code ; AX=file handle
AH = 3F DOS 2+
Read from file or device
BX=file handle
File descriptor
In computer programming, a file descriptor is an abstract indicator for accessing a file. The term is generally used in POSIX operating systems...

 ; ; DS:DX->data
CF=1 on error ; AX=error code or bytes read
AH = 40 DOS 2+
Write to file or device
BX=file handle ; CX=bytes to write ; DS:DX->data CF=1 on error ; AX=error code or bytes written
AH = 3E DOS 2+
Close file
BX=file handle CF=1 on error ; AX=error code
AH = 42 DOS 2+
Set file position
AL=origin of move, 0-start, 1-current, 2-end ; BX=file handle ; CX:DX=(signed) offset CF=1 on error ; AX=error code ; DX:AX=position from beginning

Operating systems with support for the MS-DOS API

  • MS-DOS
    MS-DOS
    MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

     - Most widespread incarnation
  • PC-DOS - IBM version
  • DR-DOS
    DR-DOS
    DR-DOS is an MS-DOS-compatible operating system for IBM PC-compatible personal computers, originally developed by Gary Kildall's Digital Research and derived from Concurrent PC DOS 6.0, which was an advanced successor of CP/M-86...

     - Digital Research clone
  • ROM-DOS - Read only memory version
  • FreeDOS
    FreeDOS
    FreeDOS is an operating system for IBM PC compatible computers. FreeDOS is made up of many different, separate programs that act as "packages" to the overall FreeDOS Project...

     - Free, open source
  • Microsoft Windows
    Microsoft Windows
    Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

     - 1.x, 2.x, 3.x, and 9x were based on DOS

Programs with support for the MS-DOS API

  • NTVDM.EXE for Windows NT
    Windows NT
    Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...

  • DOSEMU
    DOSEMU
    DOSEMU, alternatively rendered dosemu, is a compatibility layer software package that enables MS-DOS systems, DOS clones such as FreeDOS, and DOS software to run under Linux on x86-based PCs ....

     for Linux
    Linux
    Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

  • DOSBox
    DOSBox
    DOSBox is emulator software that emulates an IBM PC compatible computer running MS-DOS. It is intended especially for use with old PC games. DOSBox is free software....


See also

  • BIOS interrupt call
    BIOS interrupt call
    BIOS interrupt calls are a facility that DOS programs and some other software, such as boot loaders, use to invoke the facilities of the Basic Input/Output System...

  • Ralf Brown's Interrupt List
    Ralf Brown's Interrupt List
    Ralf Brown's Interrupt List or RBIL is a comprehensive list of interrupts, calls, hooks, interfaces, data structures, memory and port addresses, and processor opcodes for x86 for machines from the very start of the PC era in 1981 up into the year 2000, most of it still applying to PCs today as well...

  • Comparison of x86 DOS operating systems
    Comparison of x86 DOS operating systems
    - Historical and licensing information :Originally MS-DOS was designed to be an operating system that could run on any computer with a 8086-family microprocessor. It competed with other Operating Systems written for such computers, such as CP/M-86 and UCSD Pascal. Each computer would have its own...

  • DOS/4GW
    DOS/4GW
    DOS/4G is a 32-bit DOS extender developed by Rational Systems . It allows DOS programs to eliminate the 640 KB conventional memory limit by addressing up to 64 MB of extended memory on Intel 80386 and above machines....

  • DOS MZ executable
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK