A complete implementation of Microsoft BASIC-80 5.21 (CP/M era) with an interactive interpreter and TWO compiler backends (Z80/8080 + JavaScript), written in Python.
About MBASIC: MBASIC was a BASIC interpreter originally developed by Microsoft in the late 1970s. This is an independent, open-source reimplementation created for educational purposes and historical software preservation. See MBASIC History for more information.
π Want the full story? See MBASIC Project Overview for a comprehensive feature showcase.
Status: Full MBASIC 5.21 implementation complete with 100% compatibility in interpreter and both compiler backends.
- β 100% Compatible: All original MBASIC 5.21 programs run unchanged
- β Modern Extensions: Optional debugging commands (BREAK, STEP, WATCH, STACK)
- β Multiple UIs: CLI (classic), Curses, Tk (GUI), Web (browser)
- β Full REPL: Interactive command mode with RUN, LIST, SAVE, LOAD, etc.
- β 100% Feature Complete: ALL compilable MBASIC 5.21 features implemented
- β Generates CP/M Executables: Produces native .COM files for 8080 or Z80 CP/M systems
- β Efficient Runtime: Optimized string handling with O(n log n) garbage collection
- β Hardware Access: Full support for PEEK/POKE/INP/OUT/WAIT
- β Machine Language: CALL/USR/VARPTR for assembly integration
- β 100% Feature Complete: All MBASIC 5.21 features except hardware access
- β Generates JavaScript: Produces standalone .js files for Node.js and browsers
- β Cross-Platform: Same code runs in browsers and Node.js
- β Full File I/O: localStorage in browser, fs module in Node.js
- β Standalone HTML: Optional HTML wrapper for browser deployment
See Features and Implementation Status for details, Extensions for modern features, Compilers for compiler information, and PROJECT_STATUS.md for current project health and metrics.
# Minimal install - CLI backend only (zero dependencies)
pip install mbasic
# With all UI backends
pip install "mbasic[all]"The other extras (curses, tk, web, dev) and the Tkinter notes are in the
Installation Guide.
For end users (interpreter only): See INSTALL.md for detailed installation instructions.
For developers (full development environment including compiler): See Linux Mint Developer Setup for comprehensive system setup with all packages and tools.
python3 mbasic myprogram.bas # Load a BASIC program, then enter RUN
python3 mbasic # Curses screen editor (default UI)
python3 mbasic --ui cli # CLI mode (line-by-line REPL)
python3 mbasic --list-backends # Show which UI backends are availableThe curses editor keys, the debugger keys, and a CLI session example are in Interactive Mode.
To compile BASIC to JavaScript (no external dependencies):
mbasic --compile-js program.js program.bas
node program.jsThe Z80/8080 compiler emits C and prefers the uc80 compiler and the cpmemu emulator. The Z80/8080 compiler setup is in Compilers.
- Features and Implementation Status - Full feature list and implementation status
- Interactive Mode - Curses screen editor and CLI REPL
- Compilers - Z80/8080 and JavaScript compilers: requirements, usage, features
- Example Programs - Sample BASIC programs, including hardware access
- Curses Screen Editor - Full-screen terminal editor (default UI)
- Quick Reference - Command reference
- Installation Guide - Detailed installation instructions
- Compiler Status Summary - Complete feature list (100% complete!)
- Compiler Setup - z88dk installation and configuration
- CP/M Emulator Setup - tnylpo installation for testing
- Linux Mint Developer Setup - Complete system setup guide (all packages & tools)
- Testing - Running and writing tests (
python3 tests/run_regression.py) - Debug Information -
--compile-c -g: break and step on BASIC lines with udb80 - Project Structure - Source tree layout
- Developer Documentation - Parser, interpreter, and compiler architecture and implementation notes
- Development History - How the project was built, phase by phase
- Credits and Disclaimers - Credit to Microsoft and disclaimers
See the docs/ directory for complete documentation.
GPLv3 License - see LICENSE file for details.
This project is an independent implementation created for educational and historical preservation purposes. It is not affiliated with, endorsed by, or supported by Microsoft Corporation. MBASIC and Microsoft BASIC are historical products of Microsoft Corporation.
- 80un - Unpacker for the CP/M archive and compression formats LBR, ARC, squeeze, crunch, and CrLZH.
- cpmdroid - Z80/CP/M emulator for Android phones and tablets. It emulates the RomWBW HBIOS interface and a VT100 terminal.
- cpmemu - Z80/CP/M emulator for Linux and Windows, with Z80 and 8080 CPU cores. It translates the BDOS and BIOS calls of CP/M 2.2 programs to the host file system.
- ioscpm - Z80/CP/M emulator for iOS and macOS. It emulates the RomWBW HBIOS interface and runs CP/M 2.2 and CP/M 3.
- learn-ada-z80 - Collection of more than 90 Ada example programs for uada80, the Ada compiler for the Z80 processor and CP/M.
- mbasic2025 - Reconstruction of the lost source code of MBASIC 5.21, the Microsoft BASIC-80 for CP/M. The MACRO-80 source code assembles to a binary that matches mbasic.com byte for byte.
- mbasicc - C++17 interpreter for MBASIC 5.21, the Microsoft BASIC-80 for CP/M. It runs on Linux and macOS.
- mbasicc_web - Web browser interpreter for MBASIC 5.21, the Microsoft BASIC-80 for CP/M. Emscripten compiles the mbasicc interpreter to WebAssembly.
- mpm2 - Z80 emulator for MP/M II, the multi-user CP/M operating system. Users connect over SSH, and SFTP clients transfer files.
- romwbw_emu - Hardware-level Z80/CP/M emulator for Linux and macOS. It emulates the RomWBW HBIOS interface and switches banks in 512 KB of ROM and 512 KB of RAM.
- scelbal - Floating-point BASIC interpreter for the 8080 processor and CP/M. A translator converts the original 8008 source code to 8080 source code.
- uada80 - Ada compiler for the Z80 processor and CP/M 2.2. It compiles a subset of Ada 2012 to CP/M .COM files.
- uc80 - C compiler for the Z80 processor and CP/M. It optimizes for small code size.
- ucow - Cowgol compiler for the Z80 processor and CP/M. It runs on Linux in Python.
- um80_and_friends - Linux toolchain that is compatible with Microsoft MACRO-80. It has an assembler, a linker, a librarian, and a disassembler.
- upeepz80 - Peephole optimizer for Z80 compilers that write lowercase Z80 assembly language. It shortens jumps to jr, builds djnz loops, and removes dead stores.
- uplm80 - PL/M-80 compiler for the Z80 processor and CP/M. It writes Intel 8080 and Zilog Z80 assembly language.
- z80cpmw - Z80/CP/M emulator for Windows. It emulates the RomWBW HBIOS interface and boots CP/M from disk images.