____ ____ _ ____ ___ ____
/ ___|| __ ) / \ / ___|_ _/ ___|
\___ \| _ \ / _ \ \___ \| | |
___) | |_) / ___ \ ___) | | |___
|____/|____/_/ \_\____/___\____|
BASIC> PRINT 6 * 7
42
BASIC> _
Structured BASIC 1.0 compiles line-number-free BASIC to bytecode for a small C99 virtual machine. The compiler and VM share a configurable arena that defaults to 8 KiB.
| Language | Runtime | Targets |
|---|---|---|
| INTEGER, SINGLE, STRING and one-dimensional arrays | Two-pass compiler and bounded call stack | Native Windows CLI and ATmega1284P via UART |
| IF, SELECT, structured loops, FUNCTION and SUB | Fixed arena and platform callbacks | NUCLEO-F412ZG via the sibling STM32 port |
Build with CMake, Ninja, Clang and Python 3. On Windows use an MSYS2 CLANG64 shell. The build guide covers the Windows release, sanitizers and AVR builds.
cmake -S . -B build/host -G Ninja -DCMAKE_C_COMPILER=clang -DSB_PROFILE=DEBUG
cmake --build build/host
ctest --test-dir build/host --output-on-failure
./build/host/sbasic examples/factorial.basOn Windows the executable is sbasic.exe. The sample prints 479001600.
FUNCTION FACT(N)
IF N <= 1 THEN
RETURN 1
END IF
RETURN N * FACT(N - 1)
END FUNCTION
PRINT FACT(12)Run sbasic without a filename to open the host shell.
The examples cover arrays, strings, recursion and I/O.
Register functions from your own C modules and call them by name from BASIC. The native extension guide covers the registration table, binary strings and error reporting. The BME280 example uses an I²C adapter supplied by the application.
| Start here | What it covers |
|---|---|
| Language reference · EBNF grammar | Source accepted by the parser and runtime semantics |
| Embedding · Platform adapters | CMake integration and the SBPlatform callback contract |
| Architecture · Bytecode · Memory | Compiler, instruction format and arena |
| Build · Testing · Verification | Reproducing checks and measured results |
The sibling structured-basic-stm32 repository provides a VT100 editor,
command shell and FAT storage over SDIO. It pins this repository as the
basic/ submodule and documents its own board, SDK and flashing steps.