V4N4 - Complang
V4N4 - Complang
V4N4 - Complang
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
ROMeble FORTH (continued from page I I)<br />
Another pair of examples is given in<br />
Figures 4(a) and 4(b) to show the struc-<br />
ture of definitions for system and<br />
target variables. Again, the system<br />
variable's definition is similar in form<br />
to the traditional one. The CFA points<br />
to the generic run-time procedure for<br />
variables called (VAR). Since the two-<br />
byte space for the variable is allocated<br />
in line, the procedure (VAR) is usually<br />
used only for system-based (dictionary)<br />
variables and is itself therefore, stored<br />
in system memory.<br />
Figure 4(b) shows how pro-<br />
FORTH'" separates the definition<br />
components for a target variable. The<br />
system component is the header -<br />
essentially, the name. A DFA pointer<br />
is added to it, and in it is stored the<br />
CFA or body address. The body is<br />
compiled in target ROM. However, in-<br />
stead of the generic procedure (VAR),<br />
the CFA of the ROM-based body is<br />
pointed to (CONST). In addition, the<br />
space allocated for the variable will be<br />
in the target RAM area. The address of<br />
the RAM space allotted is stored at the<br />
PFA in ROM, i.e., it is the value of the<br />
constant. When the variable's name is<br />
typed, the (CONST) support procedure<br />
executes, placing the variable's ad-<br />
dress on the stack in the usual way.<br />
Other definition structures follow<br />
the same principles as those discussed.<br />
For example, a code word is similar in<br />
structure to the constant, except that<br />
the CFA points to the PFA, and the<br />
assembly language code begins at the<br />
PFA. A colon definition's CFA points<br />
to the colon support procedure (COL-<br />
ON), and at the PFA is compiled the list<br />
of addresses of pointers to executable<br />
code which will be processed by the<br />
address interpreter at run time. All<br />
these structures can be compiled "in<br />
line" or in target ROM (connected by<br />
a DFA pointer).<br />
Extensions involve more complex<br />
structures than those illustrated, but to<br />
avoid obscuring the principles in a<br />
mass of details, we will concentrate on<br />
the simpler definition forms.<br />
Compilation Control<br />
The first step in compiling pro-<br />
FORTH'" code is to define the ROM,<br />
FORTH Dimensions<br />
1- LFA<br />
I<br />
I<br />
HEADER - 1 NFA<br />
I<br />
I<br />
I_<br />
I- DFA/CFA<br />
BODY -1<br />
h DATA I PFA<br />
I_<br />
1- (VAR)<br />
I<br />
SUPPORT - 1<br />
PROCEDURE I<br />
I<br />
I_<br />
LINK<br />
I<br />
I LENGTH<br />
I<br />
NAME<br />
VALUE<br />
I<br />
I<br />
1<br />
ACTIVE<br />
1 - DICTIONARY<br />
I<br />
I -------<br />
I I<br />
I I<br />
I I<br />
I -<br />
I<br />
I<br />
< ------ I<br />
-1<br />
I ACTIVE<br />
I- DICTIONARY<br />
I (USUALLY)<br />
I<br />
- I<br />
FIGURE 4(a) - proFORTH DICTIONARY STRUCTURE FOR SYSTEM VARIABLE<br />
1- LFA<br />
I<br />
I NFA<br />
I<br />
HEADER -I<br />
I<br />
I<br />
I DFA<br />
1-<br />
LINK I<br />
I LENGTH<br />
I<br />
NAME<br />
I<br />
I<br />
I<br />
I<br />
I<br />
I ---<br />
I<br />
I- CFA I I