QuadBasic — a gentle on‑ramp to Intel 4004 assembly

If you know a little BASIC, you can start with short, line‑numbered programs and let Quadium turn them into real Intel 4004 assembly. You do not need to “be an assembler hero” on day one: write, transpile, then inspect the generated code when you are curious.

QuadBasic is the product name you see in the app. The compiler core is implemented as Basic4 internally (“BASIC shaped for 4‑bit work”), but the idea is the same in plain language: high‑level source → 4004 ASM → run on the virtual MCS‑4 bench.

Start here (no compiler vocabulary required)

What you do in the workbench

Type a small QuadBasic program, press transpile, and Quadium fills the assembler view with generated 4004 instructions. From there you follow the normal lab flow: assemble, program ROM, run, pause, step — with CPU and bus visibility when you want it.

Who this is for

Teachers, curious retro folks, and anyone who wants a readable first step before diving into raw 4004 code. It is still a technical tool, but the entry path is closer to “classic BASIC” than to “blank assembler file”.

What it is not

It is not Microsoft BASIC, and it is not a full modern language. It is intentionally small, 4‑bit oriented, and designed to map cleanly to the MCS‑4 world. When you outgrow the shortcuts, the assembly is right there.

Technical details (for curious / advanced readers)

How it works inside (step by step)

Quadium reads your whole program, checks it for consistency, then emits 4004 assembly text. If something is wrong, you get a clear error stage (tokenizing/parsing/validation/code generation) instead of a mysterious crash.

Program-wide validation (not “only line by line”)

After parsing, Quadium enforces basic structural correctness that matches how labels are emitted: unique top-level line numbers, FOR/NEXT pairing in source order, and GOTO/GOSUB targets that refer to real executable line labels (comment-only lines do not define jump targets).

Codegen output is annotated 4004 assembly

Generated assembly includes a small header explaining the register plan: BASIC variables map to R0–R9 (assigned on first use), R10–R11 are used as expression temporaries / logical operands, and additional registers are reserved for emitted helper routines when required. This is meant to make the translation auditable while you learn.

Language reference (exactly what the current parser accepts)

You can skip this section until you need it. It is here for accuracy and search keywords, not because beginners must read it up front.

Line numbers, statements, and inline statement packs

Each physical line starts with a line number in the range 0–65535. A line may contain multiple statements separated by : (colon), which becomes a composite statement in the AST (useful for dense teaching examples).

Nibble arithmetic and literals

Expressions include + − * / on the nibble model. General integer literals are accepted in the range -8..15 (still a 4‑bit-oriented language). FOR loops support a constant STEP in -8..7 (zero step is rejected).

Logical operators (bit-serial runtime when needed)

The keyword set includes NOT and bitwise-style operators AND OR XOR NAND NOR XNOR. On the 4004 target, these map to emitted instructions plus helper routines when the straightforward instruction path is insufficient (this is why the generator tracks “needs runtime” flags while emitting).

PRINT to virtual devices (workbench integration)

PRINT supports an optional device prefix @SCR (default screen), @PRN, @LCD, @DSK, and @NUL. Items can be string literals, expressions, or CHR(lo,hi). Inside PRINT only, separators ; and & are equivalent for concatenation/no-newline semantics. PRINT @DSK does not embed file paths in the language — the output file is selected in Settings.

MCS‑4 memory and ports via PEEK/POKE forms

QuadBasic includes structured MCS‑4 access forms such as POKE @RAM(...), PEEK @RAM(...), @RAMSTATUS (status index must be a constant 0..3), @RAMPORT, and @ROMPORT. PEEK @ROM(hi,lo) reads a ROM byte into two destination variables. Note: PEEK @RAMPORT is rejected because the 4002 RAM I/O port is modeled as write-only (WMP), matching the hardware-oriented teaching goal.

Where to go next

Full language + hardware semantics

This page is an overview for search and sharing. The complete QuadBasic manual (and the hardware manual for MCS‑4 details) lives under Documentation. If you care about the full system context, start with the MCS‑4 / 4004 emulator overview.

Copy/paste samples

For ready-made programs and screenshots, see Examples and the captioned Gallery.

Wishlist / follow on Steam

Quadium 4004 Workbench on Steam

FAQ

Does QuadBasic run as bytecode?

No — the workbench’s “Compile/Transpile” path produces Intel 4004 assembly text intended for the normal assemble → ROM → run workflow.

Is it Microsoft BASIC compatible?

No. It is intentionally small and MCS‑4/4004 oriented (nibbles, device prints, MCS‑4 access forms). Think “BASIC-shaped syntax for a 4‑bit lab”, not a full vintage BASIC dialect.

Trademark note

Intel and MCS-4 are trademarks of Intel Corporation. Quadium Workbench is independent and is not affiliated with or endorsed by Intel. Legal.