I wrote a BASIC interpreter that boots on UEFI machines and ported it to Windows

Aug 24, 2026 12:48 AM - 1 day ago 2

Thoreau BASIC

A GW-BASIC–compatible expert that runs connected bare metallic (a Windows type is available, too).

The information conception is sized to the largest artifact of accepted representation the firmware (or Windows) reports, which connected a modern instrumentality is gigabytes.

Language

  • (mostly) GW-BASIC compatible. Programs load and prevention arsenic ASCII.
  • Numeric types, including 32 and 64-bit integers (%, &, &&), azygous and double precision, strings.
  • 32 spot wide statement numbers.
  • DEF FN, GOSUB, ON…GOTO/GOSUB, DATA/READ/RESTORE, and the remainder of the power flow.
  • Error trapping: ON ERROR GOTO, RESUME / RESUME NEXT / RESUME n, ERL, ERR, ON BREAK GOTO<br>

Graphics

  • PSET, LINE, CIRCLE, PAINT and friends astatine autochthonal framebuffer resolution. PSET, LINE and PAINT usable pinch 16 colour EGA aliases 24 spot R,G,B syntax.
  • 16-color EGA palette and 24-bit color: COLOR r,g,b (and a inheritance triple).
  • Bitmaps: LOADBMP slot, file$ sounds a 24/32-bpp Windows .BMP into a data-segment slot; BITBLT slot, x, y [,key] blits it, pinch an optional transparent colour cardinal for sprites.
  • GRAMAXX / GRAMAXY (graphics) and TXTMAXX / TXTMAXY (text) are readable variables holding the existent bounds.
  • SCREEN x,y requests a mode. SCREEN 1024,768 useful connected almost each instrumentality and is usually the footwear mode; effort your autochthonal solution for a sharper picture. GRAMAXX/GRAMAXY update aft a SCREEN command.

Text

  • IBM VGA 8×16 font, soft-scrolling console.
  • Multiple matter windows: WINDOW @n, x1,y1,x2,y2 carves a region; PRINT @n, CLS @n, LOCATE @n and COLOR @n activity wrong it, each model pinch its ain cursor and pen/paper. Plain PRINT still owns the full screen.

Memory & hardware

  • A three-pointer representation exemplary pinch nary 64KB ceiling. Arrays successful the billions of elements, if you want them.
  • PEEK, POKE, VARPTR, and readable pointers into the machine: LOMEM, HIMEM, FREEBOT, FREETOP, SCRNADR, GRAPITCH.
  • 64-bit HEX$ / OCT$.

Disk I/O — SAVE, LOAD, MERGE, FILES, KILL, moving straight connected the UEFI Simple File System.

Editing — full-screen EDIT, AUTO statement numbering, and RENUM (renumbers and rewrites each GOTO/GOSUB/THEN/ELSE/ON…/RESTORE/RESUME/ERL reference).

Timing — the TIMER adaptable sounds a high-precision timepiece from the CPU's invariant TSC.

New successful v1.1.3

  • MID$ tin beryllium an duty now
  • ERL wasn't stored and nary correction statement was shown erstwhile a programme exited pinch an error
  • INPUT: backspace didn't activity right

New successful v1.1.2

  • When disposable RAM was little than 4 GB, the Windows type bailed out.
  • BASIC lines are now fixed to 244 characters without statement numbers.
  • EDIT/LIST bug: erstwhile statement number was greater 32767 it showed an quiet statement 0 instead.

New successful v1.1.1 

  • Bare metal: Fixed the slow scrolling and penning to the framebuffer.
  • Windows: Added autostart. You whitethorn now telephone ThorauBASIC pinch a .bas filename attached, it will autostart.

New successful v1.1

  • Much faster. A per-line token cache, a precedence-climbing look evaluator, and variable-slot caching . Roughly 25× quicker connected compute-heavy programs. The bundled Mandelbrot dropped from ~230s to nether 10s, and Conway's Life now runs interactively. Lunar Lander runs astatine a fixed 100 fps now.
  • Bitmaps (LOADBMP/BITBLT), matter windows pinch per-window color, ON ERROR/ON BREAK/RESUME, ERL/ERR, RENUM, and PEEK/POKE/VARPTR.
  • Correctness fixes: nonstop 64-bit integer mathematics (overflow promotes to double), cleaner number formatting, and full-width HEX$.
More