Next: , Previous: Stack Manipulation, Up: Stack Manipulation


5.6.1 Data stack

drop       w –        core       “drop”

nip       w1 w2 – w2        core-ext       “nip”

dup       w – w w        core       “dupe”

over       w1 w2 – w1 w2 w1        core       “over”

tuck       w1 w2 – w2 w1 w2        core-ext       “tuck”

swap       w1 w2 – w2 w1        core       “swap”

pick       S:... u – S:... w        core-ext       “pick”

Actually the stack effect is x0 ... xu u -- x0 ... xu x0 .

rot       w1 w2 w3 – w2 w3 w1        core       “rote”

-rot       w1 w2 w3 – w3 w1 w2        gforth       “not-rote”

?dup       w – S:... w        core       “question-dupe”

Actually the stack effect is: ( w -- 0 | w w ). It performs a dup if w is nonzero.

roll       x0 x1 .. xn n – x1 .. xn x0         core-ext       “roll”

2drop       w1 w2 –        core       “two-drop”

2nip       w1 w2 w3 w4 – w3 w4        gforth       “two-nip”

2dup       w1 w2 – w1 w2 w1 w2        core       “two-dupe”

2over       w1 w2 w3 w4 – w1 w2 w3 w4 w1 w2        core       “two-over”

2tuck       w1 w2 w3 w4 – w3 w4 w1 w2 w3 w4        gforth       “two-tuck”

2swap       w1 w2 w3 w4 – w3 w4 w1 w2        core       “two-swap”

2rot       w1 w2 w3 w4 w5 w6 – w3 w4 w5 w6 w1 w2        double-ext       “two-rote”