DOS INT 21h - DOS Function Codes

source

The follow abridged list of DOS interrupts has been extracted from a large list compiled by Ralf Brown. These are available on any Simtel mirror (e.g. sunsite.anu.edu.au) under the directory ms-dos/info/interNNp.zip

AH Description AH Description
01 Read character from STDIN 02 Write character to STDOUT
05 Write character to printer 06 Console Input/Output
07 Direct char read (STDIN), no echo 08 Char read from STDIN, no echo
09 Write string to STDOUT 0A Buffered input
0B Get STDIN status 0C Flush buffer for STDIN
0D Disk reset 0E Select default drive
19 Get current default drive 25 Set interrupt vector
2A Get system date 2B Set system date
2C Get system time 2D Set system time
2E Set verify flag 30 Get DOS version
35 Get Interrupt vector
36 Get free disk space 39 Create subdirectory
3A Remove subdirectory 3B Set working directory
3C Create file 3D Open file
3E Close file 3F Read file
40 Write file 41 Delete file
42 Seek file 43 Get/Set file attributes
47 Get current directory 4C Exit program
4D Get return code 54 Get verify flag
56 Rename file 57 Get/Set file date

[Index]AH = 01h - READ CHARACTER FROM STANDARD INPUT, WITH ECHO

Return: AL = character read

Notes:

SeeAlso: AH=06h,AH=07h,AH=08h,AH=0Ah

[Index]AH = 02h -WRITE CHARACTER TO STANDARD OUTPUT

Entry: DL = character to write

Return: AL = last character output

Notes:

SeeAlso: AH=06h,AH=09h

[Index]AH = 05h - WRITE CHARACTER TO PRINTER

Entry: DL = character to print

Notes:

SeeAlso: INT 17/AH=00h

[Index]AH = 06h - DIRECT CONSOLE OUTPUT

Entry: DL = character (except FFh)

Return: AL = character output

Notes: does not check ^C/^Break

SeeAlso: AH=02h,AH=09h

[Index]AH = 06h - DIRECT CONSOLE INPUT

Entry: AH = 06h DL = FFh

Return:

Notes:

SeeAlso: AH=0Bh

[Index]AH=07h - DIRECT CHARACTER INPUT, WITHOUT ECHO

Return: AL = character read from standard input

Notes: does not check ^C/^Break

SeeAlso: AH=01h,AH=06h,AH=08h,AH=0Ah

[Index]AH = 08h - CHARACTER INPUT WITHOUT ECHO

Return: AL = character read from standard input

Notes: ^C/^Break are checked

SeeAlso: AH=01h,AH=06h,AH=07h,AH=0Ah,AH=64h

[Index]AH = 09h - WRITE STRING TO STANDARD OUTPUT

Entry: DS:DX -> '$'-terminated string

Return: AL = 24h

Notes: ^C/^Break are checked

SeeAlso: AH=02h,AH=06h"OUTPUT"

[Index]AH = 0Ah - BUFFERED INPUT

Entry: DS:DX -> buffer (see below)

Return: buffer filled with user input

Notes:

SeeAlso: AH=0Ch

Format of DOS input buffer:

Offset Size Description
00 1 maximum characters buffer can hold
01 1 number of chars from last input which may be recalled OR number of characters actually read, excluding CR
02 n actual characters read, including the final carriage return

[Index]AH=0Bh - GET STDIN STATUS

Return:

Notes: ^C/^Break are checked

SeeAlso: AH=06h"INPUT"

[Index]AH = 0Ch - FLUSH BUFFER AND READ STANDARD INPUT

Entry:

Return: as appropriate for the specified input function

Note: if AL is not one of 01h,06h,07h,08h, or 0Ah, the buffer is flushed but no input is attempted

SeeAlso: AH=01h,AH=06h"INPUT",AH=07h,AH=08h,AH=0Ah

[Index]AH = 0Dh - DISK RESET

Notes: This function writes all modified disk buffers to disk, but does not update the directory information

SeeAlso: AX=5D01h

[Index]AH = 0Eh - SELECT DEFAULT DRIVE

Entry: DL = new default drive (0=A:, 1=B:, etc)

Return: AL = number of potentially valid drive letters

Notes: the return value is the highest drive present

SeeAlso: AH=19h,AH=3Bh,AH=DBh

[Index]AH = 19h - GET CURRENT DEFAULT DRIVE

Return: AL = drive (0=A:, 1=B:, etc)

SeeAlso: AH=0Eh,AH=47h,AH=BBh

[Index]AH = 25h - SET INTERRUPT VECTOR

Entry:

Notes: this function is preferred over direct modification of the interrupt vector table

SeeAlso: AX=2501h,AH=35h

[Index]AH = 2Ah - GET SYSTEM DATE

Return: CX = year (1980-2099) DH = month DL = day AL = day of week (00h=Sunday)

SeeAlso: AH=2Bh"DOS",AH=2Ch,AH=E7h

[Index]AH = 2Bh - SET SYSTEM DATE

Entry: CX = year (1980-2099) DH = month DL = day

Return:

Note: DOS 3.3+ also sets CMOS clock

SeeAlso: AH=2Ah,AH=2Dh

[Index]AH = 2Ch - GET SYSTEM TIME

Return: CH = hour CL = minute DH = second DL = 1/100 seconds

Note: on most systems, the resolution of the system clock is about 5/100sec, so returned times generally do not increment by 1 on some systems, DL may always return 00h

SeeAlso: AH=2Ah,AH=2Dh,AH=E7h

[Index]AH = 2Dh - SET SYSTEM TIME

Entry: CH = hour CL = minute DH = second DL = 1/100 seconds

Return:

Note: DOS 3.3+ also sets CMOS clock

SeeAlso: AH=2Bh"DOS",AH=2Ch

[Index]AH = 2Eh - SET VERIFY FLAG

Entry: AL = new state of verify flag (00 off, 01h o)

Notes:

SeeAlso: AH=54h

[Index]AH=30h - GET DOS VERSION

Entry: AL = what to return in BH (00h OEM number, 01h version flag)

Return:

Notes:

SeeAlso: AX=3000h/BX=3000h,AX=3306h,AX=4452h

[Index]AH=35h - GET INTERRUPT VECTOR

Entry: AL = interrupt number

Return: ES:BX -> current interrupt handler

SeeAlso: AH=25h,AX=2503h

[Index]AH = 36h - GET FREE DISK SPACE

Entry: DL = drive number (0=default, 1=A:, etc)

Return:

Notes:

SeeAlso: AH=1Bh,AH=1Ch,AX=4402h"CD-ROM"

[Index]AH = 39h - "MKDIR" - CREATE SUBDIRECTORY

Entry: DS:DX -> ASCIZ pathname

Return:

Notes:

SeeAlso: AH=3Ah,AH=3Bh,AH=6Dh

[Index]AH = 3Ah - "RMDIR" - REMOVE SUBDIRECTORY

Entry: DS:DX -> ASCIZ pathname of directory to be removed

Return:

Notes: directory must be empty (contain only '.' and '..' entries)

SeeAlso: AH=39h,AH=3Bh

[Index]AH = 3Bh - "CHDIR" - SET CURRENT DIRECTORY

Entry: DS:DX -> ASCIZ pathname to become current directory (max 64 bytes)

Return:

Notes: if new directory name includes a drive letter, the default drive is not changed, only the current directory on that drive

SeeAlso: AH=47h,AH=71h,INT 2F/AX=1105h

[Index]AH = 3Ch - "CREAT" - CREATE OR TRUNCATE FILE

Entry:

Return:

Notes: if a file with the given name exists, it is truncated to zero length

SeeAlso: AH=16h,AH=3Dh,AH=5Ah,AH=5Bh

[Index]AH = 3Dh - "OPEN" - OPEN EXISTING FILE

Entry:

Return:

Notes:

SeeAlso: AH=0Fh,AH=3Ch,AX=4301h,AX=5D00h

[Index]AH = 3Eh - "CLOSE" - CLOSE FILE

Entry: BX = file handle

Return:

Note: if the file was written to, any pending disk writes are performed, the time and date stamps are set to the current time, and the directory entry is updated

SeeAlso: AH=10h,AH=3Ch,AH=3Dh

[Index]AH = 3Fh - "READ" - READ FROM FILE OR DEVICE

Entry:

Return:

Notes:

SeeAlso: AH=27h,AH=40h,AH=93h

[Index]AH=40h - "WRITE" - WRITE TO FILE OR DEVICE

Entry:

Return:

Notes:

SeeAlso: AH=28h,AH=3Fh

[Index]AH = 41H - "UNLINK" - DELETE FILE

Entry:

Return:

Notes:

SeeAlso: AH=13h,AX=4301h,AX=4380h,AX=5D00h,AH=60h,AH=71h

[Index]AH=42h - "LSEEK" - SET CURRENT FILE POSITION

Entry:

Return:

Notes:

SeeAlso: AH=24h

[Index]AH=43 - GET FILE ATTRIBUTES

Entry:

Return:

BUG: Windows for Workgroups returns error code 05h (access denied) instead of error code 02h (file not found) when attempting to get the attributes of a nonexistent file.

SeeAlso: AX=4301h,AX=4310h,AX=7143h,AH=B6h

[Index]AH=43 - "CHMOD" - SET FILE ATTRIBUTES

Entry:

Return:

Notes:

SeeAlso: AX=4300h,AX=4311h,AX=7143h,INT 2F/AX=110Eh

Bitfields for file attributes:

Bits 7 6 5 4 3 2 1 0
Description shareable - archive directory vol. label system hidden read-only

[Index]AH = 47h - "CWD" - GET CURRENT DIRECTORY

Entry:

Return:

Notes:

SeeAlso: AH=19h,AH=3Bh,AH=71h

[Index]AH = 4Ch - "EXIT" - TERMINATE WITH RETURN CODE

Entry: AL = return code

Return: never returns

Notes: unless the process is its own parent, all open files are closed and all memory belonging to the process is freed

SeeAlso: AH=00h,AH=26h,AH=4Bh,AH=4Dh

[Index]AH = 4Dh - GET RETURN CODE (ERRORLEVEL)

Return:

Notes:

SeeAlso: AH=4Bh,AH=4Ch,AH=8Ah

[Index]AH = 54h - GET VERIFY FLAG

Return: AL = verify flag (00h=off, 01h=on, i.e. all disk writes verified after writing)

SeeAlso: AH=2Eh

[Index]AH = 56h - "RENAME" - RENAME FILE

Entry:

Return:

Notes:

[Index]AH = 57h - GET FILE'S LAST-WRITTEN DATE AND TIME

Entry:

Return:

SeeAlso: AX=5701h

Bitfields for file time:

Bits 15-11 10-5 4-0
Description hours minutes seconds

Bitfields for file date:

Bits 15-9 8-5 4-0
Description year (1980-) month day

[Index]AH = 57h - SET FILE'S LAST-WRITTEN DATE AND TIME

Entry:

Return:

SeeAlso: AX=5700h


This page is maintained by Barry Wilks.