Files
tyche/doc/BYTECODE
2026-05-14 20:45:58 -05:00

36 lines
798 B
Plaintext

Bytecode format
---------------
The bytecode file is composed of the following sections:
* HEADER: 8-byte header
[0:3]: Magic
[4:5]: Bytecode version
[6:7]: Reserved for future use
* CONSTANTS
[0:3]: Code start address
[4:7]: Number of constants
Each constant:
[0]: Type (0 = string, 1 = real)
if string:
[1..4]: string size
[...]: string
if real
[1..4]: real
* CODE
[0:3]: Debug start address (or zero)
[4:7]: Number of functions
Each function:
[0:3] Address of next function
[...] Code
[0] : Opcode
[between 1 and 4] : Operand
The max file size is 2 Gb.
## Values can be encoded in the following ways:
* The type is defined by the operator.
* Constant indexes and function ids are encoded as ints