int 21hinstruction. To select an appropriate DOS function, you load the
ahregister with a function number before issuing the
int 21hinstruction. 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.
int 23hinstruction. 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||-||Console Input w/Echo: Reads a single character from the keyboard and displays typed character on screen.|
|2||-||Console Output: Writes a single character to the display.|
|3||-||Auxiliary Input: Reads a single character from the serial port.|
|4||-||Auxiliary Output: Writes a single character to the output port|
|5||-||Printer Output: Writes a single character to the printer|
|6||Direct Console I/O: On input, if |
|7||-||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||-||Read Keyboard w/o Echo: Just like function 7 above, except this call checks for ctrl-C.|
|9||-||Display String: This function displays the characters from location |
|0Ah||-||Buffered Keyboard Input: This function reads a line of text from the keyboard and stores it into the input buffer pointed at by |
|0Bh||-||Check Keyboard Status: Determines whether a character is available from the keyboard.|
|0Ch||Flush Buffer: This call empties the system type ahead buffer and then executes the DOS command specified in the al register (if |
|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||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-|
|19H||-||Get Default Drive: Returns the current system default drive number (0=A, 1=B, 2=C, etc.).|
|1Ah||-||Set Disk Transfer Area Address: Sets the address that MS-DOS uses for obsolete file I/O and Find First/Find Next commands.|
|1Bh-||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:|
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||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||-||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||-||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||-||Get Disk Transfer Area Address: Returns a pointer to the
current DTA in |
|32h||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||Get Startup Drive: Returns the number of the drive used to boot DOS (1=A, 2=B, 3=C, etc.).|
|36h||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 |
|54h||-||Get Verify State: Returns the current state of the write
verify flag (|
|2Ah||-||Get Date: returns the current MS-DOS date.|
|2Bh||-||Set Date: sets the current MS-DOS date.|
|2CH||-||Get Time: reads the current MS-DOS time. Note that the hundredths of a second field has a resolution of 1/18 second.|
|2Dh||-||Set Time: sets the current MS-DOS time.|