SPECIFICATION

MAR virtual machine specification (draft)


The Mar virtualmachine (mar means sea in spanish) is designed for conducting artificial life experiments. It is intended to be the simplest architecture which is able to run evolvable code. The virtualmachine is defined by the datastructure that represents the machine state and the corresponding instructionset.
 

The structure

  • Instruction pointer: Integer. Points the instruction to be executed in the memory. The adjust of the value this register is instruction dependent. By default it is incremented by one (modulo size of the codetape, because the memory should be circular).
  • Offset register: Integer. It is used as an offset when copying memory cells.
  • Stack: Theoritically infinite deep stack of integers.

The instruction set

Labels

Labels are used for identifying locations on the codetape instead of using indexvalues. The execution can jump for example one label back or two labels forward relatively from the current position. Labels can be used for counting instructions and implementing cycles by jumping the execution.
  • label-f Label which can be found only forward by forward counting or jumping (recognised by jump-f, count-f). 
  • label-b Label which can be found only backward by backward counting or jumping.

Flow control instructions

  • if-less Executes the next instruction if the top of the stack is less than the register.
  • if-n-equ Executes the next instruction if the top of the stack is not equal the register.

Jump instructions

  • jump-f  Jumps to the next label forward (if multiple jumps are together, than search for the numberofjumpsth label).
  • jump-b  Jumps to the next label backward (the same mechanism).

Single Argument Math

Single argument math instructions work with the top of stack.
 
  • shift-r  Bitwise rotation - one step right. 
  • shift-l  Bitwise rotation - one step left.
  • inc  Increments by one. 
  • dec Decrements by one.

Double Argument Math

Double argument  math instructions work with the two top elements of stack.
 
  • add  Pops two elements from the stack and pushes their sum. 
  • sub Pops two elements from stack and pushes their difference.
  • nand  Pops two elements from stack and pushes the result of the nand operation.
  • swap  Swaps the top two elements. 

Biological Operations

  • copy copy memory location top of stack to memory location top+register (register is the offset) 
  • allocate  allocates new cells. The number of cells is in the register. 
  • divide Divides the codetape at position pointed by the offset register.

I/O_and_Sensory 

  • get  environment to push 
  • put  pop to environment 
  • count-f  put into the register the number of instructions to the next forward - count and label instructions included (n count-instructions means that the nth label must be found) 
  • count-b  the same with the backward direction 

Data Transfer

  • top2reg  top to register 
  • push pushing register 
  • pop  poping into register 
  • zero  pushing zero to stack 

Additional

  • rotate-f  rotate facing forward 
  • rotate-b  rotate facing backward 
  • rotate-rand facing to random directions
 

Helsinki July 20, 2000