Expand description
The executable format (D-20).
A header of five stored words, then the code.
§Why an instruction is six bytes
The byte boundary (D-04) maps a byte to a tryte and does not run backwards: a tryte holds 19,683 values and a byte holds 256. An instruction is three trytes, so storing one means splitting each tryte across more than one byte.
Each tryte is biased by 9,841 to make it non-negative, then split into two digits in base 243. Base 243 because it is 3^5, so a digit is a trit shift rather than a multiply, and because it is under 256, so a digit is still a byte. Two digits reach 59,049, past the 19,683 a tryte needs.
Modules§
- hdr
- Word offsets within the header.
Structs§
- Header
- A parsed executable header.
Enums§
- Exec
Error - Something wrong with a program or its source.
Constants§
- BIAS
- Added to a tryte to make it non-negative before splitting.
- BYTES_
PER_ INSTRUCTION - Bytes per instruction.
- BYTES_
PER_ TRYTE - Bytes per tryte in the encoded form.
- HEADER_
BYTES - Bytes in the header. Header fields are small, so they are stored the way filesystem fields are: three trytes in base 243, one byte each.
- HEADER_
WORDS - Words in the header.
- MAGIC
- Identifies an executable.
3^9 + 3^5 + 3and chosen only to be recognisable. - RADIX
- Digits are base 243, as in the filesystem.
- RADIX_
TRITS - Trits per digit:
RADIXis 3 to this power.