DarwinBotsManual
Open the app EspañolES

store

Stores a number at a memory address: it's how every command is given, like 20 .up store to move forward.

Facts

Word
store
Family
Writing to memory
Integer stack
pops 2, pushes 0
What it does
Pops an address and a value, and writes the value to that cell, with circular wraparound at ±32000: 32001 becomes 1. With address 0 it does not write, does not charge, and the value stays on the stack.
Cost
Store divided by the divisor of each one, only if it writes
Cost divisor
÷ 1
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 store writes v to cell d. It is the most common word in the DNA: every command you give the engine is a store on a sysvar.

WordStack afterwards
2020
.up20 1
store(empty); cell 1 holds 20

Note that .up without an asterisk is just the number 1, the address of .up. If you write *.up you are pushing what is in that cell, and the store will write somewhere else (see Common mistakes).

' copies the energy to cell 50 and pushes forward
cond
start
 *.nrg 50 store
 20 .up store
stop

The write is immediate: whatever comes after it in the same cycle already reads the new value. If you write a sense sysvar, like .nrg, the engine overwrites it at the end of the cycle; if it's a command, like .up, the engine uses it and sets it back to 0, so you have to write it every cycle in which you want it.

Three details:

To add to what's already there, instead of replacing it, there is addstore.