.bp 1 .op .cs 5 .mt 5 .mb 6 .pl 66 .ll 65 .po 10 .hm 2 .fm 2 .he .ft 1-% .pc 1 .tc 1 CP/M Features and Facilities .ce 2 .sh Section 1 .sp .sh CP/M Features and Facilities .qs .sp 3 .he CP/M Operating System Manual 1.1 Introduction .tc 1.1 Introduction .sh 1.1 Introduction .qs .fi .pp 5 CP/M \ is a monitor control program for microcomputer system development that uses floppy disks or Winchester hard disks for backup storage. Using a computer system based on the Intel \ 8080 microcomputer, CP/M provides an environment for program construction, storage, and editing, along with assembly and program check-out facilities. CP/M can be easily altered to execute with any computer configuration that uses a Zilog \ Z80 \ or an Intel 8080 Central Processing Unit (CPU) and has at least 20K bytes of main memory with up to 16 disk drives. A detailed discussion of the modifications required for any particular hardware environment is given in Section 6. Although the standard Digital Research version operates on a single-density Intel Model 800, microcomputer development system several different hardware manufacturers support their own input-output (I/O) drivers for CP/M. .pp The CP/M monitor provides rapid access to programs through a comprehensive file management package. The file subsystem supports a named file structure, allowing dynamic allocation of file space as well as sequential and random file access. Using this file system, a large number of programs can be stored in both source and machine-executable form. .pp CP/M 2 is a high-performance, single console operating system that uses table-driven techniques to allow field reconfiguration to match a wide variety of disk capacities. All fundamental file restrictions are removed, maintaining upward compatibility from previous versions of release 1. .pp Features of CP/M 2 include field specification of one to sixteen logical drives, each containing up to eight megabytes. Any particular file can reach the full drive size with the capability of expanding to thirty-two megabytes in future releases. The directory size can be field-configured to contain any reasonable number of entries, and each file is optionally tagged with Read-Only and system attributes. Users of CP/M 2 are physically separated by user numbers, with facilities for file copy operations from one user area to another. Powerful relative-record random access functions are present in CP/M 2 that provide direct access to any of the 65536 records of an eight-megabyte file. .pp CP/M also supports ED, a powerful context editor, ASM , an Intel-compatible assembler, and DDT , debugger subsystems. Optional software includes a powerful Intel-compatible macro assembler, symbolic debugger, along with various high-level languages. When coupled with CP/M's Console Command Processor (CCP), the resulting facilities equal or exceed similar large computer facilities. .pp CP/M is logically divided into several distinct parts: .sp .in 3 .nf o BIOS (Basic I/O System), hardware-dependent o BDOS (Basic Disk Operating System) o CCP (Console Command Processor) o TPA (Transient Program Area) .fi .in 0 .pp The BIOS provides the primitive operations necessary to access the disk drives and to interface standard peripherals: teletype, CRT, paper tape reader/punch, and user-defined peripherals. You can tailor peripherals for any particular hardware environment by patching this portion of CP/M. The BDOS provides disk management by controlling one or more disk drives containing independent file directories. The BDOS implements disk allocation strategies that provide fully dynamic file construction while minimizing head movement across the disk during access. The BDOS has entry points that include the following primitive operations, which the program accesses: .sp .in 5 .ti -2 o SEARCH looks for a particular disk file by name. .ti -2 o OPEN opens a file for further operations. .ti -2 o CLOSE closes a file after processing. .ti -2 o RENAME changes the name of a particular file. .ti -2 o READ reads a record from a particular file. .ti -2 o WRITE writes a record to a particular file. .ti -2 o SELECT selects a particular disk drive for further operations. .in 0 .pp The CCP provides a symbolic interface between your console and the remainder of the CP/M system. The CCP reads the console device and processes commands, which include listing the file directory, printing the contents of files, and controlling the operation of transient programs, such as assemblers, editors, and debuggers. The standard commands that are available in the CCP are listed in Section 1.2.1. .pp The last segment of CP/M is the area called the Transient Program Area (TPA). The TPA holds programs that are loaded from the disk under command of the CCP. During program editing, for example, the TPA holds the CP/M text editor machine code and data areas. Similarly, programs created under CP/M can be checked out by loading and executing these programs in the TPA. .pp Any or all of the CP/M component subsystems can be overlaid by an executing program. That is, once a user's program is loaded into the TPA, the CCP, BDOS, and BIOS areas can be used as the program's data area. A bootstrap loader is programmatically accessible whenever the BIOS portion is not overlaid; thus, the user program need only branch to the bootstrap loader at the end of execution and the complete CP/M monitor is reloaded from disk. .pp The CP/M operating system is partitioned into distinct modules, including the BIOS portion that defines the hardware environment in which CP/M is executing. Thus, the standard system is easily modified to any nonstandard environment by changing the peripheral drivers to handle the custom system. .bp .tc 1.2 Functional Description .he CP/M Operating System Manual 1.2 Functional Description .sh 1.2 Functional Description .qs .pp You interact with CP/M primarily through the CCP, which reads and interprets commands entered through the console. In general, the CCP addresses one of several disks that are on-line. The standard system addresses up to sixteen different disk drives. These disk drives are labeled A through P. A disk is logged-in if the CCP is currently addressing the disk. To clearly indicate which disk is the currently logged disk, the CCP always prompts the operator with the disk name followed by the symbol >, indicating that the CCP is ready for another command. Upon initial start-up, the CP/M system is loaded from disk A, and the CCP displays the following message: .sp .ti 8 CP/M VER x.x .sp where x.x is the CP/M version number. All CP/M systems are initially set to operate in a 20K memory space, but can be easily reconfigured to fit any memory size on the host system (see Section 1.6.9). Following system sign-on, CP/M automatically logs in disk A, prompts you with the symbol A>, indicating that CP/M is currently addressing disk A, and waits for a command. The commands are implemented at two levels: built-in commands and transient commands. .sp 2 .tc 1.2.1 General Command Structure .sh 1.2.1 General Command Structure .qs .pp Built-in commands are a part of the CCP program, while transient commands are loaded into the TPA from disk and executed. The following are built-in commands: .sp .in 3 .nf o ERA erases specified files. o DIR lists filenames in the directory. o REN renames the specified file. o SAVE saves memory contents in a file. o TYPE types the contents of a file on the logged disk. .in 0 .fi .sp Most of the commands reference a particular file or group of files. The form of a file reference is specified in Section 1.2.2. .sp 2 .tc 1.2.2 File References .sh 1.2.2 File References .qs .pp A file reference identifies a particular file or group of files on a particular disk attached to CP/M. These file references are either unambiguous (ufn) or ambiguous (afn). An unambiguous file reference uniquely identifies a single file, while an ambiguous file reference is satisfied by a number of different files. .mb 5 .fm 1 .pp File references consist of two parts: the primary filename and the filetype. Although the filetype is optional, it usually is generic. For example, the filetype ASM is used to denote that the file is an assembly language source file, while the primary filename distinguishes each particular source file. The two names are separated by a period, as shown in the following example: .bp .ti 8 filename.typ .sp .mb 6 .fm 2 In this example, filename is the primary filename of eight characters or less, and typ is the filetype of no more than three characters. As mentioned above, the name .sp .ti 8 filename .sp is also allowed and is equivalent to a filetype consisting of three blanks. The characters used in specifying an unambiguous file reference cannot contain any of the following special characters: .sp .ti 8 < > . , ; : = ? * [ ] _ % | ( ) / \\ .sp while all alphanumerics and remaining special characters are allowed. .pp An ambiguous file reference is used for directory search and pattern matching. The form of an ambiguous file reference is similar to an unambiguous reference, except the symbol ? can be interspersed throughout the primary and secondary names. In various commands throughout CP/M, the ? symbol matches any character of a filename in the ? position. Thus, the ambiguous reference .sp .ti 8 X?Z.C?M .sp matches the following unambiguous filenames .sp .ti 8 XYZ.COM .sp and .sp .ti 8 X3Z.CAM .sp The * wildcard character can also be used in an ambiguous file reference. The * character replaces all or part of a filename or filetype. Note that .sp .ti 8 *.* .sp equals the ambiguous file reference .sp .ti 8 ????????.??? .sp while .sp .ti 8 filename.* .sp and .sp .ti 8 *.typ .sp are abbreviations for .sp .ti 8 filename.??? .sp and .sp .ti 8 ????????.typ .sp respectively. As an example, .sp .ti 8 A>\c .sh DIR *.* .qs .sp is interpreted by the CCP as a command to list the names of all disk files in the directory. The following example searches only for a file by the name X.Y: .sp .ti 8 A>\c .sh DIR X,Y .qs .sp Similarly, the command .sp .ti 8 A>\c .sh DIR X?Y.C?M .qs .sp causes a search for all unambiguous filenames on the disk that satisfy this ambiguous reference. .pp The following file references are valid unambiguous file references: .sp .nf .in 8 X X.Y XYZ XYZ.COM GAMMA GAMMA.1 .fi .in 0 .pp As an added convenience, the programmer can generally specify the disk drive name along with the filename. In this case, the drive name is given as a letter A through P followed by a colon (:). The specified drive is then logged-in before the file operation occurs. Thus, the following are valid file references with disk name prefixes: .sp .nf .in 8 A:X.Y P:XYZ.COM B:XYZ B:X.A?M C:GAMMA C:*.ASM .fi .in 0 .sp All alphabetic lower-case letters in file and drive names are translated to upper-case when they are processed by the CCP. .sp 2 .tc 1.3 Switching Disks .he CP/M Operating System Manual 1.3 Switching Disks .sh 1.3 Switching Disks .qs .mb 5 .fm 1 .pp The operator can switch the currently logged disk by typing the disk drive name, A through P, followed by a colon when the CCP is waiting for console input. The following sequence of prompts and commands can occur after the CP/M system is loaded from disk A: .sp .nf .in 8 CP/M VER 2.2 A>\c .sh DIR \c .qs List all files on disk A. A:SAMPLE ASM SAMPLE PRN A>\c .sh B: \c .qs Switch to disk B. B>\c .sh DIR *.ASM \c .qs List all ASM files on B. B:DUMP ASM FILES ASM b>\c .sh A: \c .qs Switch back to A. .in 0 .fi .mb 6 .fm 2 .sp 2 .tc 1.4 Built-in Commands .he CP/M Operating System Manual 1.4 Built-in Commands .sh 1.4 Built-in Commands .qs .pp The file and device reference forms described can now be used to fully specify the structure of the built-in commands. Assume the following abbreviations in the description below: .sp .in 8 .nf ufn unambiguous file reference afn ambiguous file reference .fi .in 0 .sp Recall that the CCP always translates lower-case characters to upper-case characters internally. Thus, lower-case alphabetics are treated as if they are upper-case in command names and file references. .sp 2 .tc 1.4.1 ERA Command .sh 1.4.1 ERA Command .qs .sp .ul Syntax: .qu .sp .ti 8 ERA afn .pp The ERA (erase) command removes files from the currently logged-in disk, for example, the disk name currently prompted by CP/M preceding the >. The files that are erased are those that satisfy the ambiguous file reference afn. The following examples illustrate the use of ERA: .sp 2 .in 24 .ti -16 ERA X.Y The file named X.Y on the currently logged disk is removed from the disk directory and the space is returned. .sp .ti -16 ERA X.* All files with primary name X are removed from the current disk. .sp .ti -16 ERA *.ASM All files with secondary name ASM are removed from the current disk. .sp .ti -16 ERA X?Y.C?M All files on the current disk that satisfy the ambiguous reference X?Y.C?M are deleted. .bp .ti -16 ERA *.* Erase all files on the current disk. In this case, the CCP prompts the console with the message .sp .nf ALL FILES (Y/N)? .fi .sp which requires a Y response before files are actually removed. .sp .ti -16 ERA b:*.PRN All files on drive B that satisfy the ambiguous reference ????????.PRN are deleted, independently of the currently logged disk. .in 0 .sp 3 .tc 1.4.2 DIR Command .sh 1.4.2 DIR Command .qs .sp .ul Syntax: .qu .sp .ti 8 DIR afn .pp The DIR (directory) command causes the names of all files that satisfy the ambiguous filename afn to be listed at the console device. As a special case, the command .sp .ti 8 DIR .sp lists the files on the currently logged disk (the command DIR is equivalent to the command DIR *.*). The following are valid DIR commands: .sp .nf .in 8 DIR X.Y DIR X?Z.C?M DIR ??.Y .in 0 .fi .pp Similar to other CCP commands, the afn can be preceded by a drive name. The following DIR commands cause the selected drive to be addressed before the directory search takes place: .sp .in 8 .nf DIR B: DIR B:X.Y DIR B:*.A?M .fi .in 0 .pp If no files on the selected disk satisfy the directory request, the message NO FILE appears at the console. .bp .tc 1.4.3 REN Command .sh 1.4.3 REN Command .qs .sp .ul Syntax: .qu .sp .ti 8 REN ufn1=ufn2 .pp The REN (rename) command allows you to change the names of files on disk. The file satisfying ufn2 is changed to ufn1. The currently logged disk is assumed to contain the file to rename (ufn2). You can also type a left-directed arrow instead of the equal sign if the console supports this graphic character. The following are examples of the REN command: .sp 2 .in 31 .ti -23 REN X.Y=Q.R The file Q.R is changed to X.Y. .ti -23 .sp REN XYZ.COM=XYZ.XXX The file XYZ.XXX is changed to XYZ.COM. .in 0 .fi .sp .pp The operator precedes either ufn1 or ufn2 (or both) by an optional drive address. If ufn1 is preceded by a drive name, then ufn2 is assumed to exist on the same drive. Similarly, if ufn2 is preceded by a drive name, then ufn1 is assumed to exist on the drive as well. The same drive must be specified in both cases if both ufn1 and ufn2 are preceded by drive names. The following REN commands illustrate this format: .sp 2 .in 31 .ti -23 REN A:X.ASM=Y.ASM The file Y.ASM is changed to X.ASM on drive A. .sp .ti -23 REN B:ZAP.BAS=ZOT.BAS The file ZOT.BAS is changed to ZAP.BAS on drive B. .sp .ti -23 REN B:A.ASM=B:A.BAK The file A.BAK is renamed to A.ASM on drive B. .in 0 .sp .pp If ufn1 is already present, the REN command responds with the error FILE EXISTS and not perform the change. If ufn2 does not exist on the specified disk, the message NO FILE is printed at the console. .sp 2 .tc 1.4.4 SAVE Command .sh 1.4.4 SAVE Command .qs .sp .ul Syntax: .qu .sp .ti 8 SAVE n ufn .pp The SAVE command places n pages (256-byte blocks) onto disk from the TPA and names this file ufn. In the CP/M distribution system, the TPA starts at 100H (hexadecimal) which is the second page of memory. The SAVE command must specify 2 pages of memory if the user's program occupies the area from 100H through 2FFH. The machine code file can be subsequently loaded and executed. The following are examples of the SAVE command: .sp 2 .in 31 .ti -23 SAVE 3X.COM Copies 100H through 3FFH to X.COM. .sp .ti -23 SAVE 40 Q Copies 100H through 28FFH to Q. Note that 28 is the page count in 28FFH, and that 28H = 2*16+8=40 decimal. .sp .ti -23 SAVE 4 X.Y Copies 100H through 4FFH to X.Y. .in 0 .sp 2 The SAVE command can also specify a disk drive in the ufn portion of the command, as shown in the following example: .sp .in 31 .ti -23 SAVE 10 B:ZOT.COM Copies 10 pages, 100H through 0AFFH, to the file ZOT.COM on drive B. .in 0 .sp 3 .tc 1.4.5 TYPE Command .sh 1.4.5 TYPE Command .qs .sp .ul Syntax: .qu .sp .ti 8 TYPE ufn .pp The TYPE command displays the content of the ASCII source file ufn on the currently logged disk at the console device. The following are valid TYPE commands: .sp .in 8 .nf TYPE X.Y TYPE X.PLM TYPE XXX .in 0 .fi .pp The TYPE command expands tabs, CTRL-I characters, assuming tab positions are set at every eighth column. The ufn can also reference a drive name. .sp .in 24 .ti -16 TYPE B:X.PRN The file X.PRN from drive B is displayed. .in 0 .sp 2 .tc 1.4.6 USER Command .sh 1.4.6 USER Command .qs .sp .ul Syntax: .qu .sp .ti 8 USER n .pp The USER command allows maintenance of separate files in the same directory. In the syntax line, n is an integer value in the range 0 to 15. On cold start, the operator is automatically logged into user area number 0, which is compatible with standard CP/M 1 directories. You can issue the USER command at any time to move to another logical area within the same directory. Drives that are logged-in while addressing one user number are automatically active when the operator moves to another. A user number is simply a prefix that accesses particular directory entries on the active disks. .pp The active user number is maintained until changed by a subsequent USER command, or until a cold start when user 0 is again assumed. .sp 2 .tc 1.5 Line Editing and Output Control .he CP/M Operating System Manual 1.5 Line Editing and Output Control .sh 1.5 Line Editing and Output Control .pp The CCP allows certain line-editing functions while typing command lines. The CTRL-key sequences are obtained by pressing the control and letter keys simultaneously. Further, CCP command lines are generally up to 255 characters in length; they are not acted upon until the carriage return key is pressed. .sp 2 .ce .sh Table 1-1. Line-editing Control Characters .qs .sp .ll 60 .in 5 .nf Character Meaning .fi .sp .in 18 .ti -12 CTRL-C Reboots CP/M system when pressed at start of line. .sp .ti -12 CTRL-E Physical end of line; carriage is returned, but line is not sent until the carriage return key is pressed. .sp .ti -12 CTRL-H Backspaces one character position. .sp .ti -12 CTRL-J Terminates current input (line feed). .sp .ti -12 CTRL-M Terminates current input (carriage return). .sp .ti -12 CTRL-P Copies all subsequent console output to the currently assigned list device (see Section 1.6.1). Output is sent to the list device and the console device until the next CTRL-P is pressed. .sp .ti -12 CTRL-R Retypes current command line; types a clean line following character deletion with rubouts. .sp .ti -12 CTRL-S Stops the console output temporarily. Program execution and output continue when you press any character at the console, for example another CTRL-S. This feature stops output on high speed consoles, such as CRTs, in order to view a segment of output before continuing. .bp .ll 65 .in 0 .ce .sh Table 1-1. (continued) .qs .sp .ll 60 .in 5 .nf Character Meaning .fi .sp .in 18 .ti-12 CTRL-U Deletes the entire line typed at the console. .sp .ti -12 CTRL-X Same as CTRL-U. .sp .ti -12 CTRL-Z Ends input from the console (used in PIP and ED). .sp .ti -12 RUB/DEL Deletes and echoes the last character typed at the console. .in 0 .ll 65 .sp 2 .tc 1.6 Transient Commands .he CP/M Operating System Manual 1.6 Transient Commands .sh 1.6 Transient Commands .qs .pp Transient commands are loaded from the currently logged disk and executed in the TPA. The transient commands for execution under the CCP are below. Additional functions are easily defined by the user (see Section 1.6.3). .sp 2 .ce .sh Table 1-2. CP/M Transient Commands .qs .sp .ll 60 .in 5 .nf Command Function .fi .sp .in 16 .ti -11 STAT Lists the number of bytes of storage remaining on the currently logged disk, provides statistical information about particular files, and displays or alters device assignment. .sp .ti -11 ASM Loads the CP/M assembler and assembles the specified program from disk. .sp .ti -11 LOAD Loads the file in Intel HEX machine code format and produces a file in machine executable form which can be loaded into the TPA. This loaded program becomes a new command under the CCP. .sp .ti -11 DDT Loads the CP/M debugger into TPA and starts execution. .sp .ti -11 PIP Loads the Peripheral Interchange Program for subsequent disk file and peripheral transfer operations. .sp .ti-11 ED Loads and executes the CP/M text editor program. .sp .ti -11 SYSGEN Creates a new CP/M system disk. .bp .ll 65 .in 0 .ce .sh Table 1-2. (continued) .qs .sp .ll 60 .in 5 .nf Command Function .fi .sp .in 16 .ti -11 SUBMIT Submits a file of commands for batch processing. .sp .ti -11 DUMP Dumps the contents of a file in hex. .sp .ti -11 MOVCPM Regenerates the CP/M system for a particular memory size. .sp .ll 65 .in 0 .pp Transient commands are specified in the same manner as built-in commands, and additional commands are easily defined by the user. For convenience, the transient command can be preceded by a drive name which causes the transient to be loaded from the specified drive into the TPA for execution. Thus, the command .sp .ti 8 B:STAT .sp causes CP/M to temporarily log in drive B for the source of the STAT transient, and then return to the original logged disk for subsequent processing. .sp 2 .tc 1.6.1 STAT Command .sh 1.6.1 STAT Command .qs .sp .ul Syntax: .qu .sp .in 8 .nf STAT STAT "command line" .fi .in 0 .pp The STAT command provides general statistical information about file storage and device assignment. Special forms of the command line allow the current device assignment to be examined and altered. The various command lines that can be specified are shown with an explanation of each form to the right. .sp 2 .in 24 .ti -16 STAT If you type an empty command line, the STAT transient calculates the storage remaining on all active drives, and prints one of the following messages: .sp .nf d: R/W, SPACE: nnnK .sp d: R/O, SPACE: nnnK .fi .sp for each active drive d:, where R/W indicates the drive can be read or written, and R/O indicates the drive is Read-Only (a drive becomes R/O by explicitly setting it to Read-Only, as shown below, or by inadvertently changing disks without performing a warm start). The space remaining on the disk in drive d: is given in kilobytes by nnn. .sp .ti -16 STAT d: If a drive name is given, then the drive is selected before the storage is computed. Thus, the command STAT B: could be issued while logged into drive A, resulting in the message .sp BYTES REMAINING ON B: nnnK .sp .ti -16 STAT afn The command line can also specify a set of files to be scanned by STAT. The files that satisfy afn are listed in alphabetical order, with storage requirements for each file under the heading: .sp .nf RECS BYTES EXT D:FILENAME.TYP rrrr bbbK ee d:filename.typ .fi .sp where rrrr is the number of 128-byte records allocated to the file, bbb is the number of kilobytes allocated to the file (bbb=rrrr*128/1024), ee is the number of 16K extensions (ee=bbb/16), d is the drive name containing the file (A...P), filename is the eight-character primary filename, and typ is the three-character filetype. After listing the individual files, the storage usage is summarized. .sp .ti -16 STAT d:afn The drive name can be given ahead of the afn. The specified drive is first selected, and the form STAT afn is executed. .sp .ti -16 STAT d:=R/O This form sets the drive given by d to Read-Only, remaining in effect until the next warm or cold start takes place. When a disk is Read-Only, the message .sp BDOS ERR ON d: Read-Only .sp appears if there is an attempt to write to the Read-Only disk. CP/M waits until a key is pressed before performing an automatic warm start, at which time the disk becomes R/W. .in 0 .bp .pp The STAT command allows you to control the physical-to-logical device assignment. See the IOBYTE function described in Sections 5 and 6. There are four logical peripheral devices that are, at any particular instant, each assigned one of several physical peripheral devices. The following is a list of the four logical devices: .sp 2 .in 5 .ti -2 o CON: is the system console device, used by CCP for communication with the operator. .sp .ti -2 o RDR: is the paper tape reader device. .sp .ti -2 o PUN: is the paper tape punch device. .sp .ti -2 o LST: is the output list device. .in 0 .sp .pp The actual devices attached to any particular computer system are driven by subroutines in the BIOS portion of CP/M. Thus, the logical RDR: device, for example, could actually be a high speed reader, teletype reader, or cassette tape. To allow some flexibility in device naming and assignment, several physical devices are defined in Table 1-3. .sp 2 .ce .sh Table 1-3. Physical Devices .ll 60 .in 5 .sp .nf Device Meaning .fi .sp .in 14 .ti -8 TTY: Teletype device (slow speed console) .sp .ti -8 CRT: Cathode ray tube device (high speed console) .sp .ti -8 BAT: Batch processing (console is current RDR:, output goes to current LST: device) .sp .ti -8 UC1: User-defined console .sp .ti -8 PTR: Paper tape reader (high speed reader) .sp .ti -8 UR1: User-defined reader #1 .sp .ti -8 UR2: User-defined reader #2 .sp .ti -8 PTP: Paper tape punch (high speed punch) .sp .ti -8 UP1: User-defined punch #1 .sp .ti -8 UP2: User-defined punch #2 .sp .ti -8 LPT: Line printer .sp .ti -8 UL1: User-defined list device #1 .in 0 .ll 65 .nx oneb