TDS2020F TECHNICAL MANUAL Programming Stack manipulation Live website search Enter key words

# STACK MANIPULATION

## DEFINITIONS

These are abbreviated details from WORD LIST, page 356, grouped here for convenience.

 -ROT ( n1 n2 n3 - n3 n1 n2 ) ?DUP ( 0 - 0 ) or ( n1 - n1 n1 ) .S ( - ) Non-destructive display of stack. 2>R ( n1 n2 - ) Moves two numbers from stack to return stack. 2DROP ( n1 n2 - ) 2DUP ( n1 n2 - n1 n2 n1 n2 ) 2OVER ( d1 d2 - d1 d2 d1 ) 2R> ( - n1 n2 ) Moves two numbers from return stack to stack. 2R@ ( - n1 n2 ) Copies two numbers from return stack to stack. 2ROT ( d1 d2 d3 - d2 d3 d1 ) 2SWAP ( n1 n2 n3 n4 - n3 n4 n1 n2) >< ( n1 - n2 ) n2 is n1 with its bytes swapped. >R ( n - ) Moves number from stack to return stack. DEPTH ( - n ) n=number of items on the stack before DEPTH . DROP ( n - ) DUP ( n - n n ) I ( - n ) n is a copy of the current loop index. J ( - n ) Copies the index of outer of two nested DO loops to the stack. NIP ( n1 n2 - n2 ) OVER ( n1 n2 - n1 n2 n1 ) PICK ( N - n ) Take the (N+1)th item on the stack (not including N) and place it on top of the stack. R> ( - n ) Moves number from return stack to stack. R@ ( - n ) Copies number from return stack to stack. ROLL ( n - ) Copies (n+1)th item on stack to the top. ROT ( n1 n2 n3 - n2 n3 n1 ) RP! ( aa - ) Set return stack pointer to position aa. RP0 ( - aa ) User variable containing the initial location of return stack. RP@ ( - aa ) Address of the uppermost byte of top item on the return stack before RP@ was executed. SP! ( aa - ) Set stack pointer to address aa. SP0 ( - aa ) User variable containing the initial location of stack. SP@ ( - aa ) Address of the uppermost byte of top item on the stack before SP@ was executed. SWAP ( n1 n2 - n2 n1 ) TUCK ( n1 n2 - n2 n1 n2 )