mov dx, seg FileFCB
mov ds, dx
mov dx, offset FileFCB ;ds:dx points to FCB
mov ah, 0Fh ;Open File with FCB
int 21h
cmp al, 0 ;zero means success
jne error_handler
Open File with FCB (Function 0Fh) opens a file identified by the file control block (FCB).
This function has been superseded by Open File with Handle (Function 3Dh).
FileFCB
Points to an FCB structure that identifies the file to open. The fcbDriveId, fcbFileName, and fcbExtent fields must specify the filename and drive; all other fields must be set to zero. The FCB structure has the following form:
FCB STRUC
fcbDriveID db ? ;drive no. (0=default, 1=A, etc.)
fcbFileName db '????????' ;filename
fcbExtent db '???' ;file extension
fcbCurBlockNo dw ? ;current block number
fcbRecSize dw ? ;record size
fcbFileSize db 4 dup (?) ;size of file in bytes
fcbFileDate dw ? ;date file last modified
fcbFileTime dw ? ;time file last modified
fcbReserved db 8 dup (?) ;reserved
fcbCurRecNo db ? ;current record number
fcbRandomRecNo db 4 dup (?) ;random record number
FCB ENDS
For a full description of the FCB structure, see Chapter 3, “File System.”
If the file is found, the AL register contains 00h and the remaining fields in the FCB structure are filled in. Otherwise, the AL register contains 0FFh.
This function does not support paths, so it is possible to open only files in the current directory.
If the calling program specifies zero for the drive number, MS-DOS searches for the file on the default drive. If the system finds the file, it fills in the fcbDriveId field with the correct drive.
When a file is opened, MS-DOS sets the current block number in the FCB to zero (the file pointer is at the beginning of the file).
MS-DOS initially sets the record size to 128 bytes. If some other record size is to be used, the size must be set after the call to Open File with FCB but before any other disk operation.
Function 10h Close File with FCB
Function 3Dh Open File with Handle