Digital Research : CP/M 3 System Manual

Page 1

DIGITALRESEARCH

CP/M Plus(CP/M Version 3)

Operating System
System Guide
COPYRIGHT
Copyright (C) 1983 Digital Research Inc. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed,
stored in a retrieval system, or translated into any language or computer language, in any form or by any means, electronic,
mechanical, magnetic, optical, chemical, manual or otherwise, without the prior written permission of Digital Research Inc., 60
Garden Court, Box DRI, Monterey, California 93942.
DISCLAIMER
DIGITAL RESEARCH INC. MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE CONTENTSHEREOF AND SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.
Further, Digital Research Inc. reserves the right to revise this publication and to make changes from time to time in the content hereof
without obligation of Digital Research Inc. to notify any person of such revision or changes.
NOTICE TO USER
From time to time changes are made in the filenames and in the files actually included on the distribution disk. This manual should
not be construed as a representation or warranty that such files or facilities exist on the distribution disk or as part of the materials andprograms distributed.
Most distribution disks include a "README.DOC" file. This file explains variations from the manual which do constitutemodification of the manual and the items included therewith. Be sure to read this file before using the software.
TRADEMARKS
CP/M and Digital Research and its logo are registered trademarks of Digital Research Inc. CP/M Plus, DDT, LINK-80, RMAC, SID,
TEX, and XREF are trademarks of Digital Research Inc.
Altos is a registered trademark of Altos Corporation. IBM is a registered trademark of International Business Machines. Intel is a
registered trademark of Intel Corporation. Microsoft is a registered trademark of Microsoft Corporation. Zilog and Z80 are registeredtrademarks of Zilog Inc.
The CP/M Plus (CP/M Version 3) Operating System System Guide was prepared using the Digital Research TEX" Text Formatterand printed in the United States of America.
**
First Edition: January 1983**
Second Edition: July 1983***

Digital Research : CP/M 3 System Manual

Page 2

Table of Contents
FOREWORD .................................................................................................................................................................................................. 4
SECTION 1 : CP/M 3 OPERATING SYSTEM OVERVIEW ......................................................................................................................................... 4
1.1 INTRODUCTION TO CP/M 3 ....................................................................................................................................................................... 5
1.2 CP/M 3 SYSTEM COMPONENTS ................................................................................................................................................................. 5
1.3 COMMUNICATION BETWEEN MODULES........................................................................................................................................................ 6
1.4 BANKED AND NONBANKED SYSTEMS ............................................................................................................................................................ 7
1.5 MEMORY REQUIREMENTS.......................................................................................................................................................................... 9
1.6 DISK ORGANIZATION............................................................................................................................................................................... 11
1.7 HARDWARE SUPPORTED .......................................................................................................................................................................... 11
1.8 CUSTOMIZING CP/M 3 ........................................................................................................................................................................... 12
1.9 INITIAL LOAD (COLD BOOT) OF CP/M 3 ..................................................................................................................................................... 13
SECTION 2 : CP/M 3 BIOS OVERVIEW ........................................................................................................................................................... 13
2.1 ORGANIZATION OF THE BIOS ................................................................................................................................................................... 13
2.2 SYSTEM CONTROL BLOCK......................................................................................................................................................................... 15
2.3 SYSTEM INITIALIZATION ........................................................................................................................................................................... 16
2.4 CHARACTER I/O..................................................................................................................................................................................... 17
2.5 DISK I/O .............................................................................................................................................................................................. 17
2.6 MEMORY SELECTS AND MOVES ................................................................................................................................................................ 20
2.7 CLOCK SUPPORT .................................................................................................................................................................................... 20
SECTION 3 : CP/M 3 BIOS FUNCTIONAL SPECIFICATIONS .................................................................................................................................. 21
3.1 THE SYSTEM CONTROL BLOCK .................................................................................................................................................................. 21
3.2 CHARACTER I/O DATA STRUCTURES .......................................................................................................................................................... 24
3.3 BIOS DISK DATA STRUCTURES.................................................................................................................................................................. 25
3.4 BIOS SUBROUTINE ENTRY POINTS............................................................................................................................................................. 35
3.5 BANKING CONSIDERATIONS ...................................................................................................................................................................... 48
3.6 ASSEMBLING AND LINKING YOUR BIOS ...................................................................................................................................................... 49
SECTION 4 : CP/M 3 SAMPLE BIOS MODULES ................................................................................................................................................ 51
4.1 FUNCTIONAL SUMARY OF BIOS MODULES .................................................................................................................................................. 51
4.2 CONVENTIONS USED IN BIOS MODULES .................................................................................................................................................... 52
4.3 INTERACTIONS OF MODULES .................................................................................................................................................................... 52
4.4 PREDEFINED VARIABLES AND SUBROUTINES................................................................................................................................................. 53
4.5 BOOT MODULE .................................................................................................................................................................................... 56
4.6 CHARACTER I/O..................................................................................................................................................................................... 56
4.7 DISK I/O .............................................................................................................................................................................................. 58
4.8 MOVE MODULE ................................................................................................................................................................................... 61
4.9 LINKING MODULES INTO THE BIOS............................................................................................................................................................ 62
SECTION 5 : SYSTEM GENERATION.................................................................................................................................................................. 62
5.1 GENCPM UTILITY ................................................................................................................................................................................. 63
5.2 CUSTOMIZING THE CPMLDR ................................................................................................................................................................... 71
5.3 CPKLDR UTILITY ................................................................................................................................................................................... 72
5.4 BOOTING CP/M 3 ................................................................................................................................................................................. 73
SECTION 6 : DEBUGGING THE BIOS ................................................................................................................................................................ 74
APPENDIX A ............................................................................................................................................................................................... 76
REMOVABLE MEDIA CONSIDERATIONS ............................................................................................................................................................. 76
APPENDIX B : AUTO-DENSITY SUPPORT ........................................................................................................................................................... 78
APPENDIX C : MODIFING A CP/M 2 BIOS ...................................................................................................................................................... 78
APPENDIX D : CPM3.SYS FILE FORMAT ......................................................................................................................................................... 81
APPENDIX E : ROOT MODULE OF RELOCATABLE BIOS FOR CP/M 3 .................................................................................................................... 82
APPENDIX F : SCB DEFINITION FOR CP/M 3 BIOS ......................................................................................................................................... 100
APPENDIX G : EQUATES FOR MODE BYTE BIT FIELDS ....................................................................................................................................... 102
APPENDIX H : MACRO DEFINITIONS FOR CP/M 3 BIOS DATA STRUCTURES ....................................................................................................... 103
APPENDIX I : ACS 8000-15 BIOS MODULES ................................................................................................................................................ 107
I.1 BOOT LOADER MODULE FOR CP/M 3 ...................................................................................................................................................... 107
I.2 : CHARACTER I/O HANDLER FOR Z80 CHIP--BASED SYSTEM .......................................................................................................................... 111
I.3 : DRIVE TABLE ...................................................................................................................................................................................... 118
I.4 Z80 DMA SINGLE-DENSITY DISK HANDLER ................................................................................................................................................ 118
I.5 : BANK AND MOVE MODULE FOR CP/M 3 LINKED BIOS.............................................................................................................................. 130
I.6 : I/O PORT ADDRESSES FOR Z80 CHIP-BASED SYSTEM: PORTS.LIB................................................................................................................ 132
I.7 : SAMPLE SUBMIT FILE FOR ASC 8000-15 SYSTEM ..................................................................................................................................... 134
APPENDIX J : PUBLIC ENTRY POINTS FOR CP/M 3 SAMPLE BIOS MODULES ....................................................................................................... 135

Digital Research : CP/M 3 System Manual

Page 3

APPENDIX K : PUBLIC DATA ITEMS IN CP/M 3 SAMPLE BIOS MODULES............................................................................................................ 136
APPENDIX L : CP/M 3 BIOS FUNCTION SUMMARY ........................................................................................................................................ 137

List of Tables
TABLE 1-1. CP/M 3 OPERATING SYSTEM MEMORY REQUIREMENTS ....................................................................................................................... 9
TABLE 2-1. CP/M 3 BIOS JUMP VECTOR ........................................................................................................................................................ 14
TABLE 2-2. CP/M 3 BIOS FUNCTIONS ............................................................................................................................................................ 15
TABLE 2-3. INITIALIZATION OF PAGE ZERO ........................................................................................................................................................ 16
TABLE 2-4. CP/M 3 LOGICAL DEVICE CHARACTERISTICS ..................................................................................................................................... 17
TABLE 2-5. BDOS CALLS TO BIOS IN NONBANKED AND BANKED SYSTEMS............................................................................................................. 17
TABLE 2-7. READING TWO CONTIGUOUS SECTORS IN BANKED SYSTEM .................................................................................................................. 19
TABLE 3-1. SYSTEM CONTROL BLOCK FIELDS..................................................................................................................................................... 22
TABLE 3-2. DISK PARAMETER HEADER FIELDS ................................................................................................................................................... 27
TABLE 3-3. DISK PARAMETER BLOCK FIELDS ..................................................................................................................................................... 29
TABLE 3-4. BSH AND BLM VALUES ................................................................................................................................................................ 30
TABLE 3-5. MAXIMUM EXK VALUES ............................................................................................................................................................... 30
TABLE 3-6. BLS AND NUMBER OF DIRECTORY ENTRIES ....................................................................................................................................... 31
TABLE 3-7. PSH AND PHN VALUES ................................................................................................................................................................ 32
TABLE 3-8. BUFFER CONTROL BLOCK FIELDS ..................................................................................................................................................... 32
TABLE 3-9. FUNCTIONAL ORGANIZATION OF BIOS ENTRY POINTS......................................................................................................................... 35
TABLE 3-10. CP/M 3 BIOS FUNCTION JUMP TABLE SUNMARY ........................................................................................................................... 35
TABLE 3-11. I/O REDIRECTION BIT VECTORS IN SCB .......................................................................................................................................... 39
TABLE 4-1. CP/M 3 BIOS MODULE FUNCTION SUMMARY ................................................................................................................................. 51
TABLE 4-2. PUBLIC SYMBOLS IN CP/M 3 BIOS................................................................................................................................................. 53
TABLE 4-3. GLOBAL VARIABLES IN BIOSKRNL.ASM ......................................................................................................................................... 54
TABLE 4-4. PUBLIC UTILITY SUBROUTINES IN BIOSKRNL.ASK UTILITY I MEANING ................................................................................................... 54
TABLE 4-5. PUBLIC NAMES IN THE BIOS JUMP VECTOR ...................................................................................................................................... 55
TABLE 4-6. BOOT MODULE ENTRY POINTS...................................................................................................................................................... 56
TABLE 4-7. MODE BITS................................................................................................................................................................................. 57
TABLE 4-8. BAUD RATES FOR SERIAL DEVICES ................................................................................................................................................... 57
TABLE 4-9. CHARACTER DEVICE LABELS ........................................................................................................................................................... 58
TABLE 4-10. FIELDS OF EACH XDPH ............................................................................................................................................................... 60
TABLE 4-11. SUBROUTINE ENTRY POINTS......................................................................................................................................................... 61
TABLE 4-12. MOVE MODULE ENTRY POINTS .................................................................................................................................................... 62
TABLE 5-1. SAMPLE CP/M 3 SYSTEM TRACK ORGANIZATION .............................................................................................................................. 71
TABLE C-1. CP/M 3 BIOS FUNCTIONS ............................................................................................................................................................ 79
TABLE D-1. CPM3.SYS FILE FORMAT ............................................................................................................................................................. 81
TABLE D-2. HEADER RECORD DEFINITION......................................................................................................................................................... 81
TABLE J-1 : PUBLIC ENTRYPOINTS FOR CP/M 3 SAMPLE BIOS MODULES ............................................................................................................ 135
TABLE K-1. PUBLIC DATA ITEMS ................................................................................................................................................................... 136
TABLE L-1. BIOS FUNCTION JUMP TABLE SUMMARY........................................................................................................................................ 137

List of Figures
FIGURE 1-1 : GENERAL MEMORY ORGANIZATION OF CP/M 3 ............................................................................................................................... 7
FIGURE 1-2. MEMORY ORGANIZATION FOR BANKED CP/M 3 SYSTEM ..................................................................................................................... 8
FIGURE 1-3. MEMORY ORGANIZATION WITH BANK I ENABLED IN BANKED SYSTEM .................................................................................................... 8
FIGURE 1-4. MEMORY ORGANIZATION IN NONBANKED CP/M 3 SYSTEM ................................................................................................................ 9
FIGURE 1-5. MEMORY ORGANIZATION IN BANKED CP/M 3 ................................................................................................................................ 10
FIGURE 1-6. MEMORY ORGANIZATION IN NONBANKED CP/M 3 .......................................................................................................................... 11
FIGURE 1-7. CP/M 3 SYSTEM DISK ORGANIZATION ........................................................................................................................................... 11
FIGURE 2-1. CP/M 3 SYSTEM TRACKS ............................................................................................................................................................ 16
FIGURE 3-1. DISK DATA STRUCTURES IN A BANKED SYSTEM................................................................................................................................. 26
FIGURE 3-2. DISK PARAMETER HEADER FORMAT ............................................................................................................................................... 27
FIGURE 3-3. DISK PARAMETER BLOCK FORMAT ................................................................................................................................................. 29
FIGURE 3-4. ALO AND ALI ............................................................................................................................................................................ 31
FIGURE 3-5. BUFFER CONTROL BLOCK FORMAT ................................................................................................................................................ 32
TABLE D-2. HEADER RECORD DEFINITION......................................................................................................................................................... 81

Digital Research : CP/M 3 System Manual

Page 4Foreword
CP/M(R) 3, also marketed as CP/M Plus(R) , is a single-console operating system for 8-bit machines that use anIntel (R) 8080, 8085, or Zilog(R) Z80(R) CPU. CP/M 3 is upward-compatible with its predecessor, CP/M 2,
and offers more features and higher performance than CP/M 2. This manual describes the steps necessary tocreate or modify a CP/M 3 Basic Input Output System (BIOS) tailored for a specific hardware environment.
The CP/M Plus (CP/M Version 3) Operating System System Guide (hereafter cited as CP/M Plus System
Guide) assumes you are familiar with systems programming in 8080 assembly language and that you haveaccess to a CP/M 2 system. It also assumes you understand the target hardware and that you have functioning
disk I/O drivers. You should be familiar with the accompanying CP/M Plus (CP/M Version 3) Operating
System User's Guide (hereafter cited as CP/M Plus User's Guide) describing the operating system utilities. You
should also be familiar with the CP/M Plus (CP/M Version 3) Operating system Programmer's Guide (hereafter
cited as CP/M Plus Programmer's Guide), which describes the system calls use by the applications programmer
to interface with the operating system. The Programmer' s Utilities Guide for the CP/M Family of Operating
Systems (hereafter cited as Programmer's Utilities Guide) documents the assembling and debugging utilities.
Section 1 of this manual is an overview of the component modules of the CP/M 3 operating system. Section 2
provides an overview of the functions and data structures necessary to write an interface module between CP/M
3 and specific hardware. Section 3 contains a detailed description of these functions and data structures,
followed by instructions to assemble and link the distributed modules with your customized modules. Section 4
describes the modular organization of the sample CP/M 3 BIOS on your distribution diskette.
Section 5 documents the procedure to generate and boot your CP/M 3 system. Section 6 is a sample debugging
session.
The appendixes contain tables, and sample BIOS modules you can use, or study and modify. Appendix A
discusses removable media drives. Appendix B discusses automatic density support. Appendix C describes how
CP/M 3 differs from CP/M 2. Appendix D shows the format of the CPM3.SYS file.
Appendixes E through H are listings of the assembled source code for the four hardware-independent modulesof the sample BIOS. Appendix E is the kernel module to use when creating a modular BIOS in the form of the
distributed sample. Appendix F shows the System Control Block. Appendix G is a table of equates for the baudrate and mode byte for character I/O. Appendix H contains the macro definitions you can use to generate someof the CP/M 3 disk data structures. Appendix I lists the assembled source code for the six BIOS modules that
depend on the Altos@ 8000-15 Computer System hardware. It also contains a sample Submit file to build a
BIOS.
Appendixes J and K are tabular summaries of the public entry points and data items in the modules of thesample BIOS. Finally, Appendix L is a tabular summary of the thirty-three functions of the CP/M 3 BIOS,
complete with entry parameters and returned values.

Section 1 : CP/M 3 Operating System Overview
This section is an overview of the CP/M 3 operating system, with a description of the system components andhow they relate to each other. The section includes a discussion of memory configurations and supported
hardware. The last portion summarizes the creation of a customized version of the CP/M 3 Basic Input Output
System (BIOS).

Digital Research : CP/M 3 System Manual

Page 5

1.1 Introduction to CP/M 3
CP/M 3 provides an environment for program development and execution on computer systems that use theIntel 8080, 8085, -or ZBO microprocessor chip. CP/M 3 provides rapid access to data and programs through afile structure that supports dynamic allocation of space for sequential and random access files.
CP/M 3 supports a maximum of sixteen logical floppy or hard disks with a storage capacity of up to 512
megabytes each. The maximum file size supported is 32 megabytes. You can configure the number of directory
entries and block size to satisfy various user needs.
CP/M 3 is supplied in two versions. One version supports nonbank-switched memory; the second version
supports hardware with bank-switched memory capabilities. CP/M 3 supplies additional facilities for the bankswitched system, including extended command line editing, password protection of files, and extended error
messages.
The nonbanked system requires 8.5 kilobytes of memory, plus space for your customized BIOS. It can executein a minimum of 32 kilobytes of memory.
The bank-switched system requires a minimum of two memory banks with 11 kilobytes of memory in Bank 0
and 1.5 kilobytes in common memory, plus space for your customized BIOS.
The bank-switched system provides more user memory for application programs.
CP/M 3 resides in the file CPM3.SYS, which is loaded into memory by a system loader during system
initialization. The system loader resides on the first two tracks of the system disk.
CPM3.SYS contains the distributed BDOS and the customized BIOS.
The CP/M 3 operating system is distributed on two single- density, single-sided, eight-inch floppy disks.
Digital Research supplies a sample BIOS that is configured for an Altos 8000-15 microcomputer system withbank-switched memory and two single- density, single-sided, eight-inch floppy disk drives.

1.2 CP/M 3 System Components
The CP/M 3 operating system consists of the following three modules: the Console Command Processor(CCP), the Basic Disk Operating System (BDOS), and the Basic Input Output System (BIOS).
The CCP is a program that provides the basic user interface to the facilities of the operating system. The CCP
supplies six built- in commands: DTR, DIRS, ERASE, RENAME, TYPE, and USER. The CCP executes in theTransient Program Area (TPA), the region of memory where all application programs execute.
The CCP contains the Program Loader Module, which loads transient (applications) programs from disk into
the TPA for execution.
The BDOS is the logical nucleus and file system of CP/M 3. The BDOS provides the interface between theapplication program and the physical input/output routines of the BIOS.
The BIOS is a hardware-dependent module that interfaces the BDOS to a particular hardware environment. The
BIOS performs all physical I/O in the system. The BIOS consists of a number of routines that you must
configure to support the specific hardware of the target computer system.
The BDOS and the BIOS modules cooperate to provide the CCP and other transient programs with hardwareindependent access to CP/M 3 facilities. Because the BIOS is configured for different hardware environments

Digital Research : CP/M 3 System Manual

Page 6and the BDOS remains constant, you can transfer programs that run under CP/M 3 unchanged to systems withdifferent hardware configurations.

1.3 Communication Between Modules
The BIOS loads the CCP into the TPA at system cold and warm start. The CCP moves the Program Loader
Module to the top of the TPA and uses the Program Loader Module to load transient programs.
The BDOS contains a set of functions that the CCP and applications programs call to perform disk andcharacter input and output operations.
The BIOS contains a Jump Table with a set of 33 entry points that the BDOS calls to perform hardwaredependent primitive functions, such as peripheral device I/O. For example, CONIN is an entry point of theBIOS called by the BDOS to read the next console input character.
Similarities exist between the BDOS functions and the BIOS functions, particularly for simple device I/O. For
example, when a transient program makes a console output function call to the BDOS, the BDOS makes aconsole output call to the BIOS. In the case of disk I/O, however, this relationship is more complex.
The BDOS might make many BIOS function calls to perform a single BDOS file I/O function. BDOS disk I/O
is in terms of 128-byte logical records. BIOS disk I/O is in terms of physical sectors and tracks.
The System Control Block (SCB) is a 100-byte, decimal, CP/M 3 data structure that resides in the BDOS
system component. The BDOS and the BIOS communicate through fields in the SCB. The SCB contains
BDOS flags and data, CCP flags and data, and other system information, such as console characteristics and thecurrent date and time. You can access some of the System Control Block fields from the BIOS.
Note that the SCB contains critical system parameters which reflect the current state of the operating system. If
a program modif i es these parameters, the operating system can crash.
See Section 3 of this manual, and the description of BDOS Function 49 in the CP/M Plus Proqrammer's Guide
for more information on the System Control Block.
Page Zero is a region of memory that acts as an interface between transient programs and the operating system.
Page Zero contains critical system parameters, including the entry to the BDOS and the entry to the BIOS
Warm BOOT routine. At system start-up, the BIOS initializes these two entry points in Page Zero. All linkage
between transient programs and the BDOS is restricted to the indirect linkage through Page Zero. Figure 1-1
illustrates the general memory organization of CP/M 3.

Digital Research : CP/M 3 System Manual

Page 7

Figure 1-1 : General Memory Organization of CP/M 3
Note that all memory regions in CP/M 3 are page aligned, which means that they must begin on a page
boundary. Because a page is defined as 256 (100H) bytes, a page boundary always begins at a hexadecimal
address where the low-order byte of the hex address is zero.

1.4 Banked and Nonbanked Systems
CP/M 3 is supplied in two versions: one for hardware that supports banked memory, and the other for hardware
with a minimum of 32 kilobytes of memory. The systems are called banked and nonbanked.
Digital Research supplies System Page Relocatable (. SPR) files for both a banked BDOS and a nonbanked
BDOS. A sample banked BIOS is supplied for you to use as an example when creating a customized BIOS for
your set of hardware components.
The following figure shows the memory organization for a banked system. Bank 0 and common memory arefor the operating system. Bank 1 is the Transient Program Area, which contains the Page Zero region ofmemory. You can use additional banks to enhance operating system performance.
In banked CP/M 3 systems, CPMLDR, the system loader, loads part of the BDOS into common memory andpart of the BDOS into Bank 0. CPMLDR loads the BIOS in the same manner.
Figure 1-2 shows the memory organization for the banked version of CP/M 3.

Digital Research : CP/M 3 System Manual

Page 8Figure 1-2. Memory organization for Banked CP/M 3 System
In this figure, the top region of memory is called common memory. Common memory is always enabled andaddressable. The operating system is divided into two modules: the resident portion, which resides in common
memory, and the banked portion, which resides just below common memory in Bank 0.
The shaded areas in Figure 1-2 represent the memory available to transient programs.
The clear areas are used by the operating system for disk record buffers and directory hash tables. The clear
area in the common region above the operating system represents space that can be allocated for data buffers by
GENCPM, the CP/M 3 system generation utility.
The size of the buffer area is determined by the specific hardware requirements of the host microcomputer
system.
Bank 0, the system bank, is the bank that is enabled when CP/M 3 is cold started. Bank 1 is the transient
program bank. The transient program bank must be contiguous from location zero to the top of banked
memory. Common memory must also be contiguous. The other banks need not begin at location zero or havecontiguous memory.
Figure 1-3 shows the CP/M 3 memory organization when the TPA bank, Bank 1, is enabled in a bank-switchedsystem.

Figure 1-3. Memory Organization with Bank I Enabled in Banked System
The operating system switches to Bank 0 or other banks when performing operating system functions. In
general, any bank switching performed by the operating system is transparent to the calling program.
The memory organization for the nonbanked version of CP/M 3 is much simpler, as shown in Figure 1-4:

Digital Research : CP/M 3 System Manual

Page 9Figure 1-4. Memory Organization in Nonbanked CP/M 3 System
In the nonbanked version of CP/M 3, memory consists of a single contiguous region addressable from 0000H
up to a maximum of 0FFFFH, or 64K-1. The clear area above the operating system represents space that can beallocated for data buffers and directory hash tables by the CP/M 3 system generation utility, GENCPM, or
directly allocated by the BIOS. The minimum size of the buffer area is determined by the specific hardware
requirements of the host microcomputer system. Again, the shaded region represents the space available fortransient programs.

1.5 Memory Requirements
Table 1-1 shows typical sizes of the CP/M 3 operating system components.
Table 1-1. CP/M 3 Operating System Memory Requirements
CP/M 3 Version Nonbanked
BDOS
Floppy system
Hard system

BankedCommonBank 0
8.5K
1.5K
11K
BIOS (values vary)
1.5K
.75K
2K
2.5K
1.5K
3K

The CP/M 3 banked system requires a minimum of two banks (Bank 0 and Bank 1) and can support up to 16
banks of memory. The size of the common region is often 16K, but can be as small as 4K. Common memory
must be large enough to contain the required buffers and the resident (common) portion of the operating
system, which means a 1.5K BDOS and the common part of your customized BIOS.
In a banked environment, CP/M 3 maintains a cache of deblocking buffers and directory records using a Least
Recently Used (LRU) buffering scheme. The LRU buffer is the first to be reused when the system runs out of
buffer space. The BDOS maintains separate buffer pools for directory and data record caching.
The RSX modules shown in Figure 1-5 are Resident System Extensions (RSX) that are loaded directly below
the operating system when included in an application or utility program.
The Program Loader places the RSX in memory and chains BDOS calls through the RSX entry point in the
RSX.
Figure 1-5 shows the memory organization in a typical bank- switched CP/M 3 system.

Digital Research : CP/M 3 System Manual

Page 10Figure 1-5. Memory Organization in Banked CP/M 3
The banked system supports a TPA of 60K or more. The banked portion of the operating system in Bank 0
requires at least 16K of memory.
In the banked system, the BDOS and the BIOS are separated into two parts: a resident portion, and a banked
portion. The resident BDOS and BIOS are located in common memory.
The banked BDOS and BIOS are located in the operating system bank, referred to as Bank 0 in this manual.
The TPA extends from 100H in Bank 1 up to the bottom of the resident BDOS in common memory. The
banked BIOS and BDOS reside in Bank 0 with the directory buffers.
Typically, all data buffers reside in common. Data buffers can reside in an alternate bank if the system has a
DMA controller capable of transferring arbitrary blocks of data from one bank to another. Hashed directory
tables (one per drive) can be placed in any bank except Bank 1 (TPA). Hashed directory tables require 4 bytes
per directory entry.
Figure 1-6 shows a typical nonbanked system configuration.

Digital Research : CP/M 3 System Manual

Page 11

Figure 1-6. Memory organization in Nonbanked CP/M 3
The nonbanked CP/M 3 system requires 8.5K of memory plus space for the BIOS, buffers, and hash tables,
allowing a TPA size of up to 52K to 54K, depending on the size of the BIOS and the number of hash tables andbuffers you are using.

1.6 Disk Organization
Figure 1-7 illustrates the organization of a CP/M 3 system disk.

Figure 1-7. CP/M 3 System Disk Organization
In Figure 1-7, the first N tracks are the system tracks; the remaining tracks, the data tracks, are used by CP/M 3
for file storage. Note that the system tracks are used by CP/M 3 only during system cold start and warm start.
All other CP/M 3 disk access is directed to the data tracks of the disk. To maintain compatibility with Digital
Research products, you should use an eight-inch, single-density, IBM' 3740 formatted disk with two system
tracks.

1.7 Hardware Supported
You can customize the BIOS to match any hardware environment with the following general characteristics.

Digital Research : CP/M 3 System Manual

Page 121.7.1 Hardware Supported by CP/M 3 Banked System






Intel 8080, Intel 8085, or zilog Z80 CPU or equivalent.
A minimum of two and up to sixteen banks of memory with the top 4K-32K in common memory. Bank
1 must have contiguous memory from address 0000H to the base of common memory. A reasonableconfiguration consists of two banks of 48K RAM each, with the top 16K in common memory.
one to sixteen disk drives of up to 512 megabytes capacity each.
Some form of ASCII console device, usually a CRT.
One to twelve additional character input and or output devices, such as printers, communications
hardware, and plotters.

1.7.2 Hardware Supported by CP/M 3 Nonbanked System






Intel 8080, Intel 8085, or Zilog Z80 CPU or equivalent.
A minimum of 32K and up to 64K contiguous memory addressable from location zero.
One to sixteen disk drives of up to 512 megabytes capacity each.
Some form of ASCII console device, usually a CRT.
One to twelve additional input and or output devices, usually including a printer.

Because most CP/M-compatible software is distributed on eight- inch, soft-sectored, single-density floppy
disks, it is recommended that a CP/M 3 hardware configuration include a minimum of two disk drives, at least
one of which is a single-density floppy disk drive.

1.8 Customizing CP/M 3
Digital Research supplies the BDOS files for a banked and a nonbanked version of CP/M
3. A system generation utility, GENCPM, is provided with CP/M 3 to create a version of the operating system
tailored to your hardware. GENCPM combines the BDOS and your customized BIOS files to create aCPM3.SYS file, which is loaded into memory at system start-up. The CPM3.SYS file contains the BDOS andBIOS system components and information indicating where these modules reside in memory.
Digital Research supplies a CP/M 3 loader file, CPMLDR, which you can link with your customized loader
BIOS and use to load the CPM3.SYS file into memory. CPMLDR is a small, self-contained version of CP/M 3
that supports only console output and sequential file input.
Consistent with CP/M 3 organization, it contains two modules: an invariant CPMLDR BDOS, and a variant
CPMLDR-BIOS, which is adapted to match the host microcomputer hardware environment. The CPMLDR
BIOS module can perform cold start initialization of I/O ports and similar functions. CPMLDR can display amemory map of the CP/M 3 system at start-up. This is a GENCPM option.
The following steps tell you how to create a new version of CP/M 3 tailored to your specific hardware.
1) Write and assemble a customized BIOS following the specif ications described in Section 3. This
software module must correspond to the exact physical characteristics of the target system, including
memory and port addresses, peripheral types, and drive characteristics.
2) Use the system generation utility, GENCPM, to create the CPM3.SYS file containing the CP/M 3
distributed BDOS and your customized BIOS, as described in Section 5.
3) Write a customized loader BIOS (LDRBIOS) to reside on the system tracks as of CPMLDR. CPMLDR
loads the CPM3.SYS file into memory from disk. Section 5 gives the instructions for customizing the
LDRBIOS and generating CPMLDR. Link your customized LDRBIOS file with the supplied CPMLDR
file.
4) Use the COPYSYS utility to put CPMLDR on the system tracks of a disk.

Digital Research : CP/M 3 System Manual

Page 135) Test and debug your customized version of CP/M 3.
If you have banked memory, Digital Research recommends that you first use your customized BIOS to create anonbanked version of the CP/M 3 operating system. You can leave your entire BIOS in common memory until
you have a working system. Test all your routines in a nonbanked version of CP/M 3 before you create abanked version.

1.9 Initial Load (Cold Boot) of CP/M 3
CP/M 3 is loaded into memory as follows. Execution is initiated by a four-stage procedure. The first stage
consists of loading into memory a small program, called the Cold Boot Loader, from the system tracks of the
Boot disk. This load operation is typically handled by a hardware feature associated with system reset. The
Cold Boot Loader is usually 128 or 256 bytes in length.
In the second stage, the Cold Boot Loader loads the memory image of the CP/M 3 system loader program,
CPMLDR, from the system tracks of a disk into memory and passes control to it. For a banked system, the Cold
Boot Loader loads CPMLDR into Bank 0.
A PROM loader can perform stages one and two.
In the third stage, CPMLDR reads the CPM3.SYS f ile, which contains the BDOS and customized BIOS, fromthe the data area of the disk into the memory addresses assigned by GENCPM. In a banked system, CPMLDR
reads the common part of the BDOS and BIOS into the common part of memory, and reads the banked part ofthe BDOS and BIOS into the area of memory below common base in Bank 0. CPMLDR then transfers control
to the Cold BOCT system initialization routine in the BIOS.
For the f inal stage, the BIOS Cold BOOT routine, BIOS Function 0, performs any remaining necessary
hardware initialization, displays the sign-on message, and reads the CCP from the system tracks or from a
CCP.COM file on disk into location 100H of the TPA. The Cold BOOT routine transfers control to the CCP,
which then displays the system prompt.
Section 2 provides an overview of the organization of the System Control Block and the data structures andfunctions in the CP/M 3 BIOS.

Section 2 : CP/M 3 BIOS Overview
This section describes the organization of the CP/M 3 BIOS and the BDOS jump vector.
It provides an overview of the System Control Block, followed by a discussion of system initialization
procedures, character I/O, clock support, disk I/O, and memory selects and moves.

2.1 Organization of the BIOS
The BIOS is the CP/M 3 module that contains all hardware- dependent input and output routines. To configure
CP/M 3 for a particular hardware environment, use the sample BIOS supplied with this document and adapt it
to the specific hardware of the target system.
Alternatively, you can modify an existing CP/M 2.2 BIOS to install CP/M 3 on your target machine. Note thatan unmodified CP/M 2.2 BIOS does not work with the CP/M 3 operating system. See Appendix C for a
description of the modifications necessary to convert a CP/M 2.2 BIOS to a CP/M 3 BIOS.
The BIOS is a set of routines that performs system initialization, character-oriented I/O to the console andprinter devices, and physical sector I/O to the disk devices. The BIOS also contains routines that manage blockDigital Research : CP/M 3 System Manual

Page 14moves and memory selects for systems with bank-switched memory. The BIOS supplies tables that define thelayout of the disk devices and allocate buffer space which the BDOS uses to perform record blocking anddeblocking. The BIOS can maintain the system time and date in the System Control Block.
Table 2-1 describes the entry points into the BIOS from the Cold Start Loader and the BDOS. Entry to the
BIOS is through a jump vector. The jump vector is a set of 33 jump instructions that pass program control to theindividual BIOS subroutines.
You must include all of the entry points in the BIOS jump vector in your BIOS.
However, if your system does not support some of the functions provided for in the BIOS, you can use empty
subroutines for those functions. For example, if your system does not support a printer, JMP LIST can referencea subroutine consisting of only a RET instruction. Table 2-1 shows the elements of the jump vector.
Table 2-1. CP/M 3 BIOS Jump Vector
No.

Instruction

Description0

JMP BOOT

Perform cold start initialization

1

JMP WBOOT

Perform warm start initialization

2

JMP CONST

Check for console input character ready3

JMP CONIN

Read Console Character in

4

JMP CONOUT Write Console Character out

5

JMP LIST6JMP AUXOUT Write Auxiliary Output Character

7

JMP AUXIN

Read Auxiliary Input Character

8

JMP HOME

Move to Track 00 on Selected Disk

9

JMP SELDSK

Select Disk Drive

10

JMP SETTRK

Set Track Number

11

JMP SETSEC

Set Sector Number

12

JMP SETDMA

Set DMA Address

13

JMP READ

Read Specified Sector

14

JMP WRITE

Write Specified Sector

15

JMP LISTST

Return List Status

16

JMP SECTRN

Translate Logical to Physical Sector

17

JMP CONOST

Return Output Status of Console

18

JMP AUXISTReturn Input Status of Aux. Port19

JMP AUXOST

Return Output Status of Aux. Port20

JMP DEVTBL

Return Address of Char. I/O Table

21

JMP DEVINI

Initialize Char. I/O Devices

22

JMP DRVTBL

Return Address of Disk Drive Table

Write List Character out

Digital Research : CP/M 3 System Manual

Page 15No.

Instruction

Description

23

JMP MULTIO

Set Number of Logically Consecutive sectors to be read or written

24

JMP FLUSH

Force Physical Buffer Flushing for user-supported deblocking

25

JMP MOVE

Memory to Memory Move26

JMP TIME

Time Set/Get signal

27

JMP SELMEM Select Bank of memory28

JMP SETBNKSpecify Bank for DMA Operation

29

JMP XMOVE

Set Bank When a Buffer is in a Bank other than 0 or 1

30

JMP USERF

Reserved for System Implementor

31

JMP RESERV1 Reserved for Future Use32

JMP RESERV2 Reserved for Future Use

Each jump address in Table 2-1 corresponds to a particular subroutine that performs a specific system
operation. Note that two entry points are reserved for future versions of CP/M, and one entry point is pr ovided
for OEM subroutines, accessed only by direct BIOS calls using BDOS Function 50. Table 2 -2 shows the fivecategories of system operations and the function calls that accomplish these operations.
Table 2-2. CP/M 3 BIOS Functions
Operation
System Initialization

Function
BOOT, WBOOT, DEVTBL, DEVINI, DRVTBL

Character I/O

CONST, CONIN, CONOUT, LIST, AUXOUT, AUXIN, LISTST,CONOST, AUXIST, AUXOSTDisk I/O

HOME, SELDSK, SETTRK, SETSEC, SETDMA, READ, WRITE,SECTRN, MULTIO, FLUSH

Memory Selects and Moves MOVE, SELMEM, SETBNK, XMOVEClock Support

TIME

You do not need to implement every function in the BIOS jump vector. However, to operate, the BDOS needs
the BOOT, WBOOT, CONST, CONIN, CONOUT, HOME, SELDSK, SETTRK, SETSEC, SETDMA, READ,
WRITE, SECTRN, MULTIO, and FLUSH subroutines.
Implement SELMEM and SETBNK only in a banked environment. You can implement MULTIO, FLUSH,
and TIME as returns with a zero in register A. DEVICE and some other utilities use the remaining entry points,
but it is not necessary to fully implement them in order to debug and develop the system.
Note: include all routines but make the nonimplemented routines a RET instruction.

2.2 System Control Block
The System Control Block (SCB) is a data structure located in the BDOS. The SCB is a communications area
referenced by the BDOS, the CCP, the BIOS, and other system components. The SCB contains systemparameters and variables, some of which the BIOS can reference. The fields of the SCB are named, andDigital Research : CP/M 3 System Manual

Page 16

definitions of these names are supplied as public variable and subroutine names in the SCB.ASM file containedon the distribution disk. See Section 3.1 for a discussion of the System Control Block.

2.3 System Initialization
When the BOOT and WBOOT routines of the BIOS get control, they must initialize two system parameters inPage Zero of memory, as shown in Table 2-3.
Table 2-3. Initialization of Page Zero
Location

Description

0,1,2

Set to JMP WBOOT (0000H: JMP BIOS+3).
Location 1 and 2 must contain the address of WBOOT in the jump vector.

5,6,7

Set to JMP BDOS, the primary entry point to CP/M 3 for transient programs.
The current address of the BDOS is maintained in the variable @MXTPA in the System
Control Block. (See Section 3.1, "System Control Block," and BIOS Function 1: WBOOT)

The BOOT and WBOOT routine must load the CCP into the TPA in Bank I at location 0100H. The CCP can beloaded in two ways. If there is sufficient space on the system tracks, the CCP can be stored on the system tracks
and loaded from there. If you prefer, or if there is not sufficient space on the system tracks, the BIOS Cold
BOOT routine can read the CCP into memory from the file CCP.COM on disk.
If the CCP is in a COM file, use the BOOT and WBOOT routines to perform any necessary system
initialization, then use the BDOS functions to OPEN and READ the CCP.COM file into the TPA. In bank switched systems, the CCP must be read into the TPA in Bank 1.
In bank-switched systems, your Cold BOOT routine can place a copy of the CCP into a reserved area of analternate bank after loading the CCP into the TPA in Bank 1. Then the Warm BOOT routine can copy the CCP
into the TPA in Bank 1 from the alternate bank, rather than reloading the CCP from disk, thus avoiding all disk
accesses during warm starts.
There is a 128-byte buffer in the resident portion of the BDOS in a banked system that can be used by BOOT
and WBOOT. The address of this buffer is stored in the SCB variable @BNKBF. BOOT and WBOOT can use
this buffer when copying the CCP to and from the alternate bank.
The system tracks for CP/M 3 are usually partitioned as shown in the following figure;

Figure 2-1. CP/M 3 System Tracks
The cold start procedure is designed so you need to initialize the system tracks only once. This is possible
because the system tracks contain the system loader and need not change when you change the CP/M 3
operating system. The Cold Start Loader loads CPMLDR into a constant memory location that is chosen when
the system is configured. However , CPMLDR loads the BDOS and BIOS system components into memory as
specified in the CPM3.SYS file generated by GENCPM, the system generation utility. Thus, CP/M 3 allows theuser to configure a new system with GENCPM and then run it without having to update the system tracks of thesystem disk.

Digital Research : CP/M 3 System Manual

Page 17

2.4 Character I/O
CP/M 3 assumes that all simple character I/O operations are performed in 8-bit ASCII, upper- and lowercase,with no parity. An ASCII CRTL-Z (lAH) denotes an end-of-file condition for an input device.
Table 2-4 lists the characteristics of the logical devices.
Table 2-4. CP/M 3 Logical Device Characteristics
DeviceCharacteristics

The interactive console that communicates with the operator, accessed by CONST,
CONIN, CONOUT, and CONOUTST. Typically, the CONSOLE is a device such as a
CONIN, CONOUTCRT or teletype, interfaced serially, but it can also be a memory-mapped video display
and keyboard. The console is an input device and an output device.
The system printer, if it exists on your system. LIST is usually a hard- copy device
such as a printer or teletypewriter.

LIST
AUXOUT

The auxiliary character output device, such as a modem.

AUXIN

The auxiliary character input device, such as a modem.

Note that you can define a single peripheral as the LIST, AUXOUT, and AUXIN device simultaneously. If you
assign no peripheral device as the LIST, AUXOUT, or AUXIN device, the AUXOUT and LIST routines canjust return, and the AUXIN routine can return with a 1AH (CTRL-Z) in register A to indicate an immediate
end-of-file.
CP/M 3 supports character device I/O redirection. This means that you can direct a logical device, such as
CONIN or AUXOUT, to one or more physical devices. The DEVICE utility allows you to reassign devices anddisplay, and to change the current device configurations, as described in the CP/M Plus User's Guide. The I/O
redirection facility is optional. You should not implement it until the rest of your BIOS is fully functional.

2.5 Disk I/O
The BDOS accomplishes disk I/O by making a sequence of calls to the various disk access subroutines in the
BIOS. The subroutines set up the disk number to access, the track and sector on a particular disk, and the Direct
Memory Access (DMA) address and bank involved in the I/O operation. After these parameters are established,
the BDOS calls the READ or WRITE function to perform the actual I/O operation.
Note that the BDOS can make a single call to SELDSK to select a disk drive, follow it with a number of read or
write operations to the selected disk, and then select another drive for subsequent operations.
CP/M 3 supports multiple sector read or write operations to optimize rotational latency on block disk transfers.
You can implement the multiple sector I/O facility in the BIOS by using the multisector count passed to the
MULTIO entry point. The BDOS calls MULTIO to read or write up to 128 sectors. For every sector number 1
to n, the BDOS calls SETDMA then calls READ or WRITE.
Table 2-5 shows the sequence of BIOS calls that the BDOS makes to read or write a physical disk sector in anonbanked and a banked system. Table 2-6 shows the sequence of calls the BDOS makes to the BIOS to reador write multiple contiguous physical sectors in a nonbanked and banked system.
Table 2-5. BDOS Calls to BIOS in Nonbanked and Banked Systems
Nonbanked BDOS

Digital Research : CP/M 3 System Manual
Call

Explanation

SELDSK

Called only when disk is initially selected or reselected.

SETTRK

Called for every read or write of a physical sector.

SETSEC

Called for every read or write of a physical sector.

SETDMA

Called for every read or write of a physical sector.

Page 18

READ, WRITE Called for every read or write of a physical sector.

Banked BDOS
Call

Explanation

SELDSK

Called only when disk is initially selected or reselected.

SETTRK

Called for every read or write of a physical sector.

SETSEC

Called for every read or write of a physical sector.

SETDMA

Called for every read or write of a physical sector.

SETBNK

Called for every read or write of a physical sector.

READ, WRITE Called for every read or write of a physical sector.

Nonbanked BDOS
Call

Explanation

SELDSK

Called only when disk is initially selected or reselected.

MULTIO

Called to inform the BIOS that the next n calls to disk READ or disk WRITE requirea transfer of n contiguous physical sectors to contiguous memory.

SETTRK

Called for every read or write of a physical sector.

SETSEC

Called for every read or write of a physical sector.

SETDMA

Called for every read or write of a physical sector.

READ, WRITE Called for every read or write of a physical sector.

Banked BDOS
Call

Explanation

SELDSK

Called only when disk is initially selected or reselected.

MULTIO

Called to inform the BIOS that the next n calls to disk READ or disk WRITE requirea transfer of n contiguous physical sectors to contiguous memory.

SETTRK

Called for every read or write of a physical sector.

SETSEC

Called for every read or write of a physical sector.

Digital Research : CP/M 3 System Manual
SETDMA

Called for every read or write of a physical sector.

SETBNK

Called for every read or write of a physical sector.

Page 19

READ, WRITE Called for every read or write of a physical sector.

Table 2-7 shows the sequence of BDOS calls to read two contiguous physical sectors in a banked system.
Table 2-7. Reading Two Contiguous Sectors in Banked System
Call

Explanation

SELDSK Called to initially select disk
MULTIO With a value of 2
SETTRK For first sector
SETSECFor first sector

SETDMA For first sector
SETBNKREAD
SETTRK For second sector
SETSECFor second sector

SETDMA For second sector
SETBNKREAD
The CP/M 3 BDOS performs its own blocking and deblocking of logical 128-byte records. Unlike earlier
versions of CP/M, the BIOS READ and WRITE routines always transfer physical sectors as specified in the
Disk Parameter Block to or from the DMA buffer. The Disk Parameter Header defines one or more physicalsector buffers which the BDOS uses for logical record blocking and deblocking.
In a banked environment, CP/M 3 maintains a cache of deblocking buf fers and directory records using a Least
Recently Used (LRU) buffering scheme. The LRU buffer is the first to be reused when the system runs out of
buffer space. The BDOS maintains separate buffer pools for directory and data record caching.
The BIOS contains the data structures to control the data and directory buffers and the hash tables. You caneither assign these buffers and tables yourself in the BIOS, or allow the GENCPM utility to generate them
automatically.
Hash tables greatly speed directory searching. The BDOS can use hash tables to determine the location of
directory entries and therefore reduce the number of disk accesses required to read a directory entry. The hashtable allows the BDOS to directly access the sector of the directory containing the desired directory entry
without having to read the directory sequentially. By eliminating a sequential read of the directory records,
hashing also increases the percentage of time that the desired directory record is in a buffer, eliminating theneed for any physical disk accesses in these cases. Hash tables and directory caches eliminate many of thedirectory accesses required when accessing large files. However, in a nonbanked system, hash tables increase
the size of the operating system.

Digital Research : CP/M 3 System Manual

Page 20

When the BIOS finds an error condition, the READ and WRITE routines should perform several retries before
reporting the error condition to the BDOS. Ten retries are typical. If the BIOS returns an error condition to the
BDOS, the BDOS reports the error to the user in the following form:
CP/M Error on d: Disk I/O
The d: represents the drive specification of the relevant drive.
To provide better diagnostic capabilities for the user, it is often desirable to print a more explicit error message
from the BIOS READ or WRITE routines before the BIOS returns an error code to the BDOS. The BIOS
should interrogate the SCB Error Mode Variable to determine if it is appropriate to print a message on the
console.

2.6 Memory Selects and Moves
Four BIOS functions are provided to perform memory management. The functions are MOVE, XMOVE,SELMEM, and SETBNK. The XMOVE, SELMEM, and SETBNK memory management routines areapplicable to the BIOS of banked systems.
The BDOS uses the BIOS MOVE routine to perform memory-to-memory block transfers.
In a banked system, the BDOS calls XMOVE to specify the source and destination banks to be used by the
MOVE routine. If you use memory that is not in the common area for data record buffers, you must implement
the XMOVE routine.
The BDOS uses SELMEM when the operating system needs to execute code or access data in other than thecurrently selected bank.
The BDOS calls the SETBNK routine prior to calling disk READ or disk WRITE functions. The SETBNK
routine must save its specified bank as the DMA bank. When the BDOS invokes a disk I/O routine, the I/O
routine should save the current bank number and select the DMA bank prior to the disk READ or WRITE.
After completion of the disk READ or WRITE, the disk I/O routine must reselect the current bank. Note thatwhen the BDOS calls the disk I/O routines, Bank 0 is in context (selected).

2.7 Clock Support
If the system has a real-time clock or is capable of keeping time, possibly by counting interrupts from acounter/timer chip, then the BIOS can maintain the time of day in the System Control Block and update thetime on clock interrupts. BIOS Function 26 is provided for those systems where the clock is unable to generate
an interrupt.
The time of day is kept as four fields. @DATE is a binary word containing the number of days since 31
December 1977. The bytes @HOUR, @MIN, and @SEC in the System Control Block contain the hour,
minute, and second in Binary Coded Decimal (BCD) format.

Digital Research : CP/M 3 System Manual

Page 21

Section 3 : CP/M 3 BIOS Functional Specifications
This section contains a detailed description of the CP/M 3 BIOS The section first discusses the BIOS data
structures and their relationships, including the System Control Block, the drive table, the Disk Parameter
Header, the Disk Parameter Block, the Buffer Control Blocks, and the character I/O table. The overview of thedata structures is followed by a summary of the functions in the BIOS jump vector. A detailed description of
the entry values and returned values for each jump instruction in the BIOS jump vector follows the summary.
The last part of this section discusses the steps to follow when assembling and linking your customized BIOS.

3.1 The System Control Block
The System Control Block (SCB) is a data structure located in the BDOS. The SCB contains flags and data
used by the CCP, the BDOS, the BIOS, and other system components.
The BIOS can access specif ic data in the System Control Block through the public variables defined in the
SCB.ASM file, which is supplied on the distribution disk.
Declare the variable names you want to reference in the SCB as externals in your BIOS.ASM source file. Thenlink your BIOS with the SCB.REL module.
In the SCB.ASM file, the high-order byte of the various SCB addresses is defined as 0FEH. The linker marks
absolute external equates as page relocatable when generating a System Page Relocatable (SPR) format file.
GENCPM recognizes page relocatable addresses of 0FExxH as references to the System Control Block in the
BDOS. GENCPM changes these addresses to point to the actual SCB in the BDOS when it is relocating thesystem.
Do not perform assembly-time arithmetic on any references to the external labels of the SCB. The result of thearithmetic could alter the page value to something other than 0FEH.
Listing 3-1 shows the SCB.ASM file. The listing shows the f ield names of the System Control Block. A @before a name indicates that it is a data item. A ? preceding a name indicates that it is the label of an instruction.
In the listing, r/w means Read-Write, and r/o means Read-Only. The BIOS can modify a Read- Write variable,
but must not modify a Read-Only variable. Table 3-1 describes each item in the System Control Block in detail.
title 'System Control Block Definition for CP/M3 BIOS'
public @civec, @covec, @aivec, @aovec, @lovec, @bnkbf public @crdma, @crdsk, @vinfo,@resel, @fx, @usrcd public @mltio, @ermde, @erdsk, @media, @bflgs public @date, @hour,@min, @sec, ?erjmp, @mxtpa scb$base equ
0FE00H ; Base of the SCB@CIVEC equ scb$base+22h; Console Input Redirection Vector (word, r/w)
@COVEC equ scb$base+24h; Console Output Redirection Vector (word, r/w)
@AIVEC equ scb$base+26h; Auxiliary Input Redirection Vector (word, r/w)
@AOVEC equ scb$base+28h; Auxiliary Output Redirection Vector (word, r/w)
@LOVEC equ scb$base+2Ah; List Output Redirection Vector (word, r/w)
@BNKBF equ scb$base+35h; Address of 128 Byte Buffer for Banked BIOS (word, r/o)
@CRDMA equ scb$base+3Ch; Current DMA Address (word, r/o)
@CRDSK equ scb$base+3Eh; Current Disk (byte, r/o)
@VINFO equ scb$base+3Fh; BDOS Variable "INFO" (word, r/o)
@RESEL equ scb$base+41h; FCB Flag (byte, r/o)
@FX equ scb$base+43h; BDOS Function for Error Messages (byte, r/o)
@USRCD equ scb$base+44h; Current User Code (byte, r/o)
@MLTIO equ scb$base+4Ah; Current Multisector Count (byte,r/w)@ERMDE equ scb$base+4Bh; BDOS Error Mode (byte, r/o)

Digital Research : CP/M 3 System Manual@ERDSK equ scb$base+51h@MEDIA equ scb$base+54h@BFLGS equ scb$base+57h@DATE equ scb$base+58h@HOUR equ scb$base+5Ah@MIN equ scb$base+5Bh@SEC equ scb$base+5Ch?ERJMP equ scb$base+5Fh@MXTPA equ scb$base+62h
end

Page 22; BDOS Error Disk (byte, r/o)
; Set by BIOS to indicate open door (byte,r/w); BDOS Message Size Flag (byte,r/o); Date in Days Since 1 Jan 78 (word, r/w)
; Hour in BCD (byte, r/w)
; Minute in BCD (byte, r/w)
; Second in BCD (byte, r/w)
; BDOS Error Message Jump (3 bytes, r/w)
; Top of User TPA ; (address at 6,7)(word, r/o)

Listing 3-1. SCB.ASM File
The following table describes in detail each of the fields of the System Control Block.
Table 3-1. System Control Block Fields
Field

Meaning@CIVEC, @COVEC,@AIVEC, @AOVEC,@LOVEC(Read-Write Variables)

These fields are the 16 bit I/O redirection vectors for the five logical devices:
console input, console output, auxiliary input, auxiliary output, and the list
device. (See Section 3.4.2, "Character I/O Functions.")@BNKBF(Read-Only Variable)@BNKBF contains the address of a 128 byte buffer in the resident portion of
the BDOS in a banked system. This buffer is available for use during BOOT
and WBOOT only. You can use it to transfer a copy of the CCP from animage in an alternate bank if the system does not support interbank moves.

@CRDMA, @FX,@USRCD, @ERDSK(Read-Only Variables)

These variables contain the current DMA address, the BDOS function
number, the current user code, and the disk code of the drive on which the lasterror occurred. They can be displayed when a BDOS error is intercepted by
the BIOS. See ?ERJMP.

@CRDSK(Read-Only Variable)@CRDSK is the current default drive, set by BDOS Function 14.

@VINFO, @RESEL(Read-Only Variables)

If @RESEL is equal to OFFH then @VINFO contains the address of a valid
FCB. If @RESEL is not equal to OFFH, then @VINFO is undefined. You can
use @VINFO to display the filespec when the BIOS intercepts a BDOS error.

@MLTIO(Read-Write Variable)@MLTIO contains the current multisector count. The BIOS can change themultisector count directly, or through BDOS Function 44. The value of themultisector count can range from 1 to 128.

@ERMDE(Read-Only Variable)@ERMDE contains the current BDOS error mode. 0FFH indicates the BDOS
is returning error codes to the application program without displaying any
error messages. 0FEH indicates the BDOS is both displaying and returning
errors.
Any other value indicates the BDOS is displaying errors without notifying theapplication program.
@MEDIA is global system flag indicating that a drive door has been opened.

@MEDIA(Read-Write Variable)

The BIOS routine that detects the open drive door sets this flag to 0FFH. The
BIOS routine also sets the MEDIA byte in the Disk Parameter Header

Digital Research : CP/M 3 System Manual
Field

Page 23

Meaning
associated with the open-door drive to 0FFH.
The BDOS in CP/M 3 produces two kinds of error messages: short error
messages and extended error messages. Short error messages display one or
two lines of text. Long error messages display a third line of text containing
the filename, filetype, and BDOS Function Number involved in the error.

@BFLGS(Read-Only Variable)

In banked systems, GENCPM sets this flag in the System Control Block toindicate whether the BIOS displays short or extended error messages. Yourerror message handler should check this byte in the System Control Block. If
the high- order bit, bit 7, is set to 0, the BDOS displays short error messages.
if the high- order bit is set to 1, the BDOS displays the extended three-line
error messages.
For example, the BDOS displays the following error message if the BIOS
returns an error from READ and the BDOS is displaying long error messages.
CP/M Error on d: Disk I/O
BDOS Function = nn File = filename.typ
In the above error message, Function nn and filename.typ represent BDOS
function number and file specification involved, respectively.

@DATE(Read-Write Variable)

The number of days since 31 December 1977, expressed as a 16-bit unsigned
integer, low byte first. A real-time clock interrupt can update the @DATE
field to indicate the current date.

@HOUR, @MIN, @SEC
(Read-Write Variables)

These 2-digit Binary Coded Decimal (BCD) fields indicate the current hour,
minute, and second if updated by a real-time clock interrupt.
The BDOS calls the error message subroutine through this jump instruction.
Register C contains an error code as follows:
1 Permanent Error
2 Read Only Disk
3 Read Only File?ERJMP(Read-Write Code Label)

4 Select Error
7 Password Error
8 File Exists
9 ? in Filename
Error code 1 above results in the BDOS message Disk I/O.
The ?ERJMP vector allows the BIOS to intercept the BDOS error messages so
you can display them in a foreign language. Note that this vector is notbranched to if the application program is expecting return codes on physicalDigital Research : CP/M 3 System Manual
Field

Page 24

Meaning
errors. Refer to the CP/M Plus Programmer's Guide for more information.
?ERJMP is set to point to the default (English) error message routine
contained in the BDOS. The BOOT routine can modify the address at?ERJMP+L to point to an alternate message routine. Your error message
handler can refer to @FX, @VINFO (if @RESEL is equal to OFFH),@CRDMA, @CRDSK, and @USRCD to print additional error information.
Your error handler should return to the BDOS with a RET instruction after
printing the appropriate message.

@MXTPA(Read-Only Variable)@MXTPA contains the address of the current BDOS entry point. This is also
the address of the top of the TPA. The BOOT and WBOOT routines of theBIOS must use this address to initialize the BDOS entry JMP instruction at
location 005H, during system initialization. Each time a RSX is loaded,@MXTPA is adjusted by the system to reflect the change in the available
User Memory (TPA).

3.2 Character I/O Data Structures
TheBIOS data structure CHRTBL is a character table describing the physical I/O devices.
CHRTBL contains 6-byte physical device names and the characteristics of each physical device.
These characteristics include a mode byte, and the current baud rate, if any, of the device. The DEVICE utility
references the physical devices through the names and attributes contained in your CHRTBL. DEVICE can also
display the physical names and characteristics in your CHRTBL.
The mode byte specifies whether the device is an input or output device, whether it has a selectable baud rate,
whether it is a serial device, and if XON/XOFF protocol is enabled.
Listing 3-2 shows a sample character device table that the DEVICE utility uses to set and display I/O direction.
; sample character device table chrtbl
db 'CRT '; console VDT
db mb$in$out+mb$serial+mb$soft$baud
db baud$9600 db 'LPT '; system serial printerdb mb$output+mb$serial+mb$soft$baud+mb$xon
db baud$9600 db 'TI810 '; alternate printerdb mb$output+mb$serial+mb$soft$baud
db baud$9600 db 'MODEM '; 300 baud modem port
db mb$in$out+mb$serial+mb$soft$baud
db baud$300 db 'VAX '; interface to VAX 11/780
db mb$in$out+mb$serial+mb$soft$baud
db baud$9600 db 'DIABLO'; Diablo 630 daisy wheel printerdb mb$output+mb$serial+mb$soft$baud+mb$xon$xoff
db baud$1200 db 'CEN '; Centronics type parallel printerdb mb$output
db baud$none
db 0; table terminator

Listing 3-2. Sample Character Device Table

Digital Research : CP/M 3 System Manual

Page 25

Listing 3-3 shows the equates for the fields contained in the sample character device table. Many systems do
not support all of these baud rates.
; equates for mode byte fields
mb$input
equ 0000$000lb
mb$output
equ 0000$0010b
mb$in$out
equ mb$input+mb$output
mb$soft$baud
equ 0000$0100b
mb$serial
equ 0000$1000b
mb$xon$xoff
equ 0001$0000b; equates for baud rate byte
baud$none
equ 0
baud$50
equ 1
baud$75
equ 2
baud$110
equ 3
baud$134
equ 4
baud$150
equ 5
baud$300
equ 6
baud$600
equ 7
baud$1200
equ 8
baud$1800
equ 9
baud$2400
equ 10
baud$3600
equ 11
baud$4800
equ 12
baud$7200
equ 13
baud$9600
equ 14
baud$19200
equ 15; device may do input; device may do output; dev may do both
; software selectable baud rates; device may use protocol; XON/XOFF protocol; no baud rate associated with device; 50 baud; 75 baud; 110 baud
; 134.5 baud
; 150 baud
; 300 baud
; 600 baud
; 1200 baud
; 1800 baud
; 2400 baud
; 3600 baud
; 4800 baud
; 7200 baud
; 9600 baud
; 19.2k baud

Listing 3-3. Equates for Mode Byte Bit Fields

3.3 BIOS Disk Data Structures
The BIOS includes tables that describe the particular characteristics of the disk subsystem used with CP/M 3.
This section describes the elements of these tables.
In general, each disk drive has an associated Disk Parameter Header (DPH) that contains information about thedisk drive and provides a scratche>ad area for certain BDOS operations.
One of the elements of this Disk Parameter Header is a pointer to the Disk Parameter Block (DPB), whichcontains the actual disk description.
In the banked system, only the Disk Parameter Block must reside in common memory.
The DPHS, checksum vectors, allocation vectors, Buffer Control Blocks, and Directory Buffers can reside incommon memory or Bank 0. The hash tables can reside in common memory or any bank except Bank 1. The
data buffers can reside in banked memory if you implement the XMOVE function.
Figure 3-1 shows the relationships between the drive table, the Disk Parameter Header, and the Data and
Directory Buffer Control Block fields and their respective data structures and buffers.

Digital Research : CP/M 3 System Manual

Page 26

Figure 3-1. Disk Data Structures in a Banked System

3.3.1 Drive Table
The drive table consists of 16 words containing the addresses of the Disk Parameter Headers for each logicaldrive name, A through P, and takes the general form: drivetable dw dpho dw dphl dw dph2 dw dphf
If a logical drive does not exist in your system, the corresponding entry in the drive table must be zero.
The GENCPM utility accesses the drive table to locate the various disk parameter data structures, so that it candetermine which system configuration to use, and optionally allocate the various buffers itself. You must
supply a drive table if you want GENCPM to do this allocation.
If certain addresses in the Disk Parameter Headers referenced by this drive table are set to 0FFFEH, GENCPM
allocates the appropriate data structures and updates the DPH. You can supply the drive table even if you have
performed your own memory allocation. See the BIOS DRVTBL function described in Section 3.4.1.

3.3.2 Disk Parameter Header
In Figure 3-2, which shows the format of the Disk Parameter Header, b refers to bits.

Digital Research : CP/M 3 System Manual

Page 27

Figure 3-2. Disk Parameter Header Format
Table 3-2 describes the fields of the Disk Parameter Header.
Table 3-2. Disk Parameter Header Fields
Field

Comments
Set the XLT field to the address of the logical to hysical sector translation table. If there isno sector translation and the logical and physical sector numbers are the same, set XLT to
0000H. Disk drives with identical sector skew factors can share the same translation table.

XLT

XLT is the value passed to SECTRN in registers DE. Usually the translation tableconsists of one byte per physical sector. Generally, it is advisable to keep the number ofphysical sectors per logical track to a reasonable value to prevent the translation tablefrom becoming too large.
In the case of disks with multiple heads, you can compute the head number from the track
address rather than the sector address.

-0-

These 72 bits (9 bytes) of zeroes are the scratch area the BDOS uses to maintain various
parameters associated with the drive.

MF

MF is the Media Flag. The BDOS resets MF to zero when the drive is logged in. The
BIOS can set this flag and @MEDIA in the SCB to 0FFH if it detects that a drive door
has been opened. If the flag is set to 0FFH, the BDOS checks for a media change prior toperforming the next BDOS file operation on that drive. If the BDOS determines that thedrive contains a new volume, the BDOS performs a login on that drive, and resets the MF
flag to 00H. Note that the BDOS checks this flag only when a system call is made, andnot during an operation. Usually, this flag is used only by systems that support door-openinterrupts.

DPB

Set the DPB f ield to the address of a Disk Parameter Block that describes thecharacteristics of the disk drive. Several Disk Parameter Headers can address the same
Disk Parameter Block if their drive characteristics are identical. (The Disk Parameter
Block is described in Section 3.3.3.)
CSV is the address of a scratchpad area used to detect changed disks.

CSVThis address must be different for each removable media Disk Parameter Header. There
must be one byte for every 4 directory entries (or 128 bytes of directory). In other words,
length(CSV) = (DRM/4)+l. (See Table 3-3 for an explanation of the DRM field.) If thedrive is permanently mounted, set the CKS variable in the DPB to 8000H and set CSV to
0000H. This way, no storage is reserved for a checksum vector.
The checksum vector may be located in common memory or in Bank 0.
Set CSV to 0FFFEH for GENCPM to set up the checksum vector.

ALV

ALV is the address of the scratchpad area called the allocation vector, which the BDOS
uses to keep disk storage allocation information.

Digital Research : CP/M 3 System Manual

Page 28This area must be unique for each drive.
The allocation vector usually requires 2 bits for each block on the drive.
Thus, length(ALV) = (DSM/4) + 2.
(See Table 3-3 for an explanation of the DSM field.) In the nonbanked version of CP/M 3,
you can optionally specify that GENCPM reserve only one bit in the allocation vector per
block on the drive. In this case, length(ALV) = (DSM/8) +The GENCPM option to use single-bit allocation vectors is provided in the nonbanked
version of CP/M 3 because additional memory is required by the double-bit allocation
vector. This option applies to all drives on the system.
With double-bit allocation vectors, CP/M 3 automatically frees, at every system warm
start, all file blocks that are not permanently recorded in the directory. Note that file space
allocated to a f ile is not permanently recorded in a directory unless the file is closed.
Therefore, the allocation vectors in memory can indicate that space is allocated although
directory records indicate that space is free for allocation. With single-bit allocation
vectors, CP/M 3 requires that a drive be reset before this space can be reclaimed. Because
it increases performance, CP/M 3 does not reset disks at system warm start. Thus, withsingle-bit allocation vectors, if you do not reset the disk system, DIR and SHOW canreport an inaccurate amount of free space. With single-bit ALV allocation vectors, theuser must type a CTRL-C at the system prompt to reset the disk system to ensure accurate
reporting of free space. Set ALV to 0FFFEH for GENCPM to automatically assign space
for the allocation vector, single- or double-bit, during system generation. In thenonbanked system, GENCPM prompts for the type of allocation vector. In the banked
system, the allocation vector is always double-bit and can reside in common memory or
Bank 0. When GENCPM automatically assigns space for the allocation vector (ALV =0FFFEH) , it places the allocation vector in Bank 0.
Set DIRBCB to the address of a single directory Buffer Control Block (BCB) in an
unbanked system. Set DIRBCB to the address of a BCB list head in a banked system.

DIRBCBSet DIRBCB to 0FFFEH for GENCPM to set up the DIRBCB field. The BDOS uses
directory buffers for all accesses of the disk directory.
Several DPHs can refer to the same directory BCB or BCB list head; or, each DPH canreference an independent BCB or BCB list head.
Section 3.3.4 describes the format of the Buffer Control Block.
Set DTABCB to the address of a single data BCB in an unbanked system.
Set DTABCB to the address of a data BCB list head in a banked system.

DTABCBSet DTABCB to 0FFFEH for GENCPM to set up the DTABCB field.
The BDOS uses data buffers to hold physical sectors so that it can block and deblock
logical 128-byte records. If the physical record size of the media associated with a DPH is
128 bytes, you can set the DTABCB field of the DPH to 0FFFFH, because in this case,the BDOS does not use a data buffer.

HASH

HASH contains the address of the optional directory hashing table associated with a DPH.

Digital Research : CP/M 3 System Manual

Page 29Set HASH to 0FFFFH to disable directory hashing.
Set RASH to 0FFFEH to make directory hashing on the drive a GENCPM option. EachDPH using hashing must reference a unique hash table. If a hash table is supplied, it mustbe 4*(DRM+l) bytes long, where DRM is one less than the length of the directory. In
other words, the hash table must contain four bytes for each directory entry of the disk.

HBANK

Set HBANK to the bank number of the hash table. HBANK is not used in unbanked
systems and should be set to zero. The hash tables can be contained in the system bank,common memory, or any alternate bank except Bank 1, because hash tables cannot belocated in the Transient Program Area. GENCPM automatically sets HBANK when
HASH is set to 0FFFEH.

3.3.3 Disk Parameter Block
Figure 3-3 shows the format of the Disk Parameter Block, where b refers to bits.

Figure 3-3. Disk Parameter Block Format
Table 3-3 describes the fields of the Disk Parameter Block.
Table 3-3. Disk Parameter Block Fields
Field

Comments

SPT

Set SPT to the total number of 128-byte logical records per track.

BSH

Data allocation block shift factor. The value of BSH is determined by the data block
allocation size.

BLM

Block mask. The value of BLM is determined by the data block allocation size.

EXM

Extent mask determined by the data block allocation size and the number of disk blocks.

DSM

Determines the total storage capacity of the disk drive. DSM is one less than the total
number of blocks on the drive.

DRM

Total number of directory entries minus one that can be stored on this drive. The directory
requires 32 bytes per entry.

ALO, AL1 Determine reserved directory blocks. See Figure 3-4 for more information.

CKS

The size of the directory check vector, @DRM/4)+l. Set bit 15 of CKS to 1 if the drive ispermanently mounted. Set CKS to 8000H to indicate that the drive is permanently mounted
and directory checksumming is not required.
Note: full directory checksumming is required on removable media to support the automatic
login feature of CP/M 3.

OFF

The number of reserved tracks at the beginning of the logical disk. 0FF is the track on which
the directory starts.

PSH

Specifies the physical record shift factor.

Digital Research : CP/M 3 System Manual
PHM

Page 30

Specifies the physical record mask.

CP/M allocates disk space in a unit called a block. Blocks are also called allocation units, or clusters. BLS is thenumber of bytes in a block. The block size can be 1024, 2048, 4096, 8192, or 16384 (decimal) bytes.
A large block size decreases the size of the allocation vectors but can result in wasted disk space. A smaller
block size increases the size of the allocation vectors because there are more blocks on the same size disk.
There is a restriction on the block size. If the block size is 1024, there cannot be more than 255 blocks present
on a logical drive. In other words, if the disk is larger than 256K, it is necessary to use at least 2048 byte blocks.
The value of BLS is not a field in the Disk Parameter Block; rather, it is derived from the values of BSH and
BLM as given in Table 3-4.
Table 3-4. BSH and BLM Values
BLS

BSH BLM

1,024

3

7

2,048

4

15

4,096

5

31

8,192

6

63

16,384

7

127

The block mask, BLM, equals one less than the number of 128- byte records in an allocation unit, (BLS/128 1), or (2**BSH)-1.
The value of the Block Shift Factor, BSH, is determined by the data block allocation size. The Block Shift
Factor (BSH) equals the logarithm base two of the block size in 128-byte records, or LOG2 (BLS/128) , where
LOG2 represents the binary logarithm function.
The value of EXM depends upon both the BLS and whether the DSM value is less than 256 or greater than 255,
as shown in Table 3-5.
Table 3-5. Maximum EXK Values
BLS

EXM values
DSM<256

DSM>255

1,024

0

N/A

2,048

1

0

4,096

3

1

8,192

7

3

16,384 15

7

The value of EXM is one less than the maximum number of 16K extents per FCB.
Set EXM to zero if you want media compatibility with an extended CP/M 1.4 system.

Digital Research : CP/M 3 System Manual

Page 31This only applies to double-density CP/M 1.4 systems, with disk sizes greater than 256K bytes.
It is preferable to copy double-density 1.4 disks to single-density, then reformat them and recreate them with
the CP/M 3 system, because CP/M 3 uses directory entries more effectively than CP/M 1.4.
DSM is one less than the total number of blocks on the drive. DSM must be less than or equal to 7FFFH. If thedisk uses 1024 byte blocks (BSH=3, BLM=7), DSM must be less than or equal to 00FFH. The product
BLS*(DSM+l) is the total number of bytes the drive holds and must be within the capacity of the physical disk.
It does not include the reserved operating system tracks.
The DRM entry is one less than the total number of 32-byte directory entries, and is a 16-bit value. DRM mustbe less than or equal to (BLS/32 * 16) - 1. DRM determines the values of AL0 and ALI. The two fields AL0
and ALI can together be considered a string of 16 bits, as shown in Figure 3 -4.

Figure 3-4. ALO and ALI
Position 00 corresponds to the high-order bit of the byte labeled AL0, and position 15 corresponds to the loworder bit of the byte labeled ALI. Each bit position reserves a data block for a number of directory entries, thus
allowing a maximum of 16 data blocks to be assigned for directory entries. Bits are assigned starting at 00 andfilled to the right until position 15.
AL0 and ALI overlay the first two bytes of the allocation vector for the associated drive. Table 3 -6 shows DRM
maximums for the various block sizes.
Table 3-6. BLS and Number of Directory Entries
BLS

Directory Entries

Maximum DRM

1,024

32 * reserved blocks

511

2,048

64 * reserved blocks

1,023

4,096 128 * reserved blocks

2,047

8,192 256 * reserved blocks

4,095

16,384 512 * reserved blocks

8,191

If DRM = 127 (128 directory entries) , and BLS = 1024, there are 32 directory entries per block, requiring 4
reserved blocks. In this case, the 4 high-order bits of AL0 are set, resulting in the values AL0 = OF0H and AL1= 00H. The maximum directory allocation is 16 blocks where the block size is determined by BSH and BLM.
The OFF field determines the number of tracks that are skipped at the beginning of the physical disk. It can beused as a mechanism for skipping reserved operating system tracks, which on system disks contain the Cold
Boot Loader, CPMLDR, and possibly the CCP. It is also used to partition a large disk into smaller segmented
sections.

PSH and PHM determine the physical sector size of the disk. All disk I/O is in terms of the physical sector size.
Set PSH and PSM to zero if the BIOS is blocking and deblocking instead of the BDOS.

Digital Research : CP/M 3 System Manual

Page 32

PSH specifies the physical record shift factor, ranging from 0 to 5, corresponding to physical record sizes of128, 256, 512, 1K, 2K, or 4K bytes. It is equal to the logarithm base two of the physical record size divided by
128, or LOG2(sector-size/128). See Table 3-7 for PSH values.
PHM specifies the physical record mask, ranging from 0 to 31, corresponding to physical record sizes of 128,
256, 512, 1K, 2K, or 4K bytes. It is equal to one less than the sector size divided by 128, or, (sector -size/128)-1.
See Table 3-7 for PHM values.
Table 3-7. PSH and PHN Values
Sector size PSH PHM
128

0

0

256

1

1

512

2

3

1,024

3

7

2,048

4

15

4,096

5

31

3.3.4 Buffer Control BlockA Buffer Control Block (BCB) locates physical record buffers for the BDOS. The BDOS uses the BCB tomanage the physical record buffers during processing. More than one Disk Parameter Header can specify thesame BCB. The GENCPM utility can create the Buffer Control Block.
Note that the BANK and LINK fields of the Buffer Control Block are present only in the banked system.
Therefore, the Buffer Control Block is twelve bytes long in the nonbanked system, and fifteen bytes long in thebanked system. Note also that only the DRV, BUFFAD, BANK, and LINK fields need to contain initial values.
In Figure 3-5, which shows the form of the Buffer Control Block, b refers to bits.

Figure 3-5. Buffer Control Block Format
Table 3-8 describes the fields of each Buffer Control Block.
Table 3-8. Buffer Control Block Fields
Field

Comment

DRV

Identifies the disk drive associated with the record contained in the buffer located ataddress BUFFAD. If you do not use GENCPM to allocate buffers, you must set the DRV
field to 0FFH.

REC#

Identifies the record position of the current contents of the buffer located at address
BUFFAD. REC# consists of the absolute sector number of the record where the firstrecord of the directory is zero.

WFLG

Set by the BDOS to OFFH to indicate that the buffer contains new data that has not yet

Digital Research : CP/M 3 System Manual

Page 33

been written to disk. When the data is written, the BDOS sets the WFLG to zero toindicate the buffer is no longer dirty.
00
TRACK

Scratch byte used by BDOS.
Contains the physical track location of the contents of the buffer.

SECTOR Contains the physical sector location of the contents of the buffer.
BUFFAD Specifies the address of the buffer associated with this BCB.
BANKContains the bank number of the buffer associated with this BCB. This field is only
present in banked systems.

LINK

Contains the address of the next BCB in a linked list, or zero if this is the last BCB in thelinked list. The LINK field is present only in banked systems.

The BDOS distinguishes between two kinds of buffers: data buffers referenced by DTABCB, and directory
buffers referenced by DIRBCB. In a banked system, the DIRBCB and DTABCB fields of a Disk Parameter
Header each contain the address of a BCB list head rather than the address of an actual BCB. A BCB list headis a word containing the address of the first BCB in a linked list. If several DPHs reference the same BCB list,
they must reference the same BCB list head. Each BCB has a LINK field that contains the address of the next
BCB in the list, or zero if it is the last BCB.
In banked systems, the one-byte BANK field indicates the bank in which the data buffers are located. The
BANK field of directory BCBs must be zero because directory buffers must be located in Bank 0, usually
below the banked BDOS module, or in common memory. The BANK field is for systems that support direct
memory-to-memory transfers from one bank to another. (See the BIOS XMOVE entry point in section 3.4.4.)
The BCD data structures in a banked system must reside in Bank 0 or in common memory.
The buffers of data BCBs can be located in any bank except Bank I (the Transient Program Area).
For banked systems that do not support interbank block moves through XMOVE, the BANK field must be set
to 0 and the data buffers must reside in common memory. The directory buffers can be in Bank 0 even if thesystem does not support bank-to-bank moves.
In the nonbanked system, the DPH, DIRBCB, and DTABCB can point to the same BCB if the DPH defines afixed media device. For devices with removable media, the DPH DIRBCB and the DPH DTABCB mustreference different BCBS. In banked systems, the DPH DIRBCB and DTABCB must point to separate list
heads.
In general, you can enhance the performance of CP/M 3 by allocating more BCBS, but the enhancement
reduces the amount of TPA memory in nonbanked systems.
If you set the DPH DIRBCB or the DPH DTABCB fields to 0FFFEH, the GENCPM utility creates BCBS,
allocates physical record buffers, and sets these f ields to the address of the BCBS.
This allows you to write device drivers without regard to buffer requirements.

3.3.5 Data Structure Macro Definitions
Several macro definitions are supplied with CP/M 3 to simplify the creation of some of the data structures in
the BIOS. These macros are defined in the library file CPM3.LIB on the distribution disk.
To reference these macros in your BIOS, include the following statement:

Digital Research : CP/M 3 System Manual

Page 34

MACLIB CPM3
DTBL Macro
Use the DTBL macro to generate the drive table, DRVTBL. It has one parameter, a list of the DPHs in yoursystem. The list is enclosed in angle brackets.
The form of the DTBL macro call is label: DTBL <DPHA,DPHB,...,DPHP> where DPHA is the address of the
DPH for drive A, DPHB is the address of the DPH for drive B, up to drive P. For example, DRVTBL: DTBL
<ACSHDO,FDSDO,FDSD1>This example generates the drive table for a three-drive system. The DTBL macro always generates a sixteenword table, even if you supply fewer DPH names.
The unused entries are set to zero to indicate the corresponding drives do not exist.
DPH Macro
The DPH macro routine generates a Disk Parameter Header (DPH) . It requires two parameters: the address ofthe skew table for this drive, and the address of the Disk Parameter Block (DPB) . Two parameters are optional:
the maximum size of the checksum vector, and the maximum size of the allocation vector. If you omit the
maximum size of the checksum vector and the maximum size of the allocation vector from the DPH macro
invocation, the corresponding fields of the Disk Parameter Header are set to 0FFFEH so that GENCPM
automatically allocates the vectors.
The form of the DPH macro call is label: DPH ?trans,?dpb [,?csize] [,?asize] where:?trans is the address of the translation vector for this drive;?dpb is the address of the DPB for this drive;?csize is the maximum size in bytes of the checksum vector;?asize is the maximum size in bytes of the allocation vector.
The following example, which includes all four parameters, shows a typical DPH macro invocation for astandard single-density disk drive:
FDSDO: DPH SKEW6,DPB$SD,16,31

SKEW Macro
The SKEW macro generates a skew table and requires the following parameters: the number of physical sectors
per track, the skew factor, and the first sector number on each track (usually 0 or 1).
The form of the SKEW macro call is label: SKEW ?secs,?skf,?fsc where:?secs is the number of physical sectors per track;?skf is the sector skew factor;?fsc is the first sector number on each track.
The following macro invocation generates the skew table for a standard single-density disk drive.
SKEW6: SKEW 26,6,1

DPB Macro

Digital Research : CP/M 3 System Manual

Page 35

The DPB macro generates a Disk Parameter Block specifying the characteristics of a drive type. It requires six
parameters: the physical sector size in bytes, the number of physical sectors per track, the total number of tracks
on the drive, the size of an allocation unit in bytes, the number of directory entries desired, and the number ofsystem tracks to reserve at the beginning of the drive. There is an optional seventh parameter that defines the
CKS field in the DPB. If this parameter is missing, CKS is calculated from the directory entries parameter.
The form of the DPB macro call is label: DPB ?psize,?pspt,?trks,?bls,?ndirs,?off[,?ncks] where:?psize is the physical sector size in bytes;?pspt is the number of physical sectors per track;?trks is the number of tracks on the drive;?bls is the allocation unit size in bytes;?ndirs is the number of directory entries;?off is the number of tracks to reserve;?ncks is the number of checked directory entries.
The following example shows the parameters for a standard single-density disk drive:
DPB$SD: DPB 128,26,77,1024,64,2

The DPB macro can be used only when the disk drive is under eight megabytes. DPBs for larger disk drives
must be constructed by hand.

3.4 BIOS Subroutine Entry Points
This section describes the entry parameters, returned values, and exact responsibilities of each BIOS entry pointin the BIOS jump vector. The routines are arranged by function.
Section 3.4.1 describes system initialization. Section 3.4.2 presents the character I/O functions, followed by
Section 3.4.3, discussing the disk I/O functions. Section 3.4.4 discusses the BIOS memory select and movefunctions. The last section, 3.4.5, discusses the BIOS clock support function. Table 3 -9 shows the BIOS entry
points the BDOS calls to perform each of the four categories of system functions.
Table 3-9. Functional Organization of BIOS Entry Points
Operation

Function

System Initialization BOOT, WBOOT, DEVTBL, DEVINI, DRVTBL,
Character I/O
Disk I/O

CONST, CONIN, CONOUT, LIST, AUXOUT, AUXIN, LISTST,CONOST, AUXIST, AUXOSTHOME, SELDSK, SETTRK, SETSEC, SETDMA, READ, WRITE,SECTRN, MULTIO, FLUSH

Memory Selects and Moves MOVE, XMOVE, SELMEM, SETBNKClock Support TIME
Table 3-10 is a summary showing the CP/M 3 BIOS function numbers, jump instruction names, and the entry
and return parameters of each jump instruction in the table, arranged according to the BIOS function number.
Table 3-10. CP/M 3 BIOS Function Jump Table Sunmary
No. Function

Input

OutputDigital Research : CP/M 3 System Manual
No. Function

Input

Output

0

BOOT

None

None

1

WBOOT

None

None

2

CONST

None

A=0FFH if ready
A=00H if not ready

3

CONIN

None

A=Console Character

4

CONOUT C=Con Char
C=CharNone

6

AUXOUT C=Char

None

7

AUXIN

None

A=Char

8

HOME

None

None

9

SELDSK

C=Drive 0-15
HL=DPH addr
E=Init Sel Flag

HL=0000H if invalid drive

10

SETTRK

BC=Track No

None

11

SETSECBC=Sector No

None

12

SETDMA BC=.DMA

None

13

READ

None

A=00H if no Error
A=01H if Non-recov Err
A=0FFH if media changed

5

LIST

None

14

WRITE

C=Deblk Code

A=00H if no Error
A=01H if Physical Error
A=02H if Disk is R/O
A=0FFH if media changed

15

LISTST

None

A=00H if not ready
A=0FFH if ready

16

SECTRN

BC=Log Sect No
DE=Trans Tbl Adr

HL=Physical Sector Number

17

CONOST None

A=00H if not ready
A=0FFH if ready18

AUXIST

None

A=0H if not ready
A=0FFH if ready19

AUXOST None

A=00H if not ready
A=0FFH if ready20

DEVTBL None

HL=Chrtbl addr

21

DEVININone

22

DRVTBL None

C=Dev No 0-15

HL=Drv Tbl addr
HL=0FFFFH
HL=0FFFEH

Page 36

Digital Research : CP/M 3 System Manual
No. Function

Input

MULTIO

C=Mult Sec Cnt

None

23

Page 37

Output

24

FLUSH

None

A=00H if no err
A=01H if phys err
A=02H if disk R/O

25

MOVE

BC=Count
DE=Source Adr
HL=Dest Adr

HL & DE point to next bytes
following MOVE

26

TIME

C=Get/Set Flag

None

27

SELMEM A=Mem Bank

None

28

SETBNK

A=Mem Bank

None

29

XMOVE

B=Dest Bank
C=Source Bank

None

30

USERF

Reserved for
System Implementor

31

RESERV1 Reserved for Future Use

32

RESERV2 Reserved for Future Use

3.4.1 System Initialization Functions
This section defines the BIOS system initialization routines BOOT, WBOOT, DEVTBL, DEVINI, and
DRVTBL.
BIOS Function 0: BOOT
Get Control from Cold Start Loader and Initialize System
Entry Parameters: None
Returned Values: None
The BOOT entry point gets control from the Cold Start Loader in Bank 0 and is responsible for basic system
initialization. Any remaining hardware initialization that is not done by the boot ROMS, the Cold Boot Loader,or the LDRBIOS should be performed by the BOOT routine.
The BOOT routine must perform the system initialization outlined in Section 2.3, "System Initialization." This
includes initializing Page Zero jumps and loading the CCP.
BOOT usually prints a sign-on message, but this can be omitted. Control is then transferred to the CCP in the
TPA at 0100H.
To initialize Page Zero, the BOOT routine must place a jump at location 0000H to BIOS base + 3, the BIOS
warm start entry point. The BOOT routine must also place a jump instruction at location 0005H to the addresscontained in the System Control Block variable, @MXTPA.
The BOOT routine must establish its own stack area if it calls any BDOS or BIOS routines. In a banked system,
the stack is in Bank 0 when the Cold BOOT routine is entered.

Digital Research : CP/M 3 System Manual

Page 38

The stack must be placed in common memory.
BIOS Function 1: WBOOT
Get Control When a Warm Start Occurs
Entry Parameters: None
Returned Values: None
The WBOOT entry point is entered when a warm start occurs. A warm start is performed whenever a user
program branches to location 0000H or attempts to return to the CCP. The WBOOT routine must perform thesystem initialization outlined in BIOS Function 0, including initializing Page zero jumps and loading the CCP.
When your WBOOT routine is complete, it must transfer control to the CCP at location 0100H in the TPA.
Note that the CCP does not reset the disk system at warm start. The CCP resets the disk system when a CTRL C is pressed following the system prompt.
Note also that the BIOS stack must be in common memory to make BDOS function calls.
Only the BOOT and WBOOT routines can perform BDOS function calls.
If the WBOOT routine is reading the CCP from a file, it must set the multisector I/O count, @MLTIO in the
System Control Block, to the number of 128-byte records to be read in one operation before reading
CCP.COM. You can directly set @MLTIO in the SCB, or you can call BDOS Function 44 to set themultisector count in the SCS.
If blocking/deblocking is done in the BIOS instead of in the BDOS, the WBOOT routine must discard all
pending buffers.
BIOS Function 20: DEVTBL
Return Address of Character I/O Table
Entry Parameters: None
Returned Values:
HL=address of Chrtbl

The DEVTBL and DEVINI entry points allow you to support device assignment with a flexible, yet completely
optional system. It replaces the IOBYTE facility of CP/M 2.2. Note that the CHRTBL must be in common inbanked systems.
BIOS Function 21: DEVINI
Initialize Character I/O Device
Entry Parameters:
C=device number, 0-15

Returned Values: None

Digital Research : CP/M 3 System Manual

Page 39

The DEVINI routine initializes the physical character device specif ied in register C to the baud rate containedin the appropriate entry of the CHRTBL. It need only be supplied if I/O redirection has been implemented andis referenced only by the DEVICE utility supplied with CP/M 3.
BIOS Function 22: DRVTBL
Return Address of Disk Drive Table
Entry Parameters: None
Returned Values:
HL=Address of Drive Table of Disk Parameter Headers (DPH);

Hashing can utilized if specified by the DPHs Referenced by this DRVTBL.
HL=0FFFFH if no Drive Table; GENCPM does not set up buffers.

Hashing is supported.
HL=0FFFEH if no Drive Table; GENCPM does not set up buffers.

Hashing is not supported.
The first instruction of this subroutine must be an LXI H,<address> where <address> is one of the above
returned values. The GENCPM utility accesses the address in this instruction to locate the drive table and thedisk parameter data structures to determine which system configuration to use.
If you plan to do your own blocking/deblocking, the first instruction of the DRVTBL routine must be thefollowing: lxi h,0FFFEh
You must also set the PSH and PSM fields of the associated Disk Parameter Block to zero.

3.4.2 Character I/O Functions
This section defines the CP/M 3 character I/O routines CONST, CONIN, CONOUT, LIST, AUXOUT,AUXIN, LISTST, CONOST, AUXIST, and AUXOST.
CP/M 3 assumes all simple character I/O operations are performed in eight-bit ASCII, upper and lowercase,with no parity. ANASCII CTRL-Z (lAH) denotes an end-of-file condition for an input device.
In CP/M 3, you can direct each of the five logical character devices to any combination of up to twelve physicaldevices. Each of the five logical devices has a 16-bit vector in the System Control Block (SCB) . Each bit of thevector represents a physical device where bit 15 corresponds to device zero, and bit 4 is device eleven. Bits 0
through 3 are reserved for future system use.
You can use the public names defined in the supplied SCB.ASM file to reference the I/O redirection bit vectors.
The names are shown in Table 3-11.
Table 3-11. I/O Redirection Bit Vectors in SCB
Name

Logical Device@CIVEC

Console Input@COVEC Console Output

Digital Research : CP/M 3 System Manual@AIVEC

Page 40

Auxiliary Input@AOVEC Auxiliary Output@LOVEC List Output
You should send an output character to all of the devices whose corresponding bit is set.
An input character should be read from the first ready device whose corresponding bit is set.
An input status routine should return true if any selected device is ready. An output status routine should return
true only if all selected devices are ready.
BIOS Function 2: CONST
Sample the Status of the Console Input Device
Entry Parameters: None
Returned value:
A=0FFH if a console character is ready to read
A=00H if no console character is ready to read

Read the status of the currently assigned console device and return 0FFH in register A if a character is ready toread, and 00H in register A if no console characters are ready.
BIOS Function 3: CONIN
Read a Character from the Console
Entry Parameters: None
Returned Values:
A=Console Character

Read the next console character into register A with no parity. If no console character is ready, wait until acharacter is available'before returning.
BIOS Function 4: CONOUT
Output Character to Console
Entry Parameters:
C=Console Character

Returned Values: None
Send the character in register C to the console output device. The character is in ASCII with no parity.
Character I/O Functions
BIOS Function 5: LIST

Digital Research : CP/M 3 System Manual

Page 41

Output Character to List Device
Entry Parameters:
C=Character

Returned Values: None
Send the character from register C to the listing device. The character is in ASCII with no parity.
BIOS Function 6: AUXOUT
Output a Character to the Auxiliary Output Device
Entry Parameters:
C=Character

Returned Values: None
Send the character from register C to the currently assigned AUXOUT device. The character is in ASCII withno parity.
BIOS Function 7: AUXIN
Read a Character from the Auxiliary Input Device
Entry Parameters: None
Returned Values:
A=Character

Read the next character from the currently assigned AUXIN device into register A with no parity. A returned
ASCII CTRL-Z (lAH) reports an end-of-file.
BIOS Function 15: LISTST
Return the Ready Status of the List Device
Entry Parameters: None
Returned Values:
A=00H if list device is not ready to accept a character
A=0FFH if list device is ready to accept a character

The BIOS LISTST function returns the ready status of the list device.
BIOS Function 17: CONOST
Return Output Status of Console
Entry Parameters: None

Digital Research : CP/M 3 System Manual

Page 42Returned Values:
A=0FFH if ready
A=00H if not ready

The CONOST routine checks the status of the console. CONOST returns an OFFH if the console is ready todisplay another character. This entry point allows for full polled handshaking communications support.
BIOS Function 18: AUXISTReturn Input Status of Auxiliary Port
Entry Parameters: None
Returned Values:
A=0FFH if ready
A=00H if not ready

The AUXIST routine checks the input status of the auxiliary port. This entry point allows full polledhandshaking for communications support using an auxiliary port.
BIOS Function 19: AUXOST
Return Output Status of Auxiliary Port
Entry Parameters: None
Returned Values:
A=0FFH if ready
A=00H if not ready

The AUXOST routine checks the output status of the auxiliary port. This routine allows full polled handshaking
for communications support using an auxiliary port.

3.4.3 Disk I/O Functions
This section defines the CP/M 3 BIOS disk I/O routines HOME, SELDSK, SETTRK, SETSEC, SETDMA,
READ, WRITE, SECTRN, MULTIO, and FLUSH.
BIOS Function 8: HOME
Select Track 00 of the Specified Drive
Entry Parameters: None
Returned Values: None
Return the disk head of the currently selected disk to the track 00 position. Usually, you can translate the
HOME call into a call on SETTRK with a parameter of 0.
BIOS Function 9: SELDSK
Select the Specified Disk Drive

Digital Research : CP/M 3 System Manual

Page 43

Entry Parameters:
C=Disk Drive (0-15)
E=Initial Select Flag

Returned Values:
HL=Address of Disk Parameter
Header (DPH) if drive exists
HL=0000H if drive does not exist

Select the disk drive specified in register C for further operations, where register C contains 0 for drive A, 1 fordrive B, and so on to 15 for drive P. On each disk select, SELDSK must return in HL the base address of a 25 byte area called the Disk Parameter Header. If there is an attempt to select a nonexistent drive, SELDSK returns
HL=0000H as an error indicator.
On entry to SELDSK, you can determine if it is the first time the specified disk is selected. Bit 0, the leastsignificant bit in register E, is set to 0 if the drive has not been previously selected. This information is ofinterest in systems that read configuration information from the disk to set up a dynamic disk definition table.
When the BDOS calls SELDSK with bit 0 in register E set to 1, SELDSK must return the same Disk Parameter
Header address as it returned on the initial call to the drive. SELDSK can only return a 00H indicating an
unsuccessful select on the initial select call.
SELDSK must return the address of the Disk Parameter Header on each call. Postpone the actual physical disk
select operation until a READ or WRITE is performed, unless I/O is required for automatic density sensing.
BIOS Function 10: SETTRK
Set Specified Track Number
Entry Parameters:
BC=Track Number

Returned Values: None
Register BC contains the track number for a subsequent disk access on the currently selected drive. Normally,
the track number is saved until the next READ or WRITE occurs.
BIOS Function 11: SETSEC
Set Specified Sector Number
Entry Parameters:
BC=Sector Number

Returned Values: None
Register BC contains the sector number for the subsequent disk access on the currently selected drive. This
number is the value returned by SECTRN. Usually, you delay actual sector selection until a READ or WRITE
operation occurs.
BIOS Function 12: SETDMADigital Research : CP/M 3 System Manual

Page 44

Set Address for Subsequent Disk I/O
Entry Parameters:
BC=Direct Memory Access Address

Returned Values: None
Register BC contains the DMA (Direct Memory Access) address for the subsequent READ or WRITE
operation. For example, if B = 00H and C = 80H when the BDOS calls SETDMA, then the subsequent read
operation reads its data starting at 80H, or the subsequent write operation gets its data from 80H, until the next
call to SETDMA occurs.
BIOS Function 13: READ
Read a Sector from the Specified Drive
Entry Parameters: None
Returned Values:
A=000H if no errors occurred
A=001H if nonrecoverable error condition occurred
A=0FFH if media has changed

Assume the BDOS has selected the drive, set the track, set the sector, and specified the DMA address. T he
READ subroutine attempts to read one sector based upon these parameters, then returns one of the error codes
in register A as described above.
If the value in register A is 0, then CP/M 3 assumes that the disk operation completed properly. If an error
occurs, the BIOS should attempt several retries to see if the error is recoverable before returning the error code.
If an error occurs in a system that supports automatic density selection, the system should verify the density ofthe drive. If the density has changed, return a OFFH in the accumulator.
This causes the BDOS to terminate the current operation and relog in the disk.
BIOS Function 14: WRITE
Write a Sector to the Specified Disk
Entry Parameters:
C=Deblocking Codes

Returned Values:
A=00H if no error occurred
A=001H if physical error occurred
A=002H if disk is Read-Only
A=0FFH if media has changed

Write the data from the currently selected DMA address to the currently selected drive, track, and sector. Upon
each call to WRITE, the BDOS provides the following information in register C:

Digital Research : CP/M 3 System Manual

Page 45

0 = deferred write
1 = nondeferred write
2 = deferred write to the first sector of a new data block
This information is provided for those BIOS implementations that do blocking/deblocking in the BIOS insteadof the BDOS.
As in READ, the BIOS should attempt several retries before reporting an error.
If an error occurs in a system that supports automatic density selection, the system should verify the density ofthe drive. If the density has changed, return a 0FFH in the accumulator. This causes the BDOS to terminate thecurrent operation and relog in the disk.
BIOS Function 16: SECTRN
Translate Sector Number Given Translate Table
Entry Parameters:
BC=Logical Sector Number
DE=Translate Table Address

Returned Values:
HL=Physical Sector Number

SECTRN performs logical sequential sector address to physical sector translation to improve the overall
response of CP/M 3. Digital Research ships standard CP/M disk with a skew factor of 6, where six physicalsectors are skipped between each logical read operation. This skew factor allows enough time between sectors
for most programs on a slow system to process their buffers without missing the next sector. In computer
systems that use fast processors, memory, and disk subsystems, you can change the skew factor to improveoverall response.
Typically, most disk systems perform well with a skew of every other physical sector. You should maintainsupport of single-density, IBM 3740 compatible disks using a skew factor of 6 in your CP/M 3 system to allow
information transfer to and from other CP/M users.
SECTRN receives a logical sector number in BC, and a translate table address in DE. The logical sector number
is relative to zero. The translate table address is obtained from the Disk Parameter Block for the currently
selected disk. The sector number is used as an index into the translate table, with the resulting physical sector
number returned in HL. For standard, single-density, eight- inch disk systems, the tables and indexing code areprovided in the sample BIOS and need not be changed.
Certain drive types either do not need skewing or perform the skewing externally from the system software. In
this case, the skew table address in the DPH can be set to zero, and the SECTRN routine can check for the zeroin DE and return with the physical sector set to the logical sector.
BIOS Function 23: MULTIO
Set Count of Consecutive Sectors for READ or WRITE
Entry Parameters:
C=Multisector Count

Digital Research : CP/M 3 System Manual

Page 46

Returned Values: None
To transfer logically consecutive disk sectors to or from contiguous memory locations, the BDOS issues a
MULTIO call, followed by a series of READ or WRITE calls. This allows the BIOS to transfer multiple sectors
in a single disk operation. The maximum value of the sector count is dependent on the physical sector size,
ranging from 128 with 128-byte sectors, to 4 with 4096-byte sectors. Thus, the BIOS can transfer up to 16K
directly to or from the TPA with a single operation.
The BIOS can directly transfer all of the specified sectors to or from the DMA buffer in one operation and thencount down the remaining calls to READ or WRITE.
If the disk format uses a skew table to minimize rotational latency when single records are transferred, it ismore difficult to optimize transfer time for multisector transfers.
One way of utilizing the multisector count with a skewed disk format is to place the sector numbers andassociated DMA addresses into a table until either the residual multisector count reaches zero, or the tracknumber changes. Then you can sort the saved requests by physical sector to allow all of the required sectors on
the track to be read in one rotation. Each sector must be transferred to or from its proper DMA address.
When an error occurs during a multisector transfer, you can either reset the multiple sector counters in the
BIOS and return the error immediately, or you can save the error status and return it to the BDOS on the last
READ or WRITE call of the MULTIO operation.
BIOS Function 24: FLUSH
Force Physical Buffer Flushing for User-supported Deblocking
Entry Parameters: None
Returned Values:
A=00H if no error occurred
A=001H if physical error occurred
A=002H if disk is Read-Only

The flush buffers entry point allows the system to force physical sector buffer flushing when your BIOS isperforming its own record blocking and deblocking.
The BDOS calls the FLUSH routine to ensure that no dirty buffers remain in memory. The BIOS should
immediately write any buffers that contain unwritten data.
Normally, the FLUSH function is superfluous, because the BDOS supports blocking/deblocking internally. It is
required, however, for those systems that support blocking/deblocking in the BIOS, as many CP/M 2.2 systems
do.
Note: if you do not implement FLUSH, the routine must return a zero in register A. You can accomplish thiswith the following instructions: xra a ret

3.4.4 Memory Select and Move Functions
This section defines the memory management functions MOVE, XMOVE, SELMEM, and SETBNK.
BIOS Function 25: MOVE
Memory-to-Memory Block Move

Digital Research : CP/M 3 System Manual

Page 47

Entry Parameters:
HL=Destination address
DE=Source address

BC=Count
Returned Values:
HL and DE must point to next bytes following move operation

The BDOS calls the MOVE routine to perform memory to memory block moves to allow use of the Z80 LDIR
instruction or special DMA hardware, if available. Note that the arguments in HL and DE are reversed from theZ8O machine instruction, necessitating the use of XCHG instructions on either side of the LDIR. The BDOS
uses this routine for all large memory copy operations. On return, the HL and DE registers are expected to point
to the next bytes following the move.
Usually, the BDOS expects MOVE to transfer data within the currently selected bank or common memory.
However, if the BDOS calls the XMOVE entry point before calling MOVE, the MOVE routine must perform
an interbank transfer.
BIOS Function 27: SELMEM
Select Memory Bank
Entry Parameters:
A=Memory Bank

Returned Values; None
The SELMEM entry point is only present in banked systems. The banked version of the CP/M 3 BDOS calls
SELMEM to select the current memory bank for further instruction execution or buffer references. You must
preserve or restore all registers other than the accumulator, A, upon exit.
BIOS Function 28: SETBNKSpecify Bank for DMA Operation
Entry Parameters:
A=Memory Bank

Returned Values: None
SETBNK only occurs in the banked version of CP/M 3. SETBNK specifies the bank that the subsequent disk
READ or WRITE routine must use for memory transfers. The BDOS always makes a call to SETBNK to
identify the DMA bank before performing a READ or WRITE call. Note that the BDOS does not referencebanks other than 0 or 1 unless another bank is specified by the BANK field of a Data Buffer Control Block(BCB).
BIOS Function 29: XMOVE
Set Banks for Following MOVE

Digital Research : CP/M 3 System Manual

Page 48

Entry Parameters:
B=destination bank
C=source bank

Returned Values: NoneXMOVE is provided for banked systems that support memory-to- memory DMA transfers over the entire
extended address range. Systems with this feature can have their data buffers located in an alternate bankinstead of in common memory, as is usually required. An XMOVE call affects only the following MOVE call.
All subsequent MOVE calls apply to the memory selected by the latest call to SELMEM. After a call to the
XMOVE function, the following call to the MOVE function is not more than 128 bytes of data. If you do not
implement XMOVE, the first instruction must be a RET instruction.

3.4.5 Clock Support Function
This section defines the clock support function TIME.
BIOS Function 26: TIME
Get and Set Time
Entry Parameters:
C=Time Get/Set Flag

Returned values: None
The BDOS calls the TIME function to indicate to the BIOS whether it has just set the Time and Date fields in
the SCB, or whether the BDOS is about to get the Time and Date from the SCB. On entry to the TIME
function, a zero in register C indicates that the BIOS should update the Time and Date fields in the SCB. A
OFFH in register C indicates that the BDOS has just set the Time and Date in the SCB and the BIOS should
update its clock. Upon exit, you must restore register pairs HL and DE to their entry values.
This entry point is for systems that must interrogate the clock to determine the time.
Systems in which the clock is capable of generating an interrupt should use an interrupt service routine to set
the Time and Date fields on a regular basis.

3.5 Banking Considerations
This section discusses considerations for separating your BIOS into resident and banked modules. You canplace part of your customized BIOS in common memory, and part of it in Bank 0. However, the following data
structures and routines must remain in common memory:








the BIOS stack
the BIOS jump vector
Disk Parameter Blocks
memory management routines
the CHRTBL data structure
all character I/O routines
portions of the disk I/O routines

Digital Research : CP/M 3 System Manual

Page 49

You can place portions of the disk I/O routines in the system bank, Bank 0. In a banked environment, if the disk
I/O hardware supports DMA transfers to and from banks other than the currently selected bank, the disk I/Odrivers can reside in Bank 0. If the system has a DMA controller that supports block moves from memory tomemory between banks, CP/M 3 also allows you to place the blocking and deblocking buffers in any bankother than Bank 1, instead of common memory.
If your disk controller supports data transfers only into the currently selected bank, then the code that initiates
and performs a data transfer must reside in common memory. In this case, the disk I/O transfer routines mustselect the DMA bank, perform the transfer, then reselect Bank 0.
The routine in common memory performs the following procedure:
1) Selects the DMA bank that SETBNK saved.
2) Performs physical I/O.
3) Reselects Bank 0.
4) Returns to the calling READ or WRITE routine in Bank 0.
Note that Bank 0 is in context (selected) when the BDOS calls the system initialization functions BOOT and
DRVTBL; the disk I/O routines HOME, SELDSK, SETTRK, SETSEC, SETDMA, READ, WRITE, SECTRN,MULTIO, and FLUSH; and the memory management routines KMOVE and SETBNK.
Bank 0 or Bank 1 is in context when the BDOS calls the system initialization routines WBOOT, DEVTBL, andDEVINI; the character I/O routines CONST, CONIN, CONOUT, LIST, AUXOUT, AUXIN, LISTST,CONOST, AUXIST, and AUXOST, the memory select and move routines MOVE and SELMEM, and theclock support routine TIME.
You can place a portion of the character I/O routines in Bank 0 if you place the following procedure in common
memory.
1) Swap stacks to a local stack in common.
2) Save the current bank.
3) Select Bank 0.
4) Call the appropriate character I/O routine.
5) Reselect the saved bank.
6) Restore the stack.

3.6 Assembling and Linking Your BIOS
This section assumes you have developed a BIOS3.ASM or BNKBIOS3.ASM file appropriate to your specifichardware environment. Use the Digital Research Relocatable Macro Assembler RMAC to assemble the BIOS.
Use the Digital Research Linker LINK-8 OTM to create the BIOS3.SPR and BNKBIOS3.SPR files. The SPR
files are part of the input to the GENCPM program.
In a banked environment, your CP/M 3 BIOS can consist of two segments: a banked segment and a common
segment. This allows you to minimize common memory usage to maximize the size of the TPA. To prepare abanked BIOS, place code and data that must reside in common in the CSEG segment, and code and data thatcan reside in the system bank in the DSEG segment. When you link the BIOS, LINK-80 creates the
BNKBIOS3.SPR file with all the CSEG code and data first, then the DSEG code and data.
After assembling the BIOS with RMAC, link your BNKBIOS using LINK-80 with the[B] option. The [B] option aligns the DSEG on a page boundary, and places the length of the CSEG into the
BNKBIOS3.SPR header page.

Digital Research : CP/M 3 System Manual

Page 50

Use the following procedure to prepare a BIOS3.SPR or BNKBIOS3.SPR file from your customized BIOS.
1) Assemble your BIOS3.ASM or BNKBIOS3.ASM file with the relocatable assembler RMAC.COM toproduce a relocatable file of type REL. Assemble
SCB.ASM to produce the relocatable file SCB.REL.
Assembling the Nonbanked BIOS:
A>RMAC BIOS3

Assembling the Banked BIOS:
A>RMAC BNKBIOS32) Link the BIOS3.REL or BNKBIOS3.REL file and the SCB.REL file with LINK-80 to produce theBIOS3.SPR or BNKBIOS3.SPR file. The [OS] option with LINK causes the output of a System Page
Relocatable (SPR) file.
Linking the Nonbanked BIOS:
A>LINK BIOS3[OS]=BIOS3,SCB

Linking the Banked BIOS:
A>LINK BNKBIOS3[B]=BNKBIOS3.SCB

The preceding examples show command lines for linking a banked and nonbanked BIOS.
In these examples, the BIOS3.REL and BNKBIOS3.REL are the files of your assembled BIOS.
SCB.REL contains the definitions of the System Control Block variables. The [B] option implies the [OS]option.

Digital Research : CP/M 3 System Manual

Page 51

Section 4 : CP/M 3 Sample BIOS Modules
This section discusses the modular organization of the example CP/M 3 BIOS on your distribution disk. For
previous CP/M operating systems, it was necessary to generate all input/output drivers from a single assembler
source file. Such a file is difficult to maintain when the BIOS supports several peripherals. As a result, Digital
Research is distributing the BIOS for CP/M 3 in several small modules.
The organization of the BIOS into separate modules allows you to write or modify any I/O driver independentlyof the other modules. For example, you can easily add another disk I/O driver for a new controller withminimum impact on the other parts of the BIOS.

4.1 Functional Sumary of BIOS Modules
The modules of the BIOS are BIOSKRNL.ASM, SCB.ASM, BOOT.ASM, MOVE.ASM, CHARIO.ASM,
DRVTBL.ASM, and a disk I/O module for each supported disk controller in the configuration.
BIOSKRNL.ASM is the kernel, root, or supervisor module of the BIOS. The SCB.ASM module contains
references to locations in the System Control Block. You can customize the other modules to support any
hardware configuration. To customize your system, add or modify external modules other than the kernel andthe SCE.ASM module.
Digital Research supplies the BIOSKRNL.ASM module. This module is the fixed, invariant portion of theBIOS, aiid the interface from the BDOS to all BIOS functions. It is supplied in source form for reference only,
and you should not modify it except for the equate statement described in the following paragraph.
You must be sure the equate statement (banked equ true) at the start of the BIOSKRNL.ASM source file iscorrect for your system configuration. Digital Research distributes the BIOSKRNL.ASM file for a banked
system. If you are creating a BIOS for a nonbanked system, change the equate statement to the following:banked equ false and reassemble with RMAC. This is the only change you should make to the
BIOSKRNL.ASM file.
Table 4-1 summarizes the modules in the CP/M 3 BIOS.
Table 4-1. CP/M 3 BIOS Module Function Summary
ModuleFunction

BIOSKRNL.ASM

Performs basic system initialization, and dispatches character and disk I/O.

SCB.ASM module

Contains the public definitions of the various fields in the System Control
Block. The BIOS can reference the public variables.
Performs system initialization other than character and disk I/O. BOOT loads
the CCP for cold starts and reloads it for warm starts. CHARIO.ASM module

BOOT.ASM module

Performs all character device initialization, input, output, and status polling.
CHARIO contains the character device characteristics table.
Points to the data structures for each configured disk drive. The drive table
determines which physical disk unit is associated with which logical drive.

DRVTBL.ASM module
The data structure for each disk drive is called an Extended Disk Parameter
Header (XDPH).

Digital Research : CP/M 3 System Manual

Disk I/O modules

MOVE.ASM module

Page 52

Initialize disk controllers and execute READ and WRITE code for disk
controllers. You must provide an XDPH for each supported unit, and a separate
disk I/O module for each controller in the system. To add another disk
controller for which a prewritten module exists, add its XDPH names to the
DRVTBL and link in the new module.
Performs memory-to-memory moves and bank selects.

4.2 Conventions Used in BIOS Modules
The Digital Research RMAC relocating assembler and LINK-80 linkage editor allow a module to reference asymbol contained in another module by name. This is called an external reference. The Microsoft relocatableobject module format that RMAC and LINK use allows six-character names for externally defined symbols.
External names must be declared PUBLIC in the module in which they are defined. The external names must
be declared EXTRN in any modules that reference them.
The modular BIOS defines a number of external names for specific purposes. Some of these are defined as
public in the root module, BIOSKRNL.ASM. Others are declared external in the root and must be defined by
the system implementor. Section 4.4 contains a table summarizing all predefined external symbols used by themodular BIOS.
External names can refer to either code or data. All predefined external names in the modular BIOS prefixedwith a @ character refer to data items. All external names prefixed with a ? character refer to a code label. To
prevent conflicts with future extensions, user-defined external names should not contain these characters.

4.3 Interactions of Modules
The root module of the BIOS, BIOSKRNL.ASM, handles all BDOS calls, performs interfacing functions, andsimplifies the individual modules you need to create.

4.3.1 Initial BootBIOSKRNL.ASM initializes all configured devices in the following order:
1) BIOSKRNL calls ?CINIT in the CHARIO module for each of the 16 character devices and initializes
the devices.
2) BIOSKRNL invokes the INIT entry point of each XDPH in the FD1797SD module.
3) BIOSKRNL calls the ?INIT entry of the BOOT module to initialize other system hardware, such as
memory controllers, interrupts, and clocks. It prints a sign-on message specific to the system, if desired.
4) BIOSKRNL calls ?LDCCP in the BOOT module to load the CCP into the TPA.
5) The BIOSKRNL module sets up Page Zero of the TPA with the appropriate jump vectors, and passes
control to the CCP.

4.3.2 Character I/O Operation
The CHARIO module performs all physical character I/O. This module contains both the character device table(@CTBL) and the routines for character input, output, initialization, and status polling. The character devicetable, @CTBL, contains the ASCII name of each device, mode information, and the current baud rate of serial
devices.
To support logical to physical redirection of character devices, CP/M 3 supplies a 16-bit assignment vector foreach logical device. The bits in these vectors correspond to the physical devices. The character I/O interface
routines in BIOSKRNL handle all device assignment, calling the appropriate character I/O routines with theDigital Research : CP/M 3 System Manual

Page 53

correct device number. The BIOSKRNL module also handles XON/XOFF processing on output devices where
it is enabled.
You can use the DEVICE utility to assign several physical devices to a logical device. The BIOSKRNL root
module polls the assigned physical devices, and either reads a character from the first ready input device that isselected, or sends the character to all of the selected output devices as they become ready.

4.3.3 Disk I/O Operation
The BIOSKRNL module handles all BIOS calls associated with disk I/O. It initializes global variables with theparameters for each operation, then invokes the READ or WRITE routine for a particular controller. The
SELDSK routine in the BIOSKRNL calls the LOGIN routine for a controller when the BDOS initiates a drive
login. This allows disk density or media type to be automatically determined.
The DRVTBL module contains the sixteen-word drive table, @DTBL. The order of the entries in @DTBL
determines the logical to physical drive assignment. Each word in @DTBL contains the address of a DPH,
which is part of an XDPH, as shown in Table 4-10. The word contains a zero if the drive does not exist. The
XDPH contains the addresses of the INIT, LOGIN, READ, and WRITE entry points of the I/O driver for aparticular controller. When the actual drivers are called, globally accessible variables contain the various
parameters of the operation, such as the track and sector.

4.4 Predefined Variables and Subroutines
The modules of the BIOS define public variables which other modules can reference.
Table 4-2 contains a summary of each public symbol and the module that defines it.
Table 4-2. Public Symbols in CP/M 3 BIOS
SymbolFunction and Use@ADRV

Byte, Absolute drive code

BIOSKRNL@CBNK

Byte, Current CPU bank

BIOSKRNL@CNT

Byte, Multisector count

BIOSKRNL@CTBL

Table, Character device table

CHARIO@DBNK

Byte, Bank for disk I/O

BIOSKRNL@DMA

Word, DMA address

BIOSKRNL@DTBL

Table, Drive table

DRVTBL@RDRV

Byte, Relative drive code (UNIT) BIOSKRNL@SECTWord, Sector address

BIOSKRNL@TRK

Word, Track number

BIOSKRNL?BANKBank select

MOVE

Character device input

CHARIO?CINIT

Character device initialization

CHARIO?CIST

Character device input status

CHARIO?CI

Defined in Module

Digital Research : CP/M 3 System Manual?CO

Character device output

CHARIO?COST

Character device output status

CHARIO?INIT

General initialization

BOOT?LDCCP Load CCP for cold start

BOOT

?MOVE

Move memory to memory

MOVE

?PDEC

Print decimal number

BIOSKRNL?PDERR Print BIOS disk error header

BIOSKRNL

Print message

BIOSKRNL?PMSG?RLCCP Reload CCP for warm start

BOOT?XMOVE Set banks for extended move

MOVE

Set or Get time

BOOT

?TIME

Page 54

The System Control Block defines public variables that other modules can reference.
The System Control Block variables @CIVEC, @COVEC, @AIVEC, @AOVEC, and @LOVEC arereferenced by BIOSKR,-NL.ASM. The variable @BNKBF can be used by ?LDCCP and ?RLCCP to
implement interbank block moves. The public variable names@ERMDE, @FX, @RESEL, @VINFO, @CRDSK, @USRCD, and @CRDMA are used for error routines
which intercept BDOS errors. The publics @DATE, @HOUR, @MIN, and @SEC can be updated by aninterrupt-driven real-time clock. @MXTPA contains the current BDOS entry point.
Disk I/O operation parameters are passed in the following global variables, as shown in Table 4 -3.
Table 4-3. Global Variables in BIOSKRNL.ASM
Variable

Meaning

Byte; contains the absolute drive code (0 through F for A through P) that CP/M isreferencing for READ and WRITE operations. The SELDSK routine in the BIOSKRNL@ADRVmodule obtains this value from the BDOS and places it in @DRV. The absolute drive
code is used to print error messages.
@RDRV Byte; contains the relative drive code for READ and WRITE operations.
The relative drive code is the UNIT number of the controller in a given disk I/O module. BIOSKRNL obtains
the unit number from the XDPH.
This is the actual drive code a driver should send to the controller.
Several utility subroutines are defined in the BIOSKRNL.ASM module, as shown in Table 4 -4.
Table 4-4. Public Utility Subroutines in BIOSKRNL.ASK utility I meaning@TRK

Word; contains the starting track for READ and WRITE.

@SECT Word; contains the starting sector for READ and WRITE.
@DMA

Word; contains the starting disk transfer address.

Digital Research : CP/M 3 System Manual

Page 55@DBNK Byte; contains the bank of the DMA buffer.
@CNT

Byte; contains the physical sector count for the operations that follow.

@CBNK Byte; contains the current bank for code execution.
?PMSG Print string starting at <HL>, stop at null (0). ?PDEC Print binary number in decimal from HL.
?PDERR Print disk error message header using current disk parameters:<CR><LF>BIOS Error on d:, T- nn, S-nn.
All BIOS entry points in the jump vector are declared as public for general reference by other BIOS modules,
as shown in Table 4-5.
Table 4-5. Public Names in the BIOS Jump Vector
Public Name

Function?BOOT

Cold boot entry?WBOOT

Warm boot entry?CONST

Console input status?CONIN

Console input?CONO

Console output?LIST

List output?AUXO

Auxiliary output?AUXI

Auxiliary input?HOME

Home disk drive?SLDSK

Select disk drive?ST12RKSet track?STSECSet sector?STDMASet DMA address?READ

Read record?WRITE

Write record?LISTS

List status?SCTRN

Translate sector?CONOS

Console output status?AUXIS

Auxiliary input status?AUXOS

Auxiliary output status?DVTBL

Return character device table address?DEVIN

Initialize character device?DRTBL

Return disk drive table addressDigital Research : CP/M 3 System Manual
Public Name

Page 56

Function?MLTIO

Set multiple sector count?FLUSH

Flush deblocking buffers (not implemented)?MOV

Move memory block?TIM

Signal set or get time from clock?BNKSLSet bank for further execution?STBNKSet bank for DMA?XMOV

Set banks for next move

4.5 BOOT Module
The BOOT module performs general system initialization, and loads and reloads the CCP. Table 4 -6 shows theentry points of the BOOT module.
Table 4-6. BOOT Module Entry Points
ModuleMeaning?INIT

The BIOSKRNL module calls ?INIT during cold start to perform hardware initialization
other than character and disk I/O. Typically, this hardware can include time-of-day clocks,
interrupt systems, and special I/O ports used for bank selection.

BIOSKRNL calls ?LDCCP during cold start to load the CCP into the TPA. The CCP can beloaded either from the system tracks of the boot device or from a file, at the discretion of the?LDCCPsystem implementor. In a banked system, you can place a copy of the CCP in a reserved
area of another bank to increase the performance of the ?RLCCP routine.
BIOSKRNL calls ?RLCCP during warm start to reload the CCP into the TPA. In a banked
system, the CCP can be copied from an alternate bank to eliminate any disk access.
?RLCCP
Otherwise, the CCP should be loaded from either the system tracks of the boot device orfrom a file.

4.6 Character I/O
The CHARIO module handles all character device interfacing. The CHARIO module contains the character
device definition table @CTBL, the character input routine ?CI , the character output routine ?CO, the character
input status routine ?CIST, the character output status routine ?COST, and the character device initialization
routine ?CINIT.
The BIOS root module, BIOSKRNL.ASM, handles all character I/O redirection. This module determines theappropriate devices to perform operations and executes the actual operation by calling ?CI, ?CO, ?CIST, and?COST with the proper device number(s).
@CTBL is the external name for the structure CHRTBL described in Section 3 of this manual. @CTBL
contains an 8-byte entry for each physical device def-ined by this BIOS. The table is terminated by a zero byte
after the last entry.
The first field of the character device table, @CTBL, is the 6- byte device name. This device name should be all
upper-case, left- justified, and padded with ASCII spaces (20H).

Digital Research : CP/M 3 System Manual

Page 57

The second field of @CTBL is 1 byte containing bits that Indicate the type of device and its current mode, as
shown in Table 4-7.
Table 4-7. Mode Bits
Mode Bits

Meaning

00000001

Input device (such as a keyboard)

00000010

output device (such as a printer)

00000011

Input/output device (such as a terminal or modem)

00000100

Device has software-selectable baud rates

00001000

Device may use XON protocol

00010000

XON/XOFF protocol enabled

The third field of @CTBL is 1 byte and contains the current baud rate for serial devices. The high-order nibbleof this field is reserved for future use and should be set to zero.
The low-order four bits contain the current baud rate as shown in Table 4-8. Many systems do not support all ofthese baud rates.
Table 4-8. Baud Rates for Serial Devices
Decimal Binary Baud Rate
0

0000

none

1

0001

50

2

0010

75

3

0011

110

4

010 0

134. 5

5

0101

150

6

0110

300

7

0111

600

8

1000

1200

9

1001

1800

10

1010

2400

11

1011

3600

12

1100

4800

13

1101

7200

14

1110

9600

15

1111

19200

Digital Research : CP/M 3 System Manual

Page 58

Table 4-9 shows the entry points to the routines in the CHARIO module. The BIOSKRNL module calls theseroutines to perform machine-dependent character I/O.
Table 4-9. Character Device Labels
Label

Meaning?Ci
Character Device Input?CI is called with a device number in register B. It should wait
for the next available input character , then return thecharacter in register A. The character should be in 8-bit ASCII
with no parity.

?CO
Character Device Output?CO is called with a device number in register B and acharacter in register C. It should wait until the device is readyto accept another character and then send the character. The
character is in 8-bit ASCII with no parity.

?CIST
Character Device Input Status?CIST is called with a device number in register B. It should
return with register A set to zero if the device specified has no
input character ready; and should return with A set to 0FFH if
the device specified has an input character ready to be read.

?COST is called with a device number in register B. It should
return with register A set to zero if the device specified cannot?COST
Character Device Output Status accept a character immediately, and should return with A set
to 0FFH if the device is ready to accept a character.

?CINIT
Character Device Initialization?CINIT is called for each of the 16 character devices, andinitializes the devices. Register C contains the device number.
The ?CINIT routine initializes the physical character device
specified in register C to the baud rate contained in theappropriate entry of the CHRTBL. You only need to supply
this routine if I/O redirection has been implemented. It is
referenced only by the DEVICE utility supplied with CP/M 3.

4.7 Disk I/O
The separation of the disk I/O section of the BIOS into several modules allows you to support each particular
disk controller independently from the rest of the system. A manufacturer can supply the code for a controller
in object module form, and you can link it into any existing modular BIOS to function with other controllers inthe system.
The data structure called the Extended Disk Parameter Header, or XDPH, contains all the necessary
information about a disk drive. BIOSKRNL.ASM locates the XDPH for a particular logical drive using the
Drive Table. The XDPH contains the addresses of the READ, WRITE, initialization, and login routines. The
XDPH also contains the relative unit number of the drive on the controller, the current media type, and the Disk
Parameter Header (DPH) that the BDOS requires. Section 3 of this manual describes the Disk Parameter
Header.
The code to read and write from a particular drive is independent of the actual CP/M logical drive assignment,
and works with the relative unit number of the drive on the controller.
The position of the XDPH entry in the DRVTBL determines the actual CP/M 3 drive code.

4.7.1 Disk I/O StructureDigital Research : CP/M 3 System Manual

Page 59

The BIOS requires a DRVTBL module to locate the disk driver. it also requires a disk module for eachcontroller that is supported.
The drive table module, DRVTBL, contains the addresses of each XDPH defined in the system. Each XDPH
referenced in the DRVTBL must be declared external to link the table with the actual disk modules.
The XDPHs are the only public entry points in the disk I/O modules. The root module references the XDPHs tolocate the actual I/O driver code to perform sector READS and WRITES. When the READ and WRITE
routines are called, the parameters controlling the READ or WRITE operation are contained in a series ofglobal variables that are declared public in the root module.

4.7.2 Drive Table Module (DRVTBL)
The drive table module, DRVTBL, def ines the CP/M absolute drive codes associated with the physical disks.
The DRVTBL module contains one public label, @DTBL. @DTBL is a 16-word table containing the addressesof up to 16 XDPH'S. Each XDPH name must be declared external in the DRVTBL. The first entry corresponds
to drive A, and the last to drive P. You must set an entry to 0 if the corresponding drive is undefined. Selecting
an undefined drive causes a BDOS SELECT error.

4.7.3 Extended Disk Parameter Headers (XDPHS)
An Extended Disk Parameter Header (XDPH) consists of a prefix and a regular Disk Parameter Header as
described in Section 3. The label of a XDPH references the start of the DPH. The fields of the prefix are locatedat relative offsets from the XDPH label.
The XDPHs for each unit of a controller are the only entry points in a particular disk drive module. They
contain both the DPH for the drive and the addresses of the various action routines for that drive, including
READ, WRITE, and initialization. Figure 4-1 shows the format of the Extended Disk Parameter Header.
Figure 4-1. XDPH Format

Digital Research : CP/M 3 System Manual

Page 60

Table 4-10 describes the fields of each Extended Disk Parameter Header.
Table 4-10. Fields of Each XDPH
Field

Meaning

WRITE The WRITE word contains the address of the sector WRITE routine for the drive.
READ

The READ word contains the address of the sector READ routine for the drive.

LOGIN The LOGIN word contains the address of the LOGIN routine for the drive.
INIT

The INIT word contains the address of the f irst-time initialization code for the drive.
The UNIT byte contains the drive code relative to the disk controller.

UNIT

TYPE

This is the value placed in @RDRV prior to calling the READ, WRITE, and LOGIN entry
points of the drive.
The TYPE byte is unused by the BIOS root, and is reserved for the driver to keep thecurrent density or media type to support multiple-format disk subsystems. regular DPH
The remaining fields of the XDPH comprise a standard DPH, as discussed in Section 3 ofthis manual.

4.7.4 Subroutine Entry Points
The pointers contained in the XDPH reference the actual code entry points to a disk driver module. Theseroutines are not declared public. Only the XDPH itself is public. The BIOS root references the XDPHs only
through the @DTBL. Table 4-11 shows the BIOS subroutine entry points.

Digital Research : CP/M 3 System Manual

Page 61

Table 4-11. Subroutine Entry Points
Entry Point

Meaning

WRITE

When the WRITE routine is called, the address of the XDPH is passed in registers DE. The
parameters for the WRITE operation are contained in the public variables @ADRV, @RDRV,@TRK, @SECT, @DMA, and @DBNK. The WRITE routine should return an error code inregister A. The code 00 means a successful operation, 01 means a permanent error occurred,and 02 means the drive is write-protected if that feature is supported.

READ

When the READ routine is called, the address of the XDPH is contained in registers DE. The
parameters for the READ operation are contained in the public variables @ADRV, @RDRV,@TRK, @SECT, @DMA, and@DBNKThe READ routine should return an error code in register A. A code of 00 means a successful
operation and 01 means a permanent error occurred.

LOGIN

The LOGIN routine is called before the BDOS logs into the drive, and allows the automatic
determination of density. The LOGIN routine can alter the various parameters in the DPH,
including the translate table address (TRANS) and the Disk Parameter Block (DPB) . The
LOGIN routine can also set the TYPE byte. On single media type systems, the LOGIN routine
can simply return. When LOGIN is called, the registers DE point to the XDPH for this drive.

INIT

The BOOT entry of the BIOSKRNL module calls each INIT routine during cold start and prior
to any other disk accesses. INIT can perform any necessary hardware initialization, such as
setting up the controller and interrupt vectors, if any.

4.7.5 Error Handling and Recovery
The READ and WRITE routines should perform several retries of an operation that produces an error. If theerror is related to a seek operation or a record not found condition, the retry routine can home or restore thedrive, and then seek the correct track. The exact sequence of events is hardware-dependent.
When a nonrecoverable error occurst the READ or WRITE routines can print an error message informing theoperator of the details of the error. The BIOSKRNL module supplies a subroutine, ?PDERR, to print a standard
BIOS error message header. This routine prints the following message:
BIOS Err on D: T-nn S-nn
The D: is the selected drive, and T-nn and S-nn display the track and sector number for the operation. The
READ and WRITE routines should print the exact cause of the error after this message, such as Not Ready, orWrite Protect. The driver can then ask the operator if additional retries are desired, and return an error code to
the BDOS if they are not.
However, if the @ERMDE byte in the System Control Block indicates the BDOS is returning error codes to theapplication program without printing error messages, the BIOS should simply return an error without any
message.

4.7.6 Multiple Sector I/O
The root module global variable @CNT contains the multisector count. Refer to Sections 2.5 and 3.4.3 for a
discussion of the considerations regarding multirecord I/O.

4.8 MOVE Module

Digital Research : CP/M 3 System Manual

Page 62

The MOVE Module performs memory-to-memory block moves and controls bank selection. The ?MOVE and?XMOVE entry points correspond directly to the MOVE and XMOVE jump vector routines documented in
Section 3. Table 4-12 shows the entry points for the MOVE module.
Table 4-12. Move Module Entry Points
Entry Point

MeaningMemory-to-memory move

?MOVE

?MOVE is called with the source address for the move in register DE, the destination address
in register HL, and the byte count in register BC. If ?XMOVE has been called since the last call
to ?MOVE, an interbank move must be performed. On return, registers HL and DE must point
to the next bytes after the MOVE. This routine can use special DMA hardware for theinterbank move capability, and can use the Z8O LDIR instruction for intrabank moves.
Set banks for one following ?MOVE?XMOVE?XMOVE is called with the destination bank in register B and the source bank in register C.
Interbank moves are only invoked if the DPHs specify deblocking buffers in alternate banks.
?XMOVE only applies to one call to ?MOVE. (Not implemented in the example.)Set bank for execution?BANK?BANK is called with the bank address in register A. This bank address has already been
stored in @CBNK for future reference. All registers except A must be maintained upon return.

4.9 Linking Modules into the BIOS
The following lines are examples of typical link commands to build a modular BIOS ready for systemgeneration with GENCPK:LINK BNKBIOS3[b]=BNKBIOS,SCB,BOOT,CHARIO,MOVE,DRVTBL,<disk-modules>
LINK BIOS3[os]=BIOS,SCB,BOOT,CHARIO,MOVE,DRVTBL,<disk-modules>

Section 5 : System Generation
This section describes the use of the GENCPM utility to create a memory image CPM3.SYS file containing theelements of the CP/M 3 operating system. This section also describes customizing the LDRBIOS portion of the
CPMLDR program, and the operation of CPMLDR to read the CPM3.SYS file into memory.
Finally, this section describes the procedure to follow to boot CP/M 3.
In the nonbanked system, GENCPM creates the CPM3.SYS file from the BDOS3.SPR and your customized
BIOS3.SPR files. In the banked system, GENCPM creates the CPM3.
SYS f i le from the RESBDOS3. SPR f i le, the BNKBDOS3.SPR file, and your customized BNKBIOS3.SPR
file.
If your BIOS contains a segment that can reside in banked memory, GENCPM separates the code and data in
BNKBIOS3.SPR into a banked portion which resides in Bank 0 just below common memory, and a resident
portion which resides in common memory.

Digital Research : CP/M 3 System Manual

Page 63

GENCPM relocates the system modules, and can allocate physical record buffers, allocation vectors, checksum
vectors, and hash tables as requested in the BIOS data structures. It also relocates references to the System
Control Block, as described on page 27. GENCPM accepts its command input from a file, GENCPM.DAT, orinteractively from the console.

5.1 GENCPM Utility
Syntax:GENCPM [AUTO | AUTO DISPLAY}

Purpose:GENCPM creates a memory image CPM3.SYS file, containing the CP/M 3 BDOS and customized BIOS. The
GENCPM utility performs late resolution of intermodule references between system modules. GENCPM canaccept its command input interactively from the console or from a file GENCPM.DAT.
In the nonbanked system, GENCPM creates a CPM3.SYS file from the BDOS3.SPR and BIOS3.SPR files. In
the banked system, GENCPM creates the CPM3.SYS file from the RESBDOS3.SPR, the BNKBDOS3.SPR
and the BNKBIOS3.SPR files. Remember to back up your CPM3.SYS file before executing GENCPM,
because GENCPM deletes any existing CPM3.SYS file before it generates a new system.
Input Files:
Banked System
BNKBIOS3.SPR
RESBDOS3.SPR
BNKBDOS3.SPR
optionally GENCPM.DAT

Nonbanked System
BIOS3.SPR
BDOS3.SPR

Output File:
CPM3.SYS optionally GENCPM.DAT
GENCpm determines the location of the system modules in memory and, optionally, the number of physicalrecord buffers allocated to the system. GENCPM can specify the location of hash tables requested by the Disk
Parameter Headers (DPHS) in the BIOS. GENCPM can allocate all required disk buffer space and create all therequired Buffer Control Blocks (BCBs).
GENCPM can also create checksum vectors and allocation vectors.
GENCPM can get its input from a file GENCPM.DAT. The values in the file replace the default values of
GENCPM. If you enter the AUTO parameter in the command line GENCPM gets its input from the file
GENCPM.DAT and generates a new system displaying only its sign- on and sign-off messages on the console.
If AUTO is specified and a GENCPM.DAT file does not exist on the current drive, GENCPM reverts to manual
generation.
If you enter the AUTO DISPLAY parameter in the command line, GENCPM automatically generates a new
system and displays all questions on the console. If AUTO DISPLAY is specified and a GENCPM.DAT filedoes not exist on the current drive, GENCPM reverts to manual generation. If GENCPM is running in AUTO
mode and an error occurs, it reverts to manual generation and starts from the beginning.

Digital Research : CP/M 3 System Manual

Page 64

The GENCPM.DAT file is an ASCII file of variable names and their associated values. In the'following
discussion, a variable name in the GENCPM.DAT file is referred to as a Question Variable. A line in the
GENCPM.DAT file takes the following general form:
Question Variable = value I ? I ?value <CR><LF> value = #decimal value or hexadecimal value or drive letter(A - P) or Yes, No, Y, or N
You can specify a default value by following a question mark with the appropriate value, for example ?A or ?25
or ?Y. The question mark tells GENCPM to stop and prompt the user for input, then continue automatically. At
a ?value entry, GENCPM displays the default value and stops for verification.
The following pages display GENCPM questions. The items in parentheses are the default values. The
Question Variable associated with the question is shown below the explanation of the answers to the questions.

5.1.1 : Program Questions:
Use GENCPM.DAT for defaults (Y) ?
Enter Y - GENCPM gets its default values from the file GENCPM.DAT.
Enter N - GENCPM uses the built-in default values.
No Question Variable is associated with this question
Create a new GENCPM.DAT file (N) ?
Enter N - GENCPM does not create a new GENCPM.DAT fil,Enter Y - After GENCPM generates the new CPM3.SYS file it creates a new GENCPM.DAT filecontaining the default values.
Question Variable: CRDATAF
Display Load Table at Cold Boot (Y) ?
Enter Y - On Cold Boot the system displays the load table containing the filename, filetype, hex starting
address, length of system modules, and the TPA size.
Enter N - System displays only the TPA size on cold boot.
Question Variable: PRTMSG
Number of console columns (#80) ?
Enter the number of columns (characters-per-line) for your console.
A character in the last column must not force a new line for console editing in CP/M 3. If your terminal
forces a new line automatically, decrement the column count by one.
Question Variable: PAGWID
Number of lines per console page (#24) ?
Enter the number of the lines per screen for your console.

Digital Research : CP/M 3 System Manual

Page 65

Question Variable: PAGLEN
Backspace echoes erased character (N) ?
Enter N - Backspace (Ctrl-H, 08H) moves back one column and erases the previous character.
Enter Y - Backspace moves forward one column and displays the previous character.
Question Variable: BACKSPC
Rubout echoes erased character (Y) ?
Enter Y - Rubout (7FH) moves forward one column and displays the previous character.
Enter N - Rubout moves back one column and erases the previous character.
Question Variable: RUBOUT
Initial default drive (A:) ?
Enter the drive code the prompt is to display at cold boot.
Question Variable: BOOTDRVTop page of memory (FF) ?
Enter the page address that is to be the top of the operating system. OFFH is the top of a 64K system.
Question Variable: MEMTOP
Bank-switched memory (Y) ?
Enter Y - GENCPM uses the banked system files.
Enter N - GENCPM uses the nonbanked system files.
Question Variable: BNKSWT
Common memory base page (CO) ?
This question is displayed only if you answered Y to the previous question. Enter the page address ofthe start of common memory.
Question Variable: COMBASLong error messages (Y) ?
This question is displayed only if you answered Y to bank- switched memory.
Enter Y - CP/M 3 error messages contain the BDOS function number and the name of the file on which
the operation was attempted.
Enter N - CP/M 3 error messages do not display the function number or file.
Question Variable: LERROR

Digital Research : CP/M 3 System Manual

Page 66

Double allocation vectors (Y) ?
This question is displayed only if you answered N to bank- switched memory.
For more information about double allocation vectors, see the definition of the Disk Parameter Header
ALV field in Section 3.
Enter Y - GENCPM creates double-bit allocation vectors for each drive.
Enter N - GENCPM creates single-bit allocation vectors for each drive.
Question Variable: DBLALV
Accept new system definition (Y) ?
Enter Y GENCPM proceeds to the next set of questions.
Enter N GENCPM repeats the previous questions and displays your previous input in the default
parentheses. You can modify your answers.
No Question Variable is associated with this question.
Number of memory segments (#3) ?
GENCPM displays this question if you answered Y to bank- switched memory.
Enter the number of memory segments in the system. Do not count common memory or memory inBank 1, the TPA bank, as a memory segment. A maximum of 16 (0 - 15) memory segments areallowed. The memory segments define to GENCPM the memory available for buffer and hash tableallocation.
Do not include the part of Bank 0 that is reserved for the operating system.
Question Variable: NUMSEGS
CP/M 3 Base,size,bank (8E,32,00)
Enter memory segment table:
Base,size,bank (00,8E,00) ?
Base,size,bank (00,CO,02) ?
Base,size,bank (00,CO,03) ?
Enter the base page, the length, and the bank of the memory segment.
Question Variable: MEMSEGO# where 0 to F hex
Accept new memory segment table entries (Y) ?
Enter Y GENCPM displays the next group of questions.
Enter N GENCPM displays the memory segment table definition questions again.

Digital Research : CP/M 3 System Manual

Page 67

No Question Variable is associated with this question.

5.1.2 : Setting up directory hash tables:
Enable hashing for drive d: (Y)GENCPM displays this question if there is a Drive Table and if the DPHs for a given drive have an
0FFFEH in the hash table address field of the DPH. The question is asked for every drive d: defined in
the BIOS.
Enter Y - Space is allocated for the Hash Table. The address and bank of the Hash Table is entered into
the DPH.
Enter N - No space is allocated for a Hash Table for that drive.
Question Variable: HASHDRVD where d = drives A-P.

5.1.3 : Setting up Blocking/Deblocking buffers:
GENCPM displays the next set of questions if either or both the DTABCB field or the DIRBCB field contain
0FFFEH.
Number of directory buffers for drive d: (#l) ? 10
This question appears only if you are generating a banked system. Enter the number of directory buffers
to allocate for the specified drive. In a banked system, directory buffers are allocated only inside Bank
0. In a nonbanked system, one directory buffer is allocated above the BIOS.
Question Variable: NDIRRECD where d = drives A-P.
Number of data buffers for drive d: (#l) ? 1
This question appears only if you are generating a Banked system. Enter the number of data buffers toallocate for the specified drive. In a banked system, data buffers can only be allocated outside Bank 1,
and in common. You can only allocate data buffers in alternate banks if your BIOS supports interbank
moves.
In a nonbanked system, data buffers are allocated above the BIOS.
Question Variable: NDTARECD where d = drives A-P.
Share buffer(s) with which drive (A:) ?
This question appears only if you answered zero to either of the above questions.
Enter the drive letter (A-P) of the drive with which you want this drive to share a buffer.
Question Variable: ODIRDRVD for directory records where d = drives A-P.
Question Variable: ODTADRVD for data records where d drives A-P.
Allocate buffers outside of Commom (N) ?
This question appears if the BIOS XMOVE routine is implemented.

Digital Research : CP/M 3 System Manual

Page 68

Answer Y - GENCPM allocates data buffers outside of common and Bank 0.
Answer N - GENCPM allocates data buffers in common.
Question Variable: ALTBNKSD where d = drives A-P.
Overlay Directory buffer for drive d: (Y) ?
This question appears only if you are generating a nonbanked system.
Enter Y this drive shares a directory buffer with another drive.
Enter N GENCPM allocates an additional directory buffer above the BIOS.
Question Variable: OVLYDIRD where d = drives A-P.
Overlay Data buffer for drive d: (Y) ?
This question appears only if you are generating a nonbanked system.
Enter Y - this drive shares a data buffer with another drive.
Enter N - GENCPM allocates an additional data buffer above the BIOS.
Question Variable: OVLYDTAD for directory records where d = drives A-P.
Accept new buffer definitions (Y) ?
Enter Y GENCPM creates the CPM3.SYS file and terminates.
Enter N GENCPM redisplays all of the buffer definition questions.
No Question Variable is associated with this question.
Examples:The following section contains examples of two system generation sessions. If no entry follows a program
question, assume RETURN was entered to select the default value in parentheses. Entries different from thedefault appear after the question mark.
EXAMPLE OF CONTENTS OF GENCPM.DAT FILE
combas = c0 <CR> lerror = ? <CR> numsegs
3 <CR> memseg00
00,80,00 <CR> memseg0l
0d,b3,02 <CR> memseg0f?00,c0,10 <CR> hashdrva y <CR> hashdrvd n <CR> ndirreca
20 <CR> ndtarecf
10 <CR>

EXAMPLE OF SYSTEM GENERATION WITH BANKED MEMORY
A>GENCPM
CP/M 3.0 System Generation Copyright (C) 1982, Digital Research
Default entries are shown in (parens).

Digital Research : CP/M 3 System Manual
Default base is Hex, precede entry with # for decimalUse GENCPM.DAT for defaults (Y) ?
Create a new GENCPM.DAT file (N) ?
Display Load Map at Cold Boot (Y) ?
Number of console columns (#80) ?
Number of lines in console page (#24) ?
Backspace echoes erased character (N) ?
Rubout echoes erased character (N) ?
Initial default drive (A:) ?
Top page of memory (FF) ?
Bank switched memory (Y) ?
Common memory base page (CO) ?
Long error messages (Y) ?
Accept new system definition (Y) ?
Setting up Allocation vector for drive A:
Setting up Checksum vector for drive A:
Setting up Allocation vector for drive B:
Setting up Checksum vector for drive B:
Setting up Allocation vector for drive C:
Setting up Checksum vector for drive C:
Setting up Allocation vector for drive D:
Setting up Checksum vector for drive D:*** Bank 1 and Common are not included ****** in the memory segment table.
Number of memory segments (#3) ?
CP/M 3 Base,size,bank (8B,35,00)
Enter memory segment table:
Base,size,bank (00,8B,00)?
Base,size,bank (OD,B3,02)?
Base,size,bank (00,CO,03)?
CP/M 3 Sys SBO0H 3500H Bank 00
Memseg No. 00 0000H BBO0H Bank 00
Memseg No. 01 ODO0H B300H Bank 02
Memseg No. 02 0000H C000H Bank 03
Accept new memory segment table entries (Y) ?
Setting up directory hash tables:
Enable hashing for drive A: (Y) ?
Enable hashing for drive B: (Y) ?
Enable hashing for drive C: (Y) ?
Enable hashing for drive D: (Y) ?
9 5
Setting up Blocking/Deblocking buffers:
The physical record size is 0200H:
Available space in 256 byte pages:
TPA = 00F4H, Bank 0 = 00BBH, Other banks = 0166H
Number of directory buffers for drive A: (#32) ?
Available space in 256 byte pages:
TPA = 00F4H, Bank 0 = 0049H, Other banks = 0166H
Number of data buffers for drive A: (#2) ?
Allocate buffers outside of Common (N) ?
Available space in 256 byte pages:
TPA = 00F0H, Bank 0 = 0049H, Other banks = 0166H
Number of directory buffers for drive B; (#32) ?

Page 69

Digital Research : CP/M 3 System Manual

Page 70

Available space in 256 byte pages:
TPA = 00F0H, Bank 0 = 0007H, Other banks = 0166H
Number of data buffers for drive B: (#0) ?
Share buffer(s) with which drive (A:) ?
The physical record size is 0080H:
Available space in 256 byte pages:
TPA = 00F0H, Bank 0 = 0007H, Other banks = 0166H
Number of directory buffers for drive C: (410) ?
Available space in 256 byte pages:
TPA = 00F0H, Bank 0 = 0001H, Other banks = 0166H
Number of directory buffers for drive D: (#0) ?
Share buffer(s) with which drive (C:) ?
Available space in 256 byte pages:
TPA = 00F0H, Bank 0 = 0001H, Other banks = 0166H
Accept new buffer definitions (Y) ?
BNKBIOS3 SPR F600H 0600H
BNKBIOS3 SPR BI00H 0F00H
RESBDOS3 SPR F000H 0600H
BNKBDOS3 SPR 8700H 2A00H*** CP/M 3.0 SYSTEM GENERATION DONE

In the preceding example GENCPM displays the resident portion of BNKBIOS3.SPR first, followed by thebanked portion.
EXAMPLE OF SYSTEM GENERATION WITH NONBANKED MEMORY
A>GENCPM
CP/M 3.0 System Generation
Copyright (C) 1982, Digital Research
Default entries are shown in (parens).
Default base is Hex, precede entry with for decimalUse GENCPM.DAT for defaults (Y) ?
Create a new GENCPM.DAT file (N) ?
Display Load Map at Cold Boot (Y) ?
Number of console columns (#80) ?
Number of lines in console page (#24) ?
Backspace echoes erased character (N) ?
Rubout echoes erased character (N) ?
Initial default drive (A:) ?
Top page of memory (FF) ?
Bank switched memory (Y) ? N
Double allocation vectors (Y) ?
Accept new system definition (Y) ?
Setting up Blocking/Deblocking buffers:
The physical record size is 0200H:
Available space in 256 byte pages:
TPA = 00D8H
Directory buffer required and allocated for drive A:
Available space in 256 byte pages:
TPA = 00D5H
Overlay Data buffer for drive A: (Y) ?
Available space in 256 byte pages:
TPA = 00D5H

Digital Research : CP/M 3 System Manual

Page 71

Overlay Directory buffer for drive B: (Y) ?
Share buffer(s) with which drive (A:) ?
Available space in 256 byte pages:
TPA = 00D5H
Overlay Data buffer for drive B: (Y) ?
Share buffer(s) with which drive (A:) ?
The physical record size is 00B0H:
Available space in 256 byte pages:
TPA = 0005H
Overlay Directory buffer for drive C: (Y) ?
Share buffer(s) with which drive (A:) ?
Available space in 256 byte pages:
TPA = 00D5H
Overlay Directory buffer for drive D: (Y) ?
Share buffer(s) with which drive (C;) ?
Available space in 256 byte pages:
TPA = 00D5H
Accept new buffer definitions (Y) ?
BIOS3 SPR F300H 0B00H
BDOS3 SPR D600H 1D00H*** CP/M 3.0 SYSTEM GENERATION DONE
A>

5.2 Customizing the CPMLDRThe CPMLDR resides on the system tracks of a CP/M 3 system disk, and loads the CPM3.SYS file intomemory to cold start the system. CPMLDR contains the LDRBDOS supplied by Digital Research, and must
contain your customized LDRBIOS.
The system tracks for CP/M 3 contain the customized Cold Start Loader, CPMLDR with the customized
LDRBIOS, and possibly the CCP.
The COPYSYS utility places the Cold Start Loader, the CPMLDR, and optionally the CCP on the system
tracks, as shown in Table 5-1.
Table 5-1. Sample CP/M 3 System Track Organization
Track Sector Page Memory Address CP/M 3 Module Name
Boot Address

Cold Start Loader

0100H

CPMLDR

00

01

00

02

00

.

.

.

00

21

09

0A80H

LDRBDOS

00

22

10

0B00H

LDRBIOS

.

.

.

00

26

12

0D00H

01

01

12

0D80H

.

.

.

01

26

25

.

.

and

and

.
1A00H

CCP

Digital Research : CP/M 3 System Manual

Page 72

Typically the Cold Start Loader is loaded into memory from Track 0, Sector 1 of the system tracks when thereset button is depressed. The Cold Start Loader then loads CPMLDR from the system tracks into memory.
Alternatively, if you are starting from an existing CP/M 2 system, you can run CPMLDR.COM as a transient
program. CP/M 2 loads CPMLDR.COM into memory at location
100H. CPMLDR then reads the CPM3.SYS file from User 0 on drive A and loads it into memory.
Use the following procedure to create a customized CPMLDR.COM file, including your customized
LDRBIOS:1) Prepare a LDRBIOS.ASM file.
2) Assemble the LDRBIOS file with RMAC to produce a LDRBIOS.REL file.
3) Link the supplied CPMLDR.REL file with the LDRBIOS.REL file you created to produce a
CPMLDR.COM file.
A>LINK CPMLDR[Ll00]=CPNLDR,LDRBIOS
Replace the address 100 with the load address to which your boot loader loads CPMLDR.COM. You must
include a bias of 100H bytes for buffer space when you determine the load address.
The CPMLDR requires a customized LDRBIOS to perform disk input and console output.
The LDRBIOS is essentially a nonbanked BIOS. The LDRBIOS has the same JMP vector as the regular CP/M
3 BIOS. The LDRBIOS is called only to perform disk reads (READ) from one drive, console output(CONOUT) for sign-on messages, and minimal system initialization.
The CPMLDR calls the BOOT entry point at the beginning of the LDRBIOS to allow it to perform any
necessary hardware initialization. The BOOT entry point should return to CPMLDR instead of loading andbranching to the CCP, as a BIOS normally does. Note that interrupts are not disabled when the LDRBIOSBOOT routine is called.
Test your LDRBIOS completely to ensure that it properly performs console character output and disk reads.
Check that the proper tracks and sectors are addressed on all reads and that data is transferred to the proper
memory locations.
You should assemble the LDRBIOS.ASM file with a relocatable origin of 0000H.
Assemble the LDRBIOS with RMAC to produce a LDRBIOS.REL file. Link the LDRBIOS.REL file with the
CPMLDR.REL file supplied by Digital Research to create a CPMLDR.COM .file. Use the L option in LINK to
specify the load origin (address) to which the boot loader on track 0 sector 1 loads the CPMLDR.COM file.
Unnecessary BIOS functions can be deleted from the LDRBIOS to conserve space. There is one absolute
restriction on the length of the LDRBIOS; it cannot extend above the base of the banked portion of CP/M 3.
(GENCPM lists the base address of CP/M 3 in its load map.) If you plan to boot CP/M 3 from standard, singledensity, eight-inch floppy disks, your CPMLDR must not be longer than 1980H to place the CPMLDR.COM
file on two system tracks with the boot sector. If the CCP resides on the system tracks with the Cold Start
Loader and CPMLDR, the combined lengths must not exceed 1980H.

5.3 CPKLDR Utility
Syntax:Digital Research : CP/M 3 System Manual

Page 73

CPMLDR

Purpose:CPMLDR loads the CP/M 3 system file CPM3.SYS into Bank 0 and transfers control to the BOOT routine in
the customized BIOS. You can specify in GENCPM for CPMLDR to display a load table containing the names
and addresses of the system modules.
The CPM3.SYS file contains the CP/M 3 BDOS and customized BIOS. The file CPM3.SYS must be on drive
A in USER 0. You can execute CPMLDR under SID or DDT to help debug the BIOS. A $B in the default FileControl Block (FCB) causes CPMLDR to execute a RST 7 (SID breakpoint) just before jumping to the CP/M 3
Cold Boot BIOS entry point.
Input File:
CPM3.SYS

Examples:
A>CPMLDR
CP/M V3.0 Loader
Copyright (C) 1982, Digital Research
BNKBIOS3 SPR F600H 0A00H
BNKBIOS3 SPR BB00H 0500H
RESBDOS3 SPR F100H 0500H
BNKBDOS3 SPR 9A00H 2100H
60K TPAA>

In the preceding example, CPMLDR displays its name and version number, the Digital Research copyrightmessage, and a four-column load table containing the filename, filetype, hex starting address, and length of thesystem modules. CPMLDR completes its sign-on message by indicating the size of the Transient Program Area
(TPA) in kilobytes. The CCP then displays the system prompt, A>.

5.4 Booting CP/M 3
The CP/M 3 cold start operation loads the CCP, BDOS, and BIOS modules into their proper locations inmemory and passes control to the cold start entry point (BIOS Function 0: BOOT) in the BIOS. Typically, aPROM-based loader initiates a cold start by loading sector 0 on track I of the system tracks into memory andjumping to it. This first sector contains the Cold Start Loader. The Cold Start Loader loads the CPMLDR.COM
program into memory and jumps to it. CPMLDR loads the CPM3.SYS file into memory and jumps to the+BIOS cold start entry point.
To boot the CP/M 3 system, use the following procedure:
1) Create the CPM3.SYS file.
2) Copy the CPM3.SYS file to the boot drive.
3) Create a CPMLDR.COM for your machine.
4 ) Place the CPMLDR.COM file on your system tracks using SYSGEN with CP/M 2 or COPYSYS with
CP/M 3. The boot loader must place the CPMLDR.Com file at the address at which it originated. If CPMLDR
has been linked to load at 100H, you can run CPMLDR under CP/M 2.

Digital Research : CP/M 3 System Manual

Page 74

The COPYSYS utility handles initialization of the system tracks. The source of COPYSYS is included with thestandard CP/M 3 system because you need to customize COPYSYS to support nonstandard system disk
formats. COPYSYS copies the Cold Start Loader, the CPMLDR.COM file, and optionally the CCP to thesystem tracks. Refer to the COPYSYS.ASM source file on the distribution disk.

Section 6 : Debugging the BIOS
This section describes a sample debugging session for a nonbanked CP/M 3 BIOS. You must create and debug
your nonbanked system first, then bring up the banked system.
Note that your system probably displays addresses that differ from the addresses in the following example.
You can use SID, Digital Research' s Symbolic Debugger Program, running under CP/M 2.2, to help debug
your customized BIOS. The following steps outline a sample debugging session.
1) Determine the amount of memory available to CP/M 3 when the debugger and CP/M 2.2 are in memory. To
do this, load the debugger under CP/M 2.2 and list the jump instruction at location 0005H. In the following
example of a 64K system, C500 is the base address of the debugger, and also the maximum top of memory thatyou can specify in GENCPM for your customized CP/M 3 system.
A>SID
CP/M 3 SID - Version 3.0#L50005 JMP C500

2) Running under CP/M 2.2, use GENCPM to generate a CPM3.SYS file, which specifies a top of memory thatis less than the base address of the debugger, as determined by the previous step. Allow at least 256K bytes fora patch area. In this example, you can specify C3 to GENCPM as the top of memory for your CP/M 3 system.
A>GENCPM
Top page of memory (FF)? C3

3) Now you have created a system small enough to debug under SID. Use SID to load the CPMLDR.COM file,as shown in the following example:
A>SID CP14LDR.COM
CP/M 3 SID - Version 3.0
NEXT MSZE PC END
0E80 0EB0 0100 D4FF

4) #I$B
5) Transfer control to CPMLDR using the G command:#G

At this point, the screen clears and the following information appears:
CP/M V3.0 LOADER
Copyright (c) 1982, Digital Research
BIOS3 SPR AA00 0B00
BDOS3 SPR 8B00 1F00
34K TPA
0lA9

Digital Research : CP/M 3 System Manual

Page 75

6) With the CP/M 3 system in the proper location, you can set passpoints in your BIOS. Use the L commandwith the address specified as the beginning of the BIOS by the CPMLDR load table as shown in step 5 above.
This L command causes SID to display the BIOS jump vector which begins at that address. The jump vector
indicates the beginning address of each subroutine in the table. For example, the first jump instruction in theexample below is to the Cold Boot subroutine.
#LAA00The output from your BIOS might look like this:JMP AA68
JMP AA8E
JMP ABA4
JMP ABAF
JMP ABCA

7) Now set a passpoint in the Cold BOOT routine. Use the P command with an address to set a passpoint at that
address.
#PAA68

8) Continue with the CPMLDR.COM program by entering the G command, followed by the address of Cold
Boot, the first entry in the BIOS jump vector.
#GAA009) In response to the G command, the CPMLDR transfers control to the CP/M 3 operating system. If you set a
passpoint in the Cold BOOT routine, the program stops executing, control transfers to SID, and you can begin
tracing the BOOT routine.
10) When you know the BOOT routine is functioning correctly, enter passpoints for the other routines you want
to trace, and begin tracing step by step to determine the location of problems.
Refer to the Digital Research Symbolic Instruction Debugger User's Guide (SID) in the Programmer's Utilities
Guide for the CP/M Family of Operating Systems for a discussion of all the SID commands.

Digital Research : CP/M 3 System Manual

Page 76

Appendix A
Removable Media Considerations
All disk drives under CP/M 3 are classified as either permanent or removable. In general, removable drives
support media changes; permanent drives do not. Setting the high-order bit in the CKS field in a drive's Disk
Parameter Block (DPB) marks the drive as a permanent drive.
The BDOS file system distinguishes between permanent and removable drives. If a drive is permanent, theBDOS always accepts the contents of physical record buffers as valid. In addition, it also accepts the results ofhash table searches on the drive.
On removable drives, the status of physical record buffers is more complicated.
Because of the potential for media change, the BDOS must discard directory buffers before performing mostdirectory related BDOS function calls. This is required because the BDOS detects media changes by reading
directory records. When it reads a directory record, the BDOS computes a checksum for the record, andcompares the checksum to the currently stored value in the drive's checksum vector . If the checksum values do
not match, the BDOS assumes the media has changed. Thus, the BDOS can only detect a media change by anactual directory READ operation.
A similar situation occurs with directory hashing on removable drives. Because the directory hash table is amemory-resident table, the BDOS must verify all unsuccessful hash table searches on removable drives byaccessing the directory.
The net result of these actions is that there is a significant performance penalty associated with removable
drives as compared to permanent drives. In addition, the protection provided by classifying a drive as
removable is not total. Media changes are only detected during directory operations. If the media is changed ona drive during BDOS WRITE operations, the new disk can be damaged.
The BIOS media flag facility gives you another option for supporting drives with removable media. However,to use this option, the disk controller must be capable of generating an interrupt when the drive door is opened.
If your hardware provides this support, you can improve the handling of removable media by implementing thefollowing procedure:
1) Mark the drive as a permanent drive and set the DPB CKS parameter to th'e total number of directory entries,
divided by four. For example, set the CKS field for a disk with 96 directory entries to 8018H.
2) Implement an interrupt service routine that sets the @MEDIA flag in the System Control Block and the DPH
MEDIA byte for the drive that signaled the door open condition.
By using the media flag facility, you gain the performance advantage associated with permanent drives ondrives that support removable media. The BDOS checks the System Control Block @MEDIA flag on entry for
all disk-related function calls. If the flag has not been set, it implies that no disks on the system have beenchanged. If the flag is set, the BDOS checks the DPH MEDIA flag of each currently logged-in disk. If the DPH
MEDIA flag of a drive is set, the BDOS reads the entire directory on the drive to determine whether the drive
has had a media change before performing any other operations on the drive. In addition, it temporarily
classifies any permanent disk with the DPH MEDIA flag set as a removable drive. Thus, the BDOS discards all
directory physical record buffers when a drive door is opened to force all directory READ operations to accessthe disk.
To summarize, using the BIOS MEDIA flag with removable drives offers two important benefits. First, because
a removable drive can be classified as permanent, performance is enhanced. Second, because the BDOS

Digital Research : CP/M 3 System Manual

Page 77

immediately checks the entire directory before performing any disk-related function an the drive if the drive's
DPH MEDIA flag is set, disk integrity is enhanced.

Digital Research : CP/M 3 System Manual

Page 78

Appendix B : Auto-density Support
Auto-density support refers to the capability of CP/M 3 to support different types of media on a single drive.
For example, some floppy-disk drives accept single-sided and double-sided disks in both single-density anddouble-density formats. Auto-density support requires that the BIOS be able to determine the current density
when SELDSK is called and to subsequently be able to detect a change in disk format when the READ or
WRITE routines are called.
To support multiple disk formats, the drivers BIOS driver must include a Disk Parameter Block (DPB) for eachtype of disk or include code to generate the proper DPB parameters dynamically. In addition, the BIOS driver
must determine the proper format of the disk when the SELDSK entry point is called with register E bit 0 equal
to 0 (initial SELDSK calls). If the BIOS driver cannot determine the format, it can return 0000H in register pair
HL to indicate the select was not successful. Otherwise, it must update the Disk Parameter Header (DPH) toaddress a DPB that describes the current media, and return the address of the DPH to the BDOS.
Note: all subsequent SELDSK calls with register E bit 0 equal to 1, the BIOS driver must continue to return theaddress of the DPH returned in the initial SELDSK call. The value 0000H is only a legal return value for initial
SELDSK calls.
After a driver's SELDSK routine has determined the format of a disk, the driver's READ and WRITE routines
assume this is the correct format until an error is detected. If an error is detected and the driver determines thatthe media has been changed to another format, it must return the value OFFH in register A and set the media
flag in the System Control Block. This signals the BDOS that the media has changed and the next BIOS call tothe drive will be an initial SELDSK call. Do not modify the drivers DPH or DPB until the initial SELDSK callis made.
Note that the BDOS can detect a change in media and will make an initial SELDSK call, even though the BIOS
READ and WRITE routines have not detected a disk format change. However, the SELDSK routine must
always determine the format on initial calls.
A drive's Disk Parameter Header (DPH) has associated with it several uninitialized data areas: the allocation
vector, the checksum vector, the directory hash table, and physical record buffers. The size of these areas isdetermined by DPB parameters. If space for these areas is explicitly allocated in the BIOS, the DPB that
requires the most space determines the amount of memory to allocate. If the BIOS defers the allocation of theseareas to GENCPM, the DPH must be initialized to the DPB with the largest space requirements. If one DPB is
not largest in all of the above categories, a false one must be constructed so that GENCPM allocates sufficientspace for each data area.

Appendix C : Modifing a CP/M 2 BIOS
If you are modifying an existing CP/M 2.2 BIOS, you must note the following changes.


The BIOS jump vector is expanded from 17 entry points in CP/M 2.2 to 33 entry points in CP/M 3. You
must implement the necessary additional routines.
The Disk Parameter Header and Disk Parameter Block data structures are expanded.

See Section 3 of this manual, "CP/M 3 BIOS Functional Specifications," for details of the BIOS data structuresand subroutines. The following table shows all CP/M 3 BIOS functions with the changes necessary to support
CP/M 3.

Digital Research : CP/M 3 System Manual

Page 79

Table C-1. CP/M 3 BIOS Functions
Function

Meaning

BIOS Function 00: BOOT

The address for the JMP at location 5 must be obtained from @MXTPA in the
System Control Block.

BIOS Function 01: WBOOTThe address for the JMP at location 5 must be obtained from @MXTPA in the
System Control Block. The CCP can be reloaded from a file.

BIOS Function 02: CONST

Can be implemented unchanged.

BIOS Function 03: CONIN

Can be implemented unchanged. Do not mask the high-order bit.

BIOS Function 04: CONOUT Can be implemented unchanged.
BIOS Function 05: LISTCan be implemented unchanged.

BIOS Function 06: AUXOUT Called PUNCH in CP/M 2. Can be implemented unchanged.
BIOS Function 07: AUXIN

Called READER in CP/M 2. Can be implemented unchanged. Do not mask
the high-order bit.

BIOS Function 08: HOME

No change.

BIOS Function 09: SELDSKCan not return a select error when SELDSK is called with bit 0 in register E
equal to 1.

BIOS Function 10: SETTRK No change.
BIOS Function 11: SETSEC

Sectors are physical sectors, not logical 128-byte sectors.

BIOS Function 12: SETDMA

Now called for every READ or WRITE operation. The DMA buffer can now
be greater than 128 bytes.

BIOS Function 13: READ

READ operations are in terms of physical sectors. READ can return a 0FFH
error code if it detects that the disk format has changed.

BIOS Function 14: WRITE

WRITE operations are in terms of physical sectors. If write detects that thedisk is Read-Only, it can return error code 2. WRITE can return a 0FFH error
code if it detects that the disk format has changed.

BIOS Function 15: LISTST

Can be implemented unchanged.

BIOS Function 16: SECTRN Sectors are physical sectors, not logical 128-byte sectors.
The following is a list of new BIOS functions:
BIOS Function 17: CONOST
BIOS Function 18:

AUXIST

BIOS Function 19: AUXOSTBIOS Function 20:

DEVTBL

BIOS Function 21:

DEVINI

BIOS Function 22: DRVTBL
BIOS Function 23: MULTIODigital Research : CP/M 3 System Manual
BIOS Function 24:

FLUSH

BIOS Function 25:

MOVE

BIOS Function 26:

TIME

BIOS Function 27: SELMEM
BIOS Function 28:

SETBNK

BIOS Function 29:

XMOVE

BIOS Function 30:

USERF

BIOS Function 31: RESERV1
BIOS Function 32: RESERV2Page 80

Digital Research : CP/M 3 System Manual

Page 81

Appendix D : CPM3.SYS File Format
Table D-1. CPM3.SYS File Format
RecordContents

0

Header Record (128 bytes)

1

Print Record (128 bytes)

2-nCP/M 3 operating system in reverse order, top down.

Table D-2. Header Record Definition
Byte

Contents

0

Top page plus one, at which the resident portion of CP/M 3 is to be loaded top down.

1

Length in pages (256 bytes) of the resident portion of CP/M 3.

2

Top page plus one, at which the banked portion of CP/M 3 is to be loaded top down.

3

Length in pages (256 bytes) of the banked portion of CP/M 3.

4-5

Address of CP/M 3 Cold Boot entry point.

6-15

Reserved.

16-51

Copyright Message.

52

Reserved.

53-58

Serial Number.

59-127 Reserved.
The Print Record is the CP/M 3 Load Table in ASCII, terminated by a dollar sign ($).

Digital Research : CP/M 3 System Manual

Page 82

Appendix E : Root Module of Relocatable BIOS for
CP/M 3All the listings in Appendixes E through I are assembled with , the cP/M Relocating Macro Assembler , andcross-referenced XREF , an assembly language cross-reference program used with . listings are output from the
XREF program. The assembly sources are on your distribution disk as ASM files.
1 title 'Root module of relocatable BIOS for CP/M 3.0'
2
3 ; version 1.0 15 Sept 82
45 FFFF = true equ -1
6 0000 = false equ not true
7
8 FFFF = banked equ true
9
10
11 ;
Copyright (C), 1982
12 ;Digital Research, Inc
13 ;P.O. Box 579
14 ;Pacific Grove, CA 93950
15
16
17 ;
This is the invariant portion of the modular BIOS and is18 ;distributed as source for informational purposes only.
19 ;All desired modifications should be performed by
20 ;adding or changing externally defined modules.
21 ;This allows producing "standard" I/O modules that22 ;can be combined to support a particular system
23 ;configuration.
24
25000d = cr equ 13
26000A =
1f equ 10270007 = bell equ 7280011 = ctlQ equ 'Q'-'@'
29
0013 = ctlS equ 'S'-'@'
30
310100 = ccp equ 0100h; CCP gets loaded the TPA
32
33 cseg ; GENCPM puts CSEG stuff in common memory
34
35
36; variables in system data page37
38 extrn @covec,@civec,@aovec.@aivec,@lovec ; I/O redirection vectors
39 extrn @mxtpa; addr of system entry point
40 extrn @bnkbf; 128 byte scratch buffer41
42; initialization
43
44 extrn ?init; general initialization and signon

Digital Research : CP/M 3 System Manual

Page 83

45 extrn ?ldccp,?rlccp; load & reload CCP for BOOT & WBOOT
46
47; user defined character I/O routines
48
49 extrn 7ci,?co,?cist,?cost; each take device in <B>
50 extrn ?cinlt; (re)initialize device in <C>
51 extrn @ctbl; physical character device table
52
53; disk communication data items
54
55 extrn @dtbl; table of pointers to XDPHs
56 public @adrv,@rdrv,@trk,@sect; parameters for disk I/O
57 public @dma,@dbnk,@cnt
;
"
"
"
58
59
; memory control
60
61 public @cbnk; current bank
62 extrn ?xmove,?move; select move bank, and block move
63 extrn ?bank; select CPU bank64
65
; clock support
66
67 extrn ?time; siqnal time operation
68
69; general utility routines
70
71 public ?pmsg,?pdec; print message, print number from 0 to 65535
72 public ?pderr; print BIOS disk error message header
73
74 maclib modebaud; define mode bits
75
76
77
; External names for BIOS entry points
78
79 public ??boot,?wboot,?const,?conin,?cono,?list,?auxo,?auxi
80 public ?home,?sldsk,?sttrk ,?stsec,?stdma,7read,?write
81 public ?lists,?sctrn
82 public ?conos,?auxis,?auxos,?dvtbl,?devin,?drtbl
83 public 7mltio,?flush,?mov,7tim,?bnksl,7stbnk,?xmov
84
85
86; BIOS Jump vector
8788' All BIOS routines are invoked by calling these89; entry points.
90
91?boot: jmp boot; initial entry on cold start
92?wboot. jmp wboot; reentry on program exit, warm start
93
94?const. jmp const; return console input Status
95?conin: jmp conin; return console input character96?cono: jmp conout; send console output character
97?list: jmp list
; send list output character

Digital Research : CP/M 3 System Manual

Page 8498?auxo: jmp auxout; send auxilliary output character99?auxi: jmp auxin; return auxilliary input character
100101?home: jmp home
; met disks to logical home102
?sldsk: jmp seldek; select disk drive, return disk parm info
103
?sttrk: jmp settrk; Set disk track104?stsec: jmp setsec; set disk sector
105?stdma: jmp setdma; set disk I/O memory address
106?read: jmp read; read physical block(s)107?write: jmp write; write physical block(s)108109?lists: jmp listat; return list device Status
110?sctrn: jmp sectrn; translate logical to physical sector
111
112?conos: jmp conost; return console output status
113?auxis: jmp auxibt; return aux input status
114?auxoS: jmp auxost; return aux output status
115?dvtbl: jmp devtbl; return address of device def table
116?devin: jmp ?cinit; change baud rate of device
117
118?drtbl: jmp getdrv; return address of disk drive table
119?mltio: jmp multio; Set multiple record count for disk I/O
120?flush: jmp flush; flush BIOS maintained disk caching
121
122?mov: jmp ?move; block move memory to memory
123?tim: jmp ?time; Signal Time and date operation
124?bnksl: jmp bnksel; select bank for code execution and DMA
125?stbnk: jmp setbnk; select different bank for disk I/O DMA
126?xmov:jmp ?xmove; set source and destination banks for one 127
128
jmp
0
; reserved for system implementor
129
jmp
0
; reserved for future expansion
130
jmp
0
; reserved for future expansion
131
132
133
; BOOT
134;
Initialentry point for SyStem startup.
135
136 dseg; this part can be banked
137
138 boot:139
lxi sp,boot$stack140
mvi c,15; initialize all 16 character devices
141 c$init$loop:
142
push b142acall ?cinit
142b
pop b
143
dcr c
143a
jp c$init$loop
144
145
call ?init; perform any additiunal system initialization146; and print signon message
147
148
lxi b,16*256+0

Digital Research : CP/M 3 System Manual

Page 85148alxi h,@dtbl; Init all 16 logical disk drives
149 d$init$loop:
150
push b; save remaining count and abs drive151
mov e,m
151a
inx h
151b
mov d,m151c
inx b; grab @drv entry
152
mov a,e
152a
ora d
152b
jz d$init$next; if null, no drive
153
push h; save @drv pointer154
xchg; XDPH address in HL
155
dcx h
155a
dcx h
155b
mov a,m155c
sta @RDRV; get relative drive code
156
mov a,c156asta @ADRV; get absolute drive code
157
dcx h
; point to init pointer158
mov d,m
158a
dcx h
158b
mov e,m; get init pointer
159
xchg
159a
call ipchl; call init routine
160
pop h
; recover @drv pointer161 d$init$next:
162
pop b
; recover counter and drive #
163
inr c
163a
dcr b
163b
jnz d$init$loop; and loop for each drive164
jmp boot$l165
166 cseg; following in resident memory
167
168 boot$l:
169
call set$jumps
170
call ?ldccp; fetch CCP for first time171
jmp ccp172
173
174; WBOOT
175;
Entry for system restarts.
176
177 wboot:178
lxi sp,boot$stack
179
call set$jumps; initialize page zero
180
call ?rlccp; reload CCP
181
jmp ccp; then reset jmp vectors and exit to ccp
182
183
184 set$jumps:
185
186 if banked

Digital Research : CP/M 3 System Manual187
mvi a,1
187acall ?bnksl
188 endif
189
190
mvi a,JMP
191
sta 0
191a
sta 5
; met up jumps in page zero192
lxi h,?wboot
192ashld 1; BIOS warm start entry193
lhld @MXTPA
193a
shld 6; BDOS system call entry
194
ret
195
196
197
ds 64
198
boot$stack equ $
199
200
201
; DEVTBL
202;
Return address of character device table
203
204 devtbl:
205
lxi h,@ctbl
205a
ret
206
207
208
; GETDRV
209;
Return address of drive table
210
211 getdrv:
212
lxi h,@dtbl
212a
ret
213
214
215
216
; CONOUT
217;
Console Output. Send character in <C>
218;
to all selected devices
219
220 conout;
221
222
lhld @covec; fetch console output bit vector
223
jmp out$scan
224
225
226
; AUX0UT
227;
Auxiliary Output. Send character in <C>
228:
to all selected devices
229
230 auxout:
231
lhld @aovec; fetch aux output bit vector
232
jmp out$Scan
233

Page 86

Digital Research : CP/M 3 System Manual

Page 87

234
235; LIST
236;
List Output. Send character in <C>
237;
to all selected devices.
238
239 list:240
lhld @lovec; fetch list output bit vector
241242 out$scan:243
mvi b,; Start with device 0
244 co$next:
245
dad h
; shift out next bit
246
jnc not$out$device
247
push h; save the vector
248
push b; save the count and character
249 not$out$ready:250
call coster
250a
ora a
250b
jz not$out$ready
25l
pop b
251a
push b; restore and resave the character and device
252
call ?co; if device selected, print it
253
pop b
; recover count and character
254
pop h
; recover the rest of the vector
255 not$out$device:
256
inr b
; next device number
257
mov a,h257aora 1; see if any devices left258
jnz co$next; and go find them. . .
259
ret
260
261
262
; CONOST
263;
Console Output Status. Return true if
264;
all selected console output devices
265;
are ready.
266
267 conost:268
lhld @covec; get console output bit vector269
jmp ost$scan
270
271
272
; AUXOST
273;
Auxiliary Output Status. Return true if
274;
all selected auxiliary output devices
275;
are ready.
276
277 auxost:
278
lhld @aovec; get aux output bit vector279
jmp ost$scan
280
281
282
; LISTSTDigital Research : CP/M 3 System Manual

Page 88

283,
List Output Status. Return true if
284;
all selected list output devices285;
are ready.
286
287 listst:288
lhld @lovec; get list output bit vector289
290 ost$scan:291
mvi b,0; start with device 0292 cos$next:
293
dad h
; check next bit
294
push h; save the vector
295
push b; save the count296
mvi a,0FFh; assume device ready297
cc coster; check status for this device
298
pop b
; recover count
299
pop h
; recover bit vector
300
ora a
; see if device ready301
rz; if any not ready, return false
302
dcr b
; drop device number
303
mov a,b303aora 1; see if any more selected devices304
jnz cos$next
305
ori 0FFh; all selected were ready, return true
306
ret
307
308 coster:; check for output device ready. including optional309; xon/xorf support
310
mov l,b
310a
mvi h,0; make device code 16 bits
311
push h; save it in stack
312
dad h
312a
dad h
312b
dad h
; offset into device characteristics tbl
313
lxi d,@ctbl+6
313a
dad d
; make address of mode byte314
mov a,m314a
ani mb$xonxoff
315
pop h
; recover console number in HL
316
jz
?cost
; not a xon device, go get output status direct317
lxi d,xofflist
317a
dad d
; make pointer to proper xon/xoff flag
318
call cisti; see if this keyboard has character319
mov a,m319a
cnz cii; get flag or read key if mny320
cpi ctlq
320a
jnz not$q; if its a ctl-Q,
321
mvi a,0FFh; set the flag ready322 not$g:
323
cpi ctls
323a
jnz not$s; if its a ctl-S,
324
mvi a,00h; clear the flag
325 not$s:

Digital Research : CP/M 3 System Manual326
mov m,a; save the flag
327
call costl; get the actual output status,
328
ana m
; and mask with ctl-Q/ctl-S flag
329
ret
; return this am the status330
331 cistl:; get input status with BC and HL saved
332
push b332apush h333
call ?cist
334
pop h
334a
pop b
335
ora a
336
ret
337
338 costl; get output status, saving BC & HL
339
push b339apush h340
call ?cost
341
pop h
341a
pop b
342
ora a
343
ret
344
345 cil:; get input, saving BC & HL
346
push b346apush h347
call ?ci
348
pop h
348a
pop b
349
ret
350
351
352
; CONST
353;
Console Input Status. Return true if354;
any selected console input device355;
has an available character.
356
357 const358
lhld @civec; get console input hit vector359
jmp ist$scan
360
361
362
; AUXIST
363;
Auxiliary Input
Status. Return true if364;
any selected auxiliary input device365;
has an available character.
366
367 auxist:
368
lhld @aivec; get aux input bit vector369
370 ist$scan:371
mvi b,0; start with device 0372 cis$next:

Page 89

Digital Research : CP/M 3 System Manual

Page 90373
dad h; check next hit
374
mvi a,0, assume device not ready375
cc cistl; check status for this device
376
ora a
376a
rnz
; if any ready, return true
377
inr b
; next device number378
mov a,h378aora 1; see if any more selected devices379
jnz cis$next
380
xra a
; all selected were not ready. return false
381
ret
382
383
384
; CONIN
385;
Console Input.Return character from first386;
ready console input device.
387
388 conin:389
lhld @Civec390
jmp in$scan
391
392
393
; AUXIN
394;
Auxiliary Input. Return character from first395;
ready auxiliary input device.
396
397 auxin:398lhld @aivec
399
400 in$scan:
401
push h; save bit vector402
mvi b,0403 ci$next:
404
dad h
; shift out next bit
405
mvi a,0; insure 00 a (nonexistant device not ready)406
cc cisti; see if the device has a character
407
ora a
408
jnz ci$rdy; this device has a character
409
dcr b
; else, next device
410
mov a,h410aora 1; see if any more devices411
jnz ci$next; go look at them
412
pop h
; recover bit vector413
jmp in$scan; loop til we find a character
414
415 ci$rdy:
416
pop h
; discard extra stack417
jmp ?ci
418
419
421
;
Utility Subroutines
421
422

Digital Research : CP/M 3 System Manual
423 ipchl:; vectored CALL point
424
pchl
425
426
427
?pmsg:; print message @HL up to a null428
; saves BC & DE
429
push b430
push d431 pmsg$loop:432
mov a,m
432a
ora a
432b
jz pmsg$exit433
mov c,a433apush h434
call ?cono
434a
pop h
435
inx h
435a
jmp pmsg$loop
436 pmsg$exit:
437
pop d
438
pop h
439
ret
440
441
?pdec:; print binary number 0-65535 from HL
442
lxi b,tablel0442a
lxi d,-10000
443 next:
444
mvi a, '0'-1445 pdecl:
446
push h
446a
inr a
446b
dad d
446c
jnc stoploop447
inx sp447a
inx sp
447a
jmp pdecl
448 stoploop:
449
push d449apush b450
mov c,a450acall ?cono
451
pop b
451a
pop d
452 nextdigit:
453
pop h
454
ldax b454a
mov e,a
454b
inx b
455
ldax b455a
mov d,a
455b
inx b
456
mov a,e456aora dPage 91

Digital Research : CP/M 3 System Manual456b
jnz next
457
ret
458
459 tabel10:460dw-1000,-100,-10,-1,0461
462?pderr:463
lxi h,drive$msg
463a
call ?pmsg; error header
464
lda @adrv
464a
adi 'A'464b
mov c,a464ccall ?cono; drive code469
lxi h,track$msg
469a
call ?pmsg; track header466
lhld @trk
466acall ?pdec; track number
467
lxi h,sector$msg
467a
call ?pmsg; sector header
468
lhld @sect468acall ?pdec; sector number
469
ret
470
471
472
: BNKSEL
473;
Bank Select. Select CPU bank for further execution.
474
475 bnksel
476
sta @cbnk; remember current bank477
jmp ?bank; and go exit through users
478; physical bank select routine
479
480
481
xofflist db -1,-1,-1,-1,-1,-1,-1,-1; ctl-s clears to zero482
db
-1,-1,-1,-1,-1,-1,-1,-1
483
484
485
486 dseg; following resides in banked memory
487
488
489
490
; Disk I/O interface routines
491
492
493
; SELDSK
494;
Select Disk Drive. Drive code in <C>.
495;
Invoke login procedure for drive496;
if this is first select. Return497;
address of disk parameter header
498
;
in HL
499
500 seldsk:

Page 92

Digital Research : CP/M 3 System Manual501
mov a,c
501a
sta @adrv; save drive select code502
mov l,c502a
mvi h,0502b
dad h; create index from drive code503
lxi h,@dtbl
503a
dad b
; get pointer to dispatch table504
mov a,m
504a
inx h
504b
mov h,m504c
mov l,a; point at disk descriptor
505
ora h
505a
rz
; if no entry in table, no disk506
mov a,e
506a
ani 1
506b
jnz not$first$select; examine login bit
507
push h507axchg; put pointer in stack & DE
508
lxi h,-2
508a
dad d
508b
mov a,m508c
sta @RDRV; get relative drive509
lxi h,-6509a
dad d; find LOGIN addr
510
mov a,m
510a
inx h
510b
mov h,m510c
mov l,a; get addr of LOGIN routine
511
call ipchl; call LOGIN
512
pop h
; recover DPH pointer
513 not$first$select:
514
ret
515
516
517
;
HOME
518
;
Home selected drive. Treated as SETTRK(0).
519
520 home:
521
lxi b,0; same as set track zero
522
523
524
; SETTRK
525;
Set Track. Saves track address from BC
526;
in @TRE for further operations.
527
528 settrk:
529
mov l,c529a
mov h,b530
shld @trk
531
ret
532
533
534
; SETSEC

Page 93

Digital Research : CP/M 3 System Manual535;
Set Sector. Saves sector number from BC
536;
in @sect for further operations.
537
538 setsec
539
mov l,c539a
mov h,b540
shld @sect
541
ret
542
543
544
; SETDMA
545;
Set Disk Memory Address. Saves DMA address
546;
from BC in @DMA and sets @DBNK to @CBNK
547;
so that further disk operations take place548;
in current bank.
549
550 setdma551
mov l,c551a
mov h,b552
shld @dma
553
554
lda @cbnk; default DMA bank is current hank555
; fall through to set DMA bank556
557
; SETBNK
558;
Set DiBk Memory Bank. Saves bank number
559;
in @DBNK for future disk dBtB
560;
transfers.
561
562 setbnk
563
sta @dbnk
564
ret
565
566
567
; SECTRN
568;
Sector Translate. Indexes skew table in DE
569;
with sector in BC. Returns physical Sector570;
in HL If no skew table (DE=0) then571;
returns physical=logical.
572
573 sectrn:
574
mov l,c574a
mov h,b575
mov a,d
575a
ora e
575b
rz
576
xchg
576a
dad b
576b
mov l,m576c
mvi h,0
577
ret
578
579

Page 94

Digital Research : CP/M 3 System Manual

Page 95

580; READ
581;
Read physical record from currently selected drive,
582;
Finds address of proper read routine from583;
extended disk parameter header (XDPH) .
584
585 read:586
lhld @adrv
586a
mvi h,0586b
dad h; get drive code and double it587
lxi d,@dtbl
587a
dad d
; make address of table entry588
mov a,m
588a
inx h
588b
mov h,m588c
mov l,a; fetch table entry
589
push h; save address of table590
lxi d,-8590a
dad d; point to read routine ddress591
jmp rw$common; use common code
592
593
594
; WRITE
595;
Write physical sector from currently selected drive.
596;
Finds address of proper write routine from597;
extended disk parameter header (XDPH) .
598
599 write:
600
lhld @adrv
600a
mvi h,0600b
dad h; get drive code and double it
601
lxi d,@dtbl
601a
dad d
; make address of table entry602
mov a,B
602a
inx h
602b
mov h,m602c
mov l,a; fetch able entry
603
push h; save address of table
604
lxi d,-10
604a
dad d
; point to write routine address
605
606 rw$common:
607
mov a,m
607a
inx h
607b
mov h,m607c
mov l,a; get address of routine
608
pop d
; recover address of table
609
dcx d
609a
dcx d
; point to relative drive
610
ldax d610a
sta @rdrv; get relative drive code and post it
611
inx d
611a
inx d
; point to DPN again
612pchl; leap to driver

Digital Research : CP/M 3 System Manual

Page 96

613
614
615
; MULTIO
616;
Set multiple sector count. Saves passed count in
617
;
@CNT
618
619 multio
620
sta @cnt
620a
ret
621
622
623
; FLUSH624;
BIDS deblocking buffer flush. Not implemented.
625
626 flush:
627
xra a
627a
ret
; return with no error
628
629
630
631
; error message components
632
drive$msg db cr,lf,bell,'BIOS Error on ',0633
track$msg db ' T-',0634
sector$msg db ', S-',0
635
636
637
; disk communication data items
638
639@adrv ds
1
; currently melected dimk drive
640@rdrv ds
1
; controller relative disk drive
641@trk ds
2; current track number
642@eect ds2
; Current Sector number
643@dma ds2; Current DMA address
644@cnt db0; record count for multisectortransfer
645@dbnk db0
; bank for DMA operations
646
647
648 cseg; common memory649
650@cbnk db0
; bank fOr processor operations
651
652
653
023C end
AUXIN
0198 99
397#
AUXIST
017D 113
367#
AUXOST
0l0C 114277#
AUXOUT
00E0 98
230#
BANKED
FFFF 8#186
BAUD1100003
BAUD12000
0008
BAUD134
0004
BAUDl500005

Digital Research : CP/M 3 System Manual
BAUDl800
BAUD19200
BAUD2400
BAUD300
BAUD3600
BAUD4800
BAUD50
BAUD600
BAUD7200
BAUD75BAUD9600
BAUDNONEBELL
BNKSEL
BOOT
BOOT1
BOOTSTACKCCP
CI1CINEXT
CINITLOOPCIRDY
CISNEXTCIST1CONEXTCONIN
CONOSTCONOUTCONST
COSNEXTCOST1
COSTER
3081
CR
CTLQ
CTLS
DEVTBLDINITLOOPDINITNEXT
DRIVEMSG
FALSE
FLUSH
GETDRVHOME
INSCANIPCHL
ISTSCANLF
LIST
LISTST
MBINOUTMBINPUTMBOUTPUT

00009
000F
000A
0006
000B
000C
0001
0007
000D
0002
000E
0000
0007 27#0225 124
0000 910063 164
00D2 139
0100 31#016F 319
019E 403#
0005 141#
01B2 408
0182 372#
015D 318
00EB 244#
0192 950106 11200DA 960177 940117 292#
0166 327
012C 250
000D 25#0011 281
0013 291
00D2 115
0017 1491
0036 15200]D10000 6#00CF 12000D6 118
006E 101019B 390*01B60180 359
000A 26#
00E6 970112 109
0003
0001
0002

632
475#
138#
168#
178
171
345#
411
143
415#
379
331#
258
388#
267#
220#
357#
304
3381
297
632
320
323
2041
163
1611
463
6261
211#
5201
4001
159
3701
632
2391
2879

1981
181

375

406

6321

413
4231

511

Page 97

Digital Research : CP/M 3 System Manual
MBSERIAL
MBSOFTBAUDMBXONXOFFMULTIONEXT
NEXTDIGITNOTFIRSTSELECTNOTOUTDEVICENOTOUTREADY
NOTQ
HOTS
OSTSCANOUTSCANPDECLPMSGEXITPMSGLOOPREADRWCOMMONSECTORMSG
SECTRNSELDSKSETBNKSETDMASETJUMPSSETSECSETTRKSTOPLOOPTABLEl0
TRACKMSG
TRUE
WBOOT
WRITE
XOFFLIST?AUXI?AUXIS?AUXO?AUXOS?BANK?BNKSL?BOOT?CI?CINIT?CIST?CO?CONIN?CONO?CONOS?CONST?COST?DEVIN?DRTBL?DVTBL?FLUSH

0008
0004
0010
00CB
0lD1
01E6
006D
00FF
00Fl
0150
0157
0115
00E9
01D3
01C8
01B9
0094
00BD
00E8
0089
003F
0085
007D
0078
0077
0071
0lDE
01F3
00E3
FFFF
006C
00AA
022B
0015
0036
0012
0039
0000
0051
0000
0000
0000
0000
0000
0009
000C
0033
0006
0000
003F
0042
003C
0048

314
119
443#
452#
506
246
249#
320
323
269
223
445#
432
431#
106
591
46?
110
102
125
105
169
104
103
446
442
465
S#
92
107
317
79
82
79
82
63
83
79
49
50
49
49
79
79
82
79
49
82
82
82
83

6191
456
513#
255#
250
322#
325#
279
232
447
436#
435
SBS#
606#
634#
573#
500#
562#
550#
179
538#
528#
448#
459#
633#
6
177#
599#
481#
99#
113#
98#
114#
477
l24#
91#
347
116
333
252
95#
96#
112#
941
316
116#
118#
115#
1201

290#
242#

184#

8

187
417
142

434

340

450

464

Page 98

Digital Research : CP/M 3 System Manual
?HOME
?INIT
?LDCCP?LIST?LISTS?MLTIO
?MOV
?MOVE
?PDEC
?PDERR?PMSG?READ?RLCCP?SCTRN?SLDSK?STBNK?STDMA?STSEC?STTRK?TIM?TIME?WBOOT?WRITE?XMOV?XMOVE@ADRV@AIVEC@AOVEC@BNKBF@CBNK@CIVEC@CNT@COVEC
@CTBL
@DBNK
@DMA
@DTBL
@LOVEC@MXT'PA
@RDRV
@SECT
@TRK

0018
0000
0000
000F
002D
0045
004B
0000
0ICB
0IFD
01B7
0027
0000
0030
001B
0054
0024
0021
00lE
004E
0000
0003
002A
0057
0000
00ED
0000
0000
0000
023B
0000
00F5
0000
0000
00F6
00F3
0000
0000
0000
00EE
00F1
00EF

80
44
45]
79
81
83
83
62
71
72
71
80
45
81
80
83
80
80
80
83
67
79
80
83
62
56
38
38
40
61
38
57
38
51
57
57
55
38
39
56
56
56

l0ll
145
170
97#
109#
119#
1221
122
4411
4621
4271
106#
180
1101
1021
125#
1051
1041
1031
1231
123
921
1071
1261
126
156
368
231
476
358
620
222
205
563
552
148
240
193
155
468
466

466

468

463

465]

467

464
398
278

501

586

600

554
389
6441
268
313
645#
643#
212
288

650#

503

587

601

508
540
530

610
642#
641#

640#

192

639#

Page 99

Digital Research : CP/M 3 System Manual

Page 100

Appendix F : SCB Definition for CP/M 3 BIOS
The SCB.ASM module contains the public definitions of the fields in the System Control Block. The BIOS canreference public variables.
1 title 'System Control Block Definition for CP/M3 BIOS'
2
3 public @civec, @covec, @aivec, @aovec, @lovec, @bnkbf
4 public @cradma, @crdsk, @vinfo, @resel, @fx, @usrcd
5 public @mltio, @ermde, @erdsk, @media, @bflgs
6 public @date, @hour,@min, @sec, ?erjmp, @mxtpa
78
9 FE00 = srb*base equ
0FE00H, Baseof the SCB
10
11 FE22 =@CIVEC equ scb$base+22h ; Console Input Redirection
12; vector (word. r/w)
13 FE24 =@COVEC equ scb$base+24h ; Console Output Redirection
14; Vector (word, r/w)
15 FE26 =@AIVEC equ scb$base+26h ; Auxi1iary Input Redirection
16; Vector (word, r/w)
17 FE2B =@AOVEC equ scb$base+28h ; Auxiliary Output Redirection18; Vector (word. r/w)
19 FE2A =@LOVEC equ scb$base+2Ah ; List Output Redirection20; Vector (word, r/w)
21 FE35 =@BNKBF equ scb$base+35h ; Address of 128 Byte Buffer22; for Banked BIOS (word, r/o)
23 FE3C =@CRDMA equ scb$base+3Ch ; Current DMA Address
24; (word. r/o)
25 FE3E =@CRDSK equ scb$base+3Eh ; Current Disk (byte. r/o)
26 FE3F =@VINFO equ scb$base+3Fh ; BDOS Variable "INFO"
27; (word, r/o)
29 FE41 =@RESEL equ scb$base+41h ; FC0 Flag (byte, r/o)
29 FE43 =@FX equ scb$base+43h; BDOS Function )br Error
30; Message (byte, r/o)
31 FE44 =@USRCD equ scb$base+44h ; current User Code (byte, r/o)
32 FE4A =@MLTIO equ scb$base+4Ah ; Current Multi-Sector Count33; (byte. r/w)
34 FE4B =@ERMOE equ scb$base+4Bh ; BDOS Error Mode (byte. r/o)
35 FE51 =@BROSK equ scb$base+5lh ; BDOS Error Disk (byte.r/o)
36 FE54 =@MED!A equ scb$base+54h ; Set by BIOS to indicate
37; open door (byte. r/w)
38 FE57 =@BFLOS equ scb$base+57h ; BDOS Message Size Flag (byte. r/o)
39 FE58 =@iDATE equ scb$base+58h ; Date in Days Since I Jan 78
40; (word, r/w)
41 FE5A =@HOUR equ scb$base+5Ah ; Hour in BCD (byte. r/w)
42 FE5B =@MIN equ scb$base+58h; Minute in BCD (byte. r/w)
43 FE5c =@SEC equ scb$base+5Ch; Second in BCID (byte. r/w)
44 FE5F =@ERJMP equ scb$base+5Fh ; BDOS Error "Message Jump
45
; (word. r/w)
46 FE62 =@MXTPA equ scb$base+62h ; Top of User TPA
47; (address at 6, 7)(word, r/o)

Digital Research : CP/M 3 System Manual
4B 0000 end

Page 101

Digital Research : CP/M 3 System Manual

Page 102

Appendix G : Equates for Mode Byte Bit Fields; equates for mode byte bit fields
mb$inputequ
0000$000lb; device may do input
mb$output
equ0000$00l0b; device may do output
mb$in$out
equ
mb$input+mb$output
mb$soft$baud
equ0000$0100b; software selectable baud rates
mb$serialequ
0000$1000b; device may use protocol
mb$xon$xoff
equ000l$0000b; XON/XOFF protocol enabled
baud$none
equ0; no baud rate associated with device
baud$50equ1; S0 baud
baud$75equ2; 75 baud
baud$110equ3; 110] baud
baud$134equ4; 134.5 baud
baud$150
equ5; 150] baud
baud$300
equ
6; 300 baud
baud$600
equ
7; 600 baud
baud$1200
equ
8; 1200 baud
baud$1800equ
9; 1900 baud
baud$2400
equ10; 2400 baud
baud$3600
equ11; 3600 baud
baud$4800
equ12; 4800 baud
baud$7200
equ13; 7200 baud
baud$9600
equ14; 9600 baud
baud$19200
equ15; 19.2k baud

Listing G-1. Equates for Node Byte Fields: NODEBAUD.LIB

Digital Research : CP/M 3 System Manual

Page 103

Appendix H : Macro Definitions for CP/M 3 BIOS
Data Structures; dtbl<dph0,dphl,...>- drive table; dph translate$table,- disk parameter header; disk$Parameter$block,; checksum$size (optional); alloc$size (optional); skew sectors- skew table; skew$factor; first$sector$number; dpb physical$sector$size - disk parameter block; physical$sectors$per$track; number$tracks; block$size; number$dir$entries; track$offset; checksum$vec$size (optional); Drive Table. Contains 16 one word entries.
dtbl
macro ?list
Local ?n
?n
set 0
irp
?drv,<?list>?n
set ?n+l
dw
?drv
endm
if ?n > 16.'Too many drives. Max 16 allowed'
Exitm
Endif
if ?n < 16rept (16-?n)
dw 0
endm
endif
endm
dph
macro ?trans,?dpb,?csize,?asize
local ?csv,?alv
dw ?trans; translate table address
db 0,0,0,0,0,0,0,0,0; BDOS Scratch areadb 0
; media flagdw ?dpb; disk parameter block
if not nul ?csize
dw ?csv; checksum vector
else
dw 0FFFEh; checksum vector allocated by GENCPM
endif
if not nul ?asize

Digital Research : CP/M 3 System Manualdw ?alv; allocation vector

dw 0FFFEh; alloc vector allocated by GENCPM

else
endif
dw 0fffeh,0fffeh,0fffeh ; dirbeb, dtabcb, hash alloc'd by GENCPM
db 0; hash bank
if not nul ?csize?csv ds ?csize; checksum vector
endif
if not nul ?asize?alv ds ?asize; allocation vector
endif
endm
dpb macro ?psize,?pspt,?trks,?bls,?ndirs,?off,?ncks
local ?spt,?bsh,?blm,?exu,?dsm,?drm,?al0,?all,?cks,?psh,?psm
local ?n;; physical sector mask and physical sector shift?psh set 0?n
set ?psize/l28?psm Set ?n-1
rept 8?n
set ?n/2
if ?n = 0
exitm
endif
?psh set ?psh + 1
endm?spt set ?pspt*(?psize/128)?bsh set 3?n
set ?bls/1024
rept 8?n
set ?n/2
if ?n – 0
exits
endif
?bsh set ?bsh + 1
endm?blm set ?bls/128-1?size set (?trks-?Off)*?spt?dsm set ?size/(?bls/128)-1?exm set ?bls/1024
if ?dsm > 255
if ?bls - 1024.'Error, can''t have this size disk with 1k block size'
exitm
endif
?exm set ?exm/2
endif?exm set ?exm-1?all set 0?nset(?ndirs*32+?b1s-1)/?bls
rept ?nPage 104

Digital Research : CP/M 3 System Manual?all set (?all shr 1) or 8000h
endm?al0 set high ?all
?all set low ?a11
?drm set ?ndirs-1
if not nul ?ncks?cks set ?ncks
else?cks set ?ndirs/4
endif
dw ?spt; 128 byte records per track
db ?bsh,?blm; block shift and mask
db ?exm; extent mask
dw ?dsm; maximum block number
dw ?drm; maximum directory entry number
db ?al0,?al1; alloc vector for directory
dw ?cks; checksum size
dw ?0ff; offset for system tracks
db ?psh,?psm; physical sector size shift and mask
endm;
gcd macro ?m,?n;; greatest common divisor of m,n;; produces value gcdn as result;; (used in sector translate table generation)?gcdm set ?m;;variable for m?gcdn set ?n;;vsrisble for n?gcdr set 0;;variable for r
rept 65535?gcdx set ?gcdm/?gcdn?gcdr set ?gcdm - ?gcdx*?gcdn
if ?gcdr = 0
exitm
endif
?gcdm set ?gcdn?gcdn set ?gcdr
endm
endm

skew macro ?secs,?skf,?fsc;; generate the translate table?nxtsec
set 0 ;;next sector to fill
?nxtbasset 0 ;;moves by one on overflow
gcd %?secs,?skf;; ?gcdn - gcd(?secs,skew)?neltstset ?secs/?gcdn;; neltst is number of elements to generate;; before we overlap previous elements?neltsset ?neltst ;;counter
rept ?secs ;;once for each sector
db ?nxtsec+?fsc

Page 105

Digital Research : CP/M 3 System Manual?nxtsec
set ?nxtsec+?skf
if ?nxtsec >= ?secs?nxtsec
set ?nxtsec-?secs
endif?neltsset ?nelts-1
if ?nelts = 0?nxtbasset ?nxtbas+l?nxtsec
set ?nxtbas?neltsset ?neltst
endif
endm
endm

Page 106

Digital Research : CP/M 3 System Manual

Page 107

Appendix I : ACS 8000-15 BIOS Modules
I.1 Boot Loader Module for CP/M 3
The BOOT.ASM module performs system initialization other than and disk I/O. BOOT loads the CCP for cold
starts and it for warm starts. Note that the device drivers in the Research sample BIOS initialize devices for apolled, and an interrupt-driven, environment.
1 title 'Boot loadar module for Cp/M 3.0'
2
3 FFFF - true equ -1
4 0000 = false equ not true
5
6 FFFF = banked equ true
7
8 public ?init,?ldccp,?rlccp,?time
9 extrn ?pmsg,?conin
10 extrn @civec,@covec,@aivec,@aovec,@lovec
11 extrn @cbnk,?bnksl
12
13 maclib ports
14 maclib z80
1516 0005 = bdos equ 517
18 if banked
190001 = tpa$bank equ 1
20 else21
tpa$bank equ 0
22 endif
23
24 dseg ; init done from banked memory
25
26 ?init:
27
lxi h,08000h
27ashld @civec
27bshld @covec; assign console to CRT:
28
lxi h,04000h
28ashld @lovec; assign printer to LPT:
29lxi h,02000h29ashld @aivec
29bshld @aovec; assign AUX to CRTl:30
lxi h,init$table
30a
call out$blocks; set up misc hardware
31
lxi h,signon$msg
31acall ?pmsg; print signon message
32
ret
33
34 out$blocks:
35
mov a,m
35a
ora a
35b
rz

Digital Research : CP/M 3 System Manual35c
mov b,a
36
inx h
36a
mov c,m
36b
inx h
37
outir
38
DB
0EDH,0B3H
39
jmp out$blocks
40
41
42 cseg ; boot loading most be done from resident memory
43
44 ;This version of the boot loader loads the CCP from a file
45 ;called CCP.COM on the system drive (A:).
46
47
48 ?ldccp:
49 ; First time, load the A:CCP,COM file into TPA
50
xra a
50a
Sta ccp$fcb+15; zero extent
51
lxi h,051a
shld fcb$nr; start at beginning of file52
lxi d,ccp$fcb
52acall open; open file containing CCP
53
inr a
53a
jz no$CCP; error if no file. . '54
lxi d,0100h
54acall setdma; Start of TPA
55
lxi d,128
55acall setmulti; allow up to 16k bytes
56
lxi d,ccp$fcb
56acall read; load the thing
57 ; now,
58 ; copy CCP to bank 0 for reloading59
lxi h;0100h
59a
lxi b,0C80h; clone 3.125K, just in case
60
lda
@cbnk
60a
push psw; save current bank
61 ld$1:
62
mvi a,tpa$bank
62acall ?bnks; select TPA
63
mov a,m63apush psw; get a byte
64
mvi a,264acall ?bnksl; select extra bank65
pop psw
65a
mov m,s; save the byte
66
inx h
66a
dcx b
; bump pointer, drop count67
mov a,b67aora c; test for done68
jnz ld$1
69
pop psw
69acall ?bnksl; restore original bank

Page 108

Digital Research : CP/M 3 System Manual

Page 10970
ret
71
72 no$CCP:; here 1f we couldn't find the file73
lxi h,ccp$msg
73acall ?pms; report this. . .
74
call ?conin; get a response75
jmp?ldccp; and try again
76
77
78 ?rlccp:79
lxi h,0100h
79a
lxi b,0C80h; clone 3.125K
80 rl$l:81
mvi a,281acall ?bnksl; select extra bank82
mov a,m82apush psw; get a byte83
mvi a,tpa$bank
83acall ?bnksl; select TPA
84
pop psw
84a
mov m,a; save the byte
85
inx h
85a
dcx b
; bump pointer, drop count86
mov a,b86aora c; test for done87
jnz rl$1
88ret
8990 ; No external clock.
91 ?time:
92
ret
93
94 ; CP/M BDOS Function Interfaces
95
96 open:97
mvi c,l597a
jmp bdos; open file control block98
99 setdma:
100
mvi c,26
100a
jmp bdos; set data transfer address
101
102 setmulti:
103
mvi c,44103a
jmp bdos; set record count104
105 read:106
mvi c,20
106a
jmp bdos; read records
107
108
109
signon$msg db
13,l0,13,10,'CP/M Version 1.0, sample BIOS',13,l0,0110

Digital Research : CP/M 3 System Manual111
ccp$msg
112
113
114
ccp$fcb
115
ds
16
116
fcb$nr117
118
init$table
119
120
121
122
123
end
BANKED
FFFF
BC
0000
BDOS
0005
CCPFCB
00CC
CCPMSG
00AB
BE
0002
FALSE
0000
FCBNR
00BC
EL
0004
INITTABLE
00EF
IX
0004
IY
0004
1,01
0030
NOCCP
004A
OPEN
0073
OUTBLOCKS0025
PBANKSELECT
0025
PBAUDCON1000C
PBAUDCON20030
PBAUDCON34
0031
PBAUDLPT1000E
PBAUDLPT2
0032
PBOOT
0014
PCENTDATA
0011
PCENTSTAT
0010
PCON2DATA
002C
PCON2STAT
002D
PCON3DATA
002E
PCON3STAT
0021
PCON4DATA
002A
PCON4STAT
002B
PCONFIGURATION 0024
PCRTDAT'A
00IC
PCRTSTAT
001D
PFDCMND
0004
PFDDATA
0007
PFDINT
0008
PFDMISC
0009
PFDSBCTOR
000E
PFDSTAT
0004

Page 110db

13,l0,'BIOS Err on A: No CCP.COM file',0db

1,'CCP ','COM',0,0,0,0

db

0,0,0

db
db
db
db

3,p$zpio$3a,0CFh,0FFh,07h; set up config port
3,p$zpio$3b,0CFh,000h,07h;set up bank port
1,p$bank$select,0; select bank 00; end of init$table

6#

18

16#
97
50
52
73 111#100
56

4#51 ll6#
30

119#

61#
53
52
30
120

68
72#
96#
34#

39

103
114#

106

Digital Research : CP/M 3 System Manual
PFDTRACKPINDEX
PLPT2DATA
PLPT2STAT
PLP'TDATAPLPTSTATPRTC
PSELECTPWD1797
PZCTClPZCTC2PZDARTPZDNAPZPIO1PZPI01APZPIO1BPZPIO2PZPIO2APZPIO2BPZPIO3PZPIO3APZPIO3BPZSIO1PZSIO2RIAD
RL1
SETDMASETMULTI
SIGNONMSGTPABANKTRUE?BNKSL?CONIN?INIT?LDCCP?PMSG?RLCCP?TINE@AIVEC@AOVEC@CBNK@CIVEC@COVEC@LOVEC

0005
0001
0028
0029
001E
0011
0033
0008
0004
000C
0030
00IC
0000
0008
000A
000B
0010
0012
0013
0024
002E
0027
0028
002C
0082
005C
0078
007D
0087
0001
FFFF
0000
0000
0000
0000
0000
0056
0072
0000
0000
0000
0000
0000
0000

Page 111

118
119

56
80#
54
55
31
19#
3#
11
9
8
8
9
8
8
10
10
11
10
10
10

105#
87
99#
102#
109#
21#
4
62
74
26#
484
31
78#
914
29
29
60
27
27
28

62
6
64

83
69

81

83

75
73

I.2 : Character I/O Handler for Z80 Chip--based System
The CHARIO.ASM module performs all character device , input, output, and status polling. CHARIO contains
character device characteristics table.
1 title 'Character I/O handler for z80 chip based system'
2
3 ; Character I/O for the Modular CP/M 3 BIOS

Digital Research : CP/M 3 System Manual4
5 ; limitations:6
7 ; haud rates 19200;7200,3600,1800 and 134
8 ; are approximations.
9
10 ;9600 is the maximum baud rate that is likely
11 ; to work,
13 ; haud rates 50, 75, and 110 are not supported
14
15
16 public?cinit,?ci,?co,?cist,?cost
17 public@ctbl
18
19 maclib Z80; define Z80 op codes
20 maclib ports; define port addresses
21 maclib modebaud; define mode bits and baud equates
22
23 0006 = max$devices equ 62425 cseg
26
27 ?cinit:
28
mov a,c28a
cpi max$devlces
28bjz cent$init; init parallel printer29
rnc; invalid device
30
mov l,c30a
mvi h,0; make 16 bits from device number
31
push h; save device in stack
32
dad h
32a
dad h
32b
dad h
; *8
33
lxi d,@ctbl+7
33a
dad d
33b
mov 1,m; get baud rate
34
mov a,l34a
cpi baud$600; see if baud > 300
35
mvi a,44h
35a
jnc hi$speed; if > 600, use *16 mode36
mvi a,0C4h; else, use *64 mode
37 hi$speed:38
sta sio$reg$439
mvi h,039a
lxi d,speed$table
39b
dad d
; point to counter entry
40
mov a,m40a
sta speed; get and save ctc count41
pop h; recover42
lxi d,data$ports
42a
dad d
; point at SIO port address
43
mov a,m43a
inr aPage 112

Digital Research : CP/M 3 System Manual43b
sta sio$port; get and save port
44
lxi d,baud$ports-data$ports
44a
dad d
; offset to baud rate port
45
mov a,B
45a
sta ctc$port; get and save46
lxi h,serlal$init$tbl
47
jmp stream$out
48
49 cent$init:50
lxi h,pio$init$tbl
51
52 stream$out:
53
mov a,m
53a
ora a
53b
rz
54
mov b,a
54a
inx h
54b
mov c,m
54c
inx h
55
outir
56
DB
0EDH,0B3H
57
jmp stream$out
58
59
60 ?ci: ; character input
61
62
mov a,b
62a
cpi 6
62b
jnc null$input; can't read from centronics
63 cil:64
call ?cist
64ajz cii; wait for character ready
65
dcr c
65a
inp a
; get data
66
DB
0EDH,A*8+40H
67
ani 7Fh; mask parity
68
ret
69
70 null$lnput:
71
mvi a,lAh; return a ctl-Z for no device
72
ret
73
74 ?ciat:; character input Status
75
76
mov a,b
76a
cpi 6
76b
jnc null$status; can't read from centronics
77
mov l,b77a
mvi h,0; make device number 16 bits
78
lxi d,data$ports
78adad; make pointer to port address79
mov c,m79a
inr c; get SIO status port

Page 113

Digital Research : CP/M 3 System Manual80
inp a; read from status port
81
DB
0EDH,A*8+40H82
ani l; isolate RxRdy
83rz; return with zero84
ori 0FFh85
ret
86
87 null$status:
88 xra a88a
ret
89
90 ?co: ; character output
91
mov a,b
91a
cpi 6
91b
jz centronics$out
92
jnc null$Output
93
mov a,c93apush psw; save character from <C>
94
push b; save device number
95 co$spin:
96
call ?cost
96ajz co$spin; wait for TxEmpty
97
pop h
97a
mov l,h97b
mvi h,0; get device number in HL
98lxI d,data$ports
98a
dad d
; make address of port address99
mov c,m; get port address100
pop psw
100aoutp a; send data
101
DB
0EDH,A*8+41H
102 null$output:
103
ret
104
105 centronics$out:
106
in p$centstat
106aani 20h106b
jnz csntronics$out
107
mov a,c107aout p$centdata; give printer data
108
in p$centstat
108a
ori 1
108b
out p$centstat; set strobe
109
ani 7Eh109aout p$centstat; clear strobe
110
ret
111
112
?cost:; character output status
113
mov a,b
113a
cpi 6
113b
jz cent$stat114
jnc null$status115
mov 1,bPage 114

Digital Research : CP/M 3 System Manual

Page 115115a
mvi h,0116
lxi d,data$ports
116a
dad d
117
mov c,m
117a
inr c
118
inp a
; get input status
119
DB
0EDH,A*8+40H
120
ani 4
120a
rz
; test transmitter empty
121
ori 0FFh
121a
ret; return true if ready122
123
124 cent$stat:125
in p$centstat
125a
cas
126
ani 20h126arz
127
ori 0FFh
127a
ret
128
129 baud$ports:; CTC ports by physical device number
130
db p$baud$conl , p$baud$lptl , p$baud$con2, p$baud$con 34
131
db p$baud$con34,p$baud$lpt2
132
133 data$ports:; serial base ports by physical device number
134
db p$crt$data,p$lpt$data,p$con2data,p$con3data
135
db p$con4data,p$lpt2data
136
137
138
@ctbl db 'CRT '; device 0, CRT port 0
139
db mb$in$out+mb$serial+mb$softbaud140
db baud$9600
141
db 'LPT '; device 1, LPT port 0
142
db mb$in$out+mb$serial+mb$softbaud+mb$xonxoff
143
db baud$9600
144
db 'CRT1 '; device 2, CRT port 1
145
db mb$in$out+mb$serlal+mb$softbaud146
db baud$9600
147
db 'CRT2 '; device 3, CRT port 2
148
db mb$'in$out+mb$serial+mb$softbaud
149
db baud$9600
150
db 'CRT3 '; device 4, CRT port 3
151
db 'mb$in$out+mb$serial+mb$softbaud152
db baud$9600
153
db 'VAX '; device 5, LPT port 1 used for VAX interface
154
db mb$in$out+mb$serial+mb$softbaud
155
db baud$9600
156
db 'CEN '; device 6, Centronics parallel printer157
db mb$output
158
db baud$none
159
db 0 ; table terminator
160

Digital Research : CP/M 3 System Manual

Page 116

161
162
Speed$table db 0,255,255,255,233,208,104,208,104,69,52,35,26,17,13,7
163
164 serial$init$tbl
165
db
2; two bytes to CTC
166
ctc$port ds I
; port addresS of CTC
167
db
47h
; CTC mode byte
168
Speed ds
1
; baud multiplier169
db
7; 7 bytes to SIO
170
Sio$port ds 1
; port address of SIO
171db
18h,3,0Elh,4172
sio$reg$4 ds
1173db
5,0EAh174db
0; terminator
175
176
pio$init$tbl db
2,p$zpio$2b,0Fh,07h
177
db
3,p$zpio$2a,0CFh,0F8h,07h
178
db 0
179
180
end
BAUDII0
0003
BAUD1200
0008
BAUD134
0004
BAUD1500005
BAUD1800
0009
BAUD19200
000F
BAUD2400000A
BAUD300
0006
BAUD3600
000B
BAUD4800000C
BAUD500001
BAUD600
0007 34
BAUD7200
0000
BAUD750002
BAUD9600
000E 140
143
146
149
152
155
BAUDNONE
0000 158
BAUDPORTS
0006 44
129#
BC
0000
CENTINIT
0042 2849#
CENTRONICSOUT 00911 91
105# 106
CENTSTAT
00C0 113
124#
CII0057 63#
64
COSPIN
008B 95#
96
CTCPORT
012C 45166#
DATAPORTS
00DC 42
44
78
98
116
133#
DE
0002
HISPEED
001D 35
37#
HL
0004
IX
0004
IY
0004
MAXDEVICES
0006 23#
28
MBINOUT
0003 139
142
145
148
151
154
MBINPUT
0001

Digital Research : CP/M 3 System Manual
MBOUTPUT
0002
MBSERIAL
000B
MBSOFTBAUD
0004
MBXONXOFF
0010
NULLINPUT
0063
NULLOUTPUT
0090
NULLSTATUS
0070
PBANKSELECT
0025
PBAUDCON1000C
PBAUDCON20030
PBAUDCON34
0031
PBAUDLPT1000E
PBAUDLPT2
0032
PBOOT
0014
PCENTDATA
0011
PCENTSTAT
0010
PCON2DATA
002C
PCON2STAT
002D
PCON3DATA
002E
PCON3STAT
002F
PCON4DATA
002A
PCON4STAT
002B
PCONFIGURATION 0024
PCRT'DATA
001C
PCRTSTAT
001D
PFDCMBD
0004
PFDDATA
0007
PFDINT
0008
PFDMISC
0009
PFDSECTOR
0006
PFDSTAT
0004
PFDTRACK
0005
PINDEX000FPIOINITTBL
0139
PLPT2DATA
0028
PLPT2ST'AT
0029
PLPTDATA
001E
PLPTSTAT
001F
PRTC
0033
PSELECT
0008
PWD17970004
PZCTCl000C
PZCTC20030
PZDART
001C
PZDMA
0000
PZPIO10008
PZPIO1A000A
PZPIO1B
000B
PZPIO20010
PZPIO2A
0012
PZPIO2B
0013
PZPIO30024
PZPIO3A
0026

157
139
139
142
62
92
76

142
142

145
145

70#
102#
87#

114

130
130
130
130
131

131

107
106
134

108

134
135

134

50
135
134

177
176

176#

108

148
148

151
151

109

125

154
154

Page 117

Digital Research : CP/M 3 System ManualPZPIO3BPZSIO1PZSIO2SERIALINITTBL
SIOPORT
SIOREG4
SPEED
SPEEDTABLESTREAMOUT?CI?CINIT
?CIST
?CO
?COST
@CTBL

0027
0028
002C
012B
0130
0135
012E
011B
0045
0051
0000
0066
007F
0083
00E2

46
43
38
40
39
47
16
16
16
16
16
17

164#
170#
172#
168#
162#
52#
60#
27#
64
90#
96
33

Page 118

57

74#
112#
138#

I.3 : Drive TableThe DRVTBL.ASM module points to the data structures for each configured disk drive. The drive table
determines which physical disk unit is associated with which logical drive. The data structure for each disk
drive is called an Extended Disk Parameter
Header (XDPH) .
1 public @dtbl
2 extin fdsd0,fdsdl
3
4 cseg5
6@dtbl dw fdsd0,fdsdl
7
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; drives C-P non-existent
8
9 end
FDSDO
0000 26
FDSDl
0000 2
6@DTBL0000 1
6#

Listing I-3. Drive Table

I.4 Z80 DMA single-density Disk Handler
The FDl797SD module initializes the disk controllers for thedisks described in the Disk Parameter Headers and
Disk Parameter Blocks contained in this module. FDl797SD is written for hardware that supports Direct
Memory Access (DMA) .
1 title 'wd1797 w/ Z80 DMA Single density diskette handler'
2
3 ;CP/M-80 Version 3 -- Modular BIOS
45 ;Disk I/O Module for wd1797 based diskette systems
6
7 ;Initial version 0.01,
8 Single density floppy only.
- jrp, 4 Aug

Digital Research : CP/M 3 System Manual

Page 1199
10 dseg
1112 ; Disk drive dispatc))ing tables for linked BIOS
13
14 public fdsd0,fdsdl
15
16 ; Variables containing parameters passed by BDOS
17
18 extrn @adrv,@rdrv
19 extrn @dma,@trk,@sect
20 extrn @dbnk
21
22 ; System Control Block variables
23
24 extrn @ermde; BDOS error mode
25
26 ; Utility routines in standard BIOS
27
28 extrn ?wboot; warm hoot vector
29 extrn ?pmsg; printmessage @HL up to 00, saves BC & DE
30 extrn ?pdec; print binary number in A from 0 to 99,
31 extrn ?pderr; print BIOS disk error header
32 extrn ?conin,?cono; con in and out
33 extrn ?const; get console status3435
36 ; Port Address Equates
37
38 saclib ports
39
40 ; CP/M 3 Disk derinition macros
41
42 maclib cpm3
4344 ; Z80 macro library instruction definitions
45
46 maclib z80
47
48 ; common control characters49
50 000b = cr equ 13
51 000A = lf equ 10
52 0007 = bell equ 7
539455 ; Extended Disk Parameter Headers (XPDNS)
56
57
dw fd$write58
dw fd$read
59
dw fd$login
60
dw fd$init0
61
db
0,0
; relative drive zeroDigital Research : CP/M 3 System Manual

Page 12062
fdsd0 dph trans,dpbsd,16,31
63
DW TRANS; TRANSLATE TABLE ADDRESS
64
DB 0,0,0,0,0,0,0,0,0; BDOS SCRATCH AREA
65
DB 0
; MEDIA FLAG66
DW DPBSD; DISK PARAMETER BLOCK67
DW ??0001; CHECKSUM VECTOR
68
DW ??0002; ALLOCATION VECTOR69
DW 0FFFEH,0FFFEH,0FFFEH; DIRBCB, DTABCB, HASH ALLOC'D BY GENCPM
70
DB 0; HASH BANK
71
DS
16
; CHECKSUM VECTOR
72
DS
31; ALLOCATION VECTOR
73
74
dw fd$write79
dw fd$read76
dw fd$login
77
dw fd$initl
78
db
1,0
; relative drive one
79
fdsdl dph trans,dpbsd,16,3180
DW TRANS; TRANSLATE TABLE ADDRESS81
DB 0,0,0,0,0,0,0,0,0; BDOS SCRATCH AREA
82
DB 0
; MEDIA FLAG83
DW DPBSD; DISK PARAMETER BLOCK
84
DW ??0003; CHECKSUM VECTOR
85
DW ??0004; ALLOCATION VECTOR86
DW 0FFFEH,0FFFEH,0FFFEH; DIRBCB, DTABCB, HASH ALLOC'D BY GENCPM
87
DB 0; HASH BANK
88
DS
16
; CHECKSUM VECT0R
89
DS
31; ALLOCATION VECTOR
90 cseg ; DPB must be resident
92
93
dpbsd dpb 128,26,77,1024,64,2
94
DW??0005; 128 BYTE REC0RDS PER TRACK
95
DB??0006,??000; BLOCK SHIFT' AND MASK
96
DB??0008; EXTENT MASK97
DW??0009; MAXIMUM BLOCK NUMBER98
DW??0010; MAXIMUM DIRECTORY ENTRY NUMBER
99
DB??0011,??0012; ALLOC VECTOR FOR DIRECTORY100
DW??0013; CHECKSUM SIzE
101
DW
2
; OFFSET FOR SYSTEM TRACKS102
DB??0014,??0015; PHYSICAL SECTOR SIZE SHIFT AND MASK
103
104 dseg ; rest is banked
105
106 trans skew 26,6,1
107
DB?NXTSEC+1108
DB?NXTSEC+1
109
DB?NXTSEC+1
110
DB?NXTSEC+1
111
DB?NXTSEC+1
112
DB?NXTSEC+1
113
DB?NXTSEC+1
114
DB?NXTSEC+1
115
DB?NXTSEC+1

Digital Research : CP/M 3 System Manual116
DB?NXTSEC+1
117
DB?NXTSEC+1
118
DB?NXTSEC+1
119
DB?NXTSEC+1120
DB?NXTSEC+1
121
DB?NXTSEC+1
122
DB?NXTSEC+1
123
DB?NXTSEC+1
124
DB?NXTSEC+1
125
DB?NXTSEC+1
126
DB?NXTSEC+1
127
DB?NXTSEC+1
128
DB?NXTSEC+1
129
DB?NXTSEC+1130
DB?NXTSEC+1131
DB?NXTSEC+1132
DB?NXTSEC+1
133
134
135
136
; Disk I/O routines for standardized BIOS interface
137
138; Initialization entry point.
139
140; called for first time initialization.
141
142
143 fd$init0144
lxi h,init$table
145 fd$init$next:146
mov a,m
146a
ora a
146b
rz
147
mov b,a
147a
inx h
147b
mov c,m147c
inx h
148 outir
149
DB
0EDH,0B3H
150
jmp fd$init$next
151
152 fd$initl: ; all initialization done by drive 0
153
ret
154
155
init$table db 4,p$zpio$1A
156
db 11001111b, 11000010b, 000l0111b,11111111b
157
db 4,p$zpio$lB
158
db 11001111b, 1101110lb, 000l0111b,11111111b
159
db 0
160
161
162 fd$login
163; This entry is called when a logical drive is about toPage 121

Digital Research : CP/M 3 System Manual164; be logged into for the purpose of density determination.
165
166; It may adjust the parameters contained in the disk167
; parameter header pointed at by <DE)
168
169
00DB C9 ret ; we have nothing to do in
170; simple single density only environment.
171
172
173
; disk READ and WRITE entry points.
174
175; these entries are called with the following arguments:
176
177; relative drive number in @rdrv (8 bits)
178; absolute drive number in @adrv (8 bits)
179; disk transfer address in @dma (16 bitS)180; disk transfer bank in @dbnk (8 bits)
181; disk track address in @trk (16 bits)
182; disk sector address in @sect (16 bits)
183; pointer to XDPH in DE
184
185; they transfer the appropriate data, perform retries
186; if necessary, then return an error code in A
187
188 fd$read:189
lxi h,read$msg; point at " Read "190
mvi a,88h
190a
mvi b,0l h; 1797 read + Z80DMA direction
191
jmp rw$common
192
193 fd$write194
lxi h,write$msg; point at " Write "195
mvi a,0A8h
195a
mvi b,05h; 1797 write + Z80DMA direction
196; jmp wr$common; fall through197
198 rw$common: ; seek to correct track (if necessary),199; initialize DMA controller,200; and issue 1797 command.
201
202
shld operation$name; save message for errors
203
sta disk$command; save 1797 command204
mov a,b204asta zdma$direction; save Z80DMA direction code205
lhld @dma
205a
shld zdma$dma; get and save DMA address206
lda @rdrv
206a
mov 1,a206bmvi h, 0; get controller-relative disk drive
207
lxi d,select$table
207a
dad d
; point to select mask for drive208
mov a,m208a
sta select$mask; get select mask and save it

Page 122

Digital Research : CP/M 3 System Manual

Page 123

209
out pSelect; select drive
210 more$retries:211
mvi c,l0; allow 10 retries
212 retry$operation:
213
push b; save retry counter214
215
lda select$mask
215a
lxi h,old$select
215b
cmp m
216
mov m,a217
jnz new$track; if not same drive as last, seek
218
219
lda @trk219a
lxi h,old$track
219b
csp m
220
mov m,a221
0123
jnz new$track; if not same track, then seek
222
223
in p$fdmisc
223a
ani 2
223b
jnz same$track; head still loaded, we are OK
224
225 new$track: ; or drive or unloaded head means we should ...
226
call check$seek;... read address and seek if wrong track
227
228
lxi b,16667; 100 ms / (24 t states*250 ns)
229 spin$loop:; wait for head/seek settling
230
dcx b
231
mov a,b
231a
ora c
232
jnz spin$loop
233
234 same$track
235
lda @trk
235aout p$fdtrack; give 1797 track236
lda @sect236a
Out p$fdsector; and sector
237
238
lxi h,dma$block; point to dma command block239
lxi b,dmab$length*256 + p$zdma; command block length and port address
240 outir; send commands to Z80 DMA
241
DB
0EDH,0B3H
242
243
in p$bankselect; get old value of bank select port244
ani 3Fh244a
mov b,a; mask off DMA bank and save245
lda @dbnk
245a
rrc
245b
rrc
; get DMA bank to 2 hi-order bits246
ani 0C0h
246aora b; merge with other bank stuff
247
out p$bankselect; and select the correct DMA bank

Digital Research : CP/M 3 System Manual

Page 124

248
249
lda disk$command; get 1797 command
250
call exec$command; start it then wait for IREQ and read status
251
sta disk$status; save status for error messages
252
253
pop b
; recover retry counter
254
ora a
254a
rz
; check status and return to BDOS if no error
255
256
ani 000l$0000b; see if record not found error
257
cnz check$seek; if a record not found, we might need to seek
258
259
dcr c
259a
jnz retry$operation
260
261; suppress error message if BDOS is returning errors to application. . .
262
263
lda @ermde263a
cpi 0FFh263bjz hard$error
264
265; Had permanent error, print message like:
266
267; BIOS Err on d: T-nn, S-mm, <operation> <type>, Retry ?
268
269
call ?pderr ; print message header
270271
lhld operation$name271acall ?pmsg; last function
272
273; then, messages for all indicated error bits
274
275
lda disk$status; get Status byte from last error
276
lxi h,error$table; point at table of message addresses
277 errml:
278
mov e,m
278a
Inx h
278b
mov d,m278c
inx h; get next message address
279
add a
279a
push psw; shift left and push residual bits with status
280
xchg
280a
cc ?pmsg
280b
xchg; print message, saving table pointer281
pop psw
281a
jnz errml; if any more bits left, continue
282
283
lxi h,error$msg
283a
call ?pmsg; print <BEL>, Retry (Y/N) ? "284
call u$conin$echo; get operator response
285
cpi 'Y'285a
jz more$retries; Yes, then retry 10 more times
286 hard$error:; otherwise,Digital Research : CP/M 3 System Manual287
mvi a,1287a
ret; return hard error to BD0S
288
289 cancel:; here to abort job
290
jmp ?wboot; leap directly to warmstart vector
291
292
293
; subroutine to seek if on wrong track294; called both to set up new track or drive295
296 check$seek:
297
push b; save error counter298
call read$id; try to read ID, put track in <B>
299
jz id$ok; if OK, we're DE
300
call step$out; else step towards Trk 0
301
call read$id; and try again
302
jz id$ok; if OK, we're OK
303
call restore; else, restore the drive304
mvi b,0; and make like we are at track
305 id$ok:306
mov a,b306a
Out p$fdtrack; send current track to track port307
lda @trk
307a
cmp b
307b
pop b
307c
rz
; lf its desired track, we are done308
out p$fddata; else, desired track to data port309
mvi a,000110l0b; seek wi 10 ms. steps
310
jmp exec$command
311
312
313
314 step$out:
315
mvi a,0110l0l0b; step out once at 10 ms.
316
jmp exec$command
317
318 restore:319
mvi a,0000l0llb; restore at 15 ms
320; jmp exec$command
321
322
323 exec$command:; issue 1797 command, and wait for IREQ
324
; return Status325
out p$fdcmnd; send 1797 command
326 wait$IREQ:; spin til IREQ
327
in p$fdint
327a
ani 40h327b
jz wait$IREQ
328
in p$fdstat; get 1797 Status and clear IREQ
329
ret
330
331 read$id:332
lxi h,read$id$block; set up DMA controller

Page 125

Digital Research : CP/M 3 System Manual

Page 126333
lxi b,length$id$dmab*256 + p$zdma ; for READ ADDRESS operation
334 outir
335
DB
0EDH,0B3H
336
mvi a,11000100b; issue
1797 read address command
337
call exec$command; wait for IREQ and read status338
ani 10011101b; mask status339
lxi h;id$buffer339a
mov b,m; get actual track number in <B>
340
ret; and return with z flag true for OK
341
342
343 u$conin$echo:; get console input, echo it, and shift to upper case344
call ?const
344a
ora a
344b
jz u$cl; see if any char already struck
345
call ?conin
345a
jmp u$conin$echo; yes, eat it and try again
346 u$cl:347
call ?conin
347apush psw
348
mov c,a348acall ?cono349
pop psw
349a
cpi 'a'349b
rc
350
sui 'a'-'A'; make upper case
351
ret
352
353
354
disk$command ds
1; current wd1797 command
355
select$mask ds
1; current drive select code356
old$select ds
1; laat drive selected357
old$track ds
1; last track seeked to358
359
diik$status ds
1; last error status code for messages
360
361
select$table db
00010000b,00100000b ; for now use drives C and D
362
363
364
; error message components
365
366
read$msg db ', Read',0367
write$msg db ', Write',0368
369
operation$name dw read$msg
370371; table of pointers to error message strings
372; first entry is for bit 7 of 1797 status byte
373
374
error$table dw b7$msg
375
dw b6$msg
376
dw b5$msg
377
dw b4$msg

Digital Research : CP/M 3 System Manual
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430

Page 127dw b3$msg
dw b2$msq
dw bl$msg
dw b0$msg
b7$msg db
b6$msq db
b5$msg db
b4$msg db
b3$msg db
b2$msg db
b1$msg db
b0$msg db' Not ready,',0' protect,',0' Fault,',0' Record not found,',0' CRC,',0' Lost dsta,',0' DREQ,',0' Busy,',0

error$msg db' Retry (Y/N) ? ',0; command string for Z80DMA device for normal operation
dma$block db
0C3h; reset DMA channeldb
14h; channel A is incrementing memorydb
28h; channel B is fixed port address
db
8Ah; RDY is high, CE/ only, stop on E0B
db
79h; program all of ch. A, xfer B->A (temp)
zdma$dma ds 2
; starting DMA addressdw
128-1; 128 byte sectors in SDdb85h; xfer byte at a time, ch B is 8 bit address
db p$fddata; ch B port address (1797 data port)db
0CFh; load B as source registerdb
05h; ;'fer A->Bdb
0CFh
; load A as source register
zdma$direction ds 1
; either A->B or B->Adb
0CFh
; load final source registerdb
87h; enable DMA channel
dmab$length equ$-dma$block

read$id$block db 0C3h
; reset DMA channeldb
14h; channel A is incrementing memorydb
28h; channel B is fixed port address
db
8Ah; RDY is high, CE/ only, stop on EOB
db
7Dh; program all of ch. A, xfer A->B (temp)dw id$buffer; starting DMA addressdw
6-1; Read ID always xfers 6 bytes
db85h; byte xfer, ch B is 8 bit address
db p$fddata; ch B port address (1797 data port)db
0CFh; load dest (currently source) registerdb
0lh; xfer B->Adb
0CFh
; load source registerdb
87h; enable DMA channel
length$id$dmab equ $-read$id$blockDigital Research : CP/M 3 System Manual431
432 cseg ; easier to put ID buffer in common
433
434
id$buffer ds
6; buffer to hold ID field
435; track
436; Side437; Sector438; length439; CRC 1440
; CRC 2441
442 end
B0MSG
BlMSG
B2MSG
B3MSG
B4MSG
B5MSG
B6MSG
B7MSG
BC
BELL
CANCELCHECKSEEKCRDEDISKC0MMAMDDISKSTATUSDMABLENGTHDMABLOCK
DPBSD
ERRMl
ERRORMSGERRORTABLEEXECCOMMAND
FDINITD
FDINIT1
FDIMITNEXTFDLOGIN
FDREAD
FDSD0
FDSDl
FDWRITEHARDERRORHLIDBUFFERIDOKINITTABLE
IX
IY
LEMGTMIDDMAB
LF

0283
027C
0270
026A
0257
024F
0245
0239
0000
0007
01A6
01A9
000D
0002
0211
0215
0011
029A
0000
0186
028A
0229
0lD5
00BE
00CD
00C1
00DB
00DC
000A
005C
00E6
01A3
0004
0011
0lBE
00CE
0004
0004
000F
000A

381
380
379
378
377
376
375
374
52#
289#
226
50#

390#
389#
388#
3871
386#
3851
384#
383#

257

296#

203
251
239
238
62
277#
283
276
250
60
77
145#
59
58
14
14
57
263

249
275
4131
398#
66
281
392#
374#
310
143#
152#
150
76
75
621
791
74
286#

354#
359#

339
299
144

422
302
1551

4341
3051

333
511

430#

413
79

83

93#

316

323#

337

1621
188#

193#

Page 128

Digital Research : CP/M 3 System Manual
MORERETRIES
0l0D
NEWTRACK
012D
OLDSELECT
0213
OLDTRACK
0214
OPERATIOMMAME 0227
PBANkSELECT
0025
PBAUDCON1000C
PBAUDCON20030
PBAUDCON34
0031
PBAUDLPT1000E
PBAUDLPT2
0032
PBOOT
0014
PCENTDATA
0011
PCENTSTAT
0010
PCON2DATA
002C
PCON2STAT
002D
PCON3DATA
002E
PCON3STAT
002F
PCON4DATA
002A
PCON4STAT
002B
PCONFIGURATION 0024
PCRTDATA
001C
PCRTSTAT
001D
PFDCMND
0004
PFDDATA
0007
PFDINT
0008
PFDMISC
0009
PFDSECTOR
0006
PFDSTAT
0004
PFDTRACK
0005
PINDEX000?
PLPT2DATA
0028
PLPT2STAT0029
PLPTDATA
001E
PLPTSTAT
001F
PRTC
0033
PSELECT
0008
PWD17970004
PZCTCl000C
PZCTC20030
PZDART
001C
PZDMA
0000
PZPIO10008
PzPIOlA
000A
PZPIO1B
000B
PZPIO20010
PzPIO2A
0012
PZPIO2B
0013
PZPIO30024
PZPI03A
0026
PzPIO3B
0027
PZSIO10028
PZSIO2
002C

2101
217
215
219
202
243

325
308
327
223
236
329
235

285
221
356#
3571
271
247

406

306

209

239
155
157

333

225#

3691

425

Page 129

Digital Research : CP/M 3 System Manual
READID
01E1
READIDBLOCK
02AB
READMSG
0218
RESTORE
01D3
RETRYOPERATION 0l0F
RWCOMMONC0ED
SAMETRACK
0139
SELECTMASK
0212
SELECTTABLE
0216
SPINLOOP
0133
STEPOUT
0lCE
TRANS
00A4
UCI
0202
UCONINECHO
0lF5
WAITIREQ
0107
WRITEMSG
021F
ZDMADIRECTION 02A8
ZDMADMA
029F?CONIN
0000
?CONO
0000
?CONST
0000
?PDEC
0000
?PDERR
0000
?PMSG
0000
?WBOOT
0000
@ADRV
0000
@DBNK
0000
@DMA
0000
@ERMDE
0000
@RDRV
0000
@SECT
0000
@TRK
0000

298
332
189
303
212#
191
223
208
207
229#
300
62
344
284
326*
194
204
205
32
32
33
30
31
29
28
18
20
19
24
18
19
19

301
417#
366#
318#
259
198#
234#
215
361#
232
314#
63
346#
343#
327
367*
410#
403*
345
348
344
269
271
290
245
205
263
206
236
219

Page 130

331#
430
369

355#

79

80

106#

345

347

280

283

235

307

I.5 : Bank and Move Module for CP/M 3 Linked BIOS
The MOVE.ASM module performs memory-to-memory moves and bankselects .
1 title 'bank & move module for CP/M3 linked BIOS'
23 cseg4
5 public ?move,?xmove,?bank
6 extrn @cbnk
7
8 maclib z80
9 maclib ports
10
11 ?xmove:; ALTOS can't perform interbank moves
12
ret
13
14 ?move:15
xchg; we are passed source in DE and dest in HL
16ldir; use Z80 block move instruction

Digital Research : CP/M 3 System Manual
17
DB
0EDH,0B0H
18
xchq
19
ret
20
21 ; by exiting through bank select
22 ?bank:
23
push b
24
ral
24a
ral
24b
ral
24c
ani lBh25
mov b,a26
in p$bankselect27
ani 0E7h
27A
ora b
28
out p$bankselect
29
pop b
30
ret
31
32 ;
128 bytes at a time
33
34 end
BC
0000
DE
0002
HL
0004
IX
0004
IY
0004
PBANKSELECT
0025 26
28
PBAUDCON1000C
PBAUDCON20030
PBAUDCON34
0031
PBAUDLPT1000E
PBAUDLPT2
0032
PBOOT
0014
PCENTDATA
0011
PCENTSTAT
0010
PCON2DATA
002C
PCON2STAT
002D
PCON3DATA
002E
PCON3STAT
002F
PCON4DATA
002A
PCON4STAT
002B
PCONFIGURATION 0024
PORTDATA
001C
PCRTSTAT
001D
PFDCMND
0004
PFDDATA
0007
PFDINT
000B
PFDMISC
0009
PFDSECTOR
0006
PFDSTAT
0004
PFDTRACK
0005
PINDEX
000F

Page 131; need next addresses in same regs

; save register b for temp

; isolate bank in proper bit position; save in reg B; get old memory control byte
; mask out old and merge in new; put new memory control byte
; restore register b

Digital Research : CP/M 3 System Manual
PLPT2DATA
PLPT2STAT
PLPTDATA
PLPTSTATPRTC
PSELECTPWD1797
PZCTClPZCTC2PZDARTPZDMAPZPIO1PZPIOlAPZPIO1BPZPIO2PZPIO2APZPIO2BPZPIO3PZPI03APZPIO3BPZSIO1PZSIO2?BANK?MOVE?XMOVE
@CBNK

0028
0029
001E
001F
0033
000B
0004
000C
0030
001C
0000
0008
000A
000B
0010
0012
0013
0024
0026
0027
002B
002C
0006
0001
0000
0000

5
5
5
6

Page 132

22#
14#
11#

I.6 : I/o Port Addresses for Z80 Chip-based System: PORTS.LIB
This listing is the PORTS.LIB file on your distributiondiskette. It contains the port addresses for the Z80 chipbasedsystem with a Western Digital 1797 Floppy Disk Controller.
I/O Port addresses for Z80 chip set based system with wd1797 FDC; chip bases
p$zdmaequ0
p$wd1797
equ4
p$zpio1equ8
p$zctclequ
12
P$zpio2equ
16
p$bootequ
20; OUT disables boot EPROM
p$zdartequ
28; console 1 and printer 1
p$zpio3equ36
p$zsio1equ40
p$zsio2equ44
p$zctc2equ48; diskette controller chip ports p$fdcmnd equ p$wdl797+0 p$fdstat equ p$wdl797+0
p$fdtrackequ
p$wd1797+l
p$fdsectorequ
p$wd1797+2
p$fddataequ
p$wd1797+3; parallel I/O 1

Digital Research : CP/M 3 System Manual
p$selectequ
p$zpiol+0
p$fdintequ
p$zpiol+0
p$fdmiscequ
p$zpiol+l
p$zpiolaequ
p$zpiol+2
p$zpiolb
equ
p$zpiol+3; counter timer chip 1
p$baudconl
equ
p$zctcl+0
p$baudlptl
equ
p$zctcl+2
p$indexequ
p$zctcl+3; parallel I/O 2, Centronics printer interface
p$cent$stat
equ
p$zpio2+0
p$cent$data
equ
p$zpio2+l
p$zpio2aequ
p$zpio2+2
p$zpio2bequ
p$zpio2+3; dual asynch rcvr/xstr, console and serial printer ports
p$crt$dataequ
p$zdart+0
p$crt$statequ
p$zdart+1
p$lpt$dataequ
p$zdart+2
p$lpt$statequ
p$zdart+3; Third Parallel I/0 device
p$configurationequ
p$zpio3+0
p$bankselectequ
p$zplo3+l
p$zpio3aequ
p$zpio3+2
p$zpio3bequ
p$zpio3+3; Serial I/0 device l, printer 2 and console 4
p$lpt2dataequ
p$zsiol+0
p$lpt2statequ
p$zsiol+l
p$con4dataequp$zsiol+2
p$con4statequp$zsio1+3; Serial I/0 device 2, console 2 and 3
p$con2dataequ
p$zsio2+0
p$con2statequ
p$zsio2+l
p$con3dataequ
p$zsio2+2
p$con3statequ
p$zsio2+3; second Counter Timer Circuit
p$baudcon2
equ
p$zctc2+0
p$baudcon34
equ
p$zctc2+l
p$baudlpt2
equ
p$zctc2+2
p$rtc
equ
p$zctc2+3
PCRTSTAT
001D
PFDCMND
0004
pFDDATA
0007
PFDINT
0008
PFDMISC
0009
PFDSECTOR
0006
PFDSTAT
0004
PFDTRACK
0005
PINDEX000F
PLPT2DATA
0028
PLPT2STAT0029
PLPTDATA
001E
PLPTSTAT
001F
PRTC
0033

Page 133

Digital Research : CP/M 3 System Manual
PSELECTPWD1797
PZCTClPZCTC2PZDARTPZDMAPZPIO1PZPIO1APZPIO1BPZPIO2PZPIO2APZPIO2BPZPI03PZPI03APZPIO3BPZSIO1PZSIO2?BANK?MOVE?XMOVE
@CBNK

0008
0004
000C
0030
001C
0000
0008
000A
000B
0010
0012
0013
0024
0026
0027
002B
002C
0006
0001
0000
0000

5
5
5
6

Page 134

22#
14#
11#

I.7 : Sample Submit File for ASC 8000-15 System
Digital Research used this SUBMIT file to build the sample BIOS.
;Submit file to build sample BIOS for ACS 8000-15 single-density system rmac bioskrnl
rmac boot rmac move rmac chario rmac drvtbl rmac fdl797sd rmac scb linkbnkbios3[b,q]=bioskrnl,boot,move,chario,drvtbl,fd17975d,scb gencpm

Listing 1-7. Sample Submit File for ASC 8000-15 System

Digital Research : CP/M 3 System Manual

Page 135

Appendix J : Public Entry Points for CP/M 3
Sample BIOS Modules
Table J-1 : Public Entrypoints for CP/M 3 Sample BIOS Modules
ModuleName
BIOSERNL

Public Entry
Point
?PMSG
?PDEC
?PDERRCHARIO?CINIT

Print Message
Print DecimalPrint BIOS Disk Err
Msg Header
Char Dev Init

?CIST

MOVE

BOOT

Function

Input Parameter

Return Value

HL points to msg
HL=number
none

none
none
none
none

Char Inp Dev St

Dev Parms in @CTBL
C=Phys Dev #B=Phys Dev#

?COSTChar Out Dev St

B=Phys Dev#

?CI

Char Dev Input

B=Phys Dev#

?COChar Dev Output?MOVE

Memory to Memory
Move?xMOVESet Banks for Extended
Move
Select Bank
System Init
Load CCP
Reload CCP
Get/Set Time

B=Phys Dev#
C=Input Char
BC=byte countDE=start source adr
HL=start dest adr
B=Dest Bank
C=Source Bank
A=Bank Number
none
none
none
C=000H if get
C=0FFH if set

?BANK
?INIT
?LDCCP?RLCCP?TIME

Listing J-1. Public Entry Points for cP/M 3 Sample BIOS Modules

A=00 if no input
A=0FFH if char avail.
A=00 if output busy
A=0FFH if output
ready
A=next available
input char
None
DE,HL point to next
bytes after move
BC,DE,HL areunchanged
All unchanged
none
none
none
none

Digital Research : CP/M 3 System Manual

Page 136

Appendix K : Public Data Items in CP/M 3 Sample
BIOS Modules
Table K-1. Public Data Items
ModuleName
BIOSKRNLCHARIODRVTBL

Public
Data
@ADRV
@RDRV
@TRK
@SECT
@DMA
@DBNK
@CNT
@CBNK
@CTBL
@DTBL

Description
Absolute Logical Drive CodeRelative logical drive code (UNIT)
Track Number
Sector Address
DMA Address
Bank for Disk I/O
Multi-sector Count
Current CPU Bank
Character Device Table
Drive Table

Digital Research : CP/M 3 System Manual

Page 137

Appendix L : CP/M 3 BIOS Function Summary
Table L-1. BIOS Function Jump Table Summary
No.
0
1
2

Function
BOOT
WBOOT
CONST

Input

3
4
5
6
7
8
9

CONIN
CONOUTLIST
AUXOUTAUXINHOMESELDSK

10
11
12
13

SETTRKSETSECSETDMAREAD

None
C=Con Char
C=Char
C=CharNone
None
C=Drive 0-15
E=Init Sel Flag
BC=Track No
BC=Sector No
BC=.DMA
None

14

WRITE

C=Deblk Codes

15

LISTST

None

16

SECTRN

17

CONOST

BC=Log Sect No
DE=Trans Tbl Adr
None

18

AUXIST

None

19

AUXOST

None

20
21
22

DEVTBL
DEVINIDRVTBLNone
C=Dev No 0-15
None

23
24

MULTIOFLUSH

C=Mult Sec Cnt
None

25

MOVE

26
27
28

TIME
SELMEM
SETBNK

HL=Dest Adr
DE=Source Adr bytes following
MOVE
BC=Count
C=Get/Set Flag
A=Mem Bank
A=Mem Bank

None
None
None

Output
None
None
A=0FFH if ready
A=00H if not ready
A=Con Char
None
None
None
A=CharNone
HL=DPH addr
HL=000H if invalid dr.
None
None
None
A=00H if no Err
A=01H if Non-recov Err
A=0FFH if media changed
A=00H if no Err
A=01H if Phys Err
A=02H if Dsk is R/O
A=0FFH if media changed
A=00H if not ready
A=0FFH if ready
HL=Phys Sect No
A=00H if not ready
A=0FFH if ready
A=00H if not ready
A=0FFH if ready
A=00H if not ready
A=0FFH if ready
HL=Chrtbl addr
None
HL=Drv Tbl addr
HL=0FFFFH
HL=0FFFEH
None
A=000H if no err
A=00IH if phys err
A=002H if disk R/O
HL & DE point to next

None
None
None

Digital Research : CP/M 3 System ManualNo.
29

Function
XMOVE

30
31
32

USERF
RESERV1
RESERV2

Input
B=Dest Bank
C=Source Bank
Reserved for System Implementor
Reserved for Future Use
Reserved for Future Use

Page 138

OutputNone

Revised, reformatted, and restored from original Ami Pro and PS sources by PCPete (PCPete@audiography.com.au) 10MAR2011(Rev 1.00)