@onyxtheone
on
BTBX
I built BTBX (Bare Tiny(?) BASIC eXecutor), a self-contained BASIC interpreter that is the operating system. There's no Linux, no DOS, nothing underneath it. It boots straight off a FAT12 floppy image via a two-stage bootloader (512-byte stage1 + 2KB stage2), flips the CPU into protected mode, sets up the A20 gate, and lands you directly in a BASIC REPL, all inside 640KB of conventional memory.
From there it's a real language: GOTO, GOSUB, FOR/NEXT, WHILE/WEND, IF/THEN/ELSE, multi-dimensional arrays, 32-bit integers plus x87 80-bit floats, string functions (LEFT$, MID$, CHR$, etc.), and a full FAT12 filesystem so you can actually SAVE, LOAD, and DIR your programs on the disk image. There's also PEEK/POKE for raw memory access, BLOAD/SYS to load and jump into raw machine code, VGA graphics primitives, a PIT-driven BEEP, and — half-finished but present — a SAY command aiming for SAM-style formant speech synthesis.
What was challenging?
Everything below the interpreter, honestly. Getting the boot chain right (CHS and EDD disk reads, A20 enabling that doesn't silently hang, jumping into protected mode without immediately triple-faulting) took far longer than any language feature. The BIOS-thunk approach for file I/O (calling back into 16-bit real mode from a 32-bit kernel just to talk to disk) was its own maze.
The funniest recent challenge was building a browser demo on top of v86: getting PS/2 keyboard Shift state to survive contact with a web browser turned out to be nearly as hard as writing the A20 gate code itself :3. Real hardware (and QEMU) just work; browsers apparently have opinions about what a Shift key is allowed to do.
What am I proud of?
That it boots at all, genuinely. A homemade OS with a homemade language on top, running real math through the x87 FPU and reading/writing a real filesystem, in under 640KB, with zero borrowed runtime. Getting arrays, strings, and file I/O all coexisting cleanly in a from-scratch interpreter over ~240 hours feels like the actual milestone here, not any single feature.
What should people know to test it?
Use make && make run, that's the supported path, tested in QEMU, and it's where shift/symbols work correctly.
The browser demo (v86-based) is explicitly beta. booting and typing work, but shift-modified keys are unreliable there due to browser/emulator keyboard quirks (a real physical keyboard emulator interaction gap, not a BASIC bug ^^). Don't judge the interpreter by the demo's keyboard weirdness.
Try PRINT, FOR/NEXT loops, SAVE/LOAD/DIR to confirm the filesystem works, and BEEP for audio. SAY is a known work-in-progress ergo don't expect actual speech (yet).
Check the source tree if you want to see the boot chain (boot/stage1.asm, boot/stage2.asm) separately from the interpreter (src/kernel/basic.c).
- 25 devlogs
- 231h