CP/M
CP/M (Control Program/Monitor or Control Program for Microcomputers) is an operating system initially created in 1974 for microcomputers based on Intel 8080 CPUs, by Gary Kildall of Digital Research Inc. Version 2.0 was released in 1979, soon followed by version 2.2. Version 3.0 (also called CP/M Plus) was released in 1982. The last release was 3.1 in 1983. CP/M versions are available for systems using different CPUs, including Intel 8080, Z80, and Intel 8086.
Commands
CP/M has a number of internal commands (also called "resident" commands). In addition, any executable program (with a ".COM" extension) can be considered as a "transient" command. In this section, there will be presented the internal commands and the transient commands available on the CP/M 2.2 system disk. In order to execute a transient command, the system disk must be present in the drive and either be selected or the command must be prefixed with the drive letter (similar to any executable program). Equipment manufacturers who licensed CP/M for use with their systems may have included additional commands on the system disk. These will not be covered here.
Transient commands end with ".COM" (the normal extension for exacutable files), however when running them the extension may be ommited. Thus "PIP.COM" can also be executed by simply typing "PIP". This is true for all executables.
In the following list of commands, the first 7 are resident commands while the following are transient commands.
1. Drive selection
CP/M allows selecting a drive by specifying its letter followed by a colon sign. Example: "A:", "B:". The new drive becomes active and this is reflected in the operating system's prompt ("A>", "B>").
2. DIR
This command allows visualizing the contents of a disk. By default it will show all files without the SYS attribute from the currently selected disk. However, the command allows specifying a different disk or a pattern for displaying files. Examples:
- DIR - Default behaviour
- DIR B: - Displays files from the B drive
- DIR B:*.COM - Displays executable files (with ".COM" extension) from the B drive
- DIR TEST???.BAS - Displays files starting with "TEST", followed by any 3 letters, with a ".BAS" extension, from the current drive
3. TYPE
Displays the contents of a text file. Example "TYPE TEST1.BAS".
4. ERA
Deletes files from disk. By default there is no UNDELETE/UNERASE command available, therefore this command must be used with care. Read-Only files cannot be deleted with ERA. For deleting a Read-Only file, first the attribute must be removed using STAT and then ERA can be used to delete the file. Examples:
- ERA TEST.BAS - Deletes the file "TEST.BAS" from the current drive
- ERA B:*.BAS - Deletes all files with ".BAS" extension from the B drive
- ERA *.* - Deletes all the files from the current disk
5. REN
This command renames a file. The REN command operates on a single drive. It is not possible to move a file by renaming it to another drive. Examples:
- REN TEST.OLD=TEST.BAS - Renames the file "TEST.BAS" to "TEST.OLD".
- REN B:MYTEST.BAS=B:TEST.BAS - Renames the file "TEST.BAS" to "MYTEST.BAS" on the B drive.
6. SAVE
The SAVE command stores a number of memory pages (256-byte blocks), starting at address 0100H, to a disk file. This is useful for moving programs to a different user area (such as moving PIP). It is also useful if a file was loaded into memory by some other program. Examples:
- SAVE 10 TEST.COM - Saves 10 pages of memory into TEST.COM on the current drive
- SAVE 29 PIP.COM - Saves 29 pages of memory into PIP.COM. This is useful when transferring PIP to a new user area.
7. USER
Selects an user area. The default user area is 0. Possible values range from 0 to 15. A user area can be used to store user files in separate spaces, when multiple users are using the same computer, or to organize the files. Transfer between user areas can be done with PIP. Examples:
- USER 5 - Changes to user area 5.
- USER 0 - Changes to the default user area 0.
8. PIP
The main purpose of the PIP ("Peripheral Interchange Program") command is to copy files. However, it accepts also devices (such as CON:, PRN:, etc.) as input/output. This allows for other usage scenarios, like creating a file, printing a file, displaying a file, etc. Examples:
- PIP TEST1.BAK=TEST1.BAS - Makes a copy of the file TEST1.BAS.
- PIP CON:=TEST1.BAS - Displays the file TEST1.BAS (similar to "TYPE TEST1.BAS").
- PIP TEST.TXT=CON: - Creates the file TEST.TXT and allows you to enter text from the console (end the file with CTRL+Z).
- PIP TEST.TXT=TEST.TXT[G0] - Copies the file TEST.TXT from user area 0 to the current user area (assuming the current user area was changed with a USER command; PIP needs to be available in the current user area).
9. MOVCPM
10. SYSGEN
MOVCPM and SYSGEN allow creating a new CP/M system disk for a different memory size (the default memory size used in CP/M 2.2 is 20Kb). MOVCPM alone can create a new in-memory CP/M system for a new memory size. SYSGEN allows saving the in-memory system or just copying an existing system disk. The parameters are not checked, a command like "MOVCPM 128" may cause the system to hang. A generated SYSGEN disk may refuse to boot. The commands should be used with care and a copy of the original system disk should always be kept. Examples:
- MOVCPM - Produces and runs a CP/M system using all the available memory.
- MOVCPM 32 * - Constructs a CP/M image for 32Kb of memory and stores it in memory for SYSGEN. A message will be displayed when using the "*" parameter 'READY FOR "SYSGEN" OR "SAVE 34 CPM32.COM"'. This message actually indicates how this image may be used.
- SYSGEN - Offers a series of prompts, asking for source and destination, for transferring a CP/M image.
11. STAT
Displays disk and file information; allows setting file attributes; allows assigning peripherals. Examples:
- STAT - Displays the space available on disks.
- STAT A: DSK: - Displays detailed information about the disk in the A drive.
- STAT A:*.* - Displays detailed information about the files on the disk in the A drive.
- STAT A:TEST.TXT $R/O - Sets the "read only" attribute on the file TEST.TXT. Recognized attributes: $R/O (read only), $R/W (read write), $SYS (system, does not appear in the DIR listing), $DIR (regular file, is shown in the DIR command output). All the files are shown in the STAT command output, regardless of their attributes.
- STAT DEV: - Displays current device assignments.
- STAT CON:=TTY: - Sets the console device to TTY. If there is no device attached the system will become unresponsive.
12. LOAD
Reads a file in Intel HEX format and produces an executable COM file. Examples:
- LOAD TEST.HEX - Will create TEST.COM from the Intel HEX file.
13. DDT
This is the CP/M debugger. Allows debugging executable files. An executable file is loaded at address 0100H. When exiting the debugger, the debugged file remains loaded, therefore it can be saved using the SAVE command. Examples:
- DDT PIP.COM - Loads the file PIP.COM into memory and awaits for debugger commands.
14. ED
This is the CP/M line editor. Allows basic editing operations for files. Operations are performed by using commands (for example "I" for insert, "1:100T" display first 100 lines, "Q" exits the editor). Text entering is ended with CTRL+Z, returning to the editor command interface. Examples:
- ED TEST.TXT - Loads the file TEST.TXT into the editor.
15. SUBMIT
Allows for command batching. Multiple commands are stored in a file (usually with a .SUB extension) and can be submitted for batch processing with the SUBMIT command. Command line parameters can be accessed within the batch file with $1 ... $n. The SUBMIT command actually creates a file called "$$$.SUB" on the current disk that contains the batched commands. This file will be executed when the CP/M system is booted or reloaded from the current disk. If created on the B: drive for example, the file $$$.SUB will not be executed until the disk is inserted in the A: drive and the system is loaded from it. When a new file is submitted, the contents of $$$.SUB is overwritten. Examples:
- SUBMIT CLEANUP.SUB TEST - Will submit for batch processing the file CLEANUP.SUB with the parameter TEST. The parameter can be accessed inside the CLEANUP.SUB batch file using "$1".
16. XSUB
This command is useful in a .SUB file to redirect console input to the following lines in the .SUB file. Following an XSUB command, the .SUB file should contain first the command to be executed and on the following lines the input for the executed command.
17. DUMP
Displays the contents of a file in hexadecimal. Examples:
- DUMP DUMP.COM - Displays in hexadecimal the contents of the file "DUMP.COM".
More from this site
Useful external resources
- cpmtools | Forked on GitHub | Documentation
- Man pages for cpmtools on Linux
- CP/M Games
- Wikipedia article
- Some CP/M history
- More CP/M history
- A lot of history about Digital Research, CP/M, Gary Kildall, etc.
- Information about computers running CP/M
- CP/M 2.2 Disk formats and Directory entries
- CP/M Disk formats
- cpmfs tool for disk images on Windows
- CP/M Live
- CP/M disk images (.DSK)
- Executable (.COM) programs for CP/M 2.2 (including some FORMAT commands), probably for Z80 cpu