Operations

INC

This operation is used on 1 register and costs 2 energy units. It adds 1 to the total value stored in the register:

../_images/operation_inc.png

Attention

If the register stores the maximum value (all bits switched on), an overflow happens and the register is reset to zero:

../_images/operation_overflow.png

DEC

This operation is used on 1 register and costs 2 energy units. It subtracts 1 to the total value stored in the register:

../_images/operation_dec.png

Attention

If all the bits of the register are switched off, subtracting 1 will cause an underflow that sets all the bits of the register to one (switched on):

../_images/operation_underflow.png

ROL

This operation is used on 1 register and costs 1 energy unit.

It involves shifting every bit on the register to the left and placing the remaining bit on the left in the rightmost position:

../_images/operation_rol.png

Hint

From an arithmetic point of view, in many cases it is equivalent to multiplying the value of the register by 2:

../_images/operation_rol_mul.png

ROR

This operation is used on 1 register and costs 1 energy unit.

It involves shifting every bit on the register to the right and placing the remaining bit on the right in the leftmost position:

../_images/operation_ror.png

Hint

From an arithmetic point of view, in many cases it is equivalent to dividing the value of the register by 2:

../_images/operation_ror_div.png

MOV

This operation is used on 2 registers or 1 register and a RAM module and costs 1 energy unit (1/2 in competitive mode).

It copies all bits from one register to another, overwriting the value stored in the destination.

../_images/operation_mov.png

Hint

In competitive mode, it can be useful to copy a value into your RAM module and then recover it later, preventing other players from modifying it.

NOT

This operation is used on 1 register and costs 1 energy unit.

It negates every bit on the register: switched-on bits are switched off, and switched-off bits are switched on. This involves flipping all the bits of the register.

../_images/operation_not.png

OR

This operation is used on 2 registers and costs 1/2 energy unit.

It copies only the switched-on bits from one register to another.

../_images/operation_or.png

NOR

See How do operations NOR, NAND and XNOR work?.

AND

This operation is used on 2 registers and costs 1/2 energy unit.

It copies only the switched-off bits from one register to another.

../_images/operation_and.png

NAND

See How do operations NOR, NAND and XNOR work?.

XOR

This operation is used on 2 registers and costs 1/2 energy unit.

It copies only the switched-on bits from one register to another, but if the bit was already on, it’s turned off.

../_images/operation_xor.png

XNOR

See How do operations NOR, NAND and XNOR work?.

ADD

See How do ADD and SUB operations work?.

SUB

See How do ADD and SUB operations work?.