GA144 note: one node RAM

A node X can use all 64 words of a neighbor node R0 as RAM.

Assuming X's b register points to R0, and R0 is executing from port X, this is how node X reads word at addr from node R0:

: ramread ( addr -- v )
  @p !b !b
    @p a! @ !p
  @b ;

it works by sending a tiny four-opcode program @p a! @ !p to node R0. R0 executes this program:

After node X has sent this program to R0, it reads the result back from R0.

Writing to R0 can be done in a couple of ways. To write a value v to the same location as was just read, X can do:

: ramwrite ( v -- )
  @p !b !b ;
    @p ! . .

The trick here is that R0's a already points to the correct word, because of the preceding ramread.

The above are good factors for a read/modify/write, for example to negate a word in RAM:

call ramread
call ramwrite