Reads one or more sequential records from a file into memory, starting at a designated file location.
Call with:
AH = 27H
CX = number of records to read
DS:DX = segment:offset of previously opened file control block
Returns:
AL = 00H if all requested records read
01H if end of file
02H if segment wrap
03H if partial record read at end of file
CX = actual number of records read
Notes:
The records are read into memory at the current disk transfer area address, specified by the most recent call to Int 21H Function 1AH. It is the programmer's responsibility to ensure that this area is large enough for the group of records that will be transferred. If the size and location of the buffer are such that a segment overflow or wraparound would occur, the function fails with a return code of 02H.
The file location of the data to be read is determined by the combination of the relative-record field (offset 21H) and the record-size field (offset 0EH) of the FCB. The default record size is 128 bytes.
After the disk transfer is performed, the current block (offset 0CH), current record (offset 20H), and relative-record (offset 21H) fields of the FCB are updated to point to the next record in the file.
If a partial record is read at the end of file, the remainder of the record is padded with zeros.
Compare with Int 21H Function 21H, which transfers only one record per function call and does not update the FCB relative-record field.
[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 four 1024-byte records starting at record number 8 into the buffer named buff, using the file control block myfcb.
myfcb db 0 ; drive = default
db 'MYFILE ' ; filename, 8 chars
db 'DAT' ; extension, 3 chars
db 25 dup (0) ; remainder of FCB
buff db 4096 dup (?) ; buffer for data
.
.
.
; set DTA address
mov ah,1ah ; function number
mov dx,seg buff ; address of buffer
mov ds,dx
mov dx,offset buff
int 21h ; transfer to MS-DOS
; set relative-record number
mov word ptr myfcb+21h,8
mov word ptr myfcb+23h,0
; set record size
mov word ptr myfcb+0eh,1024
; read the records
mov ah,27h ; function number
mov cx,4 ; number of records
mov dx,offset myfcb ; address of FCB
int 21h ; transfer to MS-DOS
or al,al ; check status
jnz error ; jump if read error
.
.
.