Viua VM instruction set architecture documentation

Basic model

Programs written for Viua VM are modelled as sets of actors. Actors are concurrently executing processes completely isolated from each other, communicating only via asynchronous message passing.

Internally, each actor is executing sequentially as a sequence of function calls. An actor finishes execution when the call frame at the bottom of its call stack is popped (i.e. when the main function of the actor finishes execution). A function is a sequence of instructions manipulating values placed in registers.

If we consider:

  1. contents of registers available to an instruction
  2. the queue of messages waiting to be received by the process
  3. the instruction pointer of the process
as a process' basic "state", then we can define all instructions the follwing way:

An instruction is the most basic operation that can be executed by the virtual machine. An instruction reads its inputs from the state of an actor, executes an operation, and writes its outputs to the state of the actor: Fn : (State) -> State

Registers and register sets

A register is a slot that is capable of holding any value that may be represented by a Viua VM program. A register set is a collection of registers with a common lifetime.

There are three general purpose register sets:

  1. local
  2. static
  3. global
...two register sets used to pass values during function calls:
  1. arguments
  2. parameters
...and one register set used to store thrown errors.

Accessing values in registers

To access a value contained in a register the register must be addressed, and an access type specifier must be given. The syntax is simple: first the access type specifier is given to inform the assembler how the value will be accessed, then the register index is given, and then the register set.
A few examples:

Direct access

Direct access may be used in both output, input, and mutable operands. It yields a value contained in the addressed register.

Pointer-dereference access

Pointer-dereference access may only be used in input and mutable operands; it is illegal to use pointer-dereference access in output operands. It yields a value to which the pointer contained in the addressed register points.

Register-address operands

There are three kinds of operands that use register addresses:

Input operands provide values for an instruction to work on. An example of an input operand is the second of third operand of the add instruction.

Output operands provide the instruction with slots to save the result of its work.

If an operand provides the input for an instruction, but is not only read by also changed by the instruction while it executes it could be considered both an input and an output operand. To simplify the nomenclature such operands are called mutable.

Execution of an instruction


There are 144 opcodes in 29 groups.


(sorted alphabetically)


(sorted alphabetically)

Viua VM | docs