Special variables: Difference between revisions

Line 575:
 
===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 still 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.
 
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.
<pre>Name Type Description
---------------------------------------------
TIB integer Terminal Input Buffer address
U0 integer current user area address
>IN integer holds offset into TIB, used for parsing
BASE integer holds number conversion radix
STATE integer holds compiler state (true=compiling, false=interpreting)
DP integer holds dictionary memory pointer
'SOURCE double integer[2] contains length and address of input source
LATEST integer address of last word added to dictionary
HP integer HOLD pointer, used for number formatting routines
LP integer leave-stack pointer, used by do loops
S0 integer end of parameter stack
PAD chars[80] Generic buffer. (size is implementation dependent)
L0 integer bottom of leave stack
R0 integer end of return stack</pre>
 
=={{header|Go}}==
Anonymous user