int 21h
instruction. To select an appropriate DOS function, you load the ah
register with a function number before issuing the int 21h
instruction. Most DOS calls require other parameters as well. Generally, these other parameters are passed in the CPU's register set. The specific parameters will be discussed along with each call. Unless MS-DOS returns some specific value in a register, all of the CPU's registers are preserved across a call to DOS[4].
int 23h
instruction. Usually, this instruction will cause the program to abort and control will be returned to DOS. Keep this in mind when issuing these calls.Function # (AH) | Input Parameters | Output Parameters | Description |
---|---|---|---|
1 | - | al - char read
|
Console Input w/Echo: Reads a single character from the keyboard and displays typed character on screen. |
2 | dl - output char
|
- | Console Output: Writes a single character to the display. |
3 | - | al - char read
|
Auxiliary Input: Reads a single character from the serial port. |
4 | dl - output char
|
- | Auxiliary Output: Writes a single character to the output port |
5 | dl - output char
|
- | Printer Output: Writes a single character to the printer |
6 | dl - output char (if not 0FFh)
|
al - char read (if input dl = 0FFh)
|
Direct Console I/O: On input, if dl contains 0FFh, this function attempts to read a character from the keyboard. If a character is available, it returns the zero flag clear and the character in al . If no character is available, it returns the zero flag set. On input, if dl contains a value other than 0FFh, this routine sends the character to the display. This routine does not do ctrl-C checking.
|
7 | - | al - char read
|
Direct Console Input: Reads a character from the keyboard. Does not echo the character to the display. This call does not check for ctrl-C |
8 | - | al - char read
|
Read Keyboard w/o Echo: Just like function 7 above, except this call checks for ctrl-C. |
9 | ds:dx - pointer to string terminated with "$".
|
- | Display String: This function displays the characters from location ds:dx up to (but not including) a terminating "$" character.
|
0Ah | ds:dx - pointer to input buffer.
|
- | Buffered Keyboard Input: This function reads a line of text from the keyboard and stores it into the input buffer pointed at by ds:dx . The first byte of the buffer must contain a count between one and 255 that contains the maximum number of allowable characters in the input buffer. This routine stores the actual number of characters read in the second byte. The actual input characters begin at the third byte of the buffer.
|
0Bh | - | al - status (0=not ready, 0FFh=ready)
|
Check Keyboard Status: Determines whether a character is available from the keyboard. |
0Ch | al - DOS opcode 0, 1, 6, 7, or 8
|
al - input character if opcode 1, 6, 7, or 8.
|
Flush Buffer: This call empties the system type ahead buffer and then executes the DOS command specified in the al register (if al =0, no further action). |
Functions 1, 2, 3, 4, 5, 9, and 0Ah are obsolete and you should not use them. Use the DOS file I/O calls instead (opcodes 3Fh and 40h).
Function # (AH) |
Input Parameters |
Output Parameters |
Description |
---|---|---|---|
0Dh | - | - | Reset Drive: Flushes all file buffers to disk. Generally called by ctrl-C handlers or sections of code that need to guaranteed file consistency because an error may occur. |
0Eh | dl - drive number |
al - number of logical drives |
Set Default Drive: sets the DOS default drive to the specified value (0=A, 1=B, 2=C, etc.). Returns the number of logical drives in the system, although they may not be contiguous from 0-al . |
19H | - | al - default drive number |
Get Default Drive: Returns the current system default drive number (0=A, 1=B, 2=C, etc.). |
1Ah | ds:dx - Disk Transfer Area address. |
- | Set Disk Transfer Area Address: Sets the address that MS-DOS uses for obsolete file I/O and Find First/Find Next commands. |
1Bh- | al - sectors/clustercx - bytes/sectordx - # of clustersds:bx - points at media descriptor byte |
Get Default Drive Data: Returns information about the disk in the default drive. Also see function 36h. Typical values for the media descriptor byte include: 0F0h- 3.5" 0F8h- Hard disk 0F9h- 720K 3.5" or 1.2M 5.25" 0FAh- 320K 5.25" 0FBh- 640K 3.5" 0FCh- 180K 5.25" 0FDh- 360K 5.25: 0FEh- 160K 5.25" 0FFh- 320K 5.25" |
|
1Ch | dl - drive number |
See above | Get Drive Data: same as above except you can specify the drive number in the dl register (0=default, 1=A, 2=B, 3=C, etc.). |
1Fh | - | al - contains 0FFh if error, 0 if no error.ds:bx - ptr to DPB |
Get Default Disk Parameter Block (DPB): If successful, this function returns a pointer to the following structure: Drive (byte) - Drive number (0-A, 1=B, etc.). Unit (byte) - Unit number for driver. SectorSize (word) - # bytes/sector. ClusterMask (byte) - sectors/cluster minus one. Cluster2 (byte) - 2clusters/sector FirstFAT (word) - Address of sector where FAT starts. FATCount (byte) - # of FATs. RootEntries (word) - # of entries in root directory. FirstSector (word) - first sector of first cluster. MaxCluster (word) - # of clusters on drive, plus one. FATsize (word) - # of sectors for FAT. DirSector (word) - first sector containing directory. DriverAdrs (dword) - address of device driver. Media (byte) - media descriptor byte. FirstAccess (byte) - set if there has been an access to drive. NextDPB (dword) - link to next DPB in list. NextFree (word) - last allocated cluster. FreeCnt (word) - number of free clusters. |
2Eh | al - verify flag (0=no verify, 1=verify on). |
- | Set/Reset Verify Flag: Turns on and off write verification. Usually off since this is a slow operation, but you can turn it on when performing critical I/O. |
2Fh | - | es:bx - pointer to DTA |
Get Disk Transfer Area Address: Returns a pointer to the current DTA in es:bx .. |
32h | dl - drive number. |
Same as 1Fh | Get DPB: Same as function 1Fh except you get to specify the driver number (0=default, 1=A, 2=B, 3=C, etc.). |
33h | al - 05 (subfunction code) |
dl - startup drive #. |
Get Startup Drive: Returns the number of the drive used to boot DOS (1=A, 2=B, 3=C, etc.). |
36h | dl - drive number. |
ax - sectors/clusterbx - available clusterscx - bytes/sectordx - total clusters |
Get Disk Free Space: Reports the amount of free space. This call supersedes calls 1Bh and 1Ch that only support drives up to 32Mbytes. This call handles larger drives. You can compute the amount of free space (in bytes) by bx*ax*cx. If an error occurs, this call returns 0FFFFh in ax . |
54h | - | al - verify state. |
Get Verify State: Returns the current state of the write verify flag (al =0 if off, al =1 if on). |
Function # (AH) |
Input Parameters |
Output Parameters |
Description |
---|---|---|---|
2Ah | - | al - day (0=Sun, 1=Mon, etc.).cx - yeardh - month (1=Jan, 2=Feb, etc.).dl - Day of month (1-31). |
Get Date: returns the current MS-DOS date. |
2Bh | cx - year (1980 - 2099)dh - month (1-12)dl - day (1-31) |
- | Set Date: sets the current MS-DOS date. |
2CH | - | ch - hour (24hr fmt)cl - minutesdh - secondsdl - hundredths |
Get Time: reads the current MS-DOS time. Note that the hundredths of a second field has a resolution of 1/18 second. |
2Dh | ch - hourcl - minutesdh - secondsdl - hundredths |
- | Set Time: sets the current MS-DOS time. |