X-Git-Url: http://git.subgeniuskitty.com/vvhitespace/.git/blobdiff_plain/0c56152e6ad67ef7e311f1e394250279864edd1a..f0499c77612b74a627727336579eb6b980c35529:/stdlib/stack.pvvs?ds=inline diff --git a/stdlib/stack.pvvs b/stdlib/stack.pvvs index 0ef72bf..417b3bb 100644 --- a/stdlib/stack.pvvs +++ b/stdlib/stack.pvvs @@ -210,5 +210,40 @@ TSSS | ADD TTT | LOAD NTN | RTS +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@ Name: +@ deepdup +@ Description: +@ 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. +@ Call Stack: +@ stack word n +@ ... +@ stack word 1 +@ dupdepth <-- TOS +@ Return Stack: +@ stack word n +@ ... +@ stack word 1 +@ copy of stack word 3 <-- TOS +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +NSSVTTSSN | Mark: 1100 (deepdup) + +@ Copy 'dupdepth' and use it to bring forth the desired stack word. +SNS | DUP +SSSTN | PUSH 1 +TSSS | ADD +NSTTSTTN | JSR > 1011 (stackrotatereverse) + +@ Copy the desired stack word and return it back into the stack. +SNS | DUP +SSSTTN | PUSH 3 +NSTTSTTN | JSR > 1011 (stackrotatereverse) +SSSTN | PUSH 1 +TSSS | ADD +NSTTSTSN | JSR > 1010 (stackrotate) +NTN | RTS + #endif