CP/M 3, MP/M II and CP/Net hardware error codes

Normally, if a hardware (or similar) error is encountered CP/M will print a message describing the error and then quit to the command prompt. In CP/M 3, BDOS function 45 can be used to modify this behaviour, so that error codes are returned to the program instead.

The codes returned are in the H register:

 0 - Software error (eg file not found)
 1 - Select error (cannot access drive)
 2 - Disc is read-only
 3 - File is read-only
 4 - Invalid drive
 5 - File already open
 6 - FCB checksum error (MP/M II) - the calling program has tampered with the FCB.
 7 - Password error
 8 - File already exists
 9 - Filename contains ?
10 - Wheel protection error (ZPM3) / Too many files open (MP/M II)
11 - No room in system lock list (MP/M II)
12 - Not logged on to server (CP/Net)

CP/M 3 error codes

Most BDOS file system functions fall into three categories in regard to return codes:
  1. Return an Error Code in register A:
    Register A BDOS Error Codes
    CodeMeaning
    00Function successful
    255Physical error : refer to register H
    01Reading unwritten data or no available directory space (Write Sequential)
    02No available data block
    03Cannot close current exte
    04Seek to unwritten extent
    05No available directory space
    06Random record number out of range
    09Invalid FeB (previous BDOS close call returned an error code and invalidated the FCB
    10Media Changed (A media change was detected on the FCB's drive after the FCB was opened)
  2. The following BDOS functions return a Directory Code in register A:
    BDOS Directory Codes
    CodeMeaning
    00-03successful function
    255unsuccessful function
  3. If the Set BDOS Error Mode function is used to place the BDOS in return error mode, the following functions return an Error Flag on physical errors:

Last updated: 2004 June 4