BDOS system calls
The original version included descriptions of CP/M 1, 2 and 3, with partial MP/M and DOSPLUS details.
I reduced the descriptions here to CP/M 2 and 3 calls for 8 bit CPUs only.
How to make a call
To make a BDOS call use:
LD DE,parameter
LD C,function
CALL 5
In CP/M 1.x, 8-bit values are returned in A and 16-bit values in BA.
In later 8-bit versions, they are also returned in L and HL respectively.
|
The calls
BDOS function 0 - System Reset
|
Supported by: CP/M 2, 3.
Entered with C=0. Does not return.
Quit the current program, return to command prompt. This call is hardly ever used
since the RST 0 instruction does the same thing and saves four bytes.
BDOS function 1 - Console input
|
Supported by: All versions
Entered with C=1. Returns A=L=character.
Wait for a character from the keyboard; then echo it to the screen and return it.
BDOS function 2 - Console output
|
Supported by: All versions
Entered with C=2, E=ASCII character.
Send the character in E to the screen. Tabs are expanded to spaces. Output can be
paused with ^S and restarted with ^Q (or any key under versions prior to CP/M 3).
While the output is paused, the program can be terminated with ^C.
BDOS function 3 - Auxiliary (Reader) input
|
Supported by: All CP/M versions
Entered with C=3. Returns A=L=ASCII character
Note that this call can hang if the auxiliary input never sends data.
BDOS function 4 - Auxiliary (Punch) output
|
Supported by: All versions.
Entered with C=4, E=ASCII character.
If the device is permanently not ready, this call can hang.
BDOS function 5 - Printer output
|
Supported by: All versions
Entered with C=2, E=ASCII character.
If the printer is permanently offline or busy, this call can hang.
BDOS function 6 - Direct console I/O
|
Supported by: CP/M 1.4 and later, with variations
Entered with C=6, E=code.
Returned values (in A) vary.
E=0FFh |
Return a character without echoing if one is waiting; zero if none is available.
|
E=0FEh |
Return console input status.
Zero if no character is waiting, nonzero otherwise.
|
E=0FDh |
Wait until a character is ready, return it without echoing.
|
Values of E not supported on a particular system will output the character.
Under CP/M 2 and lower, direct console functions may interact undesirably with non-direct ones, since certain buffers may be bypassed.
Do not mix them.
BDOS function 7 - Auxiliary Input status
|
Supported by: CP/M 3 and above.
Entered with C=7. Returns A=0 or 0FFh.
0FFh is returned if the Auxiliary Input device has a character ready;
otherwise 0 is returned.
BDOS function 7 - Get I/O byte
|
Supported by: CP/M 2 and lookalikes.
Entered with C=7. Returns I/O byte.
Here's a description of how the IOBYTE works.
BDOS function 8 - Auxiliary Output status
|
Supported by: CP/M 3 and above.
Entered with C=8. Returns A=0 or 0FFh.
0FFh is returned if the Auxiliary Output device is ready for characters;
otherwise 0 is returned.
BDOS function 8 - Set I/O byte
|
Supported by: CP/M 2 and lookalikes.
Entered with C=8, E=I/O byte.
Here's a description of how the IOBYTE works.
BDOS function 9 - Output string
|
Supported by: All versions
Entered with C=9, DE=address of string.
Display a string of ASCII characters, terminated with the $ character.
Thus the string may not contain $ characters -
so, for example, the VT52 cursor positioning command ESC Y y+32 x+32 will not be able to use row 4.
Under CP/M 3 and above, the terminating character can be changed using BDOS
function 110.
BDOS function 10 - Buffered console input
|
Supported by: All versions, with variations
Entered with C=0Ah, DE=address or zero.
This function reads characters from the keyboard into a memory buffer until RETURN is pressed.
The Delete key is handled correctly.
In later versions, more features can be used at this point.
On entry, DE is the address of a buffer.
If DE=0, the DMA address is used (CP/M 3 and later) and the buffer already contains data:
DE=address: | DE=0: |
buffer: DEFB size
DEFB ?
DEFB bytes
|
buffer: DEFB size
DEFB len
DEFB bytes
|
The value at buffer+0 is the amount of bytes available in the buffer.
Once the limit has been reached, no more can be added, although the line editor can still be used.
If DE=0 the next byte contains the number of bytes already in the buffer;
otherwise this is ignored.
On return from the function, it contains the number of bytes present in the buffer.
The bytes typed then follow.
There is no end marker.
BDOS function 11 - Console status
|
Supported by: All versions
Entered with C=0Bh. Returns A=L=status
Returns A=0 if no characters are waiting, nonzero if a character is waiting.
BDOS function 12 - Return version number
|
Supported by: Versions 2.0 and later
Entered with C=0Ch. Returns B=H=system type, A=L=version number.
The system type is subdivided into a machine type and a CP/M type.
The machine type occupies the high nibble of the byte;
the CP/M type is a bitmapped field stored in the low nibble.
Machine types:
|
CP/M types:
|
Version numbers:
|
0 - 8080
1 - 8086
2 - 68000/Z8000
|
Bit 0 set for MP/M
Bit 1 set for CP/Net
(ie:network present)
Bit 2 set in 16-bit multi-user OSes
For plain CP/M, the CP/M type is 0.
|
00h - Version 1
20h - Version 2.0
21h - Version 2.1
22h - Version 2.2
25h - Version 2.5 (DOS +)
28h - Version 2.8 (Personal CP/M-80)
30h - Version 3.0 (MP/M II)
31h - Version 3.1 (CP/M Plus)
41h - Version 4.1 (DOSPLUS 1)
60h - Version 6.0 (DOSPLUS 2)
|
BDOS function 13 - Reset discs
|
Supported by: All versions.
Entered with C=0Dh. Returned values vary.
Resets disc drives.
Logs out all discs and empties disc buffers.
Sets the currently selected drive to A:.
Any drives set to Read-Only in software become Read-Write;
replacement BDOSses tend to leave them Read-Only.
In versions 1 and 2, logs in drive A: and returns 0FFh if there is a file present whose name begins with a $, otherwise 0.
Replacement BDOSses may modify this behaviour.
In MP/M II, returns 0 if succeeded, or 0FFh if other processes have files open on removable or read-only drives.
BDOS function 14 - Select disc
|
Supported by: All versions
Entered with C=0Eh, E=drive number. Returns L=A=0 or 0FFh.
The drive number passed to this routine is 0 for A:, 1 for B: up to 15 for P:.
Sets the currently selected drive to the drive in A; logs in the disc.
Returns 0 if successful or 0FFh if error.
Under MP/M II and later versions, H can contain a physical error number.
BDOS function 15 - Open file
|
Supported by: All versions
Entered with C=0Fh, DE=FCB address. Returns error codes in BA and HL.
This function opens a file to read or read/write.
The FCB is a 36-byte data structure, most of which is maintained by CP/M.
Look here for details.
The FCB should have its DR, Fn and Tn fields filled in, and the four fields EX, S1, S2 and RC set to zero.
Under CP/M 3 and later, if CR is set to 0FFh then on return CR will contain the last record byte count.
Note that CR should normally be reset to zero if sequential access is to be used.
If the file is opened in "unlocked" mode, the file's identifier (used for record locking) will be returned at FCB+21h.
Under MP/M II and later versions, a password can be supplied to this function by pointing the DMA address at the password.
On return from this function, A is 0FFh for error, or 0-3 for success.
Some versions (including CP/M 3) always return zero;
others return 0-3 to indicate that an image of the directory entry is to be found at (80h+20h*A).
If A=0FFh, CP/M 3 returns a hardware error in H and B.
It also sets some bits in the FCB:
- F7' is set if the file is read-only because writing is password protected and no password was supplied;
- F8' is set if the file is read-only because it is a User 0 system file opened from another user area.
BDOS function 16 - Close file
|
Supported by: All versions
Entered with C=10h, DE=FCB address. Returns error codes in BA and HL.
This function closes a file, and writes any pending data.
This function should always be used when a file has been written to.
On return from this function, A is 0FFh for error, or 0-3 for success.
Some versions always return zero;
others return 0-3 to indicate that an image of the directory entry is to be found at (80h+20h*A).
Under CP/M 3, if F5' is set to 1 then the pending data are written and the file is made consistent, but it remains open.
If A=0FFh, CP/M 3 returns a hardware error in H and B.
BDOS function 17 - Search for first
|
Supported by: All versions
Entered with C=11h, DE=address of FCB. Returns error codes in BA and HL.
Search for the first occurrence of the specified file;
the filename should be stored in the supplied FCB.
The filename can include ? marks, which match anything on disc.
If the first byte of the FCB is ?, then any directory entry (including disc labels, date stamps etc.) will match.
The EX byte is also checked;
normally it should be set to zero, but if it is set to ? then all suitable extents are matched.
Returns A=0FFh if error (CP/M 3 returns a hardware error in H and B), or A=0-3 if successful.
The value returned can be used to calculate the address of a memory image of the directory entry; it is to be found at DMA+A*32.
BDOS function 18 - Search for next
|
Supported by: All versions
Entered with C=12h, (DE=address of FCB)?. Returns error codes in BA and HL.
This function should only be executed immediately after function 17 or another invocation of function 18.
No other disc access functions should have been used.
Function 18 behaves exactly as number 17, but finds the next occurrence of the specified file after the one returned last time.
The FCB parameter is not documented, but Jim Lopushinsky states in LD301.DOC:
In none of the official Programmer's Guides for any version of CP/M does it say that an FCB is required for Search Next (function 18).
However, if the FCB passed to Search First contains an unambiguous file reference (i.e. no question marks), then the Search Next function requires an FCB passed in reg DE.
BDOS function 19 - Delete file
|
Supported by: All versions
Entered with C=13h, DE=address of FCB. Returns error codes in BA and HL.
Deletes all directory entries matching the specified filename.
The name can contain ? marks.
Returns A=0FFh if error, otherwise 0-3 (CP/M 3 returns a hardware error in H and B).
Under CP/M 3, if bit F5' is set to 1, the file remains but any password protection is removed.
If the file has any password protection at all, the DMA address must be pointing at the password when this function is called.
BDOS function 20 - Read next record
|
Supported by: All versions
Entered with C=14h, DE=address of FCB. Returns error codes in BA and HL.
Load a record (normally 128 bytes, but under CP/M 3 this can be a multiple of 128 bytes) at the previously specified DMA address.
Values returned in A are:
0 1 9 10 0FFh |
- - - - - |
OK end of file invalid FCB media changed hardware error |
If on return A is not 0FFh, H contains the number of 128-byte records read before the
error (MP/M II and later).
BDOS function 21 - Write next record
|
Supported by: All versions
Entered with C=15h, DE=address of FCB. Returns error codes in BA and HL.
Write a record (normally 128 bytes, but can be a multiple of 128 bytes) to be found at previously specified DMA address.
Values returned in A are:
0 1 2 9 10 0FFh |
- - - - - - |
OK directory full disc full invalid FCB media changed hardware error |
If on return A is not 0FFh, H contains the number of 128-byte records written before the error (CP/M 3 only).
BDOS function 22 - Create file
|
Supported by: All versions
Entered with C=16h, DE=address of FCB. Returns error codes in BA and HL.
Creates the file specified. Returns A=0FFh if the directory is full.
If the file exists already, then the default action is to return to the command prompt, but CP/M 3 may return a hardware error instead.
Under MP/M II, set F5' to open the file in "unlocked" mode.
Under MP/M II and later versions, set F6' to create the file with a password; the DMA address should point at a 9-byte buffer:
DEFS 8 ;Password
DEFB 1 ;Password mode
BDOS function 23 - Rename file
|
Supported by: All versions
Entered with C=17h, DE=address of FCB. Returns error codes in BA and HL.
Renames the file specified to the new name, stored at FCB+16.
This function cannot rename across drives so the "drive" bytes of both filenames should be identical.
Returns A=0-3 if successful; A=0FFh if error.
Under CP/M 3, if H is zero then the file could not be found; if it is nonzero it contains a hardware error number.
BDOS function 24 - Return bitmap of logged-in drives
|
Supported by: All versions
Entered with C=18h. Returns bitmap in HL.
Bit 7 of H corresponds to P: while bit 0 of L corresponds to A:.
A bit is set if the corresponding drive is logged in.
BDOS function 25 - Return current drive
|
Supported by: All versions
Entered with C=19h. Returns drive in A. Returns currently selected drive. 0 => A:, 1 => B: etc.
BDOS function 26 - Set DMA address
|
Supported by: All versions
Entered with C=1Ah, DE=address.
Set the Direct Memory Access address;
a pointer to where CP/M should read or write data.
Initially used for the transfer of 128-byte records between memory and disc, but over the years has gained many more functions.
BDOS function 27 - Return address of allocation map
|
Supported by: All versions, but differs in banked versions.
Entered with C=1Bh. Returns address in HL.
Return the address of the allocation bitmap (which blocks are used and which are free) in HL.
Under banked CP/M 3 and MP/M, this will be an address in bank 0 (the system bank) and not easily accessible.
Under previous versions, the format of the bitmap is a sequence of bytes, with bit 7 of the byte representing the lowest-numbered block on disc, and counting starting at block 0 (the directory).
A bit is set if the corresponding block is in use.
Under CP/M 3, the allocation vector may be of this form (single-bit) or allocate two bits to each block (double-bit).
This information is stored in the SCB.
BDOS function 28 - Software write-protect current disc
|
Supported by: All versions, with differences
Entered with C=1Ch.
Temporarily set current drive to be read-only; attempts to write to it will fail.
Under genuine CP/M systems, this continues until either call 13 (disc reset) or call 37 (selective disc reset) is called;
in practice, this means that whenever a program returns to the command prompt, all drives are reset to read/write.
Newer BDOS replacements only reset the drive when function 37 is called.
BDOS function 29 - Return bitmap of read-only drives
|
Supported by: All versions
Entered with C=1Dh. Returns bitmap in HL.
Bit 7 of H corresponds to P: while bit 0 of L corresponds to A:.
A bit is set if the corresponding drive is set to read-only in software.
BDOS function 30 - set file attributes
|
Supported by: All versions
Entered with C=1Eh, DE=address of FCB. Returns error codes in BA and HL.
Set and reset the bits required.
Standard CP/M versions allow the bits F1', F2', F3', F4', T1' (read-only), T2' (system) and T3' (archive) to be changed.
Some alternative BDOSses allow F5', F6', F7' and F8' to be set, but this is not to be encouraged since setting these bits can cause CP/M 3 to behave differently.
Under CP/M 3, the Last Record Byte Count is set by storing the required value at FCB+32 (FCB+20h) and setting the F6' bit.
The code returned in A is 0-3 if the operation was successful, or 0FFh if there was an error.
Under CP/M 3, if A is 0FFh and H is nonzero, H contains a hardware error.
BDOS function 31 - get DPB address
|
Supported by: CP/M 2 and later.
Entered with C=1Fh. Returns address in HL.
Returns the address of the Disc Parameter Block for the current drive.
See the formats listing for details of the DPBs under various CP/M versions.
BDOS function 32 - get/set user number
|
Supported by: CP/M 2 and later.
Entered with C=20h, E=number. If E=0FFh, returns number in A.
Set current user number.
E should be 0-15, or 255 to retrieve the current user number into A.
Some versions can use user areas 16-31, but these should be avoided for compatibility reasons.
DOS+ returns the number set in A.
BDOS function 33 - Random access read record
|
Supported by: CP/M 2 and later.
Entered with C=21h, DE=FCB address. Returns error codes in BA and HL.
Read the record specified in the random record count area of the FCB, at the DMA address.
The pointers in the FCB will be updated so that the next record to read using the sequential I/O calls will be the record just read.
Error numbers returned are:
0 1 4 6 9 10 0FFh |
- - - - - - - |
OK Reading unwritten data Reading unwritten extent (a 16k portion of file does not exist) Record number out of range Invalid FCB Media changed [CP/M 3] hardware error in H |
BDOS function 34 - Random access write record
|
Supported by: CP/M 2 and later.
Entered with C=22h, DE=FCB address. Returns error codes in BA and HL.
Write the record specified in the random record count area of the FCB, at the DMA address.
The pointers in the FCB will be updated so that the next record to write using the sequential I/O calls will be the record just written.
Error numbers returned are:
0 2 3 5 6 9 10 0FFh |
- - - - - - - - |
OK Disc full Cannot close extent Directory full
Record number out of range
Invalid FCB Media changed [CP/M 3] hardware error in H |
If the record indicated is beyond the end of the file, the record will be written and the file may contain a gap;
attempting to read this gap may give "reading unwritten data" errors, or nonsense.
BDOS function 35 - Compute file size
|
Supported by: CP/M 2 and later.
Entered with C=23h, DE=FCB address. Returns error codes in BA and HL.
Set the random record count bytes of the FCB to the number of 128-byte records in the file.
Returns A=0FFh if error (file not found, or CP/M 3 hardware error); otherwise A=0.
BDOS function 36 - Update random access pointer
|
Supported by: CP/M 2 and later.
Entered with C=24h, DE=FCB address.
Set the random record count bytes of the FCB to the number of the last record read/written by the sequential I/O calls.
BDOS function 37 - Selectively reset disc drives
|
Supported by: CP/M 2 and later.
Entered with C=25h, DE=bitmap of drives to reset. Returns A=0.
Bit 7 of D corresponds to P: while bit 0 of E corresponds to A:.
A bit is set if the corresponding drive should be reset.
Resetting a drive removes its software read-only status.
BDOS function 38 - Access drives
|
Supported by: MP/M, Concurrent CP/M, CP/Net redirector.
Entered with C=26h, DE=drive bitmap.
Locks one or more disc drives.
Processes will not be able to reset these drives; the effect is the same as if there were open files on the drives.
Returns A=0 if OK, and 0FFh if there is an error.
If there is, H will contain the error code.
BDOS function 39 - Free drive
|
Supported by: MP/M, Concurrent CP/M, CP/Net redirector.
Releases locks on disc drives.
Entered with C=27h, DE = bitmap of drives to free.
Open files on the drives in question must be closed before this call is made, or data may be corrupted.
BDOS function 40 - Write random with zero fill
|
Supported by: CP/M 2.2 and later.
Entered with C=28h, DE=FCB address. Returns error codes in BA and HL.
As function 34, but if the write is to a newly allocated disc block the remainder of the block is filled with zeroes.
BDOS function 41 - Test and write record
|
Supported by: MP/M.
Entered with C=29h, DE=FCB address. Returns error codes in BA and HL.
This function compares the contents of the file with the record at the DMA address.
If the comparison is successful, the data at (DMA + record size) are written to the file.
For example, if the multisector count is set to 4 records, the DMA address will have 512 bytes (4x128) to compare with the file, and then another 512 to write to the file.
On return, A is:
0 1 3 4 6 7 8 10 11 0FFh |
- - - - - - - - - - |
OK
Reading unwritten data Cannot close current extent Seek to unwritten extent (a 16k portion of file does not exist) Record number out of range Records did not match Record is locked by another process FCB checksum error Unlocked file verification error hardware error in H |
BDOS function 42 - Lock record
|
Supported by: MP/M.
Entered with C=2Ah, DE=FCB address. Returns error codes in BA and HL.
This function locks the number of records specified by function 44, starting at the record number at FCB+21h.
The DMA address should point to the file ID returned by function 15.
On return, A is:
0 1 3 4 6 8 10 11 12 13 14 0FFh |
- - - - - - - - - - - - |
OK Reading unwritten data Cannot close current extent Seek to unwritten extent (a 16k portion of file does not exist) Record number out of range Record is locked by another process FCB checksum error Unlocked file verification error No more locks available for this process Invalid file ID No room in the system lock list hardware error in H |
BDOS function 43 - Unlock record
|
Supported by: MP/M.
This function behaves as function 42 above, but unlocks records rather than locking them.
If a record is locked by a different process, it remains locked; but no error is returned.
BDOS function 44 - Set number of records to read/write at oncet
|
Supported by: MP/M II and later.
Entered with C=2Ch, E=number of records. Returns A=0 or 0FFh.
Sets the number of records that functions 14, 15, 31, 32 and 40 should attempt to read at once.
E should be 1-127 in CP/M 3 and later.
Returns A=0 if E was valid, 0FFh otherwise.
The random access counters still operate with 128 bytes/record.
BDOS function 45 - Set action on hardware error
|
Supported by: MP/M II and laterr.
Entered with C=2Dh, E=action.
Instructs CP/M what action to take if there is a hardware error:
E < 254 E = 254 E = 255 |
Compatibility mode; program is terminated and an error message printed
Error code is returned in H, error message is printed
Error code is returned in H, no error message is printed |
Note that the messages (if printed) are not followed by a carriage return or linefeed.
BDOS function 46 - Find free space on a drive
|
Supported by: MP/M II and later.
Entered with C=2Eh, E=drive. Returns error codes in BA and HL.
Sets the three bytes at the DMA address to the number of free 128-byte records on the disc, low byte first.
E is the drive (0 for A:, 1 for B: etc.).
If on return A=0FFh, there is a hardware error in H.
BDOS function 47 - Chain to program
|
Supported by: MP/M II and later.
Entered with C=2Fh, E=chain flag. Only returns if it fails.
Execute the command line at 80h.
The error return code is not changed, so the new program can discover the status returned by the previous one.
If E=255, then the currently set drive and user (as set by calls 25 and 32) become those used by the CCP;
otherwise the CCP drive and user remain the same.
BDOS function 48 - Empty disc buffers
|
Supported by: MP/M II and later.
Entered with C=30h, E=flag. Returns error codes in BA and HL.
Forces all pending disc writes to be executed.
If E=255, then all disc read buffers are emptied as well (so that information must be read from the disc - used by file verification programs).
Returns A=0FFh if there is a hardware error in H.
BDOS function 49 - Access the System Control Block
|
Supported by: CP/M 3.
Entered with C=31h, DE=address of parameter area. Returned values vary.
The SCB is a 100-byte area of memory (officially) used for storing system settings.
The parameter area is formed:
pb+0: DB offset ;0-99
pb+1: DB command ;0 => Read byte at offset into A,
; and word at offset into HL.
;0FEh => Write word at pb+2 to SCB at
; offset and offset+1
;0FFh => Write byte at pb+2 to SCB at offset
BDOS function 50 - Use the BIOS
|
Supported by: CP/M 3 and later.
Entered with C=32h, DE=address of parameter area. Returned values vary.
Under CP/M 3, the BIOS should not be directly called, except possibly the character I/O and USERF calls.
Instead, this function should be used.
The parameter area is formed:
pb+0: DB bios-function ;0-32
pb+1: DB bios-a ;Value for A register
pb+2: DB bios-c ;Value for C register
pb+3: DB bios-b ;Value for B register
pb+4: DB bios-e ;Value for E register
pb+5: DB bios-d ;Value for D register
pb+6: DB bios-l ;Value for L register
pb+7: DB bios-h ;Value for H register
BDOS function 59 - Load overlay
|
Supported by: CP/M 3 and higher Loaders.
Entered with C=3Bh, DE=FCB address. Returns error code in A.
Load a program or RSX.
The FCB should have been opened before making this call; the load address should be stored at FCB+21h.
If the program is a PRL (Paged Relocatable), the original CP/M loader will relocate it;
some replacement loaders, such as that in CCP+ need a special flag set to indicate this.
If DE=0, the Loader will not load anything, but it will remove from the RSX chain any RSXs marked as due for deletion.
Returns A=0 if OK, 0FEh if there was an error, or 0FFh if the Loader is not present.
BDOS function 60 - Call to RSX
|
Supported by: CP/M 3 and later RSXs.
Entered with C=3Ch, DE=RSXPB address
This call is provided for programs to communicate with Resident System Extensions.
There is a separate list of functions provided by specific RSXs.
The format of the RSXPB is:
DEFB function, 0-127 ;(128-255 used internally by CP/M)
DEFB numwords ;Number of parameter words passed to RSX.
DEFW parameters
A popular convention is for the first parameter word to point to a copy within the program of the name of the intended RSX; for example:
RSXPB: DEFB 100 ;Function
DEFB 1 ;1 Parameter
DEFW RNAME ;RSX name
RNAME: DEFB 'GETERL '
This call returns BA=HL=00FFh if the requested RSX is not resident;
otherwise, the values are those returned by the RSX.
BDOS function 98 - Clean up disc
|
Supported by: CP/M 3 (Internal?).
Entered with C=62h. Returns A=0 if OK, 0FFh if current drive is invalid
This function is called by the CCP when a program terminates.
Open files are closed;
buffered data are not written, so files opened for writing may be destroyed if not properly closed.
BDOS function 99 - Truncate file
|
Supported by: CP/M 3 and later.
Entered with C=63h, DE=FCB address. Returns error codes in BA and HL.
Set the random record count of the FCB to the required file size in records.
If the file is password protected, point the DMA address at the password.
Returns A=0-3 for success, 0FFh for failure; H may contain a hardware error code.
BDOS function 100 - Set directory label
|
Supported by: MP/M II and later.
Entered with C=64h, DE=FCB. Returns error codes in BA and HL.
The EX byte (FCB+0Ch) of the FCB should contain a flags byte:
Bit Meaning if set
----------------------------------------
7 Passwords enabled
6 Stamp on access
5 Stamp on update
4 Stamp on creation
0 Assign password at DMA+8 to label.
This function may need a password at the DMA address, if there is a label on the disc which has a password.
This function returns A=0 if OK, 0FFh for failure.
H may contain a hardware error code.
BDOS function 101 - Get directory label byte
|
Supported by: MP/M II and later.
Entered with C=65h, E=drive. Returns A=byte
The byte returned has the following bits set:
Bit Meaning if set
----------------------------------------
7 Passwords enabled
6 Stamp on access
5 Stamp on update
4 Stamp on creation
0 Directory label exists
If bit 0 is zero, the other bits are meaningless.
If a label does exist, it can be found using functions 17 and 18 with the first 13 bytes of the FCB set to "?", and checking for a file whose user number is 32.
BDOS function 102 - Get file date and time
|
Supported by: MP/M II and later.
Entered with C=66h, DE=FCB address. Returns error codes in BA and HL.
Gets the file date and time stamps, and the password mode.
The stamps end up at FCB+18h (create or access), FCB+1Ch (update);
the password mode ends up at FCB+0Ch.
This returns A=0-3 for success, or 0FFh for failure.
To tell whether a stamp is for creation or access, check the directory label byte.
For information on the format of date and time stamps, see the date and time calls.
The password mode is documented in the next function.
BDOS function 103 - Set file password and protection
|
Supported by: MP/M II and later.
Entered with C=67h, DE=FCB address. Returns error codes in BA and HL.
Sets file password and protection mode.
Set FCB+0Ch to the required password mode, and point the DMA address at the current password.
The password mode byte should have the following bits set:
Bit Meaning if set
----------------------------------------
7 Reading requires password
6 Writing requires password
5 Deletion requires password
0 Assign password at DMA+8 to file.
BDOS function 104 - Set date and time
|
Supported by: MP/M II and later.
Entered with C=68h, DE=address of time stamp.
The format of the time stamp is:
DW day ;Day 1 is 1 January 1978
DB hour ;Packed BCD
DB minute ;Packed BCD
Under CP/M 3 the "seconds" counter will be reset to zero when this function is called.
BDOS function 105 - Get date and time
|
Supported by: MP/M II and later.
Entered with C=69h, DE=address of time stamp. Returns A=seconds (packed BCD).
The format of the time stamp is:
DW day ;Day 1 is 1 January 1978
DB hour ;Packed BCD
DB minute ;Packed BCD
Under MP/M II and later versions, the "seconds" value will be returned in A.
BDOS function 106 - Set default password
|
Supported by: MP/M II and above.
Entered with C=6Ah, DE=address of password.
Sets the default password, used for all file operations requiring passwords when no password is given explicitly.
BDOS function 107 - Get serial number
|
Supported by: MP/M II and above.
Entered with C=6Bh, DE=address of buffer.
Stores a 6-byte serial number at the address given by DE.
Usually this number will be printable ASCII.
BDOS function 108 - Get/put program return code
|
Supported by: CP/M 3 and above.
Entered with C=6Ch, DE=code. Returns HL=code.
If DE=0FFFFh, then the current code is returned in HL.
Otherwise, it is set to the value in DE.
Allowable values are:
00000h - 0FEFFh 0FF00h - 0FF7Fh 0FF80h - 0FFFCh 0FFFDh 0FFFEh |
No fatal error
Fatal error
Reserved
Program terminated because of a hardware error.
Program terminated by Control-C. |
If a program was chained by function 47, an error code stored by the previous program will be available to it.
Otherwise the CCP sets the return code to zero when it executes a program (some replacement CCPs do not do this).
If the error code is 0FF00h or above, and the next command begins with the character : then it will not be run.
BDOS function 109 - Set or get console mode
|
Supported by: CP/M 3 and above
Entered with C=6Dh, DE=mode or 0FFFFh. Returns HL=mode.
The mode is a bitmapped value. Under CP/M 3, the significant bits are:
0 | If set, function 11 detects only ^C. |
1 | If set, ^S does not pause screen output. |
2 | If set, output does not expand tabs, nor is it echoed to the printer even if ^P was pressed. |
3 | If set, ^C does not cause the program to terminate. |
4 | Behaves like bit 2. The BDOS source comments imply it also signifies "escape sequence decoding" but whatever this is, it is not implemented in the CP/M 3 BDOS. |
8 | } | These form a 2-bit number controlling GET and SUBMIT: |
9 | } |
0 | Return "conditional" status to function 11. Programs using function 11 to test for interruption (eg SID) are not interrupted, but those using it to test for input do get the input. It does this by returning "false", then "true". |
1 | Function 11 always returns "true". |
2 | Function 11 always returns "false". |
3 | Temporarily disable GET/SUBMIT, input comes from keyboard. |
|
BDOS function 110 - Get/set string delimiter
|
Supported by: CP/M 3 and above
Entered with C=6Eh, DE=0FFFFh or ASCII value. Returns ASCII value in A.
This function gets or sets the string delimiter (used in function 9 to mark the end of the string to print).
If DE=0FFFFh, this gets the current ASCII value into A; otherwise it sets the delimiter to the value in E.
BDOS function 111 - Send block of text to console
|
Supported by: PCP/M 3 and above
Entered with C=6Fh, DE=address of character control block.
For 8-bit CP/M, the character control block is formed:
DW text_begin
DW text_length
BDOS function 112 - Send block of text to printer
|
Supported by: CP/M 3 and above
Entered with C=70h, DE=address of character control block.
Format of character control block
BDOS function 152 - Parse filename
|
Supported by: MP/M, CP/M 3 and higher.
Entered with C=98h, DE=address of PFCB. Returns codes in HL.
This parses an ASCII filename to a FCB.
The format of the PFCB is:
DEFW ascii-address
DEFW fcb-address
The value returned in HL is 0FFFFh if the ASCII filename was invalid;
0 if the ASCII filename was terminated with a zero or a carriage return;
and otherwise the address of the next character after the filename.
The filename can be of any form up to the full d:filename.typ;password
(password only under CP/M 3 and above).
When the filename is parsed, the password is copied to FCB+10h, with its length at FCB+1Ah.
Under ZPM3, the filename may be of the form du:filename.typ;password;
FCB+0Dh will be 0 if no user number was specified, or 1+number otherwise.
If a Z-System is loaded, ZPM3 can also parse filenames of the form dir:filename.typ;password.
BUG: ZPM3 (version N10) puts the password at FCB+0Ch rather than FCB+10h, overwriting the user number stored at FCB+0Dh.
It does not zero the last four bytes of the FCB, while CP/M does.
The filename can be terminated by any of: space tab cr nul ; = > < . : , [ ] / | .
CP/M 2 Input/Output mapping
Under CP/M 2, input and output device selection are performed by the BIOS.
Some BIOSes may implement a feature called the IOBYTE which allows the user to change which device the screen, printer etc. output go to.
The IOBYTE lives at address 3 (in the Zero Page) and should be changed using BDOS calls 7 and 8 (get/set IOBYTE).
The value is bitmapped:
Bits Bits 6,7 Bits 4,5 Bits 2,3 Bits 0,1
Device LIST PUNCH READER CONSOLE
Value
00 TTY: TTY: TTY: TTY:
01 CRT: PTP: PTR: CRT:
10 LPT: UP1: UR1: BAT:
11 UL1: UP2: UR2: UC1:
BAT = batch mode. Use the current Reader for console input, and he current List (printer)
device as the console output.
CRT = Standard console (keyboard and terminal screen).
LPT = Standard line printer.
PTP = Standard Paper Tape Punch.
PTR = Standard Paper Tape Reader.
TTY = Teletype device, eg a serial port.
UC1 = User defined (ie implementation dependent) console device.
UL1 = User defined (ie implementation dependent) printer device.
UPn = User defined (ie implementation dependent) output device.
URn = User defined (ie implementation dependent) input device.
Last updated:
2004 June 4