DOS Fn 3fH: Read from File via Handle
Compatibility: 2.0+
Expects: AH 3fH
BX file handle
CX number of bytes to read
DS:DX address of buffer to receive data
──────────────────────────────────────────────────────────────────
Returns: AX error code if CF is set to CY
if no error, AX=number of bytes actually read
──────────────────────────────────────────────────────────────────
Info: Reads CX bytes of data (or fewer) from the file or device with
handle number BX. The data is read from the current position of
the file's read/write pointer and is placed into the caller's
buffer pointed to by DS:DX.
This updates the file's read/write pointer to set up for a
subsequent sequential-access read or write. To access a specific
part of a file, use Fn 42H (Lseek) before this call.
Notes: ■ You should always compare the return value of AX (number of
bytes read) to CX (number of bytes requested):
• if AX = CX, (and CF=NC) the read was correct with no error
• if AX = 0, the end of the file (EOF) was reached
• if AX < CX (but not zero):
if reading from a device, the input line is AX bytes long
if reading from a file, the call has read up to the EOF
■ It is handy to use this function for reading default handles
such as the Standard I/O handles, instead of the buffered input
or character-by-character input functions.
■ When you read from a device, AX returns the length of the line
up to and including the terminating CR (ASCII 13H).
See Also: Handle-Oriented File I/O
DOS Functions
-♦-