Instruction format and execution

Each instruction in the virtual machine consists of an opcode and up to three operands named P1, P2, and P3. P1 may be an arbitrary integer. P2 must be a non-negative integer. In any operation that might cause a jump, P2 is always the jump destination. P3 may point to a function, a data structure, or a string, or it may be NULL. Some operators use all three operands, some use one or two, and some use none.

The virtual machine begins execution on instruction number 0. Execution continues until:

  1. a Halt instruction is seen, or
  2. the program counter becomes one greater than the address of last instruction, or
  3. there is an execution error.

When the virtual machine halts, all memory that it allocated is released, and all database cursors it may have had open are closed. If the execution stopped due to an error, any pending transactions are terminated, and changes made to the database are rolled back.