Int 21H [1.0] Function 14H (20) Sequential read

Reads the next sequential block of data from a file, then increments the file pointer appropriately.

Call with:

AH = 14H

DS:DX = segment:offset of previously opened file control block

Returns:

AL = 00H if read successful

01H if end of file

02H if segment wrap

03H if partial record read at end of file

Notes:

The record is read into memory at the current disk transfer area (DTA) address, specified by the most recent call to Int 21H Function 1AH. If the size of the record and the location of the buffer are such that a segment overflow or wraparound would occur, the function fails with a return code of 02H.

The number of bytes of data to be read is specified by the record-size field (offset 0EH) of the file control block (FCB).

The file location of the data that will be read is specified by the combination of the current block field (offset 0CH) and current record field (offset 20H) of the file control block (FCB). These fields are also automatically incremented by this function.

If a partial record is read at the end of file, it is padded to the requested record length with zeros.

[3.0+] If the program is running on a network, the user must have Read access rights to the directory containing the file to be read.

Example:

Read 1024 bytes of data from the file specified by the previously opened file control block myfcb.

myfcb db 0 ; drive = default

db 'QUACK ' ; filename, 8 chars

db 'DAT' ; extension, 3 chars

db 25 dup (0) ; remainder of FCB

.

.

.

mov ah,14h ; function number

mov dx,seg myfcb ; address of FCB

mov ds,dx

mov dx,offset myfcb

; set record size

mov word ptr myfcb+0eH,1024

int 21h ; transfer to MS-DOS

or al,al ; check status

jnz error ; jump if read failed

.

.

.