The classic CP/M, the operating system that dominated the microcomputer era before DOS, gains a new life for the modern x86 architecture. The CP/M-386 project, available on GitHub, brings the system to the 32-bit protected mode of the 386 processors, derived directly from CP/M-68K.
According to the GitHub repository, CP/M-386 is in early development stage, but already presents a complete implementation of protected mode with Ring-3 TPA. The system can be booted from a 3.5-inch 1.44MB floppy disk or as a GRUB Multiboot kernel.
The project supports VGA text consoles (address 0xB8000) and serial COM1 (9600/N/8/1, 0x3F8). There are no drivers yet for hard disk, CD, USB, network, or sound, but the system is compatible with 386 or higher processors with at least 2MB of memory.
Systems with PC BIOS or UEFI with CSM are supported. Covered hardware includes VGA, 8042 PS/2 controller, UART 8250/16450/16550, CMOS RTC, and PIT 8253/8254.
Compatibility with other CP/M implementations is a highlight. The BDOS of CP/M-386 covers 100% of CP/M-68K 1.3 and CP/M 2.2, 71% of CP/M-Plus, 62% of DOS-Plus, and 50% of MP/M 2.1. The system currently reports BDOS 2.2 to applications.
Most of the CP/M-Plus (CP/M 3) functions are also supported. Over 60% of DOS-Plus additions have been implemented, and approximately half of MP/M extensions are complete. Missing functionality focuses on multiuser, multitasking, message queues, and process control calls, which do not apply to a single-user implementation.
Exclusive CP/M-386 extensions have been added to the BDOS to accommodate new features, such as direct video access, high-resolution timing, and a pseudo-random number generator (PRNG).
To compile CP/M-386, several dependencies are required: AWK, Cpmtools (version 2.23 or later), GNU Binutils, GNU Coreutils, GCC or LLVM Clang, GNU Make, NASM, and QEMU (only for testing). The project warns that old versions of cpmtools may appear to work but have known bugs.
Compilation is supported on NetBSD, FreeBSD, and most recent Linux distributions. Verified minimum versions include CentOS Stream 9, Fedora 36, Debian 12, Ubuntu 18.04 (with gcc-16 from PPA), Ubuntu 22.04, Alpine 3.24, and OpenSUSE Leap 15.4.
The recommended build uses GCC, but it is also possible to compile with Clang. The project recommends GCC because the i386 code generated by Clang is larger. It is important to run ‘make clean’ when switching compilers or adjusting flags. 32-bit support libraries are needed to run the test suite.
On FreeBSD, there is a warning: the cpmtools2 packages are broken, with mkfs.cpm non-functional. To compile successfully, you must rebuild cpmtools and ensure it is not linked against libdsk. If the error ‘Disc rejected by driver’ occurs, the tools are broken.
The build produces two main artifacts: cpm386.elf (Multiboot kernel image) and floppy.img (bootable 1.44MB floppy image). Pre-compiled binaries are available for download.
To test in QEMU, the Multiboot kernel can be run with: qemu-system-i386 -m 2M -serial stdio -monitor none -kernel cpm386.elf. Alternatively, the floppy MBR loader: qemu-system-i386 -m 2M -serial stdio -monitor none -drive if=floppy,format=raw,file=floppy.img -boot a.
It is possible to disable VGA with -nographic -display none -vga none to use only the serial console, or disable serial with -serial none to use only VGA.
The project includes a wide range of utilities, such as ACLOCKDV.386 (clock in VGA text), ACLOCKVT.386 (ANSI version), CLEARTPA.386 (clears TPA), CLS.386 (clears screen), DELAY.386 (delay test), DUMPDIR.386 (directory dump), DUMPFCB.386 (FCB dump), FPARSE.386 (F_PARSE test), GETSN.386 (serial number), GFXTEST.386 (graphics demo), HD.386 (hex dump), HELLO.386 (first CP/M-386 program), ILLEGAL.386 (Ring-3 protection test), IOTEST.386 (I/O tests), JULIA.386 (Julia fractal), LS.386 (list files), MANDEL.386 (Mandelbrot fractal), MEM.386 (memory map), MORE.386 (UNIX-style pager), OD.386 (octal dump), PAUSE.386 (wait for key), PRINTENV.386 (print environment), PRNG.386 (PRNG test), REBOOT.386 (reboots), RM.386 (remove files), STAT.386 (port of CP/M-Z8000 STAT), SYNC.386 (sync disks), TOD.386 (clock), TOUCH.386 (create file), TRUNCATE.386 (truncate file), VER.386 (version), VGAFONT.386 (text font), VGAOFF.386/VGAON.386 (turn off/on VGA console), VGATEXT.386 (direct VGA text access), and many others.
The repository also includes SUBMIT scripts like DEMO.SUB and PROFILE.SUB, which is executed automatically at startup.
Regarding AI usage, the project is clear: there is no AI-generated code in the operating system currently, although there are some tests, comments, and analyses done with AI. The author intends the project to be a learning experience. Contributions with large amounts of LLM-generated code will be rejected immediately. The use of AI tools by contributors is allowed, subject to the terms of the LLVM AI Tool Use Policy, but this permission may be withdrawn at any time.
Code statistics show a substantial project: 65 C files with 20,635 lines of code, 22 C headers, 6 assembly files, among others, totaling 100 files and 24,464 lines of code.
CP/M-386 is distributed under the permissive MIT license. The project’s canonical home is GitLab, with a mirror on GitHub. Bryan W. Sparks, of DRDOS, Inc., successor to the CP/M rights from Digital Research, has granted unlimited permission to use, distribute, modify, and enhance CP/M technology.
CP/M-386 represents a notable effort to preserve and modernize a historic operating system, bringing it to the 32-bit era with memory protection features. For retro software enthusiasts and developers interested in operating systems, it is a fascinating project to explore.