Quick reference cards for CASM and Crush.
| Instruction | Effect | Example |
push_int | → int | {"op": "push_int", "value": 42} |
push_str | → str | {"op": "push_str", "value": "hello"} |
pop | value → | {"op": "pop"} |
dup | a → a, a | {"op": "dup"} |
| Instruction | Effect | Example |
add | a, b → result | {"op": "add"} |
sub | a, b → result | {"op": "sub"} |
mul | a, b → result | {"op": "mul"} |
div | a, b → result | {"op": "div"} |
| Instruction | Effect | Example |
jmp | Jump | {"op": "jmp", "target": 10} |
jmp_if | cond → jump if true | {"op": "jmp_if", "target": 10} |
call | Call function | {"op": "call", "function": "add"} |
ret | Return | {"op": "ret"} |
| Instruction | Effect | Example |
cap_call | Call capability | {"op": "cap_call", "name": "io.print", "argc": 1} |
let x = 42;
let name: String = "Alice";
fn greet(name: String) {
io.print("Hello, " + name);
}
fn add(a: Int, b: Int) -> Int {
return a + b;
}
if condition {
// ...
} else {
// ...
}
while condition {
// ...
}
for item in collection {
// ...
}
io.print("Hello");
fs.read("file.txt");
net.http("https://api.example.com");
@python {
print("Hello from Python")
}
@javascript {
console.log("Hello from JS");
}
@bash {
echo "Hello from Bash"
}
if fs.exists("file.txt") {
let content = fs.read("file.txt");
io.print(content);
}
let response = net.get("https://api.example.com/data");
io.print(response);
let args = sys.args();
if args.length < 2 {
io.eprint("Usage: program <arg>");
sys.exit(1);
}
| Type | Example | Description |
Int | 42 | 64-bit integer |
Float | 3.14 | 64-bit float |
String | "hello" | UTF-8 string |
Bool | true | Boolean |
Null | null | Null value |
Array | [1, 2, 3] | Array |
Map | {"key": "value"} | Map/Object |
| Capability | Description |
io.print | Print to stdout |
io.read | Read from stdin |
fs.read | Read file |
fs.write | Write file |
fs.exists | Check if file exists |
net.http | HTTP request |
sys.exec | Execute command |
sys.args | Get CLI arguments |