Computer
The computer cell function is able to run small executable programs consisting of instructions in machine code. The machine code for the instructions is stored in the cell memory and, if executed, can access both the cell and the token memory. Both memories can have a maximum size of 256 bytes and all variables and addresses are one byte long. For calculations, all values are interpreted as 8-bit signed integers. The number of instructions a computer cell function can have, the size of the cell memory as well as the size of the token memory are specified in the simulation parameters.
To simplify programming, the machine code can be written in a kind of assembly language and variables as well as constants can be used (and defined in the symbol map). To control other cell functions, there are already some predefined variables and constants (see symbol map) with which one can access certain bytes of the token memory that encode control commands.
Before we give a detail overview to all instruction, we start with an example of how a simple cell program may look like:
if [10] = (0)
mov [10], 0
else
add [10], 1
endif
mov PROP_IN_ANGLE, [10]
In the first line it is checked whether the content of the token memory at address 10 is equal to the content of the cell memory at address 0. If this is the case, the content of the token memory at address 10 is set to 0, otherwise it is incremented by 1. Finally, the memory cell 10 is copied to the memory cell named PROP_IN_ANGLE, which encodes the angle of the propulsion function.
Generally, each instruction (except endif and else) has the form
operation operand1, operand2
and is encoded as 24 bits (3 bytes) in the cell memory with the following allocation:
Bits |
Abbreviation |
Explanation |
23 - 20 |
opCode |
determines the type of operation |
19 - 18 |
opType1 |
how the value of operand1 is interpreted, e.g. as a constant, address in memory, etc. (see below) |
17 - 16 |
opType2 |
how the value of operand2 is interpreted |
15 - 8 |
opValue1 |
value of operand1 |
7 - 0 |
opValue2 |
value of operand2 |
The subsequent operations are implemented:
Syntax |
Value of opCode |
Explanation |
mov |
0 |
copy: operand1 := operand2 |
add |
1 |
addition: op1 := op1 + op2 |
sub |
2 |
subtraction: op1 := op1 - op2 |
mul |
3 |
multiplication: op1 := op1 * op2 |
div |
4 |
division: op1 := op1 / op2 |
xor |
5 |
bitwise XOR: op1 := op1 XOR op2 |
or |
6 |
bitwise OR: op1 := op1 OR op2 |
and |
7 |
bitwise AND: op1 := op1 AND op2 |
if operand1 > operand2 |
8 |
compares that operand1 is greater than operand2 |
if operand1 >= operand2 |
9 |
compares that operand1 is greater or equal than operand2 |
if operand1 = operand2 |
10 |
compares that operand1 is equal to operand2 |
if operand1 != operand2 |
11 |
compares that operand1 is not equal to operand2 |
if operand1 <= operand2 |
12 |
compares that operand1 is less or equal than operand2 |
if operand1 < operand2 |
13 |
compares that operand1 is less than operand2 |
else |
14 |
else-clause of comparison |
endif |
15 |
finish comparison |
opValue1 and opValue2 refer to 8-bit values with a meaning that depends on opType1 and opType2 respectively. Note that there are no instructions for loops. They can be realized with circular constructions of cell connections.
Syntax |
Value of opType |
Explanation |
[opValue] |
0 or 3 |
operand points to a byte in token memory |
[[opValue]] |
1 |
operand points to a pointer to a byte in token memory |
(opValue) |
2 |
operand points to a byte in cell memory |
Created with the Personal Edition of HelpNDoc: Free help authoring environment