Exact file sizes in CP/M Plus

DOS Plus, CP/M 3 and some CP/M 2 clones (specifically, DOS+2.5) support exact file sizes. The following system calls support them:

BDOS function 15 - open a file

Entered with DE=address of File Control Block, C=15 (0Fh)

If the byte at FCB+32 (FCB+20h) is 255 (0FFh) then on return from this function the byte will contain the Last Record Byte Count. Remember to reset this byte to zero before attempting sequential I/O.

BDOS function 17 - search for first

Entered with DE=address of File Control Block, C=17 (11h)

Returns a pointer to the file's directory entry. The byte at ENTRY+13 (ENTRY+0Dh) contains the Last Record Byte Count.

BDOS function 18 - search for next

Entered with C=18 (12h)

Returns a pointer to the file's directory entry. The byte at ENTRY+13 (ENTRY+0Dh) contains the Last Record Byte Count.

BDOS function 30 - set file attributes

Entered with DE=address of File Control Block, C=30 (1Eh)

To set the Last Record Byte Count, store the required value at FCB+32 (FCB+20h), and set bit 7 of FCB+6.

What is the Last Record Byte Count?

From CP/M's point of view, it's just a number from 0-255 associated with the file which programs can use for any purpose whatever. The documentation defines no interpretation for it.

If we want programs to be able to share files with exact lengths, then there had better be some sort of agreement on what the numbers mean. They must satisfy:

Unfortunately, this still leaves two plausible systems:

The only programs I have seen using the system are Tilmann Reh's MSDOS, my MSODBALL and PIP under DOS Plus; all of these adopt the second interpretation.

Return to archive listing