Appendix D: CP/M Cheat Sheet

Note

This cheat sheet summarizes the essential commands for CP/M (Control Program for Microcomputers), the first disk operating system for personal computers. It covers the core built-in commands, important control keys, and a quick reference to the BDOS (Basic Disk Operating System) functions.

Control Keys

CP/M uses several control keys for system interaction. To use them, hold the CTRL key and press the appropriate letter.

Key

Function

CTRL-C

Re-initialize the system. Use after changing diskettes so CP/M recognizes the new disk.

CTRL-P

Toggle printer echo on/off. When active, all console output is also sent to the printer.

CTRL-S

Pause screen output (freeze scrolling). Press any key to resume.

CTRL-X

Erase the current command line.

CTRL-U

Delete the entire current line.

CTRL-R

Retype the current command line on a new line.

CTRL-E

Physical end of line (carriage return without executing the command)[citation:6].

RUBOUT / DEL

Delete and echo the last character typed.

Built-in Commands

These commands are part of the CCP (Console Command Processor) and are available directly from the CP/M prompt (e.g., A>).

Command

Function

DIR drive:

Display a list of files on the specified disk. If no drive given, uses current drive.

DIR *.ext

Use wildcards to list specific files (e.g., DIR *.TXT shows all text files).

ERA filename

Erase (delete) a file from disk.

REN newname=oldname

Rename a file. Include drive if needed.

TYPE filename

Display a text file on the console.

STAT filename

Report file size or remaining disk space. STAT A: shows space on drive A.

PIP

Peripheral Interchange Program: copy or move files between devices and disks.

SYSGEN

Write a copy of CP/M to a disk (to make it bootable).

SAVE n filename.com

Save n pages (256 bytes each) from memory to a disk file.

USER n

Change to a different user area (0-15) for file organization.

drive:

Change the logged-in drive. For example, typing B: switches to drive B.

Hint

Filenames in CP/M follow the 8.3 format: up to 8 characters, a dot, and a 3-character extension (e.g., REPORT.TXT). Drive identifiers are letters followed by a colon (e.g., B:).

BDOS Function Calls (Programmer’s Reference)

The BDOS provides system services via function calls. Programs invoke these by loading the function number into register C and calling address 0005H

Common Function Codes

Code

Function Name

Description

0

System Reset

Return control to the CCP (warm boot).

1

Console Input

Read a character from the console, echo it.

2

Console Output

Output a character to the console.

5

List Output

Output a character to the list device.

6

Direct Console I/O

Direct character I/O (no control char handling) - E=FFh: input, returns char, 0 if none - E=FEh: status, returns FF if ready - E=char: output char

9

Print String

Output a string terminated by $

10

Read Console Buffer

Read an edited line into a buffer

11

Get Console Status

Check if a character is ready (return 01 if yes)

12

Return Version

Return CP/M version number in HL

13

Reset Disk System

Reinitialize disk system

14

Select Disk

Select the default disk (E = drive #)

15

Open File

Open a file via FCB (File Control Block)

16

Close File

Close a file via FCB

19

Delete File

Delete a file via FCB

20

Read Sequential

Read next record from an open file

21

Write Sequential

Write next record to an open file

23

Rename File

Rename a file via FCB

25

Get Current Disk

Return current default disk number in A

Important

Many BDOS functions use a File Control Block (FCB) structure. The default FCB for command-line arguments is at address 5CH, and the default DMA (Disk Memory Access) buffer is at 80H.

PIP (Peripheral Interchange Program) Options

PIP is a powerful utility for copying and transferring files. It supports several options (typed after the command):

Option

Function

V

Verify copy operation (check for errors)

U

Translate lowercase to uppercase

L

Translate uppercase to lowercase

N

Add line numbers to output

E

Echo transferred data to the console

F

Remove form feeds from the file

T n

Expand tabs to n spaces

Common PIP Examples:

  • PIP B:=A:FILENAME.TXT – Copy a single file from drive A to drive B.

  • PIP B:=A:*.* – Copy all files from drive A to drive B.

  • PIP PRN:FILENAME.TXT – Send a file to the printer.

Quick Reference Card

Need To…

Type This

See what’s on a disk

DIR

Delete a file

ERA FILENAME.EXT

Rename a file

REN NEWNAME.EXT=OLDNAME.EXT

View a text file

TYPE DOCUMENT.TXT (use CTRL-S to pause)

Copy a file

PIP B:=A:DATA.DAT

Switch drives

B: (or any drive letter)

Check disk space

STAT A: