V4N4 - Complang
V4N4 - Complang
V4N4 - Complang
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
ROMable FORTH with Separate Headers<br />
Robert H. Hertel<br />
Robert D. Villwock<br />
Microsys terns, Inc.<br />
Traditional implementations of<br />
FORTH assume a single computer en-<br />
vironment in which the program is<br />
compiled, tested and used. In this en-<br />
vironment it is expected that:<br />
Memory is all-RAM<br />
Terminal and disk are available<br />
System software (compiler,<br />
editor, etc.) is needed<br />
In a typical dedicated micropro-<br />
cessor application such as a "smart"<br />
product of some kind, there are two<br />
distinct environments which we will<br />
call the development and target envir-<br />
onments. The development environ-<br />
ment is usually the same as the<br />
traditional FORTH environment, but<br />
the target environment is different:<br />
ROMlRAM memory organiza-<br />
tion<br />
No conventional terminal or disk<br />
System software is not needed.<br />
In our own work, the development<br />
setup consists of a microprocessor<br />
development system connected to a<br />
prototype target system by means of<br />
an in-circuit emulator. The memory<br />
space can be mapped so that some<br />
parts of the memory reside in the<br />
development system and other parts in<br />
the target hardware.<br />
Until recently, the usual method of<br />
developing FORTH software for<br />
dedicated applications has been to<br />
compile and test with a traditional<br />
FORTH implementation. After testing<br />
is completed in this mode, a "target<br />
compiler" or cross compiler is used to<br />
reprocess the source code to produce<br />
the final target code. This produces<br />
headerless target code without the<br />
name fields and without unneeded<br />
system software. ROM copies of this<br />
code can be installed in the target<br />
system.<br />
The cross-compilation method of<br />
producing ROMable code has several<br />
drawbacks. Obviously it adds an extra<br />
step to the software development pro-<br />
cess. The cross compiler itself is com-<br />
plex and much more difficult to use<br />
than an ordinary compiler. With the<br />
target names discarded, interactive<br />
testing becomes difficult or impossible<br />
at a critical point in the development<br />
process.<br />
When we selected FORTH as our<br />
primary software development tool,<br />
we decided to develop a new compiler<br />
to recognize and fully support the dual<br />
developmentltarget environments. In<br />
the resulting implementation (called<br />
proFORTH'") the ROMlRAM and<br />
systemltarget separations are made as<br />
the code is compiled. Target names<br />
are retained in the system area of<br />
memory in such a way that interactive<br />
testing can continue until and even<br />
after the target code is transferred to<br />
ROM. When development is com-<br />
pleted it is only necessary to program<br />
ROMs for the appropriate memory<br />
areas; system code is simply dis-<br />
carded.<br />
The remainder of this discussion<br />
will describe those elements of the<br />
proFORTH'" system related to com-<br />
piling ROMable target code, and will<br />
explain how the programmer uses the<br />
system.<br />
Memory Organization<br />
The processor's memory space is<br />
divided into three kinds of segments:<br />
ROM -target code or read-only<br />
memory<br />
RAM - target variables or<br />
readlwrite memory<br />
DICTIONARY - system code,<br />
names, etc. (also readlwrite)<br />
Any number of segments of each<br />
kind may be defined. ROM and RAM<br />
segments are dictated by the needs of<br />
the application and the design of<br />
its hardware. For example, separate<br />
ROM segments might be assigned for<br />
an interrupt vector jump table, op-<br />
tional code, and for all other target<br />
code. RAM areas might be set up for<br />
a CRT refresh memory and for all<br />
other target RAM. Figure 1 shows a<br />
memory map with these ROM and<br />
RAM segments defined.<br />
FORTH Dimensions 9<br />
0000<br />
lFEO<br />
2000<br />
4000<br />
4800<br />
6000<br />
6400<br />
7000<br />
8000<br />
FFFF<br />
I<br />
ROM 1 1<br />
I<br />
ROU 2 f<br />
ROU 3 I<br />
mmmmi<br />
/I/////////// I<br />
///////////// I<br />
I<br />
I<br />
I<br />
DICTIONARY I<br />
I<br />
0 I<br />
I<br />
I<br />
I<br />
I<br />
I<br />
FIGURE 1 - SAMPLE MEMORY MAP<br />
Often a single dictionary area will<br />
suffice, but proFORTH'" supports<br />
multiple dictionaries and they can be<br />
used in a variety of ways. For now we<br />
will assume that only one dictionary<br />
is needed.<br />
Segments within each class are<br />
numbered as indicated in Figure 1.<br />
ROM and RAM numbers begin with<br />
1; dictionaries are numbered from<br />
zero. They are established using the<br />
words ROM, RAM and DICTIONARY. Thus<br />
the directives<br />
8000 FFFF 0 DICTIONARY<br />
6000 63FF 2 RAM<br />
4000 47FF 3 ROM<br />
assign the address space 8000 through<br />
FFFF to dictionary 0, 6000 through<br />
63FF to RAM segment 2 and 4000 to<br />
47FF to ROM segment 3 (we will<br />
assume throughout this article that<br />
numbers are expressed in hex-<br />
adecimal). More specifically, each<br />
memory segment has a segment con-<br />
trol block structure like the one for<br />
Continued on next page<br />
Volume IV, No. 4