Topology
Programs
Fabric, spec, syntax and ports
Fabric. A slot is one processor: reserved cycles, 32K words of private memory, a link table of at most 16 entries, and a 4-deep queue of up to 16-word messages on every link. All slots are allocated at boot; there is no pool. Spawning subdivides: writing n to SPAWN makes a child holding n spare slots and costs the parent n+1. A halted processor is destroyed: its slot and spare budget go back to its nearest living ancestor, and every handle to it, anywhere, is rewritten to point at nothing (processor −1). Such a tombstone still yields any messages the dead peer had already queued; sends and introductions through it fail; and it keeps its number until its holder writes it to LINK.CLOSE, so a stale handle can never alias a newer peer.
Reads and writes. A read never changes state; a write may. Latches (ALU.A, CMP.A, MEM.ADDR, SPAWN.ID) and results read back; trigger ports have no storage and read as 0. The one exception is IMM, whose read consumes the literal. A trigger that can fail (SPAWN, MSG.SEND, MSG.DATA, MSG.INTRO, MSG.ACCEPT, STK.PUSH, LINK.CLOSE) reports in G; one that cannot leaves G alone.
Links. A link exists only because both ends agreed to it: by spawning, by boot spec, or by introduction, where each end's table grows only when that end reads MSG.INTRO. Handle 0 is the parent. Freed handle numbers are reused. Devices (the console) are endpoints in the table like any peer and may be introduced onward.
Spec. The root object names a program, a start pc (default 0, which is also where assembly starts unless a program says .org), a spare-slot quota (default 0), devices, children and links. Children are groups: name, count, an optional id (instance k reads id+k), and the same fields. Any entry may fix its handle (a base, for counted groups); unfixed ones are numbered in declaration order from the next free number. A link entry is {"to": "name"}, "name:2", or "name:+1" (a sibling, wrapping); the far end gets a handle too, either its own declared entry or the next free number.
Programs. .program name starts a program; the spec's memory field picks one. Handles appear as symbols: @parent, @console, @worker (a group's base), @worker+1. A handle is a value, never an address, so @x in source position is always a literal. Moves: src -> dst, src ->? dst (only if G), #42 literals, labels, name = expr, .org, .word, .str. Macros: add a, b -> c (sub and or xor shl shr), cmp.eq a, b (ne lt ge ult uge), not, jmp, jif, call (push, jump, drop on return), ret (STK.TOP -> PC), push, pop (top, then drop), load p -> x, store x -> p, spawn n or spawn n, id, intro h, connect a, b, send a, b -> h, drop, close h, wait, open, recv -> x (word, then next), accept -> x (accept, then the handle), putc x -> h, print x -> h (a character or a number, to any handle that speaks the console protocol), halt.
- IMM
- read: the next program word, then skip it
- PC
- read: next instruction; write: jump
- G
- the guard flag. A move with
->?always reads its source and writes its destination only if G is set: the guard is a write-enable, and since reads are pure the only thing a skipped move still does is consume a literal - ID
- a label from whoever made you: the spec's
id(plus your index in a group), or the tag your parent staged inSPAWN.ID. Defaults: 0 on the root, 1 elsewhere - QUOTA
- read: spare slots you could spend on spawns
- ALU.A, ALU.ADD…SHR, ALU.OUT
- first operand; trigger with the second; the result, read-only
- CMP.A, CMP.EQ…UGE, CMP.NOT
- first operand; trigger sets G; invert G
- MEM.ADDR, MEM.DATA
- a pointer, and the word it points to
- STK.PUSH, STK.DROP, STK.TOP, STK.DEPTH
- a private 256-word stack, not in memory: push (G clear if full), discard the top, read the top, read the depth
- SPAWN
- write a budget to fork; G set in both halves on success, clear on refusal
- SPAWN.ID
- a latch: the tag every child spawned from now on reads as
ID, until rewritten; reset value 1 - SPAWN.CHILD
- read: the new child's handle, or 0 if you are the child
- LINK.COUNT
- read: handles held, tombstones included
- LINK.CLOSE
- write a handle: frees it if its peer has halted (G set), refused if the peer is alive (G clear). So it doubles as “is this peer dead?”
- MSG.DATA
- write appends a word to the outgoing message (G clear past 16)
- MSG.INTRO
- write a handle to attach that peer to the outgoing message; read: the handle of the peer you accepted from the open message, or −1 before accepting
- MSG.ACCEPT
- any write accepts the peer the open message carries, growing your table; G set on success
- MSG.SEND
- write a handle to send. G set if queued; clear if the handle is bad, the link is half-open, or that link's queue is full, and the message is kept for retry
- MSG.DROP
- any write discards the staged message, kept after a refused send
- MSG.AVAIL
- read: messages waiting across all links
- MSG.OPEN / MSG.WAIT
- take the next message, links served round-robin; WAIT sleeps until one arrives
- MSG.FROM, MSG.LEN, MSG.WORD
- the open message's sender handle, words left, and the word at the cursor
- MSG.NEXT
- any write advances the cursor one word
- HALT
- any write destroys this processor
Console protocol: a message whose first word is 0 prints the rest as characters; first word 1 prints the next as a signed number. Typed input arrives as messages 2, char on the selected processor's console link.