FCB

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

The FCB structure contains information that identifies a file and its characteristics.

Fields

fcbDriveID

Identifies the drive containing the file (0 = default, 1 = A, 2 = B, and so on).

fcbFileName

Specifies the name of the file. The filename must be padded with space characters (ASCII 20h) if it has fewer than eight characters.

fcbExtent

Specifies the filename extension. The filename extension must be padded with space characters (ASCII 20h) if it has fewer than three characters.

fcbCurBlockNo

Specifies the current block number, which points to the block that contains the current record. A block is a group of 128 records. This field and the fcbCurRecNo field make up the record pointer. MS-DOS sets this field to zero when opening the file.

fcbRecSize

Specifies the size of a logical record, in bytes. MS-DOS sets this field to 128. A program that uses a different record size must fill this field after opening the file.

fcbFileSize

Specifies the size of the file, in bytes. When opening an existing file, MS-DOS initializes this field from the file's directory entry.

fcbFileDate

Specifies the date the file was created or last updated. When opening an existing file, MS-DOS initializes this field from the file's directory entry. This 16-bit field has the following form:

Bits Meaning

0–4 Specifies the day. Can be a value in the range 1 through 31.
5–8 Specifies the month. Can be a value in the range 1 through 12.
9–15 Specifies the year, relative to 1980.

fcbFileTime

Specifies the time the file was created or last updated. If the file already exists, MS-DOS initializes this field from the file's directory entry when opening the file. This 16-bit field has the following form:

Bits Meaning

0–4 Specifies two-second intervals. Can be a value in the range 0 through 29.
5–10 Specifies minutes. Can be a value in the range 0 through 59.
11–15 Specifies hours. Can be a value in the range 0 through 23.

fcbReserved

Reserved; do not use.

fcbCurRecNo

Specifies the current record number, which points to one of 128 records in the current block. This field and the fcbCurBlockNo field make up the record pointer. MS-DOS does not initialize this field when opening the file. The calling program must set it before performing a sequential read or write operation. This field is maintained by MS-DOS.

fcbRandomRecNo

Specifies the relative record number for random file access. This field specifies the index of the currently selected record, counting from the beginning of the file. MS-DOS does not initialize this field when opening the file. The calling program must set it before performing a random read or write operation. If the record size is less than 64 bytes, all 4 bytes of this field are used. Otherwise, only the first 3 bytes are used.

Comments

When opening or creating a file, a program initializes an FCB that contains only the drive number, the filename, and the filename extension. All other fields are zero. MS-DOS fills in the remaining fields, as described in the preceding “Fields” section, once the file is open.

See Also

Interrupt 21h Function 0Fh Open File with FCB
Interrupt 21h Function 10h Close File with FCB
Interrupt 21h Function 11h Find First File with FCB
Interrupt 21h Function 12h Find Next File with FCB
Interrupt 21h Function 13h Delete File with FCB
Interrupt 21h Function 14h Sequential Read
Interrupt 21h Function 15h Sequential Write
Interrupt 21h Function 16h Create File with FCB
Interrupt 21h Function 17h Rename File with FCB
Interrupt 21h Function 1Bh Get Default Drive Data
Interrupt 21h Function 1Ch Get Drive Data
Interrupt 21h Function 21h Random Read
Interrupt 21h Function 22h Random Write
Interrupt 21h Function 23h Get File Size
Interrupt 21h Function 24h Set Random Record Number
Interrupt 21h Function 27h Random Block Read
Interrupt 21h Function 28h Random Block Write
Interrupt 21h Function 29h Parse Filename