-
Notifications
You must be signed in to change notification settings - Fork 0
ByteCode Format
Stephen001 edited this page Apr 17, 2011
·
8 revisions
The bytecode is currently structured to contain the following rules:
- file ::= stmts
- stmts ::= stmt stmts | Empty
- stmt ::= bytecode args
- args ::= arg args | Empty
- arg ::= constant | register
- bytecode ::= [5 byte little-endian] prefix byte 0x00, rest is value
- register ::= [5 byte little-endian] prefix byte 0x01, rest is value
- constant ::= [6 byte little-endian] prefix byte 0x02, next byte is constant type (see below), rest is value
As the current implementation only supports integers and floating point numbers, the constant types are:
- 0x00 = integer
- 0x01 = floating point
Byte-codes themselves are structured as such:
[2 byte code value][2 byte group value]
An example of a file may be:
00 0200 0100 01 01000000 02 00 01000000 = Total width 16 bytes
Reading as:
ByteCode 2, Group 1, first arg is register index 1, second arg is constant (int) value 1.
Under the current implementation, we just added 1 to register number 1, and stored the result back in register number 1. In pseudo-assembly:
add reg1, 1
Currently this is all the byte-code has, format-wise. Watch this space for revisions to include function blocks, string support etc.