@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Maximum rotation depth is five. Stomps on heap[9]-heap[14].
@ Assumes rotation depth greater than two, otherwise use SWAP.
@ rotation depth (rd) <-- TOS
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSTTN | Mark: 1011 (stackrotatereverse)
@ 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.
NSSVSSSSTSTTSSSSSSSSN | Mark: 00001011 00000000
SSSTSSTN | PUSH 9 (starting register)
@ See if the loop is complete.
NTSSSSSTSTTSSSSSSSTN | BRZ > 00001011 00000001
@ Increment the loop counter
NSNSSSSTSTTSSSSSSSSN | JMP > 00001011 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.
NSSVSSSSTSTTSSSSSSSTN | Mark: 00001011 00000001
@ Read one word per pass through this loop.
@ Store it behind 'rd' on the stack.
NSSVSSSSTSTTSSSSSSTSN | Mark: 00001011 00000010
SSSTSSTN | PUSH 9 (starting register)
@ See if the loop is complete.
NTSSSSSTSTTSSSSSSTTN | BRZ > 00001011 00000011
@ Decrement the loop counter and loop again.
NSNSSSSTSTTSSSSSSTSN | JMP > 00001011 00000010
@ Read in the final value manually and return.
NSSVSSSSTSTTSSSSSSTTN | Mark: 00001011 00000011
SSSTSSTN | PUSH 9 (starting register)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Duplicates an item deep on the stack, placing the duplicate on TOS.
@ By default, maximum depth is 11.
@ True maximum depth is (max depth of stackrotate & stackrotatereverse)-3.
@ copy of stack word 3 <-- TOS
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTTSSN | Mark: 1100 (deepdup)
@ Copy 'dupdepth' and use it to bring forth the desired stack word.
NSTTSTTN | JSR > 1011 (stackrotatereverse)
@ Copy the desired stack word and return it back into the stack.
NSTTSTTN | JSR > 1011 (stackrotatereverse)
NSTTSTSN | JSR > 1010 (stackrotate)