Three fixes that lift seven test programs from skipped to passing, bringing the AOT compiler harness from 56/56 to 63/63. - Unnumbered programs (compiler_main.c): src/compiler_main.c skipped any line that didn't start with a digit, so direct-mode .bas files like hello.bas, math_ops.bas, string_ops.bas (no line numbers) failed with "No program lines found". load_file now auto-assigns line numbers (last_num + 10) to unnumbered lines, with overflow protection at line 65520. - String concatenation in PRINT (codegen.c): emit_str_atom had a broken concat loop that emitted "; _cat = gw_str_concat(&... _cat.sval ...)" — _cat was never declared, so any program with a string-literal concat in PRINT (like PRINT "ABC" + "DEF") failed to link. Concat is properly handled by emit_str_expr's outer loop; remove the dead/broken code in the atom. Fixes string_ops.bas. - Transcendental result type (codegen.c): peek_expr_type returned VT_DBL for ATN/LOG/EXP/VAL, so PRINT formatted them with 15-digit double precision (e.g. 3.141592653589793) while real GW-BASIC and the interpreter format the single-precision result as 3.141593. Real GW-BASIC's transcendentals are single-precision; only CDBL forces double. Demote ATN/LOG/EXP/VAL to VT_SNG; CDBL stays VT_DBL. Fixes math_ops.bas. Also: tests/run_compiler_tests.sh now runs the compiled binary from the project root rather than the tempdir where it was built, so test programs that reference tests/programs/ via relative paths (chain_test, common_test, run_file, misc_stmts) resolve their targets. Earlier I'd misdiagnosed those failures as ON ERROR divergence — they were just CWD-dependent path lookups. Doc/test counts: 56 → 63 in README, docs/index.md, docs/development.md, docs/roadmap.md. Roadmap updated to note the compiler now accepts unnumbered programs.
2.1 KiB
2.1 KiB
GW-BASIC 2026
A portable C reimplementation of Microsoft GW-BASIC, using the original 8088 assembly source (released by Microsoft in 2020) as the authoritative reference.
This is not a transpilation -- it reimplements the algorithms in clean C11
with modern data structures while targeting bug-compatible behavior.
Unlike the original assembly (43,771 lines across 43 .ASM files), this
version is structured as modular C suitable for new feature development.
Highlights
- Authentic full-screen editor -- dynamically sized screen buffer (25×80
default, full terminal with
--full), free cursor movement, Enter-on-any-line, F1-F10 function keys, Insert/Overwrite toggle - Binary and ASCII file formats --
SAVEwrites tokenized binary by default,LOADauto-detects format (just like the real thing) - INKEY$ extended keys -- arrow keys, F-keys, and navigation keys return proper
CHR$(0)+ scan code two-byte sequences - Sixel graphics --
SCREEN 1/SCREEN 2rendering in compatible terminals - Sound --
SOUND,BEEP,PLAY(MML) via PulseAudio, plus continuous tone viaOUT(8253 PIT / PPI speaker emulation) - Hardware I/O --
OUT,INP,WAITport emulation (PIT, PPI, CGA, COM1, game port) for classic programs that drive hardware directly - Full file I/O -- sequential, random-access, SAVE/LOAD/MERGE/CHAIN/COMMON
- Printer output --
LPRINT/LLISTto file or real hardware via--lpt - Classic programs -- Hamurabi, Lunar Lander, Gunner, and Diamond from David Ahl's BASIC Computer Games (1978) run out of the box
- Ahead-of-time compiler --
gwbasic-compile prog.bas -cproduces native executables via C codegen + GCC (63/63 eligible tests pass, 100%) - Jupyter kernel -- inline Sixel graphics, INPUT support, Pygments syntax
highlighting;
pip install -e . && gwbasickernel-install --user - 72 test programs with golden-file regression testing and DOSBox-X compatibility testing against real GWBASIC.EXE
- MIT License
:maxdepth: 2
getting-started
language-reference
architecture
development
roadmap