@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Maximum rotation depth is five. Stomps on heap[9]-heap[14].
@ Assumes rotation depth greater than two, otherwise use SWAP.
@ rotation depth (rd) <-- TOS
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSTSN | Mark: 1010 (stackrotate)
@ For the convenience of other functions, modulo the
@ rotation depth by the available registers.
@ Use heap[14] for generating register addresses.
@ Dump one word from stack to heap each pass through the loop.
NSSVSSSSTSTSSSSSSSSSN | Mark: 00001010 00000000
SSSTSSTN | PUSH 9 (starting register)
@ See if the loop is complete.
NTSSSSSTSTSSSSSSSSTN | BRZ > 00001010 00000001
@ Increment the loop counter
NSNSSSSTSTSSSSSSSSSN | JMP > 00001010 00000000
@ The correct number of words have been stored to registers.
@ Time to read them back in rotated order.
@ First, prepare the counter in heap[14] again.
@ This consumes 'rd' from the stack.
NSSVSSSSTSTSSSSSSSSTN | Mark: 00001010 00000001
@ Second, read in the old TOS manually.
SSSTSSTN | PUSH 9 (starting register)
@ Read one word per pass through this loop.
NSSVSSSSTSTSSSSSSSTSN | Mark: 00001010 00000010
SSSTSSTN | PUSH 9 (starting register)
@ See if the loop is complete.
NTSSSSSTSTSSSSSSSTTN | BRZ > 00001010 00000011
@ Decrement the loop counter and loop again.
NSNSSSSTSTSSSSSSSTSN | JMP > 00001010 00000010
NSSVSSSSTSTSSSSSSSTTN | Mark: 00001010 00000011