For CP/M, the widely used and distributed version of Microsoft BASIC is 5.21. Unfortunately, the original source code for this version has been lost to time.
This project takes the nearest available 5.2x sources and reconstructs them to compile byte-for-byte identical to the original MBASIC 5.21 binary.
It has been a constant request on retro computing forums to get the MBASIC 5.21 sources. Some folks just want to learn how the interpreter works. Others want to add extensions for specific hardware or implement new features.
A set of sources labeled "MBASIC 5.2" exists, but while they are in the same family, they are clearly not the sources for 5.21. These original 5.2 sources are preserved in the mbasic_52/ directory.
- A custom disassembler (ud80) was used to disassemble the original
mbasic.com5.21 binary - The disassembly was analyzed to identify differences from the 5.2 sources
- Minimal changes were made to the 5.2 sources to generate a byte-for-byte match with 5.21
- The reconstructed sources are in
mbasic_521/mbasic_src/
mbasic2025/
├── mbasic_52/ # Original MBASIC 5.2 sources (reference)
├── mbasic_521/ # recreated 5.21 sources
├── mbasicz/ # latest available, optimized for z80
├── 4k8k/ # 4k basic and 8k basic
│ ├── mbasic_src/ # Reconstructed 5.21 sources
│ ├── com/ # Reference mbasic.com 5.21 binary
│ ├── disasm/ # Disassembly of mbasic.com
│ ├── build.sh # Build script
│ └── utils/ # Utility scripts
└── README.md
You need um80, a MACRO-80 compatible assembler toolchain for Linux.
Install from PyPI:
pip install um80Or install from source:
git clone https://github.com/avwohl/um80_and_friends.git
cd um80_and_friends
pip install -e .cd mbasic_521
./build.shThis will:
- Assemble all source modules (
.macfiles) into relocatable object files (.rel) - Link them together to produce
out/mbasic_go.com - Generate a symbol file
out/mbasic_go.sym
The um80 toolchain includes:
um80 - MACRO-80 compatible assembler
um80 source.mac -o output.rel [-l listing.prn]
ul80 - LINK-80 compatible linker
ul80 -o output.com [-s] file1.rel file2.rel ...
-sgenerates a.symsymbol file-xoutputs Intel HEX format-p ORIGINsets program origin (default: 0x100)
The interpreter is built from these modules (in link order):
| Module | Description |
|---|---|
| bintrp.mac | Main interpreter core |
| f4.mac | Floating point math |
| biptrg.mac | Program storage/management |
| biedit.mac | Line editor |
| biprtu.mac | Print utilities |
| bio.mac | I/O routines |
| bimisc.mac | Miscellaneous functions |
| bistrs.mac | String handling |
| binlin.mac | Line input |
| fiveo.mac | File I/O |
| dskcom.mac | Disk commands |
| dcpm.mac | CP/M interface |
| fivdsk.mac | Disk file handling |
| init.mac | Initialization |
The original MBASIC sources are copyright Microsoft. This reconstruction is provided for educational and historical preservation purposes.
- Project repository: https://github.com/avwohl/mbasic2025
- um80 assembler: https://github.com/avwohl/um80_and_friends
- 80un - Unpacker for CP/M compression and archive formats (LBR, ARC, squeeze, crunch, CrLZH)
- cpmdroid - Z80/CP/M emulator for Android with RomWBW HBIOS compatibility and VT100 terminal
- cpmemu - CP/M 2.2 emulator with Z80/8080 CPU emulation and BDOS/BIOS translation to Unix filesystem
- ioscpm - Z80/CP/M emulator for iOS and macOS with RomWBW HBIOS compatibility
- learn-ada-z80 - Ada programming examples for the uada80 compiler targeting Z80/CP/M
- mbasic - Modern MBASIC 5.21 Interpreter & Compilers
- mbasicc - C++ implementation of MBASIC 5.21
- mbasicc_web - WebAssembly MBASIC 5.21
- mpm2 - MP/M II multi-user CP/M emulator with SSH terminal access and SFTP file transfer
- romwbw_emu - Hardware-level Z80 emulator for RomWBW with 512KB ROM + 512KB RAM banking and HBIOS support
- scelbal - SCELBAL BASIC interpreter - 8008 to 8080 translation
- uada80 - Ada compiler targeting Z80 processor and CP/M 2.2 operating system
- ucow - Unix/Linux Cowgol to Z80 compiler
- um80_and_friends - Microsoft MACRO-80 compatible toolchain for Linux: assembler, linker, librarian, disassembler
- upeepz80 - Universal peephole optimizer for Z80 compilers
- uplm80 - PL/M-80 compiler targeting Intel 8080 and Zilog Z80 assembly language
- z80cpmw - Z80 CP/M emulator for Windows (RomWBW)