mov dx, seg FileFCB
mov ds, dx
mov dx, offset FileFCB ;ds:dx points to FCB
mov ah, 23h ;Get File Size
int 21h
cmp al, 0 ;zero means success
jne error_handler
Get File Size (Function 23h) returns the number of records in a file specified by a file control block (FCB).
This function has been superseded by Move File Pointer (Function 42h).
FileFCB
Points to an FCB structure that identifies the file to examine. The fcbDriveID, fcbFileName, and fcbExtent fields must contain the filename information. Also, the fcbRecSize field must contain the size of a single file record. Other fields should contain 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, and the fcbRandomRecNo field contains the number of records in the file. Otherwise, the AL register contains 0FFh.
MS-DOS returns the size of the file in records by dividing the size in bytes by the size of a single record (as specified by the fcbRecSize field). If the fcbRecSize field in the FCB structure is set to 1 byte, MS-DOS returns the size of the file in bytes.
Function 42h Move File Pointer