CP/M is a text-oriented, command-line interface. Only a few simple utilities were included with the original base system.
The original CP/M manuals are online. This version has been scanned and is pretty easy on the eyes but has occasional weird mistakes introduced by the optical character recognition process. There's also a good quality scan on archive.org. If you want to get in depth about how to use ED, PIP, ASM, and the rest, this is a good place to start.
Similar to MS-DOS, you can select among drives with the commands "A:" and "B:". If you followed the instructions when setting up the SD card, the A: drive will be filled with the CP/M operating system and some utilities; the B: drive has several games in the Zork series.
Most references will show the CP/M prompt as A>
or B>
but RunCPM also displays the "user number", which defaults to 0: A0>
or B0>
. (Drives can actually go up to letter "P", which is the 16th letter)
Another feature of RunCPM is that when searching for a program, A0 is searched after the current drive and user are searched, so think of A0 as the place you install programs.
The easiest way to move and copy files is probably to put the SD card in a real computer and use the file manager on that computer. In CP/M the multi-purpose program PIP could be used to copy a file to a new name or to a new drive. For example, to copy the program ASM.COM from the A drive to the B drive, you would write
PIP B:=A:ASM.COM
The command REN renames files, for instance if you need to correct a mis-typed filename:
REN EXAMPLE.TXT=EXMAPLE.TXT
To erase (delete) a file, use the ERA command (the extension $$$ is often used for temporary files):
ERA TEMPFILE.$$$
ED.COM, the CP/M editor
The original CP/M editor, ED, is a line oriented editor that feels very primitive by modern standards. Have you encountered a joke about how the classic Unix editor vi is for beginners? ED says "hold my beverage!"
- To begin inserting lines, use the "i" command
- When done inserting lines, use Ctrl+Z on its own line to return to command mode
- Write your file & exit with the "e" command.
Here's a sample ED session, with the parts that the user types shown in bold code
and the stuff that RunCPM prints in regular code
:
RunCPM [v6.0] => CCP:[INTERNAL v3.0] TPA:64K
B0>ed hello.txt
: *i
1: now is the time for all cool people
2: to write text in ED.COM
3: and then save it to disk
4: (type ctrl-z here)
: *e
RunCPM [v6.0] => CCP:[INTERNAL v3.0] TPA:64K
B0>type hello.txt
now is the time for all cool people
to write text in ED.COM
and then save it to disk
It's also possible to read back a file and make changes, but showing how to use ED fluently is outside the scope of this guide.
ASM.COM, the CP/M assembler
Using ED, or by preparing the file on your host computer and copying it, put the following content into HELLO.ASM on the B drive for user 0 (B\0\HELLO.ASM is the path on the host computer):
bdos equ 0005H org 0100H ; lxi d,message mvi c,9 call bdos ret ; message db 'Hello world.', 10, 13, '$'
Like most CP/M programs, this program begins (has its origin) at the hex address 0100 (256 in decimal). It calls into the operating system ("bdos", at address 0005 hex) with the command register set to 9 (print string), and the address argument set to the message. bdos command 9 prints each byte starting at its address argument until a "$" is encountered. 10 and 13 represent the "carriage return" and "line feed" special characters. When call bdos finishes, the program exits by running the return instruction.
Note that in order for this file to work properly, it has to be created with "DOS-style line endings", or CRLF line endings. This may require special settings in your text editor, so feel free to grab a correct copy using the link below.
Now, assemble it to create hello.hex, which you can show with the TYPE command:
B0>asm hello CP/M ASSEMBLER - VER 2.0 0118 000H USE FACTOR END OF ASSEMBLY CPM [v6.0] => CCP:[INTERNAL v3.0] TPA:64K B0>type hello.hex :100100001109010E09CD0500C948656C6C6F207797 :080110006F726C642E0A0D24CD :0000000000
To convert it to an executable program, load it using the debugger DDT, then immediately exit DDT by jumping to the warm start address 0 with the g0 command, and finally save the program using the SAVE command (the count argument, 1, is the number of 128-byte units occupied by the program). After doing this, it is possible to run the HELLO.COM program:
B0>ddt hello.hex DDT VERS 2.2 NEXT PC 0118 0000 -g0 RunCPM [v6.0] => CCP:[INTERNAL v3.0] TPA:64K B0>save 1 hello.com .. B0>hello Hello world.
(In real CPM usage, it would be more typical for the LOAD program to be used instead of the DDT program, but for an unknown reason this did not work in RunCPM when the author tested it, so the method using DDT is shown instead.)
You can also develop CP/M software on your host computer with software suites like the z88 development kit or the Amsterdam Compiler Kit, though this is beyond the scope of this guide.
Text editor powered by tinymce.