add operands to guide

This commit is contained in:
Chris Wanstrath 2025-10-06 09:11:30 -07:00
parent d057bf4b10
commit e4443c65df

View File

@ -9,21 +9,30 @@ Quick reference for compiling to Reef bytecode.
OPCODE operand ; comment OPCODE operand ; comment
``` ```
### Labels ### Operand Types
```
.label_name: ; Define label
JUMP .label_name ; Reference label
```
### 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` - Numbers: `PUSH 42`, `PUSH 3.14`
- Strings: `PUSH "hello"` or `PUSH 'world'` - Strings: `PUSH "hello"` or `PUSH 'world'`
- Booleans: `PUSH true`, `PUSH false` - Booleans: `PUSH true`, `PUSH false`
- Null: `PUSH null` - Null: `PUSH null`
### Variables **Native function names**: Registered TypeScript functions
- Load: `LOAD varname` - `CALL_NATIVE print`
- Store: `STORE varname`
### Functions ### Functions
``` ```