512 code + 512 asset bytes
Four layers. 256 instructions. Every artifact valid.
A tiny machine for
less tiny worlds.
Babel-8 v2 is a deterministic fantasy computer with eight registers, 1 KiB of RAM, four composited 64×64 layers, four audio voices, and no route out of its sandbox. Write C-like Babble with completion and live diagnostics, compile it locally, then inspect every byte and machine state.
Composite display / 64 × 64
Four-layer framebuffer
Keyboard: arrows · Z / X · Enter · Shift
Live v2 state
Debugger
00 00 00 LDI R0, 0x00
Writable data memory
RAM / 1,024 bytes
Live RAM is separate from both dedicated stacks. Pause before editing.
Best-effort reverse engineering
Bytecode → pseudo-Babble
Analyze the loaded artifact to recover reachable functions, blocks, RAM references, built-ins, and compiler-generated input patterns.
Reproducibility
Freeze the whole machine
Save registers, RAM, both stacks, all layer colors and visibility, palette, timers, RNG, input, and four voices. A state restores only into its original artifact.
The useful manual
Babel-8 v2 without guesswork.
Every instruction remains exactly two bytes: a one-byte opcode and a one-byte operand. All 256 opcode values are occupied, so the machine gained capability without an escape hatch into variable-width instructions.
Four layers
Draw calls target one layer. The compositor chooses the highest visible pixel, so erasing a sprite reveals the untouched background beneath it.
More machine
Eight byte registers, two 10-bit index registers, 1 KiB RAM, 32 return addresses, 64 data-stack bytes, and 256 instruction slots.
Four voices
Square, triangle, saw, and sine voices run independently. Four frame timers handle cooldowns and animation without busy loops.
Still deterministic
The complete 1,024-byte artifact seeds the RNG. Input is sampled once per frame and expensive instructions are atomic under a 16,384-unit budget.
Babble v2 language guide C-like source / byte semantics
Babble v2 has byte variables and arrays, immutable assets, functions with up to four byte parameters and a byte return value, for loops, switch, and the familiar structured statements.
asset hero = [0x18, 0x3C, 0x7E, 0xDB, 0xFF, 0x24, 0x42, 0x81];
u8 position[2] = [28, 28];
fn move(u8 value, u8 key) {
if (held(key)) { return value + 1; }
return value;
}
fn main() {
layer(0); fill(0);
loop {
layer(1); clear();
position[0] = move(position[0], RIGHT);
sprite1(position[0], position[1], hero, 2, REPLACE);
yield;
}
}
Declarations: u8 score;, u8 map[64];, const SPEED = 2;, and asset ship = [...]. Assets live in the immutable 512-byte asset ROM rather than consuming RAM or startup instructions.
Control flow: if/else, while, for, loop, switch/case/default, break, continue, return, and yield.
Arithmetic: byte arithmetic wraps modulo 256. Operators include + - * / % & | ^ ~ << >>, comparisons, boolean operators, compound assignment, and increment/decrement. Division by zero returns zero.
Functions: parameters use u8, arguments travel through R0–R3, and return values use R0. Recursive calls preserve the caller's parameters, locals, and live expression values on the 64-byte data stack. Keep recursion bounded: return addresses have 32 slots and frame data has 64 bytes.
ROM optimizer: enable Optimize ROM to fold constant expressions and arithmetic identities, branch directly from comparisons, thread jumps, and remove redundant or unreachable machine instructions. The build summary compares the optimized instruction count with the unoptimized baseline.
Editor: completion, snippets, signature help, hover documentation, bracket guides, minimap, compile markers, find/replace, multi-cursor editing, and glyph-margin breakpoints come from Monaco—the editor core used by VS Code.
Babble v2 built-ins layers / input / audio / time
layer(n)Select layer 0–3 for subsequent drawing.
clear() / fill(color)Clear to transparency or opaque-fill the active layer.
pixel(x,y,color,blend)Draw with REPLACE, XOR, ADD, or ERASE.
erase(x,y)Reveal lower layers at one pixel.
read_layer(x,y)Read active-layer color; transparency returns 255.
read_screen(x,y)Read the final composited color.
hline / vline / rect / fill_rectDraw wrapped primitives on the active layer.
sprite1 / sprite2Blit one-bit or two-bit 8×8 asset sprites.
collide1 / collide2Test a sprite against lower layers or the full composite.
invert / scroll_left / scroll_right / scroll_up / scroll_downTransform only the active layer, including its visibility mask.
palette(slot,color)Map one of four active slots to the 16-color master palette.
held / pressed / releasedRead level, rising-edge, or falling-edge input.
random(mask) / frame(byte)Read deterministic randomness or the 32-bit frame counter.
timer_get / timer_setUse four independent frame timers.
voice / beep / silence / silence_allControl four oscillator voices.
sleep(frames) / yieldSuspend future frames or end the current one.
Babel-8 v2 machine model state / timing / composition
R0–R7, 10-bit X/Y, 8-bit instruction-index PC, zero/carry flags, a 32-entry return stack, and a 64-byte data stack.
RAM1,024 writable bytes. Indexed accesses wrap; stacks no longer overwrite program data.
DisplayFour 64×64 layers. Every pixel has a two-bit palette slot and separate visibility bit. Layer 3 is topmost; transparent pixels reveal lower layers.
BlendingReplace makes a pixel visible; XOR and Add combine two-bit colors; Erase clears visibility without inventing a transparent color.
InputLeft, Right, Up, Down, A, B, Start, Select. Edge masks are calculated once per VM frame.
AudioFour independent declarative voices with tone, waveform, volume, and optional frame duration. Browser audio requires an explicit Enable sound gesture.
FramesTimers and voices tick first, then instructions receive 16,384 work units. Expensive operations never partially execute.
SafetyAll addresses wrap, all 256 opcodes are defined, and the VM cannot access host APIs.
Raw v2 instruction reference all 256 opcodes
The high nibble identifies the family; ranges containing eight opcodes use the low three opcode bits to select R0–R7. Descriptor bits are shown by the live disassembler.
00–0FMovement
LDI · MOVImmediate and register-to-register loads.
10–1FImmediate arithmetic
ADDI · SUBIWrapping byte arithmetic with zero and carry/no-borrow flags.
20–2FRegister ALU
ADD ADC SUB SBC MUL DIV MOD AND OR XOR CMP MIN MAX SWAP TEST MOVF · CMOVSixteen ALU modes and eight flag conditions.
30–3FBits and unary
SHL SHR ROL ROR · INC DEC NEG NOT CLZ BITREV SWAPNIB ABSShifts, rotations, and byte transforms.
40–5FMemory
LOAD STORE · LOADX STOREXZero-page RAM plus indexed RAM and immutable asset access through X/Y.
60–6FIndex registers
SETX/Y · ADDX/Y · X/YFROM · X/YTO · SWAPXY · INC/DEC · CMPXYBuild and manipulate 10-bit addresses.
70–7FControl
JMP JZ JNZ JC JNC CALL RET YIELD · DJNZAbsolute branches over 256 instruction slots and a dedicated return stack.
80–8FPixels
PIXEL · PGETDraw with four blend modes or read active/composited pixels.
90–9FShapes
HLINE VLINE RECT FILLRECTWrapped primitives on the active layer.
A0–AFCompositor
LAYER CLEAR INVERT FLIP SCROLL ROTATE NOISE TILE ROWSHIFT COLSHIFTSelect and transform one layer, colors and visibility together.
B0–BFSprites
BLIT1 · BLIT28×8 one-bit and packed two-bit blits from asset ROM or RAM.
C0–CFRandom and reads
RAND · READRNG, input masks, frame bytes, system state, voices, and palette.
D0–DFDevices
VOICE BEEP PALETTE TIMER SLEEP SILENCEFour voices, four timers, active palette remapping, and suspension.
E0–EFBulk and emergent
RAM ops · COLLIDE · LIFE · TOTALISTIC · FLOOD · ERODE · DILATE · HASHAtomic high-level operations for games, procedural programs, and conformance.
F0–FFLifecycle and stack
NOP HALT YIELD WAITR RESET* · PUSH POP PEEK DEPTHMachine lifecycle and the dedicated 64-byte data stack.
Debugger guide break, step, inspect
Click Monaco’s glyph margin, a source line number, or any disassembly row to toggle a breakpoint. A hit produces a persistent red action panel, highlights both source and bytecode, and requires Continue, Step over, or removal.
Step instruction executes one atomic instruction. Step frame samples input, ticks devices, and runs until yield, sleep, halt, breakpoint, or budget boundary. Profile heat bars show hot instruction slots.
The layer inspector can view the final composite or any raw layer without changing VM state. Transparent pixels are displayed as a checkerboard.
Best-effort decompiler bytecode / control flow / pseudo-Babble
Attempt decompile starts at instruction 00, follows static branches and calls, discovers function candidates and basic blocks, assigns names such as ram_04 to direct memory references, and emits readable pseudo-Babble.
The decompiler recognizes arithmetic, comparisons, input edges, drawing, audio, timers, stack operations, and common compiler-generated instruction sequences. Instructions that cannot be represented faithfully become explicit asm("...") statements.
Exact source recovery is impossible: comments, names, lexical scopes, types, and the author's original choice of loops or conditions are absent from bytecode. Consequently the output uses synthetic registers, labels, goto, and helper operations that the current Babble compiler does not accept. Treat it as an analysis document, not guaranteed round-trip source.
Only instructions reachable from the reset entry and discovered calls are emitted. Unreachable padding or random dead regions are counted and omitted. The complete asset-ROM byte array is retained whenever it contains non-zero data.