An instruction generating word is *DUP. It says: Generate the instructions that will duplicate the top of the stack when executed. It is used by verbs that wish to manipulate the arguments they find on the stack.
The word DUP is interpretive. It says: Duplicate the top of the stack. It is used when the stack is to be changed at once, it contrast to *DUP.
There is clearly a similarity between the two, in fact DUP is defined in terms of *DUP:
. DUP *DUP RETURN
is a FORTH statement that effects a dictionary entry. The . declares the next word (DUP) to be a verb. The words following it generate the code for the verb. *DUP generates its instructions, RETURN generates a branch to the scanner.
In general, instruction generating words are prefixed by one of several special characters, for ready identification. For example,
represent a pair of related words that generate a
condition forward branch.
*IF generates instructions to test the top of the stack for true (1) or false (0) and branch on the false condition. *THEN fills in the branch address.
*IF *DUP *THEN
is a FORTH statement that will generate code to test the top of the stack for true or false and duplicate on true.
Analogous to the above is the statement:
IF DUP THEN
which will test and duplicate the top of the stack on true. This statement actually tests the stack when encountered, in contrast to the previous example, which generates instruction to do the same thing.
Commonly used words fall into 3 categories:
+ - x / MOD OR GREATER
IF ELSE THEN
There is a certain equivalence between definitions and verbs. In fact, most operations could be written as either. Definitions are easier to code, but their execution, being interpretive, is slow. Verbs are harder to code, but are most versatile as they may use the full hardware instruction set and are 100 times faster in execution. It seems that a good balance between ease of coding and execution time is achieved by coding the inner loop as a verb and the remainder as a definition.