Bitcoin BASIC — compiler and decompiler

Bitcoin Script is what BASIC's expression evaluator looks like with the front end deleted.
`V = V + F/M - V*D` becomes the same sequence of stack operations in either machine. That is not a
metaphor: every infix language has a stack machine underneath, and Script is that machine with nothing
sitting on top of it. So this archive contains a compiler that emits Script from a BASIC dialect — and a
reader that renders a deployed locking script back into it.
The reader is the half with no precedent. A compiler tells you what you meant. **A reader tells you what
the bytes say**, including bytes you did not write, fetched off the chain, belonging to somebody else.
A 1,108-opcode hand-written covenant reads back as a listing; a 1,428-byte one reads back as 216 lines.
That matters because a covenant cannot be amended. A permanent, unamendable constant sits somewhere inside
a few thousand opcodes with no names and no structure, one edit moves every offset behind it, and what gets
verified is a mental model of the script rather than the script. Errors surface after minting and funding,
when nothing can be changed. A reader is how that stops being true.
Four demonstrations are included as tests, each solving the same problem — **Script has no arrays** — a
different way. Noughts and crosses packs its board in base 3 and reads a square by arithmetic. The same game
in base 4 spends one extra byte of state to save 105 bytes of program. Space Invaders builds its array out of
`2 ^ k` folded at compile time inside an unrolled loop, and runs the full 55-alien fleet in 1,082 bytes. And
Rule 110 — Turing complete by Cook's proof — runs both ways: eight generations unrolled into one script, or
eight generations as eight chained spends, arriving at exactly the same state. Script still has no backward
jump. The pair shows where the loop went.
The compiler and the reader depend on nothing but an opcode table: `OP` and a type that erases at runtime.
Anyone implementing this in another language needs a list of opcode numbers and nothing more.
Verify it: unzip, `npm install @bsv/sdk@2.1.4`, then
```
node --experimental-strip-types mint/test/basic.ts 42/42
node --experimental-strip-types mint/test/basic-state.ts 18/18
node --experimental-strip-types mint/test/basic-covenant.ts 10/10
```
All three were run exactly that way, from a fresh unpack of this archive, before it was published. The
workbench needs no build at all: open `basic.html` and it runs offline.
```
files 15 · 200,280 bytes · SHA-256 for every one, listed in MANIFEST.md
archive f308f18b952360b46d207beb8539bb202d704ab80e23c39425c76f024d908175
workbench grafverse.com/basic.html
source github.com/sun-dive/grafverse · mint/src/
licence Open BSV License Version 6 · © 2026 sun-dive