mk90.basic

MBX1 executable format

The file header and opcode encoding for bytecode ABI 1.

Byte offsetLengthValue
04ASCII MBX1.
42Bytecode ABI, 1.
62Flags, 0.
82Total file size, including header.
102Variable count, 26.
122Operand-stack limit, 16.
142Reserved, 0.

Words are little-endian. The minimum accepted executable length is 17 bytes: the header and at least an instruction byte. The file-data checksum is the MKS2 inode checksum, not a field in this header. The entire file is checked before execution.

Encoding

Each opcode is one byte. Variable operands are zero-based, A=0 through Z=25. Immediate word operands and branch offsets are little-endian. Branch offsets count from the start of the file, so executable targets must be at least 16 and less than the total size.

LINE is an internal source-line marker used for error reporting; the source-language drawing LINE compiles to DRAW. KEY implements INKEY. STRING and PATH carry a length byte followed by data. All other opcodes have no inline operand unless listed below; their arguments come from the operand stack.

Opcode index

DecimalHexMnemonicInline operand
000ENDNone
101LINEu16 source-line marker
202CONSTu16 bit pattern
303LOADu8 variable index
404STOREu8 variable index
505ADDNone
606SUBNone
707MULNone
808DIVNone
909MODNone
100ANEGNone
110BEQNone
120CNENone
130DLTNone
140ELENone
150FGTNone
1610GENone
1711ANDNone
1812ORNone
1913NOTNone
2014PRINTNone
2115STRINGu8 length, then literal bytes
2216NLNone
2317JMPu16 byte offset
2418JNZu16 byte offset
2519CALLu16 byte offset
261ARETNone
271BFORu8 variable index
281CNEXTu8 variable index
291DINPUTu8 variable index
301ECLSNone
311FBEEPNone
3220WAITNone
3321LOCATENone
3422PSETNone
3523PRESETNone
3624DRAWNone
3725SOUNDNone
3826TICKSNone
3927KEYNone
4028ABSNone
4129RNDNone
422AOPENRNone
432BOPENWNone
442CGETu8 variable index
452DPUTNone
462ECLOSENone
472FEOFNone
4830HOURNone
4931MINUTENone
5032SECONDNone
5133PATHu8 length, then pathname bytes

Compatibility

MBX1 is a format for this VM. It is not ELF, PDP-11 a.out, a native instruction stream or a tokenized factory-BASIC cartridge. Header and bounds validation do not establish full semantic validity for manually edited bytecode. Use MBC from the matching release.