Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Register I/O

Instructions for moving data between the stack, register file, calldata, and output slots.

CodeMnemonicArgumentsStack EffectRegister EffectDescription
0x0ALOADreg: Register\([\ldots] \to [\ldots, v]\)readreg must hold \(\text{Int}(v)\). Push \(v\) onto the stack. Errors if reg holds any other variant.
0x0BSTOWreg: Register\([\ldots, v] \to [\ldots]\)writePop \(v\). Write \(\text{reg} \leftarrow \text{Int}(v)\).
0x0CDROPreg: Register\([\ldots] \to [\ldots]\)writeWrite \(\text{reg} \leftarrow \text{Int}(0)\), releasing any heap allocation the slot held (models, vectors, samples).
0x0EINPUTreg: Register\([\ldots, s] \to [\ldots]\)writePop \(s\) (slot index). Clone \(\text{calldata}[s]\) into reg. Any RegVal variant is transferable. Errors if \(s\) is out of range.
0x0FOUTPUTreg: Register\([\ldots, s] \to [\ldots]\)readPop \(s\) (slot index). Clone reg’s value into \(\text{outputs}[s]\). Errors if \(s\) is out of range.

Stack-Register Bridge

The stack holds only i64 integers. To move richer types (models, vectors, samples) into and out of the VM, use INPUT and OUTPUT with the calldata and output slot arrays.

LOAD and STOW bridge the stack and register file for integer values only. LOAD errors if the register does not hold Int – it will not silently coerce other types.

Memory Management

DROP is the only way to explicitly free a register’s allocation. Setting a register to \(\text{Int}(0)\) releases any model, vector, or sample that was previously stored there. This is important for controlling memory usage in long-running programs.