forked from defunkt/ReefVM
add operands to guide
This commit is contained in:
parent
d057bf4b10
commit
e4443c65df
27
GUIDE.md
27
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
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user