Bytecode Format
Technical reference for the Quartz bytecode (.qzb) format.
File Format
QZB files have the following structure:
+------------------+
| Magic Number (4B)| "QZB\0"
+------------------+
| Version (4B) |
+------------------+
| Metadata Section |
+------------------+
| Constant Pool |
+------------------+
| Code Section |
+------------------+
Inspecting Bytecode
# Compile to bytecode
./quartz --compile -o program.qzb program.qz
# Dump metadata
./quartz --dump-qzb-meta program.qzb
# Disassemble
python3 tools/qzb_disasm.py program.qzb
Common Opcodes
| Opcode | Description |
|---|---|
LOAD_CONST | Push constant onto stack |
LOAD_VAR | Load variable value |
STORE_VAR | Store to variable |
ADD | Add top two stack values |
SUB | Subtract |
MUL | Multiply |
DIV | Divide |
CALL | Call function |
RETURN | Return from function |
JUMP | Unconditional jump |
JUMP_IF_FALSE | Conditional jump |
For more details, see the Bytecode Compilation guide.