DarwinBotsManual
Open the app EspañolES

substore

Subtracts a number from what's already in a cell: the cell minus the value.

Facts

Word
substore
Family
Writing to memory
Integer stack
pops 2, pushes 0
What it does
Pops an address and a value, and leaves in the cell what it had minus the value, with circular wraparound at ±32000. With address 0 the value stays on the stack.
Cost
Store divided by the divisor of each one, only if it writes
Cost divisor
÷ 5
Runs
in the body of a gene (start or else), and only if the top of the boolean stack is true or the stack is empty
Marks ties
yes

v d substore leaves in cell d what it held minus v. It is *d v sub d store in two words, at a fifth of the cost of a store.

WordStack afterwards
33
503 50
substore(empty); cell 50 holds 3 less
' counts down in steps of 3, from 30
cond
 *.robage 0 =
start
 30 50 store
stop
cond
 *50 0 >
start
 3 50 substore
stop

In the first cycle .robage is 0: the first gene loads 30 and the second already subtracts 3 from it. The cell goes through 27, 24, 21… and in cycle 10 it reaches 0, where the condition stops it.

With address 0 the value is left on the stack unused, and the result is clipped to ±32000. Subtracting 1 is cheaper with dec, but on .tieang1 or .tielen1 you should use substore, which notifies the tie system. Addition is addstore.