Radar van Elk Solutions

Hackaday · Creativity & design

Retrocomputing Enhanced with a BASIC Preprocessor

A project aims to make programming old computers more enjoyable by developing a preprocessor for MBASIC, adding modern features and enabling self-translation on the target machine.

The Hackaday Retrocomputing Challenge inspired a project to revive programming on an old CP/M machine using MBASIC. Raw MBASIC proved cumbersome, recalling the need for a BASIC preprocessor.

The preprocessor, prototyped in awk and Python, converts modern constructs and labels into standard MBASIC. Early versions struggled with parsing, leading to a redesign using comments for labels and a two-pass system.

The preprocessor evolved to include modern control structures like IF/THEN/ENDIF and WHILE/WEND, plus conditional compilation and source inclusion.

The project has three versions: awk, Python, and MBASIC. An LLM assisted with documentation and tests to ensure consistency across versions.

The MBASIC translator, though convoluted, runs on the CP/M machine. It uses a compatible syntax, allowing for self-translation.

A sample program demonstrates driving an LED display. Another, HILO.BAL, showcases compile-time constants and control loops. The translator itself is about 1300 lines of preprocessor code.

The preprocessor reduces programming friction, making development enjoyable. Crucially, the translator can reside and operate on the target machine for an authentic experience.

AI-samenvatting op basis van de bron.

Hackaday