Aseba Specification 001
The contributor centre is in English only.
AS001: Bytecode serialisation
This specification describes the bytecode serialisation format.
- Status
- Deployed since commit a017da2f.
- Written by
- Stéphane Magnenat and Philippe Rétornaz
File structure and extension
The file is a binary file, in which words are 16-bit integers in little endian. The extension shall be "abo".
Memory layout
address | field type | length | content |
---|---|---|---|
0x0 | null-terminated string | 4 | "ABO\0" |
0x4 | word | 2 | binary format version (currently: 0) |
0x6 | word | 2 | aseba protocol version |
0x8 | word | 2 | product id |
0xA | word | 2 | firmware version |
0xC | word | 2 | node id |
0xE | word | 2 | CRC-16 of node name |
0x10 | word | 2 | CRC-16 of VM description (see below) |
0x12 | word | 2 | len: length of bytecode in words |
0x14 | array of words | 2 * len | bytecode data |
0x14 + 2 * len | word | 2 | CRC-16 of bytecode data |
To compute CRC, we use the CRC-CCITT variant. When a value is on 8 bits, we pad the MSB with 0. If a value is signed, the CRC is applied on the bits directly considering the value as unsigned. We define the CRC of a string or of an array as the sequential application of CRC to every element of the string/array. Note that we do not use the length of the string/array, as applying the CRC to every element already captures the length.
CRC-16 of VM description
We compute the CRC with the following algorithm:
crc = 0 crc C= bytecodeSize crc C= variablesSize crc C= stackSize for (varLength, varName) in namedVariables: crc C= varLength crc C= varName for (eventName) in localEvents: crc C= eventName for (funcName, funcArgs) in nativeFunctions: crc C= funcName for (argLength, argName) in funcArgs: crc C= argLength crc C= argName
where a C= b is a shortcut for a = CRC(a, b) and CRC is the CRC-16 poly: 0x1021, init 0x0