ScratchForth also borrows some functions from Forth for stack manipulation.
Here they are.
dup duplicates the last item of the stack
dup
Before: 1 2 3 4
1 2 3 4
After: 1 2 3 4 4
1 2 3 4 4
swap swaps the last two items of the stack
swap
After: 1 2 4 3
1 2 4 3
over duplicates the second to last item of the stack
over
After: 1 2 3 4 3
1 2 3 4 3
drop removes the last item of the stack
drop
After: 1 2 3
1 2 3
rot rotates the last 3 items of the stack
rot
After: 1 3 4 2
1 3 4 2
There was an error while loading. Please reload this page.