Special variables: Difference between revisions

Content deleted Content added
Line 575: Line 575:


===Common Practice===
===Common Practice===
Although not mandated in the Forth language specification, traditionally the language implements system variables as what are called USER variables. The name dates back to the a time when FORTH was used as a multi-user O/S and therefore each user needed a set of variables to control the state of their instance of the system. The user variables exist in a memory block called the USER AREA and are replicated for each task. When used for embedded systems, Forth is commonly implemented as a multi-tasking system, so this architecture is still relevant today. On a context switch the system assigns a system VARIABLE called 'UP' (user pointer) to point to the new USER AREA. UP is commonly held in a CPU register on machines that have larger register sets.
Although not mandated in the Forth language specification, traditionally the language implements system variables as what are called USER variables. The name dates back to the a time when FORTH was used as a multi-user O/S and therefore each user needed a set of variables to control the state of their instance of the system. The user variables exist in a memory block called the USER AREA and are replicated for each task. When used for embedded systems, Forth is commonly implemented as a multi-tasking system, so this architecture is still relevant today. On a context switch the system assigns a system VARIABLE called 'UP' (user pointer) to point to the new task's USER AREA. Using UP, the task's local stack pointers can be read into the machine and a fast context switch can be completed. UP is commonly held in a CPU register on machines that have larger register sets.


This following list is an example of a set of USER variables in a small system. Consult the implementation documents for details on the USER variables in a specific FORTH system.
This following list is an example of a set of USER variables in a small system. Consult the implementation documents for details on the USER variables in a specific FORTH system.