Version 3 (modified by cotto, 12 years ago)

updates from #ps

This page describes a current approximation of Lorito's ops. It is expected to converge with the eventual implementation as the number of edits increases.

Control Flow (5 ops)

  • noop - do nothing
  • call - call a sub (or an object method or vtable function)
  • end - halt the interpreter cleanly
  • goto - unconditional branch
  • if - conditional branch

Value (12 ops)

The Value, Math, Comparison and Object ops are designed to minimize op proliferation. Apart from type coercion via set_[ins]_[ins], all ops require that each of their arguments be of the same type.

  • set_[ins]_[ins] - copy/coerce registers between primitive types (objects will provide the same functionality via vtable functions)
  • load_const_[ins] - load a constant into a register

Math (14 ops)

  • add_[in] - add two registers of the same type
  • sub_[in] - subtract two registers of the same type
  • mul_[in] - multiply two registers of the same type
  • div_[in] - divide two registers of the same type
  • mod_[in] - return the remainder of $2/$3
  • and - bitwise and of an int
  • or - bitwise or of an int
  • not - bitwise not of an int
  • xor - bitwise exclusive or of an int

Comparison (6 ops)

  • iseq_[in] - compute equality between two registers of the same type
  • isgt_[in] - a > b
  • isge_[in] - a >= b

Objects (8 ops)

  • box - turn an int, float or string into an object
  • new - create a new object
  • new_[insp] - create a new object with an argument
  • getattr - retrieve an object attribute's value
  • setattr - set an object attribute's value

Other (1 op)

  • loadlib - load a (dll/so, pbc or HLL?) library

I/O (3 ops, bootstrapping only)

These three ops are only intended for use during Lorito's implementation phase. Once Lorito matures to the point where we have a fixed set of ops and have tools that can generate Lorito, we expect these ops to become methods on a FileHandle.

  • read - read from stdin
  • write - write to stdout
  • gripe - write to stderr