In addition to serving as the reservoir of return addresses,
the return stack is where the counter for the for ... next
construct is placed.
(See section11.)
The user can also store to and retrieve from the rstack but this must be done carefully
because the rstack is critical to program execution.
If you use the rstack for temporary storage, you must return it to its original state,
or else you will probably crash the FlashForth system.
Despite the danger, there are times when use of the rstack as temporary storage can make
your code less complex.
To store to the rstack, use >r
to move TOS from the parameter stack
to the top of the rstack.
To retrieve a value, r>
moves the top value from the rstack
to the parameter stack TOS.
To simply remove a value from the top of the rstack there is the word rdrop
.
The word r@
copies the top of the rstack to the parameter stack TOS
and is used to get a copy of the loop counter in a for
loop
discussed in Section11.