multstore
Multiplies what's in a cell by a number and stores the result right there.
Facts
- Word
multstore- Family
- Writing to memory
- Integer stack
- pops 2, pushes 0
- What it does
- Pops an address and a value, and multiplies the cell by 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 multstore leaves in cell d what it held multiplied by v. It is *d v mult d store in two words, at a fifth of the cost of a store.
| Word | Stack afterwards |
|---|---|
2 | 2 |
50 | 2 50 |
multstore | (empty); cell 50 holds double |
' doubles cell 50 every cycle, starting at 1
cond
*50 0 =
start
1 50 store
stop
start
2 50 multstore
stopThe cell goes through 2, 4, 8… up to 16384. The next cycle it doesn't give 32768 but 768: the result is clipped to ±32000 in a circular way, as in all stores (see Numbers and addresses). With multiplications it's easy to go over, so if the number can grow, put a ceiling on it with ceilstore before it reaches the edge.
Some uses: -1 50 multstore changes the sign (so does negstore, more cheaply), and 0 50 multstore sets it to 0.
With address 0 the value is left on the stack unused. Like store, it notifies the tie system if you write to .tieang1 or .tielen1.