2 - Forth Interest Group
2 - Forth Interest Group
2 - Forth Interest Group
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
1 Figure Two. Conditional com~ilation tailored to memory model. I<br />
-- -<br />
UNDEF UNUSED<br />
CODE UNUSED SI POP<br />
SEPSSEG? O= [IF]<br />
SP AX MOV<br />
[ELSE] SEPDSEG? [IF]<br />
dssize 10 * # AX MOV<br />
[ELSE]<br />
FIND PSIZE [IF]<br />
DROP PSIZE<br />
[ELSE]<br />
FFFE<br />
[THEN]<br />
# AX MOV<br />
[THEN] [THEN]<br />
DP [I AX SUB<br />
AX PUSH<br />
SI JMPI<br />
END-CODE<br />
[THEN]<br />
\ compile what follows only if UNUSED is needed<br />
\ to resolve a reference.<br />
\ stash return address<br />
\ if stack segment is same as data segment, then<br />
\ top of memory is at stack pointer location.<br />
\ else if data segment is different from<br />
\ code segment,<br />
\ then top of memory is top of allocated segment<br />
\ (paragraph count)<br />
\ Code and data segments the same, stack segment<br />
\ different.<br />
\ program size defined -- use it<br />
\ single segment and program size not defined.<br />
\ subtract dictionary pointer<br />
\ return value on stack<br />
\ return from function<br />
\ ends the UNDEF<br />
Total control<br />
with [MI FORTHTM<br />
For Programming Professionals:<br />
an expanding family of compatible, high-<br />
performance, compilers for microcomputers<br />
I<br />
For Development:<br />
Interactive <strong>Forth</strong>-83 Interpreter/Compilers<br />
for MS-DOS, 80386 32-bit protected mode,<br />
and Microsoft WindowsTM<br />
Editor and assembler included<br />
Uses standard operating system files<br />
500 page manual written in plain English<br />
Support for graphics, floating point, native code generation<br />
For Applications: <strong>Forth</strong>-83 Metacompiler<br />
Unique table-driven multi-pass <strong>Forth</strong> compiler<br />
Compiles compact ROMable or disk-based applications<br />
= Excellent error handling<br />
Produces headerless code, compiles from intermediate states,<br />
and performs conditional compilation<br />
Cross-compiles to 8080, Z-80, 64180, 680x0 family, 80x86 family,<br />
80x96197 family, 8051131 family, 6303,6809, 68HC11<br />
No license fee or royalty for compiled applications<br />
Laboratory Microsystems Incorporated<br />
Post Office Box 10430, Marina Del Rey, CA 90295<br />
Phone Credit Card Orders to: (310) 306-74 12<br />
Fax: (3 10) 30 1-076 1<br />
during compilation, this value should be the space remaining<br />
in the target image, assuming nothing else to be<br />
compiled. The situation is complicated by all the possible<br />
memory models that can change these values. During<br />
compilation, the value is estimated by subtracting the<br />
target value HERE from the size of the target data segment<br />
(normally 64~, but can be less). At runtime, the library has<br />
a definition of UNUSED that provides an exact value. The<br />
definition makes use of conditional compilation to compile<br />
code tailored for the particular memory model [see<br />
Figure Twol.<br />
This generates a five-instruction subroutine for any<br />
memory model. The process is certainly more complicated<br />
than one might expect!<br />
Conclusion<br />
The new ANS <strong>Forth</strong> standard provided some unex-<br />
pected challenges which could not be completely solved.<br />
However, the situation has improved over earlier stan-<br />
dards. I expect that, as <strong>Forth</strong> compilation is more widely<br />
used, future standards will reflect these approaches.<br />
Tom Almy has been a user of <strong>Forth</strong> since 1981, when he used it to implement<br />
an integrated circuit layout program, PRIDE. Graduating from Stanford with an<br />
MSEE and hired by Tektronix in 1973 to design processors, Tom joined<br />
Tektronix's research laboratories in 1979, where he has since been involved<br />
with various aspects of integrated circuit and system design. Outside the work<br />
environment, Tom enjoys hiking and running a literary bulletin board system.<br />
He can be reached at tom.almy@tek.com via e-mail.<br />
July 1995 August 10 <strong>Forth</strong> Dimensions