I changed the Inc and Dec operators to two new operators:
Index
Swap
Index looks at the tape, reads the value, and uses that as an index for a pointer stored in the register. The address of the cell at that index is stored in the register. For implementations that use tape indexes as pointers, like the interpreter, this operation is simply addition. For implementations where pointers do not increment by 1 (an implementation with real pointers), this is addition with a constant multiplier.
Swap simply swaps the value at the tape with the value in the register.
I changed the
IncandDecoperators to two new operators:IndexSwapIndexlooks at the tape, reads the value, and uses that as an index for a pointer stored in the register. The address of the cell at that index is stored in the register. For implementations that use tape indexes as pointers, like the interpreter, this operation is simply addition. For implementations where pointers do not increment by 1 (an implementation with real pointers), this is addition with a constant multiplier.Swapsimply swaps the value at the tape with the value in the register.