mar.virtualmachine
Class MarVM

java.lang.Object
  |
  +--physis.core.virtualmachine.VirtualMachine
        |
        +--physis.core.virtualmachine.PhysisVirtualMachine
              |
              +--mar.virtualmachine.MarVM

public class MarVM
extends PhysisVirtualMachine

Simple stack machine with one stack and one register.


Field Summary
(package private) static short add
           
(package private) static short allocate
           
(package private) static short copy
           
(package private) static short count_b
           
(package private) static short count_f
           
(package private) static short dec
           
(package private) static short divide
           
static int EMPTY
           
static int FULL
           
(package private) static short get
           
(package private) static short if_less
           
(package private) static short if_n_equ
           
(package private) static short inc
           
private  int IP
          instruction pointer
(package private) static short jump_b
           
(package private) static short jump_f
           
(package private) static short label_b
           
(package private) static short label_f
           
(package private) static short nand
           
(package private) static short nop
           
(package private) static short pop
           
(package private) static short push
           
(package private) static short put
           
private  int register
           
(package private) static short rotate_b
           
(package private) static short rotate_f
           
(package private) static short rotate_rand
           
(package private) static short shift_l
           
(package private) static short shift_r
           
protected  int SP
          stack_pointer, it points to the next available element, also equals with stacksize
protected  int[] stack
           
static int STACK_SIZE
          Size of the internal stack.
(package private) static short sub
           
(package private) static short swap
           
(package private) static short top2reg
           
(package private) static short zero
           
 
Fields inherited from class physis.core.virtualmachine.PhysisVirtualMachine
alien, bearer, blank, counter, gestation_time, GESTATION_TIME_INVALID, tape
 
Constructor Summary
MarVM()
           
 
Method Summary
(package private)  void add()
           
protected  void allocate()
           
protected  void copy()
           
(package private)  void count_b()
           
(package private)  void count_f()
           
(package private)  void dec()
           
protected  void divide()
           
 void execute()
          Executes the next instruction.
 void execute(int n)
          Calling this method forces te VM to execute the next N instructions.
(package private)  void get()
           
 Genome getGenome()
          Returns the genetic information.
 int getGenomeSize()
          Returns the size of the genome.
 java.lang.String getState()
          Returns the String representation of the current state of the virtualmachine including all stacks registers in the architecture and the instruction point by the instructionpointer: etc.
(package private)  void if_n_equ()
          If the top of the stack is less than the registercontent executes the next instruction, otherwise skips it.
(package private)  void ifless()
          If the top of the stack is less than the registercontent executes the next instruction, otherwise skips it.
(package private)  void inc()
           
(package private)  void incrementIP(int value)
          The instruction pointer-register is incremented.
(package private)  void jump_b()
           
(package private)  void jump_f()
           
(package private)  void nand()
           
(package private)  void pop()
           
(package private)  void push()
           
(package private)  void put()
           
 void reset()
          Brings the machine into the base-state.
 void restart()
          Brings the machine into base-state but doesn't change the gestation time.
(package private)  void rotate_b()
           
(package private)  void rotate_f()
           
(package private)  void rotate_rand()
           
(package private)  void setIP(int value)
           
(package private)  void shift_l()
           
(package private)  void shift_r()
           
(package private)  void stackClear()
           
(package private)  boolean stackEmpty()
           
(package private)  boolean stackFull()
           
(package private)  int stackPop()
           
(package private)  void stackPush(int val)
           
(package private)  int stackTop()
           
(package private)  void sub()
           
(package private)  void swap()
           
(package private)  void top2reg()
           
(package private)  void zero()
           
 
Methods inherited from class physis.core.virtualmachine.PhysisVirtualMachine
getBearer, getEffectiveLength, getGestationTime, loadCodeTape, setBearer
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

STACK_SIZE

public static final int STACK_SIZE
Size of the internal stack. (hardcoded 16, because it's the attribute of the architecture

stack

protected int[] stack

EMPTY

public static final int EMPTY

FULL

public static final int FULL

SP

protected int SP
stack_pointer, it points to the next available element, also equals with stacksize

register

private int register

IP

private int IP
instruction pointer

label_f

static final short label_f

label_b

static final short label_b

if_less

static final short if_less

if_n_equ

static final short if_n_equ

jump_f

static final short jump_f

jump_b

static final short jump_b

shift_r

static final short shift_r

shift_l

static final short shift_l

inc

static final short inc

dec

static final short dec

add

static final short add

sub

static final short sub

nand

static final short nand

swap

static final short swap

copy

static final short copy

allocate

static final short allocate

divide

static final short divide

get

static final short get

put

static final short put

count_f

static final short count_f

count_b

static final short count_b

top2reg

static final short top2reg

push

static final short push

pop

static final short pop

zero

static final short zero

rotate_f

static final short rotate_f

rotate_b

static final short rotate_b

rotate_rand

static final short rotate_rand

nop

static final short nop
Constructor Detail

MarVM

public MarVM()
Method Detail

execute

public void execute()
Executes the next instruction.
Overrides:
execute in class VirtualMachine

execute

public void execute(int n)
Description copied from class: VirtualMachine
Calling this method forces te VM to execute the next N instructions.
Overrides:
execute in class VirtualMachine
Following copied from class: physis.core.virtualmachine.VirtualMachine
Parameters:
number_of_instructions - The exact number of the instructions to be executed.

reset

public void reset()
Brings the machine into the base-state. It's used when vivivying the organism.
Stack is empty, register contains 0.
Overrides:
reset in class VirtualMachine

restart

public void restart()
Brings the machine into base-state but doesn't change the gestation time. It's used after succesfull proliferation.
Overrides:
restart in class PhysisVirtualMachine

getGenome

public Genome getGenome()
Description copied from class: PhysisVirtualMachine
Returns the genetic information.
Overrides:
getGenome in class PhysisVirtualMachine

getGenomeSize

public int getGenomeSize()
Description copied from class: PhysisVirtualMachine
Returns the size of the genome.
Overrides:
getGenomeSize in class PhysisVirtualMachine

getState

public java.lang.String getState()
Description copied from class: VirtualMachine
Returns the String representation of the current state of the virtualmachine including all stacks registers in the architecture and the instruction point by the instructionpointer: etc. It's mainly used by the debuggers or tracers.
Overrides:
getState in class VirtualMachine

incrementIP

void incrementIP(int value)
The instruction pointer-register is incremented. The codetape is circular.
Parameters:
value - the amount of incrementation

setIP

void setIP(int value)

ifless

void ifless()
If the top of the stack is less than the registercontent executes the next instruction, otherwise skips it. Empty stack is not equal.

if_n_equ

void if_n_equ()
If the top of the stack is less than the registercontent executes the next instruction, otherwise skips it. Empty stack is not equal.

jump_f

void jump_f()

jump_b

void jump_b()

shift_r

void shift_r()

shift_l

void shift_l()

inc

void inc()

dec

void dec()

add

void add()

sub

void sub()

nand

void nand()

swap

void swap()

copy

protected void copy()

allocate

protected void allocate()

divide

protected void divide()

put

void put()

get

void get()

count_f

void count_f()

count_b

void count_b()

top2reg

void top2reg()

push

void push()

pop

void pop()

rotate_f

void rotate_f()

rotate_b

void rotate_b()

rotate_rand

void rotate_rand()

zero

void zero()

stackPush

void stackPush(int val)

stackPop

int stackPop()

stackTop

int stackTop()

stackEmpty

boolean stackEmpty()

stackFull

boolean stackFull()

stackClear

void stackClear()