FWD (f) |
Move memory pointer forward one position |
BACK (b) |
Move memory pointer back one position |
GO (g) |
Move memory pointer to location specified by accumulator (also starts execution) |
ADD (+) |
Add memory value at current position to accumulator |
MUL (*) |
Multiply accumuator with memory value at current position |
DIV (/) |
Divide accumuator by memory value at current position (divide by zero results in zero) |
AND (&) |
Bitwise AND accumulator with memory value at current position |
OR (|) |
Bitwise OR accumulator with memory value at current position |
XOR (^) |
Bitwise XOR accumulator with memory value at current position |
SHL (]) |
Bitwise left shift accumulator value |
SHR ([) |
Bitwise right shift accumulator value |
INC (>) |
Increment accumulator |
DEC (<) |
Decrement accumulator |
STA (#) |
Store accumulator to memory at current position and zero accumulator |
CMP (?) |
Set accumulator to -1, 0, or 1 depending on whether memory value is less than, equal to, or greater than accumulator |
LOOP ({) |
Jump to matching REP (}) if accumulator is zero |
REP (}) |
Jump back to matching LOOP ({) if accumulator is nonzero |
READ (r) |
Read from current I/O channel into accumulator |
WRITE (w) |
Write accumulator to current I/O channel |
SCH (s) |
Set I/O channel to current accumulator value |
STOP (!) |
Stop execution until a GO (g) instruction is reached and zero accumulator |
All instructions such as ADD, SUB, MUL, AND, etc. that operate on the accumulator place their
results in the accumulator as well. Instructions such as GO and SCH that set locations based
on the value of the accumulator wrap if the accumulator is out of range and take the absolute
value if the accumulator is negative. (e.g. GO uses abs(a) % sizeof(memory))
When execution starts, the virtual machine is in "intron" state, meaning that
it doesn't execute anything until a GO instruction is encountered. (GO doubles
as a "start gene" instruction.) The genome virtual machine then enters "exon"
state and executes instructions until a STOP instruction is encountered. A
STOP instruction places the GVM back into intron state and zeros the memory
pointer, channel, and accumulator values. STOP has this effect no matter
where it occurs, even inside a false {} block. The resetting of state upon
encountering a STOP instruction means that seperate blocks delimited by GO
and STOP can function independently of each other, permitting modularity to
evolve.
The RegisterMachineGenome instruction set was very loosely based on a toy programming language
called Brainfuck.