17

Building my own version of CP/M has always been a fascinating to-do project. Problem is that it seems that the source code is not in regular assembler, but some kind of macro-assembler like language Gary Kildall developed to ease CP/M maintenance, so:

Is there a toolchain and documented workflow that I can use to customize my own version of CP/M (both BIOS and BDOS)? Is the CP/M source code available in regular Z80 assembler (I'm most used to Z80 nmemonics than 8080's)

To clarify things, I'm looking for something like: grab this well-commented ASM source code, modify it, assemble it with PASMO (or SjASM or any other available Z80 assembler) to have a pure binary file with BIOS/BDOS/whatever. And if possible, CP/M Plus.

NOTE: I'm aware that after getting my binary, I would need some custom tools to put it in the boot sector of whatever media I use to boot the machine, but I'm not asking for that part of the workflow.

6
  • 5
    Some of the CP/M code is actually written in PLM, a "close-to-C and close-to-asm" language. Compilers for this language are actually available (I think that is what you are referring to as "some kind of mactro-assembler"). If you look here, cpm.z80.de/download/cpm2-asm.zip you will find a pretty well documented z80 source code disassembly of CP/M 2.2 - To my knowledge, DR never released any Z80 sources for 2.2 themselves
    – tofro
    Commented Jun 2, 2016 at 16:26
  • I'm afraid that is not Z80 assembly code, but 8080's. Besides, I'm looking towards CP/M Plus, so I can add memory banking. Commented Jun 2, 2016 at 22:21
  • 1
    Then you didn't look hard enough - One of the disassemblies is definitively Z80 (there's a .z80 file in the zip). But also definitely not CP/M3...
    – tofro
    Commented Jun 3, 2016 at 6:58
  • Oh! I thought the .z80 was some sort of snapshot (I'm most used to see that extension applied to a specific kind of ZX Spectrum snapshot :D ) Commented Jun 3, 2016 at 8:51
  • 1
    DR's CP/M development was always 8080 code. Only third party used to go for Z80.
    – Raffzahn
    Commented Jul 25, 2020 at 18:27

4 Answers 4

11

This page has quite a few variants of the source code, including compilers for PL/M, including Z80 variants, and including source marked as copyrighted by Digital Research.

There's no documented workflow to build your own system from that, and it probably needs quite a bit of fiddling, especially the PL/M part (if you manage to do it, a writeup would be nice). But at first glance, everything you need should be there.

Edit: Here is an article that describes how to modify CP/M 2.2 to set it up for a new computer. It references two other writeups on the same subject, here and here, and the latter uses a CP/M 2.2 source converted to Z80-style using an awk script.

Setting CP/M up for a new computer doesn't require recompiling the PL/M utility programs, but maybe the Z80-style source and the writeups themselves are helpful.

7

Another option to build CP/M 2.2 is to build the sources inside a Z80 emulator as described on the z80pack site. I tried this with z80pack version 1.28:

Install the CP/M source disk images inside z80pack. Modify the cpm22src shell script:

  • change .cpm to .dsk
  • replace ./format c with mkfs.cpm disks/drivec.dsk, same for d (you need cpmtools).

Build process:

$ ./cpm22src
A>submit cmd1
A>submit cmd3
A>submit cmd4
A>submit cmd5
A>submit kernel-s

Running movcpm directly fails, so you do the workaround:

A>ddt d:movcpm.com
DDT VERS 2.2
NEXT  PC
2700 0100
-s234
0234 C2 0
0235 5A 0
0236 02 0
0237 02 .
-s2cb
02CB C2 0
02CC 5A 0
02CD 02 0
02CE 23 .
-i64 *
-g
CONSTRUCTING 64k CP/M vers 2.2
READY FOR "SYSGEN" OR
"SAVE 34 CPM64.COM"
A>save 34 d:cpm64.sys
A>d:sysgen d:cpm64.sys
SYSGEN VER 2.0
DESTINATION DRIVE NAME (OR RETURN TO REBOOT)d
DESTINATION ON D, THEN TYPE RETURN
FUNCTION COMPLETE
DESTINATION DRIVE NAME (OR RETURN TO REBOOT)

A>bye

Now move the disk image d to a, and boot again:

$ rm disks/drive[ab].dsk
$ mv disks/drived.dsk disks/drivea.dsk
$ ./cpmsim

There were error messages in the build process, at least some of which appear to be benign. I haven't verified any functions in the new system except that it boots, so there may very well be some problems to fix.

I also tried the two versions of the PL/M cross compiler. They compile fine under GNU Fortran, but fail on the PL/M sources for CP/M, so there appear to be some differences in the language variant used.

6

There are a few bios projects circling around the Z80 SBC homebrew scene that grew out of Andrew Lynch's N8___ computer project (name redacted as Andrew no longer wishes his radio call sign associated with the projects). I've found the developers to be exceptionally helpful when I was cluelessly building my Zeta SBC V2 (which, incidentally, has RAM banking galore, should you wish to build hardware).

The BIOS/BDOS projects include the RomWBW Firmware and UNA BIOS.

6

If you want to build CP/M Plus, the second and third links in the "CP/M 3" section at www.cpm.z80.de contain the CP/M 3 source tree and build scripts, for cross-compiling under DRDOS (second link) or UNIX (third link).

In the case of the UNIX one in particular, it should just be a matter of installing ZXCC and Thames, unpacking the source tree and typing 'make'.

Update 2024: Since CP/M has now been fully open-sourced, I have put the CP/M 3 source tree and scripts on my website, and added similar archives for CP/M 2.0, 2.1 and 2.2.

The assembly source for the CCP and BDOS is in 8080 mnemonics. To convert to Z80, I would use XIZ.COM to translate to Z80 mnemonics. It should then be possible to build relocatable files with pasmo --prl (you may also need to replace $ characters in labels with _, as pasmo may try to parse them as variable names).

1
  • I'll give that a try :) Commented Jun 8, 2016 at 12:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .