Pre-parsed Word Format

# Pre-parsed words

Text is stored as 32-bit words, with possible extension words

bits | 31..........................4 | 3..0 | function | color
| characters | 0 | extension
|  | 1 | execute | yellow
|  | 3 | define | red
|  | 4 | compile | green
|  | 7 | compile | cyan
|  | 9 | comment | white
|  | a | Capitalized | white
|  | b | all caps | white
|  | c | variable | magenta

Numbers have a bit for display format (decimal/hex). Those that fit in 27 bits (with sign extend) are stored

bits | 31.........................5 | 4 | 3..0 | function | color
| number | hex | 8 | execute | yellow
|  |  | 6 | compile | green

Larger numbers require 2 32-bit words

bits | 31.........................5 | 4 | 3..0 | function | color
|  | hex | 2 | execute | yellow
|  |  | 5 | compile | green

bits | 31..............................0
| number

# Functions

A red word is defined: its name (1st word only) is placed in the next entry of a table of names. The current location in the dictionary is placed in a parallel table of locations. The name table will be searched backwards (from most recent to earliest). If a word is not found, a ? is displayed and the Editor points at the word in the source code.

A yellow word is executed. Which means that the code it points to is called. Upon return, the Data stack may be different. A yellow number is pushed onto the Data stack.

The word 'forth' selects the main dictionary. The word 'macro' selects another dictionary. Red words will now be defined here. A green word causes this to be searched. If found here, it is executed and presumably compiles some code. Otherwise the forth dictionary is searched and a call to the word's location is compiled. A green number compiles code that pushes it onto the Data stack.

If a macro is cyan it is compiled, not executed. This allows nesting macros. An ordinary word could be cyan, but this is unnecessary and confusing. Should a macro be yellow, it will not be found.

Yellow words within a definition will be executed, as expected. However, they should leave a (single) number on the stack. The transition from yellow to green words causes this number to be compiled. Thus numbers can be calculated inside definitions, which helps understand where they came from.

A magenta word defines a variable. Its code is shared with other variables. The next word in the dictionary is used to point back to the source code, where the value of the variable is stored (initially 0). A yellow variable pushes its address onto the Data stack.

The value of a variable is not disturbed by recompilation. It is saved with the source code and restored with the next boot. Its value is displayed by the Editor. These variables have the flavor of 'state variables'. Temporary variables are usually held on the stack.

On the Pentium, yellow variables are preferred. At compile time, their address is returned and will be compiled as a literal at the yellow-green transition. (Remember, only 1 number is compiled per yellow-green transition.) A green variable compiles a call to code executed at run time to put the address on the stack.