Forth Lesson 3
Jump to navigation
Jump to search
Review
In the previous lesson we learned that:
- Forth words are described by stack diagrams like: ( argn .. arg0 -- resultm .. result0 )
- Comments are either ( this is a comment ) or \ the rest of the line is a comment
- Both "(" and "\" must be followed by whitespace
- Comments work by executing a word that then explicitly calls the input parser
Arithmetic and Logical Operators
We have already seen " ", which pops two numbers, adds them, and pushes the result. Here are some more numeric operators with their stack diagrams:
( n1 n2 -- n1 n2 ) - ( n1 n2 -- n1-n2 ) * ( n1 n2 -- n1*n2 ) \ Signed multiplication / ( n1 n2 -- n1/n2 ) \ Signed division mod ( n1 n2 -- n1%n2 ) /mod ( n1 n2 -- n1%n2 n1/n2 ) and ( n1 n2 -- n1