← Hub
Babel-8 babel8-v2
Paused

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.

Babble v2 / Monaco-powered IDE

Write programs like a human.

main.babble ⌘/Ctrl + Space completes · ⌘/Ctrl + Enter runs

Composite display / 64 × 64

Four-layer framebuffer

Inspect layer VM active: L0
Audio is muted

Keyboard: arrows · Z / X · Enter · Shift

Live v2 state

Debugger

R000
R100
R200
R300
R400
R500
R600
R700
PC00
X000
Y000
RS/DS0/0
Z C frame 0 work 0
RNG00000000 INPUT00 SLEEP00 TIMERS00 00 00 00
V0silent V1silent V2silent V3silent
Next instruction 00 00 00 LDI R0, 0x00
Code ROM disassembly click a row to break

512 code + 512 asset bytes

Artifact / 1,024 bytes

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.

01

Four layers

Draw calls target one layer. The compositor chooses the highest visible pixel, so erasing a sprite reveals the untouched background beneath it.

02

More machine

Eight byte registers, two 10-bit index registers, 1 KiB RAM, 32 return addresses, 64 data-stack bytes, and 256 instruction slots.

03

Four voices

Square, triangle, saw, and sine voices run independently. Four frame timers handle cooldowns and animation without busy loops.

04

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
ArtifactExactly 1,024 immutable bytes: 512 bytes of code (256 instructions) followed by 512 asset bytes. CPUR0–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–0F

Movement

LDI · MOV

Immediate and register-to-register loads.

10–1F

Immediate arithmetic

ADDI · SUBI

Wrapping byte arithmetic with zero and carry/no-borrow flags.

20–2F

Register ALU

ADD ADC SUB SBC MUL DIV MOD AND OR XOR CMP MIN MAX SWAP TEST MOVF · CMOV

Sixteen ALU modes and eight flag conditions.

30–3F

Bits and unary

SHL SHR ROL ROR · INC DEC NEG NOT CLZ BITREV SWAPNIB ABS

Shifts, rotations, and byte transforms.

40–5F

Memory

LOAD STORE · LOADX STOREX

Zero-page RAM plus indexed RAM and immutable asset access through X/Y.

60–6F

Index registers

SETX/Y · ADDX/Y · X/YFROM · X/YTO · SWAPXY · INC/DEC · CMPXY

Build and manipulate 10-bit addresses.

70–7F

Control

JMP JZ JNZ JC JNC CALL RET YIELD · DJNZ

Absolute branches over 256 instruction slots and a dedicated return stack.

80–8F

Pixels

PIXEL · PGET

Draw with four blend modes or read active/composited pixels.

90–9F

Shapes

HLINE VLINE RECT FILLRECT

Wrapped primitives on the active layer.

A0–AF

Compositor

LAYER CLEAR INVERT FLIP SCROLL ROTATE NOISE TILE ROWSHIFT COLSHIFT

Select and transform one layer, colors and visibility together.

B0–BF

Sprites

BLIT1 · BLIT2

8×8 one-bit and packed two-bit blits from asset ROM or RAM.

C0–CF

Random and reads

RAND · READ

RNG, input masks, frame bytes, system state, voices, and palette.

D0–DF

Devices

VOICE BEEP PALETTE TIMER SLEEP SILENCE

Four voices, four timers, active palette remapping, and suspension.

E0–EF

Bulk and emergent

RAM ops · COLLIDE · LIFE · TOTALISTIC · FLOOD · ERODE · DILATE · HASH

Atomic high-level operations for games, procedural programs, and conformance.

F0–FF

Lifecycle and stack

NOP HALT YIELD WAITR RESET* · PUSH POP PEEK DEPTH

Machine 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.