User`s guide

Section 2
The BDOS System Interface
This section describes the operating system services available to a transient pro-
gram through the BDOS module of CP/M 3. The section begins by defining how a
transient program calls BDOS functions, then discusses serial I/O for console, list and
auxiliary devices, the file system, and Page Zero initialization.
2.1 BDOS Calling Conventions
CP/M 3 uses a standard convention for BDOS function calls. On entry to the
BDOS, register C contains the BDOS function number, and register pair DE contains
a byte or word value or an information address. BDOS functions return single-byte
values in register A, and double-byte values in register pair HL. In addition, they
return with register A equal to L, and register H equal to B. If a transient program
makes a BDOS call to a nonsupported function number in the range of 0 to 127, the
BDOS returns with register pair HL set to OFFFFH. For compatibility with MP/M,
the BDOS returns with register pair HL set to OOOOH on nonsupported function
numbers in the range of 128 to 255. Note that CP/M 2 returns with HL set to zero
on all invalid function calls. CP/M 3's register passing conventions for BDOS func-
tion calls are consistent with the conventions used by the Intel PL/M systems pro-
gramming language.
When a transient program makes a BDOS function call, the BDOS does not restore
registers to their entry values before returning to the calling program. The responsi-
bility for saving and restoring any critical re 'ster values rests with the calling program.
When the CCP loads a transient program, the LOADER module sets the stack
pointer to a 16 level stack, and then pushes the address OOOOH onto the stack. Thus,
an immediate return to the system is equivalent to a jump to OOOOH. However, most
transient programs set up their own stack, and terminate execution by making a
BDOS System Reset call (Function 0) or by jumping to location OOOOH.
2-1