diff --git a/GUIDE.md b/GUIDE.md index af85d94..d6f6762 100644 --- a/GUIDE.md +++ b/GUIDE.md @@ -9,21 +9,30 @@ Quick reference for compiling to Reef bytecode. OPCODE operand ; comment ``` -### Labels -``` -.label_name: ; Define label -JUMP .label_name ; Reference label -``` +### Operand Types -### Constants +**Immediate numbers** (`#N`): Counts or relative offsets +- `MAKE_ARRAY #3` - count of 3 items +- `JUMP #5` - relative offset of 5 instructions (prefer labels) +- `PUSH_TRY #10` - absolute instruction index (prefer labels) + +**Labels** (`.name`): Symbolic addresses resolved at parse time +- `.label:` - define label at current position +- `JUMP .loop` - jump to label +- `MAKE_FUNCTION (x) .body` - function body at label + +**Variable names**: Plain identifiers +- `LOAD counter` - load variable +- `STORE result` - store variable + +**Constants**: Literals added to constants pool - Numbers: `PUSH 42`, `PUSH 3.14` - Strings: `PUSH "hello"` or `PUSH 'world'` - Booleans: `PUSH true`, `PUSH false` - Null: `PUSH null` -### Variables -- Load: `LOAD varname` -- Store: `STORE varname` +**Native function names**: Registered TypeScript functions +- `CALL_NATIVE print` ### Functions ```