As my count of CP/M computers suddenly increased substantially in the last week I went looking for more CP/M and MP/M info and discovered /r/cpm but it had been abandoned with no mods, no subscribers, and no posts.
I have now taken over mod duties on /r/cpm and it is a place to discuss CP/M, MP/M, FUZIX, and other 8080/Z80 operating systems. I'm sure most everything that is on-topic for /r/cpm is on-topic for /r/RetroBattlestations so don't be afraid to cross-post.
I had quite a lot of help from Claude, so yes, this is "AI slop". However it does compile to working code for i386. Here is a screen cap of it booting in QEMU for i386. z80 and 8080 builds are supported also.
If you want to see the resulting C code, it's here:
The compiler was released by Intel in 1974, prior to CP/M's release, so it doesn't generate .com files. I built a python wrapper that invokes a pdp-10 emulator to run the compiler binaries then generates a .com file. This works on Windows, Linux, and MacOS.
The compiler generates decent code! But it doesn't support recursion like later PL/M compilers.
I'm not aware of any compiler that generates faster code for BYTE Magazine's SIEVE benchmark until 1980 when Digital Research released PL/I 80 v1.0.
Gary Kildall targeted his PL/M compiler for the 8008 before the 8080 (for CP/M), and you can run it to create 8008 apps in the emulator described here.
Z80 core written from scratch in TypeScript. Passes zexdoc and zexall, Zilog T-state timing, clock limit at 2/4/8 MHz or flat out.
Host-side BDOS/BIOS/CCP, running the original DRI binaries from cpm.z80.de: PIP, STAT, ED, ASM, LOAD, DDT, SUBMIT and XSUB.
Details I cared about: S2:EX:CR record numbering, F_OPEN keeping the requested extent, BDOS 6 with E=FFh never blocking, S/C on console output, the CCP's real fillfcb rules (so STAT FILE $R/O works).
Disk images: 8" SSSD with standard skew 6 (cpmtools ibm-3740 / z80pack), 512K, 4 MB, and z80pack's 4 MB hard disk (hd-tools.dsk works). Real BIOS sector I/O, so disk tools work on mounted images.
ANSI/VT100, ADM-3A and VT52 terminal profiles with CP437. WordStar 3.3, MBASIC, Turbo Pascal 3, Zork and Sargon run if you upload your own copies.
The fun part: it dials out
There's a Hayes-style modem on I/O ports 04h/05h (status/data; bit 0 RX ready, bit 7 DCD; OUT 04h bit 0 is DTR). It's also the RDR:/PUN: device, so PIP PUN:=FILE.TXT goes down the line.
TERM.COM (8080, source included) is a dumb terminal. ATI lists a phone book of telnet BBSes that are still up (Vertrauen, Black Flag, RetroCampus, Telehack and more), ATDT 1 dials. Browsers can't open raw TCP, so boards with a WebSocket gateway are called straight from your browser; the rest go through a small relay that only connects to the phone book.
The speaker plays dial tone, DTMF, ringback and the handshake, all synthesized, and CONNECT waits for it like it used to. ATM0&W if you value your sanity.
XMODEM.COM and ZMODEM.COM are written in 8080 assembly for DRI ASM (sources included), with timeouts from the BDOS 105 seconds. CI tests them byte for byte against lrzsz, including recovery from a corrupted byte (ZRPOS). Ctrl-] in TERM leaves the call up, so you can ZMODEM R and then go back with TERM.
The silly part
ATDT DEEPSEEK connects to an "AI board". Chat with an LLM sysop, or order a program: it writes 8080 assembly, the real ASM.COM assembles it in the page, assembler errors go back to the model to fix, and the .ASM and .COM come down by ZMODEM. It needs your own DeepSeek API key, which stays in your browser. There's also a BOFH option. He hangs up on you.
How it was built
Most of the code was written by AI: DeepSeek V4.1 Flash did the first build for under $1 in tokens, then Claude reviewed it and fixed the CP/M compatibility bugs, each fix with a regression test. The README has the whole story. I steer and test; I'd rather say that up front.
Feedback welcome, especially from people who know CP/M's corners better than I do. If something behaves differently from real hardware or z80pack, an issue with a repro (a .COM or the steps) is gold.
I am testing the djbottrill & VanzT CP/M-80 Emulator on my credit card size micro-controller called Cardputer by M5-Stack.
I wrote a simple sorting COBOL program on MS-COBOL v4.65 using the ANSI-74 build-in SORT feature. It does not get through the linkedit phase as it requires an external sort library COBSRT.REL. I am not able to find that library file on the web so I wrote the sorting code inside the COBOL program instead. The program works fine for a while until it hits a big file. CP/M-80 does not leave a lot of memory space for internal sorting. So I need a disk sort routine.
Instead of writing my own disk sort code, I use the COBOL build-in ISAM capability to use as my disk sort solution.
It's pretty straight forward, first read the input file and then write it to an ISAM file with the intended sorting key as the index file's key. Next read back from the index file using the index and write the sorted records to the final sorted file.
To test out the idea, I wrote a small COBOL program EMPOUT.COB to generate the input file EMPOUT.DAT. It has 5 records.
K>TYPE EMPOUT.COB
IDENTIFICATION DIVISION.
PROGRAM-ID. EMPOUT.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPLOYEE-FILE ASSIGN TO DISK
ACCESS MODE IS SEQUENTIAL
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD EMPLOYEE-FILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "EMPOUT.DAT"
DATA RECORD IS EMPLOYEE-RECORD.
01 EMPLOYEE-RECORD.
05 EMP-NUMBER PIC X(5).
05 EMP-LAST-NAME PIC X(30).
05 EMP-FIRST-NAME PIC X(30).
PROCEDURE DIVISION.
MAIN-PROGRAM.
OPEN OUTPUT EMPLOYEE-FILE.
MOVE "00001" TO EMP-NUMBER.
MOVE "SMITH" TO EMP-LAST-NAME.
MOVE "JOHN" TO EMP-FIRST-NAME.
WRITE EMPLOYEE-RECORD.
MOVE "00002" TO EMP-NUMBER.
MOVE "JONES" TO EMP-LAST-NAME.
MOVE "MARY" TO EMP-FIRST-NAME.
WRITE EMPLOYEE-RECORD.
MOVE "00003" TO EMP-NUMBER.
MOVE "BROWN" TO EMP-LAST-NAME.
MOVE "ROBERT" TO EMP-FIRST-NAME.
WRITE EMPLOYEE-RECORD.
MOVE "00004" TO EMP-NUMBER.
MOVE "WILSON" TO EMP-LAST-NAME.
MOVE "PATRICIA" TO EMP-FIRST-NAME.
WRITE EMPLOYEE-RECORD.
MOVE "00005" TO EMP-NUMBER.
MOVE "DAVIS" TO EMP-LAST-NAME.
MOVE "JAMES" TO EMP-FIRST-NAME.
WRITE EMPLOYEE-RECORD.
CLOSE EMPLOYEE-FILE.
STOP RUN.
K>
After compile the program we have the executable EXPOUT.COM
EMPOUT.COM is the executableRun EMPOUT.COM and created the EMPOUT.DAT data fileFive records in the EMPOUT.DAT file
There are 5 records in the file EMPOUT.DAT, the records are in the EMP-NUMBER order.
Then I wrote my sorting program to sort the record by EMP-LAST-NAME and then EMP-FIRST-NAME.
Here is the program code:
K>TYPE EMPSORT6.COB
IDENTIFICATION DIVISION.
PROGRAM-ID. EMPSORT6.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPLOYEE-FILE ASSIGN TO DISK
ACCESS MODE IS SEQUENTIAL
ORGANIZATION IS LINE SEQUENTIAL.
SELECT EMP-ISAM-FILE ASSIGN TO DISK
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS EMP-ISAM-KEY
FILE STATUS IS EMP-ISAM-STATUS.
SELECT EMP-SORT-FILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD EMPLOYEE-FILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "EMPOUT.DAT"
DATA RECORD IS EMPLOYEE-RECORD.
01 EMPLOYEE-RECORD.
05 EMP-NUMBER PIC X(5).
05 EMP-LAST-NAME PIC X(30).
05 EMP-FIRST-NAME PIC X(30).
FD EMP-ISAM-FILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "EMPISAM.DAT".
01 EMP-ISAM-RECORD.
05 EMP-ISAM-NUMBER PIC X(5).
05 EMP-ISAM-KEY.
10 EMP-ISAM-LAST-NAME PIC X(30).
10 EMP-ISAM-FIRST-NAME PIC X(30).
FD EMP-SORT-FILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "EMPSORT.DAT".
01 EMP-SORT-RECORD.
05 EMP-SORT-NUMBER PIC X(5).
05 EMP-SORT-LAST-NAME PIC X(30).
05 EMP-SORT-FIRST-NAME PIC X(30).
WORKING-STORAGE SECTION.
01 EOF-SWITCH PIC X VALUE "N".
88 END-OF-FILE VALUE "Y".
01 EMP-ISAM-STATUS PIC XX VALUE "00".
01 ISAM-EOF-FLAG PIC X VALUE "N".
88 ISAM-END-OF-FILE VALUE "Y".
01 RECORD-COUNTS.
05 EMP-ISAM-REC-CNT PIC 9(5) VALUE ZERO.
05 EMP-SORT-REC-CNT PIC 9(5) VALUE ZERO.
PROCEDURE DIVISION.
0000-MAIN-PROGRAM.
DISPLAY "*** START CREATING ISAM FILE ***".
OPEN INPUT EMPLOYEE-FILE
OUTPUT EMP-ISAM-FILE.
PERFORM 0010-READ-REC THRU 0010-READ-REC-EXIT
UNTIL END-OF-FILE.
DISPLAY "RECORDS PROCESSED: " EMP-ISAM-REC-CNT.
CLOSE EMPLOYEE-FILE
EMP-ISAM-FILE.
DISPLAY "*** START CREATING SORTED FILE ***".
OPEN INPUT EMP-ISAM-FILE
OUTPUT EMP-SORT-FILE.
MOVE LOW-VALUE TO EMP-ISAM-KEY.
PERFORM 0020-READ-INDEX THRU 0020-READ-INDEX-EXIT
UNTIL ISAM-END-OF-FILE.
DISPLAY "RECORDS PROCESSED: " EMP-SORT-REC-CNT.
CLOSE EMP-ISAM-FILE
EMP-SORT-FILE.
STOP RUN.
0010-READ-REC.
READ EMPLOYEE-FILE
AT END MOVE "Y" TO EOF-SWITCH.
IF NOT END-OF-FILE
ADD 1 TO EMP-ISAM-REC-CNT
MOVE EMPLOYEE-RECORD TO EMP-ISAM-RECORD
WRITE EMP-ISAM-RECORD
INVALID KEY
DISPLAY 'ERROR WRITING INDEX RECORD'
DISPLAY "STATUS = " EMP-ISAM-STATUS
STOP RUN.
0010-READ-REC-EXIT.
EXIT.
0020-READ-INDEX.
READ EMP-ISAM-FILE NEXT RECORD
AT END MOVE "Y" TO ISAM-EOF-FLAG.
IF NOT ISAM-END-OF-FILE
ADD 1 TO EMP-SORT-REC-CNT
MOVE EMP-ISAM-RECORD TO EMP-SORT-RECORD
WRITE EMP-SORT-RECORD.
0020-READ-INDEX-EXIT.
EXIT.
K>
After the compile and linkedit, we have the executable program EMPSORT6.COM
Run the sorting program EMPSORT6.COM
EMPISAM.DAT and EMPISAM.KEY are the indexed files.
EMPSORT.DAT is the final sorted file
The final file EMPSORT.DAT is sorted by last name and first name
I hadn't seen this done before (though I'm sure someone has done it) and I was curious what bugs in might find in my emulator. The tests have some Spectrum dependencies and use an older assembler, so it took a little work. I ran some popular emulators with the tests. It can be found here: ntvcm/z80test-cpm at main · davidly/ntvcm
The net: there's not a lot of interesting new test coverage in these tests beyond what's available in other well-known Z80 test suites.
The only real bugs I found were in my emulator, NTVCM. Using Z80 loop instructions to create self-modifying code wasn't supported (though every other emulator I ran pass that test without a problem).
NTVCM also doesn't update the R register by default because it's unused and slows execution substantially. Once enabled with a #define those tests pass too.
Details about the results are in the link above. Some emulators don't support IN/OUT instructions (why would they?) and that causes some tests to fail.
Almost all Z80 emulators pass the well-known test ZEXDOC.COM, which covers documented instructions. Some also pass ZEXALL.COM, which covers undocumented instructions. Many emulators fail ZEXALL.COM in the name of code clarity, performance, and need -- apps don't use those instructions so why implement them?
I created ZEXSUP.MAC (supplemental) to cover documented instructions not tested in ZEXDOC.COM. I found that all emulators that pass ZEXDOC.COM also pass ZEXSUP.COM. It can be found here: cpm_compilers/m80/ZEXSUP.MAC at main · davidly/cpm_compilers
I am about to approve a post that was removed by Reddit's spam filter, and I would like to discuss it with the community. If I see good arguments against it, I will remove it again, along with removing this post.
The post is titled "I Gave an AI an 8-Bit Computer. It Chose a World." and it was written by an AI.
I am like most of you and really hate the steaming piles of slop AIs create. But I think this one is worth looking at, perhaps to convince me to not allow this sort of thing ever again.
Please look it over with an open mind, then gather your pitchforks and torches and come back here.
I implemented C runtime support for two Aztec C compilers: 3.6b and 5.2a. Both have better floating-point support and generate better code than the native Digital Research C compiler in CP/M 68K.
The 5.2a version of the compiler supports a more modern C syntax but has four drawbacks compared to the 3.6b version:
free() corrupts memory. I implemented a replacement malloc/free that works.
it generates code to use signed div/mod for unsigned 16-bit integer mod operations, so 65533 % 65522 gives 13 instead of 11.
it generates slightly less-efficient code overall than the 3.6b version of the compiler.
it defaults to 32-bit int, and I haven't found a way to use 16-bit int. though it ships with C runtimes for both 16 and 32-bit int.
Both of the compilers can be found in several places on the internet including with my m68 CP/M 68K emulator. The "tests" folder under each compiler has build scripts, sample apps, and the CP/M-specific portions of the C runtime.
Renaldas Zioma's FOSS Z80 project, launched shortly after the end-of-life notice, now has working silicon. The design is built around Guy Hutchison's TV80 Verilog core, and the project's Tiny Tapeout page says the 130nm CMOS implementation should support clocks up to 50 MHz, against 4 MHz for the original NMOS part.
TPZASM (pronounceable as ‘Topaz Assembler’) is a portable cross‑assembler intended to be fully interchangeable (and in most cases bug‑for‑bug compatible) with the TDL ZASM 2.21, PSA PASM 1.02, and PSA PASM 2.00G assemblers, targeting the Intel 8080, Zilog Z80, and other equivalent processors.
An enhanced clone of HEXCOM 3.00, the DRI Intel HEX to binary conversion tool, is also included.
Precompiled binaries for many systems are available for download.
Note: It runs on Linux. Tested in WSL on Windows 11, a Pi 4B and Termux on Android ( may have some issues in Termux ). It also works on another platform, mentioned below. By developing on two platforms at once, it forces me to write the code in a more portable way.
The following link shows a typical usage scenerio, seeing details of what happens when the DIR command is executed in CP/M. Great for learning more about the inner workings of CP/M.
I am in the early stages of building a CP/M Emulator. The focus may be a little different than some of the other CP/M emulators, as it is more about the tools I am building than the emulation itself. The emulation works and I have built quite a few of the tools I intend to build. It is however immature, I have not built in a lot of error checking yet. I am just wondering where I might find a few people that can check it out. It currently runs on linux and the M5Cardputer using a serial terminal.
I have generally been hesitant to share code, but I think it might help motivate me to put more effort into improving the quality of the code and maybe even go as far as to write some documentation. The link is here if anyone is interested in checking it out.
The latest bin for the M5Cardputer is in the src/emu-esp32/bin folder, plus on M5Burner. There have been downloads, but I have no idea if anyone has actually tried it. For linux, you just need to clone the repository, go into the src/emu-linux folder and type "make main" Then it can be executed by entering "./main".
Since there was no good open source compressor like UPX for CP/M-80, I created this one. Algorithmically compatible with PopCom and can decompress its files, but always gets better ratios as it has optimized decompression stubs. It supports both 8080 and Z80 systems and can even run directly on CP/M-80. An "extra" compression mode is available when run on larger systems to get a bit more compression, while still being unpackable with the same stubs. It has full support for the LRBC (last record byte count) of CP/M-Plus (CP/M 3.0 and later) and DOS-PLUS.
I hope to add more documentation and release a version 1.0 soon. Building all the binaries (CP/M-80, CP/M-86, DOS, Windows, etc.) from source code requires a lot of tools to be installed, but I provide precompiled binaries for all non-UNIX systems.
All source is available including the decompression stubs and the assembler I created that is good enough to build them, so anyone can build a native binary without any cross-assembler installed, just a C89 compiler.
Ever want to run ANSI C apps on CP/M? This compiler runs on Windows/Linux/MacOS to generate .MAC files. Then you can use M80 and L80 (in emulators) to assemble and link, and the resulting COM files run on old CP/M machines.
It's a very silly thing to build, sure. But I had fun. It generates faster and smaller apps than compilers from the CP/M era. Details on github.