Skip to content

Installing CPM

Peter Wilson edited this page Jan 25, 2023 · 16 revisions

The CP/M system comprises a custom CP/M BIOS and the BDOS (Basic Disk Operating System) and command line processor, CPP (Console Command Processor).

The Open Source status of CP/M has fairly recently been clarified so I feel safe including the Digital Research portions of the system in this Git repository.

BIOS

CP/M is a layered system with, effectivly, a hardware abstraction layer called the BIOS (Basic Input/Output System). This is the only component that needs to be modified to port CP/M to a new system. I've written a BIOS for my system that utilises the ZLoader/ZIOS core functions to provide I/O. In this way the BIOS itself is kept fairly small, maximising the Transient Programme Area (TPA) and reducing the development overhead.

Main features:

  • Utilises the ZIOS core functions for I/O
  • Understands the ZIOS virtual disk model, allowing access to any of the potential 1023 virtual 4MB 'disks' per SDCard.
  • Leaves console I/O to the underlying system

Installing CP/M

The BIOS along with the CP/M code resides in the apps/cpm22 directory. A precomiled CP/M system is provided in the images top-level directory. You need to follow these steps to get a working CP/M system:

  1. Format a virtual disk to host your CP/M system
  2. Copy the compiled CPM system to the prepared virtual disk
  3. Add an entry to the Zloader boot system
  4. Install download.com to facilitate bulk loading of applications
  5. Install common CP/M applications

Format a CP/M disk

You don't need to understand the disk format CP/M uses, all you need to know is how to create a suitable 'empty' structure. Luckily all this requires is for the start of the disk to contain the byte 0xE5 repeated a number of times. You can do this from ZLoader as follows, assuming CP/M is to be installed on virtual drive A:

> f 0 0 e5
> wi 80:A 8000 8000

The first line fills all memory with the byte E5. The second line writes that data to drive A starting from sector 128 (0x80), which is right after the first 64K bytes. Once you've done this the disk is ready for CP/M.

Note that in this implementation the first 64K of any disk used for CP/M is reserved for the system.

Install CP/M

CP/M is going to reside in the first logical track of the virtual disk. It only needs a fraction of that space! The steps to get the CP/M system onto the track are as follows:

  1. Obtain an Intel Hex file containing the CP/M you want to run (eg images/cpm22.hex). You can build your own version, or make your own changes using these build instructions
  2. Load the Intel Hex CP/M file into application space RAM
  3. Write the image to the start of the target virtual disk

This can be achieved via Zloader as follows:

> F 0 0 0
> L
paste Intel Hex format version of CP/M here
> WI 0:A DB00 FE00

The F command clears all application memory to zero. L allows you to transfer an Intel hex format file into application memory. Finally WI writes data to one of the virtual disks on one of the SDCards. In this case DB00 and FE00 are the range of application space memory to write. 0:A is where to write it (start of the virtual disk mounted on A). NOTE: the range may be different for your version of CP/M.

Updating the Zloader boot menu

Zloader manages a boot menu of applications that can be run from the SDCard. The loader knows nothing about the application other than what's in the boot menu structure.

You can see a list of currently installed boot items by entering bos? at the Zloader prompt.

To add the CP/M that you've installed into this menu you need the following information:

  • Where the code to load exists on the SDCard
  • Where to start loading that image into application memory (0xDB00)
  • How many bytes to load into memory from that starting location (0x2300)
  • The execution address which can be found in the build instructions or the README in the images directory (0xF10C)
  • An available boot application ID. List the existing menu items using bos? and choose an ID that doesn't appear in the menu

The values in (braces) are the values correct at time of writing but may change as CP/M is updated.

Once you have all this information you can add an entry to the boot menu with:

WB 3 0:A DB00 2300 F10C 01 CP/M

Parameters here are:

  • 3: the unique ID for this image, as selected above. There will be an error if there's already an image with this ID.
  • 0:A: Where to load the image from the SDCard. Should match where you placed CP/M in the last section.
  • DB00: Where to place loaded data in application memory
  • 2300: The number of bytes to load into memory
  • F10C: The execution address (where to run the code)
  • 01: Flag byte (see below)
  • CP/M: The name of this application. Maximum 8 characters

The flag byte is a bitmask:

  • bit 0: Whether this application uses ZIOS (CP/M does)
  • bit 1: Whether ZIOS should intercept break characters to return to Zloader. No for CP/M

Assuming you have the parameters right you now have a functional CP/M system. You can test that it works by using the Zloader bos X command where X is the ID that you used in the WB command above.