CP/M-386 – CP/M for 386 protected mode, derived from CP/M‑68K

Hacker News Top Tools

Summary

CP/M-386 is an early-stage open-source implementation of CP/M for 386 protected mode, derived from CP/M-68K, offering full BDOS parity with CP/M 2.2 and CP/M-68K 1.3.

No content available
Original Article
View Cached Full Text

Cached at: 08/03/26, 01:28 AM

johnsonjh/cpm386

Source: https://github.com/johnsonjh/cpm386

CP/M-386

CP/M‑386 is CP/M for 386 protected mode, derived from CP/M‑68K.



Overview

CP/M‑386 is currently in the very early development stages.

Hardware support

  • Compatible with 386 (and later systems) with 2MB (or more) memory.
  • Systems using either PC BIOS or UEFI (with CSM) are supported.
  • VGA, 8042 PS/2, 8250/16450/16550 UART, CMOS RTC, and 8253/8254 PIT are supported.

CP/M compatibility

CP/M‑386 should be highly source‑compatible with other implementations:

SystemBDOS coverage
CP/M‑68K 1.3100%
CP/M 2.2100%
CP/M‑Plus71%
DOS‑Plus62%
MP/M 2.150%

The system currently reports BDOS 2.2 to applications.

  • The CP/M‑386 BDOS is at full parity with CP/M‑68K 1.3 and CP/M 2.2.
  • A large majority of the CP/M‑Plus (CP/M 3) BDOS is also supported.
  • More than 60% of the DOS‑Plus additions have been implemented.
  • Approximately half of the MP/M extensions have been completed.
    • The missing functionality is largely the multi‑user, multi‑tasking, message queuing, and process control calls that don’t apply to a single‑user CP/M implementation.
  • Unique CP/M‑386‑specific BDOS extensions have been added to accommodate new features like direct video access, high‑resolution timing, PRNG, etc.

Build requirements

The following dependencies are required to compile CP/M‑386:

Be sure to use cpmtools version 2.23 or later. Older versions may appear to work but have several known bugs.

Downloads

Compilation

Building CP/M‑386 is supported on current releases of NetBSD and FreeBSD, and most recent Linux distributions.

The following are the minimum versions of Linux distributions that have been verified to build CP/M‑386 successfully: CentOS Stream 9, Fedora 36, Debian 12, Ubuntu 18.04 (with gcc-16 from ppa:ubuntu-toolchain-r/test), Ubuntu 22.04, Alpine 3.24, and OpenSUSE Leap 15.4.

  • GCC build (recommended):
    make -Orecurse -j "$(nproc 2> /dev/null || printf '%s' 1)"
    make test
    

  • Clang build:
    make -Orecurse -j "$(nproc 2> /dev/null || printf '%s' 1)" CC="clang"
    

  • It is recommended to use GCC as Clang‑compiled i386 code is larger.
  • Be sure to make clean if switching compilers or adjusting compiler flags.
  • 32‑bit support libraries are required to run the test suite (make test).
  • At the time of writing, FreeBSD is shipping non‑functional cpmtools2 packages with broken mkfs.cpm functionality. To successfully build on FreeBSD, you must rebuild cpmtools and ensure it is not linked with libdsk. If you receive a Disc rejected by driver error on FreeBSD from mkfs.cpm, your tools are broken and cannot be used to build CP/M‑386.

Build output

  • The build produces two primary artifacts:

    FileDescription
    cpm386.elfMultiboot kernel image
    floppy.imgBootable 3.5“ 1.44MB floppy disk image

You can download pre‑compiled binaries above.

QEMU testing

  • Multiboot kernel (recommended):
    qemu-system-i386 -m 2M -serial stdio -monitor none -kernel "cpm386.elf"
    

  • Floppy MBR loader:
    qemu-system-i386 -m 2M -serial stdio -monitor none -drive if=floppy,format=raw,file="floppy.img" -boot a
    

QEMU notes

  • Use -nographic -display none -vga none to disable VGA video (and use only serial console).
  • Use -serial none to disable the serial UART (and use only VGA console).

Included utilities

ProgramDescription
ACLOCKDV.386aclock (VGA text console version)
ACLOCKVT.386aclock (ANSI terminal version)
BIG.386Multi‑extent loading test executable
CLEARTPA.386Clears (zeros) and optionally verifies the TPA
CLS.386Clear screen (BDOS 221)
DELAY.386Delay test (BDOS 141)
DEMO.SUBSUBMIT demonstration
DUMPDIR.386Directory entry dump utility (BDOS 17/18)
DUMPFCB.386File control block dump utility (BDOS 15)
ENV.DATEnvironment data file
FPARSE.386F_PARSE test (BDOS 152)
GETSN.386Display serial number (BDOS 107)
GFXTEST.386Graphics and framebuffer demo (BDOS 229/230/231/233)
HD.386Hex dump utility
HELLO.386Hello world (the very first CP/M‑386 program!)
ILLEGAL.386Ring‑3 protection and exception handler test
IOTEST.386File I/O BDOS tests
JULIA.386Draw a Julia set fractal (terminal version)
LRBC.386Query and/or set Last Record Byte Count
LS.386List files (with sizes)
MANDEL.386Draw a Mandelbrot set fractal (terminal version)
ALVTST.386Get Allocation Vector test (BDOS 27)
MEM.386Memory map utility (BDOS 227/228)
MORE.386UNIX more‑style pager
OD.386Octal dump utility
PAUSE.386Wait for keypress
PRINTENV.386Print environment and system data
PRNG.386PRNG test and demo utility (BDOS 253/254)
PROFILE.SUBSUBMIT script (automatically executed at boot)
RC.386Return code test and query (BDOS 108)
README.TXTSample text file
REBOOT.386Reboot utility (BDOS 220)
RM.386UNIX rm‑like interactive file deletion utility
SEROFF.386Disable serial console (BDOS 223)
SERON.386Enable serial console (BDOS 223)
STAT.386STAT (A port of Zilog CP/M‑Z8000 STAT v1.0C 01/03/84)
SYNC.386Synchronize disks (BDOS 48)
TEST211.386Numeric format test (BDOS 211)
TEXTMODE.386Query and set the console text mode (BDOS 229/230/231)
TICKS.386High‑resolution timer tests (BDOS 225/226)
TOD.386Get (and set) Time of Day clock (BDOS 104/105)
TOUCH.386Create an empty file
TRUNCATE.386File truncation utility (LRBC aware)
TRUNCTST.386Truncation tests (BDOS 99)
TSEC.386Get date and time (BDOS 155)
VER.386Display OS version (BDOS 163)
VGAFONT.386Load a text console font or restore the ROM font (BDOS 232)
VGAOFF.386Disable VGA text console (BDOS 222)
VGAON.386Enable VGA text console (BDOS 222)
VGATEXT.386VGA text direct access demo (BDOS 224)

Contributing

  • Do not open pull requests with large amounts of LLM‑generated code. These will be immediately rejected.
  • There is currently no AI‑generated code in the operating system at this time (though there are some AI tests, comments, and analysis), as the project is intended to be as much of a learning experience for me as it is a useful OS port.
  • Usage of AI (artificial intelligence) tools by contributors is currently permitted, subject to the same terms and conditions as the LLVM AI Tool Use Policy, but this permission may be withdrawn at any time and without notice.

Future plans

See FUTURE.md.

Code statistics

Language Files Lines Blank Comment Code Complexity Bytes Uloc
C 65 31160 6146 4379 20635 4356 730364 10665
C Header 22 3054 551 1233 1270 13 111663 1558
Makefile 2 1570 300 201 1069 331 52823 773
Assembly 6 1351 235 266 850 1 31040 700
Markdown 2 478 58 0 420 0 21907 378
Linker Script 2 169 34 0 135 0 3923 82
YAML 1 80 6 15 59 0 3196 63
Total 100 37862 7330 6094 24438 4701 954916 14146

Mirrors

License

  • CP/M‑386 is distributed under the terms of the permissive MIT License.
  • Bryan W. Sparks of DRDOS, Inc. dba DeviceLogics LLC, successor in interest to Digital Research, Inc.’s CP/M assets, explicitly grants an unlimited authorization to use, distribute, modify, enhance, and otherwise make available CP/M technology, including the CP/M operating systems and their derivatives.

Similar Articles

CP/M-68K emulator

Lobsters Hottest

A hobbyist developer created an emulator for the Motorola 68000 CPU that runs CP/M-68K, with custom BIOS and RAM disk support; source code is available on GitHub and GitLab.

z386: An Open-Source 80386 Built Around Original Microcode

Hacker News Top

The article details z386, an open-source FPGA implementation of an 80386 CPU built using the original Intel microcode. It can boot DOS 6/7, run protected-mode programs, and play classic games like Doom, serving as both an educational reconstruction and a usable FPGA CPU.

Os8088: A powerful Mac-like OS for the IBM XT, 286, 386

Hacker News Top

os8088 is a hobbyist Macintosh System 1-style GUI operating system for the Intel 8086/8088 PC, written entirely in real-mode assembly with preemptive multitasking and fitting in 256K of RAM. The project is complete and its source code is available.

M/PC – A Concatenative OS

Hacker News Top

M/PC is a concatenative operating system for the Varvara platform, inspired by Openfirmware, designed for file management via a postfix command interface without a graphical file browser.