Stack operators
    [ Il "Quarto" fuso ] The 4th Time Zone ]   


 

Introduction
Input/Output operations
Mathematical Operators
Stack operators
Other operators
Colon definition
Control structures
Conditional branching
Constants and variables
Other Forth words
Using the editor
Error messages


                                   

[ Index ][ Back ][ Next ]

DUP

This will duplicate the top number on the stack.

e.g.      719 DUP . . <CR>

will print 719 719.

DROP

This will drop the number from the top of the stack.

e.g.      111 222 DROP . <CR>

will print 111.

SWAP

This will swap the two top numbers on the stack.

e.g.      111 222 SWAP . . <CR>

will print 111 222.

OVER

This will copy the second number on the stack, making it a new number at the top of the stack without destroying the other numbers.

e.g.      111 222 OVER . CR . CR . <CR>

will print

111
222
111

since the stack before OVER was:

222            TOS
111

and after OVER is

111            (copy)
222
111

ROT

This will rotate the top three numbers on the stack, bringing the third number to the top of the stack.

e.g.      1 2 3 ROT . CR . CR . <CR>

will print

1
3
2

since the stack before ROT was:

3            TOS
2

1

and after ROT is

1
3
2

[ Index ][ Back ][ Next ]


Ultimo aggiornamento: 06-09-2002. Copyright (c) 2000-2001 Matteo Vitturi. 
Per problemi o domande relativamente a questo sito contattare il webmaster
Last update: 09.06.2002. Copyright (c) 2000-2001 Matteo Vitturi.
For problems or questions related to this web please contact the webmaster.
Hosted by www.Geocities.ws

1