Numbers and reads
The two simplest words in the DNA: a number, which is pushed as is, and an asterisk read, which pushes what's in a memory cell.
Cost: Number for the number, *.number read for the read
| Operator | What it does |
|---|---|
<numero> | A number written in the DNA, or the name of a sysvar without an asterisk, is pushed as is onto the integer stack. |
*<numero> | *.<sysvar> | An asterisk attached to a number or a sysvar pushes the contents of that memory cell: it's how you read the senses and your own variables. |
Every calculation in the DNA starts by pushing something, and for that there are two words that are not commands but data:
- The number (<numero>):
50,-5or the name of a sysvar such as.up, which is just its address (number 1). It is pushed as is. - The read (*<numero> | *.<sysvar>): an attached asterisk, like
*50or*.nrg, pushes what is in that memory cell.
They are, by far, the most frequent words in any bot. A typical condition like *.nrg 1000 > has one of each, and a store like 10 .up store has two numbers: the value and the address. The rule of thumb is short: no asterisk when you want to write to a sysvar, an asterisk when you want to know how much it holds.
When you don't know the address beforehand but it comes out of a calculation, the read is done with the operator *, which takes the address from the stack.
This bot shows the difference: in cell 50 it keeps its age (.robage), which goes up by one every cycle, and in cell 51 it keeps the address of the age, which is always 9.
cond
start
*.robage 50 store
.robage 51 store
stopEach number costs whatever Number says and each read whatever *.number read says; under the F1 rules both are free (see Execution and costs). All the details about ranges and addresses are in Numbers and addresses.