Lingo bytecode

This is a partial, work-in-progress examination of the bytecode created when Lingo code is compiled in Macromedia Director 4.0. This is also sometimes known as IML, or Idealized Machine Language. It describes instructions for a stack-based virtual machine.

Each instruction is one, two or three bytes.
 * If the first byte is in the range 0x00-0x3F, then the full instruction is one byte.
 * If the first byte is in the range 0x40-0x7F, then the full instruction is two bytes.
 * If the first byte is in the range 0x80-0xFF, then the full instruction is three bytes.

Constant blobs like string literals are stored after the bytecode, and referred to by records that are six bytes long regardless of the actual length of the data. This means the first constant will be referred to as 0x00, the second constant as 0x06, the third as 0x0C, and so on. Integer literals over 32767 and floating-point number literals are also stored as constants.

There is also a namelist for referring to external identifiers, stored separately from the bytecode. This is a simple array of strings.

= Syntactic Sugar =

Some functions get special syntax when written out in source code, but the compiler just transforms it into something more common. Here is a mapping that shows the equivalent in plain, generalized Lingo that gets used for the bytecode.