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

Quick Reference

Quick reference cards for CASM and Crush.

CASM Instructions Quick Reference

Stack Operations

InstructionEffectExample
push_int→ int{"op": "push_int", "value": 42}
push_str→ str{"op": "push_str", "value": "hello"}
popvalue →{"op": "pop"}
dupa → a, a{"op": "dup"}

Arithmetic

InstructionEffectExample
adda, b → result{"op": "add"}
suba, b → result{"op": "sub"}
mula, b → result{"op": "mul"}
diva, b → result{"op": "div"}

Control Flow

InstructionEffectExample
jmpJump{"op": "jmp", "target": 10}
jmp_ifcond → jump if true{"op": "jmp_if", "target": 10}
callCall function{"op": "call", "function": "add"}
retReturn{"op": "ret"}

Capabilities

InstructionEffectExample
cap_callCall capability{"op": "cap_call", "name": "io.print", "argc": 1}

Crush Syntax Quick Reference

Variables

let x = 42;
let name: String = "Alice";

Functions

fn greet(name: String) {
    io.print("Hello, " + name);
}

fn add(a: Int, b: Int) -> Int {
    return a + b;
}

Control Flow

if condition {
    // ...
} else {
    // ...
}

while condition {
    // ...
}

for item in collection {
    // ...
}

Capabilities

io.print("Hello");
fs.read("file.txt");
net.http("https://api.example.com");

Polyglot

@python {
    print("Hello from Python")
}

@javascript {
    console.log("Hello from JS");
}

@bash {
    echo "Hello from Bash"
}

Common Patterns

Read File

if fs.exists("file.txt") {
    let content = fs.read("file.txt");
    io.print(content);
}

HTTP Request

let response = net.get("https://api.example.com/data");
io.print(response);

Command-Line Args

let args = sys.args();
if args.length < 2 {
    io.eprint("Usage: program <arg>");
    sys.exit(1);
}

Type Reference

TypeExampleDescription
Int4264-bit integer
Float3.1464-bit float
String"hello"UTF-8 string
BooltrueBoolean
NullnullNull value
Array[1, 2, 3]Array
Map{"key": "value"}Map/Object

Capability Reference

CapabilityDescription
io.printPrint to stdout
io.readRead from stdin
fs.readRead file
fs.writeWrite file
fs.existsCheck if file exists
net.httpHTTP request
sys.execExecute command
sys.argsGet CLI arguments