DOS API

From English Wikipedia @ Freddythechick

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.[1] 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.

Interrupt vector Description Version Notes
<syntaxhighlight lang="text" class="" style="" inline="1">20h</syntaxhighlight> Terminate program 1.0+ Implemented in DOS kernel
<syntaxhighlight lang="text" class="" style="" inline="1">21h</syntaxhighlight> Main DOS API 1.0+ Implemented in DOS kernel
<syntaxhighlight lang="text" class="" style="" inline="1">22h</syntaxhighlight> Program terminate address 1.0+ Return address in calling program
<syntaxhighlight lang="text" class="" style="" inline="1">23h</syntaxhighlight> Control-C handler address 1.0+ Default handler is in the command shell (usually COMMAND.COM)
<syntaxhighlight lang="text" class="" style="" inline="1">24h</syntaxhighlight> Critical error handler address 1.0+ Default handler is in the command shell (usually COMMAND.COM)
<syntaxhighlight lang="text" class="" style="" inline="1">25h</syntaxhighlight> Absolute disk read 1.0+ Implemented in DOS kernel, enhanced in DOS 3.31 to support up to 2 GB partitions
<syntaxhighlight lang="text" class="" style="" inline="1">26h</syntaxhighlight> Absolute disk write 1.0+ Implemented in DOS kernel, enhanced in DOS 3.31 to support up to 2 GB partitions
<syntaxhighlight lang="text" class="" style="" inline="1">27h</syntaxhighlight> Terminate and stay resident 1.0+ Implemented in COMMAND.COM in DOS 1.0, DOS kernel in DOS 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">28h</syntaxhighlight> Idle callout 2.0+ Called by DOS kernel when waiting for input
<syntaxhighlight lang="text" class="" style="" inline="1">29h</syntaxhighlight> Fast console output 2.0+ Implemented by the built-in console device driver or a replacement driver like ANSI.SYS
<syntaxhighlight lang="text" class="" style="" inline="1">2Ah</syntaxhighlight> Networking and critical section 3.0+ Called by DOS kernel to interface with networking software
<syntaxhighlight lang="text" class="" style="" inline="1">2Bh</syntaxhighlight> Unused
<syntaxhighlight lang="text" class="" style="" inline="1">2Ch</syntaxhighlight> Unused
<syntaxhighlight lang="text" class="" style="" inline="1">2Dh</syntaxhighlight> Unused
<syntaxhighlight lang="text" class="" style="" inline="1">2Eh</syntaxhighlight> Reload transient 2.0+ Implemented in COMMAND.COM
<syntaxhighlight lang="text" class="" style="" inline="1">2Fh</syntaxhighlight> Multiplex 3.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.

<syntaxhighlight lang="text" class="" style="" inline="1">AH</syntaxhighlight> Description Version
<syntaxhighlight lang="text" class="" style="" inline="1">00h</syntaxhighlight> Program terminate 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">01h</syntaxhighlight> Character input 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">02h</syntaxhighlight> Character output 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">03h</syntaxhighlight> Auxiliary input 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">04h</syntaxhighlight> Auxiliary output 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">05h</syntaxhighlight> Printer output 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">06h</syntaxhighlight> Direct console I/O 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">07h</syntaxhighlight> Direct console input without echo 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">08h</syntaxhighlight> Console input without echo 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">09h</syntaxhighlight> Display string 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">0Ah</syntaxhighlight> Buffered keyboard input 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">0Bh</syntaxhighlight> Get input status 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">0Ch</syntaxhighlight> Flush input buffer and input 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">0Dh</syntaxhighlight> Disk reset 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">0Eh</syntaxhighlight> Set default drive 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">0Fh</syntaxhighlight> Open file 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">10h</syntaxhighlight> Close file 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">11h</syntaxhighlight> Find first file 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">12h</syntaxhighlight> Find next file 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">13h</syntaxhighlight> Delete file 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">14h</syntaxhighlight> Sequential read 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">15h</syntaxhighlight> Sequential write 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">16h</syntaxhighlight> Create or truncate file 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">17h</syntaxhighlight> Rename file 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">18h</syntaxhighlight> Reserved 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">19h</syntaxhighlight> Get default drive 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">1Ah</syntaxhighlight> Set disk transfer address 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">1Bh</syntaxhighlight> Get allocation info for default drive 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">1Ch</syntaxhighlight> Get allocation info for specified drive 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">1Dh</syntaxhighlight> Reserved 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">1Eh</syntaxhighlight> Reserved 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">1Fh</syntaxhighlight> Get disk parameter block for default drive 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">20h</syntaxhighlight> Reserved 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">21h</syntaxhighlight> Random read 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">22h</syntaxhighlight> Random write 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">23h</syntaxhighlight> Get file size in records 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">24h</syntaxhighlight> Set random record number 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">25h</syntaxhighlight> Set interrupt vector 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">26h</syntaxhighlight> Create PSP 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">27h</syntaxhighlight> Random block read 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">28h</syntaxhighlight> Random block write 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">29h</syntaxhighlight> Parse filename 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">2Ah</syntaxhighlight> Get date 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">2Bh</syntaxhighlight> Set date 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">2Ch</syntaxhighlight> Get time 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">2Dh</syntaxhighlight> Set time 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">2Eh</syntaxhighlight> Set verify flag 1.0+
<syntaxhighlight lang="text" class="" style="" inline="1">2Fh</syntaxhighlight> Get disk transfer address 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">30h</syntaxhighlight> Get DOS version 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">31h</syntaxhighlight> Terminate and stay resident 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">32h</syntaxhighlight> Get disk parameter block for specified drive 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">33h</syntaxhighlight> Get or set Ctrl-Break 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">34h</syntaxhighlight> Get InDOS flag pointer 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">35h</syntaxhighlight> Get interrupt vector 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">36h</syntaxhighlight> Get free disk space 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">37h</syntaxhighlight> Get or set switch character 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">38h</syntaxhighlight> Get or set country info 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">39h</syntaxhighlight> Create subdirectory 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">3Ah</syntaxhighlight> Remove subdirectory 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">3Bh</syntaxhighlight> Change current directory 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">3Ch</syntaxhighlight> Create or truncate file 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">3Dh</syntaxhighlight> Open file 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">3Eh</syntaxhighlight> Close file 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">3Fh</syntaxhighlight> Read file or device 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">40h</syntaxhighlight> Write file or device 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">41h</syntaxhighlight> Delete file 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">42h</syntaxhighlight> Move file pointer 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">43h</syntaxhighlight> Get or set file attributes 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">44h</syntaxhighlight> I/O control for devices 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">45h</syntaxhighlight> Duplicate handle 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">46h</syntaxhighlight> Redirect handle 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">47h</syntaxhighlight> Get current directory 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">48h</syntaxhighlight> Allocate memory 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">49h</syntaxhighlight> Release memory 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">4Ah</syntaxhighlight> Reallocate memory 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">4Bh</syntaxhighlight> Execute program 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">4Ch</syntaxhighlight> Terminate with return code 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">4Dh</syntaxhighlight> Get program return code 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">4Eh</syntaxhighlight> Find first file 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">4Fh</syntaxhighlight> Find next file 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">50h</syntaxhighlight> Set current PSP 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">51h</syntaxhighlight> Get current PSP 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">52h</syntaxhighlight> Get DOS internal pointers (SYSVARS) 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">53h</syntaxhighlight> Create disk parameter block 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">54h</syntaxhighlight> Get verify flag 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">55h</syntaxhighlight> Create program PSP 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">56h</syntaxhighlight> Rename file 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">57h</syntaxhighlight> Get or set file date and time 2.0+
<syntaxhighlight lang="text" class="" style="" inline="1">58h</syntaxhighlight> Get or set allocation strategy 2.11+
<syntaxhighlight lang="text" class="" style="" inline="1">59h</syntaxhighlight> Get extended error info 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">5Ah</syntaxhighlight> Create unique file 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">5Bh</syntaxhighlight> Create new file 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">5Ch</syntaxhighlight> Lock or unlock file 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">5Dh</syntaxhighlight> File sharing functions 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">5Eh</syntaxhighlight> Network functions 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">5Fh</syntaxhighlight> Network redirection functions 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">60h</syntaxhighlight> Qualify filename 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">61h</syntaxhighlight> Reserved 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">62h</syntaxhighlight> Get current PSP 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">63h</syntaxhighlight> Get DBCS lead byte table pointer 3.0+
<syntaxhighlight lang="text" class="" style="" inline="1">64h</syntaxhighlight> Set wait for external event flag 3.2+
<syntaxhighlight lang="text" class="" style="" inline="1">65h</syntaxhighlight> Get extended country info 3.3+
<syntaxhighlight lang="text" class="" style="" inline="1">66h</syntaxhighlight> Get or set code page 3.3+
<syntaxhighlight lang="text" class="" style="" inline="1">67h</syntaxhighlight> Set handle count 3.3+
<syntaxhighlight lang="text" class="" style="" inline="1">68h</syntaxhighlight> Commit file 3.3+
<syntaxhighlight lang="text" class="" style="" inline="1">69h</syntaxhighlight> Get or set media id 4.0+
<syntaxhighlight lang="text" class="" style="" inline="1">6Ah</syntaxhighlight> Commit file 4.0+
<syntaxhighlight lang="text" class="" style="" inline="1">6Bh</syntaxhighlight> Reserved 4.0+
<syntaxhighlight lang="text" class="" style="" inline="1">6Ch</syntaxhighlight> Extended open/create file 4.0+

Operating systems with native support

Operating systems with DOS emulation layer

Other emulators

See also

References

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

Further reading

External links