Introduction
    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 ][ Next ]

This introduction does not set out to teach Forth programming but rather to serve as a supplement to available bases on the subject. 

The sintax consists of Forth words or literals, separated by spaces and terminated by a carriage return. A valid name must non contain any embedded space since this will be interpreted as two distint words, and must be less than 31 character in length. If a word is entered which does not exist or has been spelt wrongly, or the number entered is not valid in the current base, then an error message will be displayed. To compile and execute programs created using the editor type

8 LOAD <CR>

Throughout these examples <CR> means "press ENTER" 

e.g.    -FINE <CR>

will generate an error message 0 since the word does not exist. 

HEX 17FZ

will generate an error message 0 since Z is not valid in hexadecimal base.

Other errors messages include: STACK EMPTY, STACK FULL, DICTIONARY FULL

In order to program in Forth, it is necessary to define new words based on the words already in the vocabulary. Values to be passed to these words are pushed onto the stack and if required, the world will pull these values from the stack, operate on them and push the result onto the stack for use by another word. As mentioned previously, Forth uses Reverse Polish Notation and integer numbers, therfore no precedence of operators is available, thus all operation are performed in the sequence in which they are found on the stack. e.g. 1 2 + 3 *  is equivalent to 3*(1+2).

As can be seen, in RPN the operators are input after the numbers on which they have to operate have been input. We will now discuss some off the words in greater depth.

[ Index ][ Next ]


Ultimo aggiornamento: 10-12-2002. Copyright (c) 2000-2002 Matteo Vitturi. 
Per problemi o domande relativamente a questo sito contattare il webmaster
Last update: 12.10.2002. Copyright (c) 2000-2002 Matteo Vitturi.
For problems or questions related to this web please contact the webmaster.
1