mov dx, seg FileFCB
mov ds, dx
mov dx, offset FileFCB ;ds:dx points to FCB
mov ah, 16h ;Create File with FCB
int 21h
cmp al, 0 ;zero means success
jne error_handler
Create File with FCB (16h) creates a new file having the filename specified by the file control block (FCB). If a file with the specified name already exists, MS-DOS opens it and truncates it to zero length.
This function has been superseded by Create File with Handle (Function 3Ch).
FileFCB
Points to an FCB structure that identifies the file to create. The fcbDriveId, fcbFileName, and fcbExtent fields must specify the filename and drive. All other fields must be 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 function is successful, the AL register contains 00h. Otherwise, the AL register contains 0FFh.
This function can be used to create files on a network drive but only if the network has granted create (or similar) access to the given drive.
The EXTENDEDFCB structure can be used in place of the FCB structure to assign attributes to the file when creating it. In this case, the EXTENDEDFCB structure is used for all subsequent read, write, and close operations.
Function 3Ch Create File with Handle