Revision as of 04:59, 23 June 2012 editAnonMoos (talk | contribs)Autopatrolled, Extended confirmed users, Pending changes reviewers71,937 edits Undid revision 498882037 by Asmpgmr (talk)← Previous edit | Revision as of 15:30, 23 June 2012 edit undoAsmpgmr (talk | contribs)920 edits Undid revision 498942465 by AnonMoos (talk)Next edit → | ||
Line 1: | Line 1: | ||
The '''MS-DOS API''' is an ] used originally in ]/], and later by other ]<!--disambiguate--> systems. Most calls to the DOS API invoke ] 21h (] 21h). By calling INT 21h with a subfunction number in the AH ] 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 ]. 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 (]). In MS-DOS version 3.1 (released in 1985), several subfunctions were added for dealing with networks. |
The '''MS-DOS API''' is an ] used originally in ]/], and later by other ]<!--disambiguate--> systems. Most calls to the DOS API invoke ] 21h (] 21h). By calling INT 21h with a subfunction number in the AH ] 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 ]. 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 (]). In MS-DOS version 3.1 (released in 1985), several subfunctions were added for dealing with networks. | ||
There are various implementations of the DOS API, including ], ], ], ], ], and others. | There are various implementations of the DOS API, including ], ], ], ], ], and others. |
Revision as of 15:30, 23 June 2012
The MS-DOS API is an API used originally in MS-DOS/PC-DOS, and later by other DOS systems. Most calls to the DOS API invoke software interrupt 21h (INT 21h). By calling INT 21h with a subfunction number in the AH processor register 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. 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.
There are various implementations of the DOS API, including PC-DOS, MS-DOS, DR-DOS, FreeDOS, PTS-DOS, and others.
DOS extenders along with the DOS Protected Mode Interface (DPMI) extend the DOS API to either 16-bit or 32-bit protected mode.
The MS-DOS API and Windows
Microsoft Windows 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 for Windows programs). Windows 9x 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 "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 (LFNs).
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). DOSEMU for Linux uses a similar approach.
Interrupt vectors used by DOS
Interrupt vector | Description | Version | Notes |
---|---|---|---|
20h
|
Terminate program | 1.0+ | Implemented in DOS kernel |
21h
|
Main DOS API | 1.0+ | Implemented in DOS kernel |
22h
|
Program terminate address | 1.0+ | Return address in calling program |
23h
|
Control-C handler address | 1.0+ | Default handler is in the command shell (usually COMMAND.COM) |
24h
|
Critical error handler address | 1.0+ | Default handler is in the command shell (usually COMMAND.COM) |
25h
|
Absolute disk read | 1.0+ | Implemented in DOS kernel |
26h
|
Absolute disk write | 1.0+ | Implemented in DOS kernel |
27h
|
Terminate and stay resident | 1.0+ | Implemented in COMMAND.COM in DOS 1.0, DOS kernel in DOS 2.0+ |
28h
|
Idle callout | 2.0+ | Called by DOS kernel when waiting for input |
29h
|
Fast console output | 2.0+ | Implemented by the builtin console device driver or a replacement driver like ANSI.SYS |
2Ah
|
Networking and critical section | 3.0+ | Called by DOS kernel to interface with networking software |
2Bh
|
Unused | ||
2Ch
|
Unused | ||
2Dh
|
Unused | ||
2Eh
|
Reload transient | 2.0+ | Implemented in COMMAND.COM |
2Fh
|
Multiplex | 3.0+ | Implemented in DOS kernel and various programs (PRINT, MSCDEX, DOSKEY, APPEND, etc.) depending on subfunction number |
DOS INT 21h services
AH
|
Description | Version |
---|---|---|
00h
|
Program terminate | 1.0+ |
01h
|
Character input | 1.0+ |
02h
|
Character output | 1.0+ |
03h
|
Auxiliary input | 1.0+ |
04h
|
Auxiliary output | 1.0+ |
05h
|
Printer output | 1.0+ |
06h
|
Direct console I/O | 1.0+ |
07h
|
Direct console input without echo | 1.0+ |
08h
|
Console input without echo | 1.0+ |
09h
|
Display string | 1.0+ |
0Ah
|
Buffered keyboard input | 1.0+ |
0Bh
|
Get input status | 1.0+ |
0Ch
|
Flush input buffer and input | 1.0+ |
0Dh
|
Disk reset | 1.0+ |
0Eh
|
Set default drive | 1.0+ |
0Fh
|
Open file | 1.0+ |
10h
|
Close file | 1.0+ |
11h
|
Find first file | 1.0+ |
12h
|
Find next file | 1.0+ |
13h
|
Delete file | 1.0+ |
14h
|
Sequential read | 1.0+ |
15h
|
Sequential write | 1.0+ |
16h
|
Create or truncate file | 1.0+ |
17h
|
Rename file | 1.0+ |
18h
|
Reserved | 1.0+ |
19h
|
Get default drive | 1.0+ |
1Ah
|
Set disk transfer address | 1.0+ |
1Bh
|
Get allocation info for default drive | 1.0+ |
1Ch
|
Get allocation info for specified drive | 1.0+ |
1Dh
|
Reserved | 1.0+ |
1Eh
|
Reserved | 1.0+ |
1Fh
|
Get disk parameter block for default drive | 1.0+ |
20h
|
Reserved | 1.0+ |
21h
|
Random read | 1.0+ |
22h
|
Random write | 1.0+ |
23h
|
Get file size in records | 1.0+ |
24h
|
Set random record number | 1.0+ |
25h
|
Set interrupt vector | 1.0+ |
26h
|
Create PSP | 1.0+ |
27h
|
Random block read | 1.0+ |
28h
|
Random block write | 1.0+ |
29h
|
Parse filename | 1.0+ |
2Ah
|
Get date | 1.0+ |
2Bh
|
Set date | 1.0+ |
2Ch
|
Get time | 1.0+ |
2Dh
|
Set time | 1.0+ |
2Eh
|
Set verify flag | 1.0+ |
2Fh
|
Get disk transfer address | 2.0+ |
30h
|
Get DOS version | 2.0+ |
31h
|
Terminate and stay resident | 2.0+ |
32h
|
Get disk parameter block for specified drive | 2.0+ |
33h
|
Get or set Ctrl-Break | 2.0+ |
34h
|
Get InDOS flag pointer | 2.0+ |
35h
|
Get interrupt vector | 2.0+ |
36h
|
Get free disk space | 2.0+ |
37h
|
Get or set switch character | 2.0+ |
38h
|
Get or set country info | 2.0+ |
39h
|
Create subdirectory | 2.0+ |
3Ah
|
Remove subdirectory | 2.0+ |
3Bh
|
Change current directory | 2.0+ |
3Ch
|
Create or truncate file | 2.0+ |
3Dh
|
Open file | 2.0+ |
3Eh
|
Close file | 2.0+ |
3Fh
|
Read file or device | 2.0+ |
40h
|
Write file or device | 2.0+ |
41h
|
Delete file | 2.0+ |
42h
|
Move file pointer | 2.0+ |
43h
|
Get or set file attributes | 2.0+ |
44h
|
I/O control for devices | 2.0+ |
45h
|
Duplicate handle | 2.0+ |
46h
|
Redirect handle | 2.0+ |
47h
|
Get current directory | 2.0+ |
48h
|
Allocate memory | 2.0+ |
49h
|
Release memory | 2.0+ |
4Ah
|
Reallocate memory | 2.0+ |
4Bh
|
Execute program | 2.0+ |
4Ch
|
Terminate with return code | 2.0+ |
4Dh
|
Get program return code | 2.0+ |
4Eh
|
Find first file | 2.0+ |
4Fh
|
Find next file | 2.0+ |
50h
|
Set current PSP | 2.0+ |
51h
|
Get current PSP | 2.0+ |
52h
|
Get DOS internal pointers (SYSVARS) | 2.0+ |
53h
|
Create disk parameter block | 2.0+ |
54h
|
Get verify flag | 2.0+ |
55h
|
Create program PSP | 2.0+ |
56h
|
Rename file | 2.0+ |
57h
|
Get or set file date and time | 2.0+ |
58h
|
Get or set allocation strategy | 2.11+ |
59h
|
Get extended error info | 3.0+ |
5Ah
|
Create unique file | 3.0+ |
5Bh
|
Create new file | 3.0+ |
5Ch
|
Lock or unlock file | 3.0+ |
5Dh
|
File sharing functions | 3.0+ |
5Eh
|
Network functions | 3.0+ |
5Fh
|
Network redirection functions | 3.0+ |
60h
|
Qualify filename | 3.0+ |
61h
|
Reserved | 3.0+ |
62h
|
Get current PSP | 3.0+ |
63h
|
Get DBCS lead byte table pointer | 3.0+ |
64h
|
Set wait for external event flag | 3.2+ |
65h
|
Get extended country info | 3.3+ |
66h
|
Get or set code page | 3.3+ |
67h
|
Set handle count | 3.3+ |
68h
|
Commit file | 3.3+ |
69h
|
Get or set media id | 4.0+ |
6Ah
|
Commit file | 4.0+ |
6Bh
|
Reserved | 4.0+ |
6Ch
|
Extended open/create file | 4.0+ |
Operating systems with support for the MS-DOS API
- MS-DOS - Most widespread incarnation
- PC-DOS - IBM version
- DR-DOS - Digital Research clone
- ROM-DOS - Read only memory version
- FreeDOS - Free, open source
- Microsoft Windows - 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
- DOSEMU for Linux
- DOSBox
See also
- BIOS interrupt call
- Ralf Brown's Interrupt List
- Comparison of DOS operating systems
- DOS/4GW
- DOS MZ executable
References
- Microsoft MS-DOS Programmer's Reference - The Official Technical Reference to MS-DOS, Microsoft Press, 1993 ISBN 1556155468
- The MS-DOS Encyclopedia, Microsoft Press, 1988, ISBN 1556151748
- The Programmer's PC Sourcebook by Thom Hogan, Microsoft Press, 1991 ISBN 155615321X
- IBM PC DOS 7 Technical Update
- The x86 Interrupt List (a.k.a. RBIL, Ralf Brown's Interrupt List)
- ctyme.com - INT Calls by function