About this project
PB-Compiler (`pbc`) is a clean-room reimplementation of the PowerBASIC-family compilers, written in modern C#. Its primary goal is to allow vintage BASIC source code from the DOS era to be compiled into real, runnable 16-bit MS-DOS `.EXE` binaries on modern 64-bit hardware. The project emphasizes strict fidelity to historic dialects, ensuring that programs behave identically to those produced by the original proprietary compilers, including documented bugs.
Key capabilities include:
**Dialect Support**: The compiler supports a wide range of dialects via the `--dialect` flag, covering the Borland lineage (Turbo Basic, PowerBASIC 2.0-3.5) and Microsoft lineage (BASICA, GW-BASIC, QuickBASIC 1.0-4.5, QBasic, BASIC PDS). Each dialect gates newer features and enables version-specific behaviors.
**Fidelity Contract**: For historic dialects, output is verified against original binaries using an oracle-driven differential harness. This ensures that the generated code produces byte-identical program output, maintaining compatibility with legacy software ecosystems.
**Optimization Pipeline**: An advanced SSA-based optimization backend is available across all dialects via the `--optimize` flag. This pipeline includes constant folding, dead-code elimination, common-subexpression elimination, strength reduction, and more. It can significantly reduce binary size (e.g., shrinking a Hello World program to 25 bytes) without altering observable behavior.
**PowerBASIC 3.6 Superset**: A forward-looking dialect (`pb36`) adds modern language features such as expression-bodied functions, tuples, overloading, default parameters, lambdas/closures, generics, coroutines (`YIELD`), and structured exception handling (`TRY/CATCH`). These are opt-in and do not affect existing PB 3.5 code.
**Output Formats**: Generates standard DOS MZ `.EXE` files, compiled units (`.PBU`), and unit libraries (`.PBL`). It also supports emitting portable C99 or LLVM IR for further processing.
**Installation & Usage**: Built using .NET, it runs on any OS supporting .NET 6+. Users clone the repository, build with `dotnet`, and compile BASIC sources using the `pbc` CLI tool. Results can be tested in DOSBox or on real DOS hardware.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.