DarwinBotsManual
Open the app EspañolES

negstore

Flips the sign of what's in a cell: 20 becomes −20 and −20 becomes 20.

Facts

Word
negstore
Family
Writing to memory
Integer stack
pops 1, pushes 0
What it does
Pops an address and flips the sign of the cell: 20 becomes −20.
Cost
Store divided by the divisor of each one, only if it writes
Cost divisor
÷ 8
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
no

d negstore pops the address d and flips the sign of whatever is in that cell. It takes no value from the stack.

WordStack afterwards
5050
negstore(empty); if cell 50 held 20, it now holds −20

Applied every cycle, it makes a value swing between two extremes:

' moves forward wiggling: turns 20 to one side and 20 to the other, every other cycle
cond
 *50 0 =
start
 20 50 store
stop
start
 50 negstore
 *50 .aimdx store
 10 .up store
stop

The first gene loads 20 the first time. From then on cell 50 alternates between −20 and 20, and the bot turns with .aimdx to one side and then the other while moving forward with .up.

It's the same as -1 50 multstore (see multstore), but cheaper: an eighth of the cost of a store. Watch out for .tieang1 and .tielen1: negstore changes the number, but the tie doesn't find out; there use -1 .tieang1 multstore (see Writing to memory).