CP/M Porting in a Few Hours [Hackaday]

View Article on Hackaday

If you’ve ever wanted to watch someone bring CP/M up on a new system and you have a couple of hours to spare, check out the recorded live stream of [Poking Technology]. The system in question is an Agon Light, a modern board with a Z-80-derived CPU. If you want to get right to the porting part, you might want to skip about 31 minutes of the nearly 2.5-hour video.

The first half hour is more about the built-in assembler and the board in general. If you’ve ever ported CP/M before, you know it isn’t as hard as bootstrapping a modern operating system. There are two major things you need: A BIOS, which is specific to your machine, and a BDOS, which is usually taken verbatim from the operating system sources. Your programs typically call one of the 40 or so functions in the BDOS.

The BIOS has about 20 functions you must provide and is mainly called by the BDOS. While BDOS worries about things like directories and file structure, the BIOS simply reports information about disks and devices and lets a caller directly access those things.

Part of the task of creating a BIOS involves building data structures to describe the disk hardware. You also provide a jump table with a few common functions. For the original CP/M there were only 15 functions. CP/M 2 added two more. CP/M 3 added a whopping 16 functions. The functions fall into three broad categories: system management (like BOOT and WBOOT), device I/O (like CONIN and PUNCH), and disk I/O (like HOME, DETTRK, and READ).

As you’ll see in the video, it doesn’t take much to write the handful of functions you need. CP/M is small, software-wise. It can be small physically, too. While it is perhaps more satisfying to run it on period hardware, it is easier to run it on new devices and they don’t even have to be very complex, either.