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.
| Word | Stack afterwards |
|---|---|
20 | 20 |
.up | 20 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
stopThe 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:
- With address 0 nothing happens and nothing is charged, but the value stays on the stack: in
7 0 store 60 store, cell 60 ends up at 7. - The value is clipped to ±32000:
32001is stored as 1. - It is one of the stores that notify the tie system when you write to
.tieang1or.tielen1(see Writing to memory).
To add to what's already there, instead of replacing it, there is addstore.