Skip to main content

Full text of "Forth Dimension Volume 07 Number 4"

See other formats


1 FORTH 



Dimensions 



Volume 7, Number 4 



November/December 1985 
$4.00 



Mailboxes 
& Multi-Tasking 



Wordwrapping Tool 
Benchmark Readability 
Atari Graphics 
F83 Word Usage 



FORTH 
IS NOW 
VERY.FAST! 

.Sieve 1.3s/pass 

Compile 300 screens/minute 

.Drop 1.82 us 

.Concurrent I/O @ 250K baud 

DEVELOP YOUR 
APPLICATIONS IN 
A TOTAL FORTH 
ENVIRONMENT 



MICROPROGRAMMED BIT SLICE 
FORTH ENGINE 

.iMicrocoded forth kernel 
.MIcrocoded forth primitives 
Multi-level task switching architecture 
for real time applications 
.Optional writable control store 

H.FORTH OPERATING SYSTEM 

.Hierarchical file system 
.Monitor level for program debug 
.Multi-user multi-tasking 
.Target compiler 
.1/0 management 
.Forth 83 Compatible 

H4TH/01 OEM SINGLE BOARD 

.Floppy disk controller 

.2 channel SIO to 38. 2K baud 

.Calendar clock— 4HR backup 



.44K Byte ram 200NS 

.32 K Byte EPROM operating system 

. 1 K X 32 microprogram memory 70ns 

H4TH/10 DESKTOP 

.Dual 0.8m Byte floppys 
.H4TH/01 processor 
.Three user slots 
.Two expansion slots 
.Powers cooling 

H4TH/20 DESKTOP 

. 10 m Byte Winchester 

.0.8 m Byte floppy 

.H4TH/01 processor 

.300K byte RAM expandable 2m byte 

.Three user slots 

.One expansion slot 

.Powers cooling 




A forth-engine consisting of a state-of-the-art integrated hardware/software 
system giving unsurpassed performance for professionals and their applications 
from a company that is totally dedicated to the forth concept and its implementation. 



HARTRONIX, Inc. 1201 North Stadem Drive Tempe, Arizona 85281 602.966.7215 



FORTH Dimensions 



2 



VoiumeVM, No. 4 



_ FORTH 



FORTH Dimensions 

Published by the 
Forth Interest Group 

Volume VII, Number 4 

November/December 1985 

Editor 
Marlin Ouverson 

Production 
Cynthia Lawson Berglund 

Forth Dimensions solicits editorial 
material, comments and letters. No 
responsibility is assumed for accuracy 
of material published. Unless noted 
otherwise, material published by the 
Forth Interest Group (a non-profit 
organization) is in the public domain. 
Such material may be reproduced 
with credit given to the author and to 
the Forth Interest Group. 

Subscription to Forth Dimensions 
is free with membership in the Forth 
Interest Group at $20 per year ($33 
foreign air). For membership, change 
of address and to submit material for 
publication, write to: Forth Interest 
Group, P.O. Box 8231, San Jose, 
California 95155. 
ISSN No. 0884-0822 



i 

I 



1 




Symbol Table 

Simple; introductory tu- 
torials and simple appli- 
cations of Forth. 

Intermediate; articles 
and code for more com- 
plex applications, and 
tutorials on generally dif- 
ficult topics. 

Advanced; requiring stu- 
dy and a thorough under- 
standing of Forth. 



Code and examples con- 
form to Forth-83 stand- 
ard. 



Code and examples con- 
form to Forth-79 stand- 
ard. 



Code and examples con- 
form to fig-FORTH. 



Deals with new propos- 
als and modifications 
to standard Forth sys- 
tems. 



Dimensions 



FEATURES 



Word Indexer by Mike Eiola 

This programming aid locates all occurrences of a specified variable or Forth 
procedure call. It can help you locate references to a target word within all other 
application words and locate references to a target variable within apphcation 
words. 

F83 Word Usage Statistics by C.H. Ting 

Access to good statistics about frequency of word use can lead to better design 
and to the optimization of Forth systems. This utility is specific to the F83 
implementation of Forth-83, and may provide some good ideas to users of other 
systems as well. 

Benchmark Readability by Victor H. Yngve 

A frequently used timing benchmark is the Eratosthenes Sieve. This final 
installment in the "Synonyms and Macros" series provides a convenient test bed 
for illustrating special uses of the tools presented previously. 

Extending the Multi-Tasker: Mailboxes by R.W. Dobbins 

The Lcixen multi-tasker is an excellent tool to harness the full power of Forth and 
to enable independent tasks to exchange information. In this article, some ideas 
are presented on how the multi-tasker can be extended to incorporate inter-task 
communication and cooperation. 

Atari Painting Forth by Stephen James 

"Paint with the power of Forth. Splash vivid hues with your Atari. Create alien 
worlds and magical kingdoms — quickly and colorfully." The Forth code 
includes various pens and brushes for designing graphic art. 

Redefining Words by Phil Koopman, Jr. 

Recompilation of the dictionary after a redefinition can often take several 
minutes for a large application. This article discusses a simple method to 
eliminate the time-consuming recompile step after making a minor change to your 
code. No changes to the Forth compiler or dictionary structure are required. 

Forth Component Libraries by John S. James 

This proposal addresses the need to transport large pieces of programs from one 
developer or installation to another, and the abihty to purchase software 
packages "off the shelf" that will run identically on Forth-83, Forth-79 or any 
vendor's Forth system. 

1985 Forth National Convention by Marlin Ouverson 

This year's convention hosted by the Forth Interest Group provided a show-case 
for some of today's most exciting developments and applications of Forth. This 
brief summation touches the tip of the iceberg. 

DEPARTMENTS 

5 Letters 

7 Editorial: "Leaders' Edge" 

8 Application Tutorial: "Wordwrapping Tool" by Michael Ham 
40 Advertisers Index 

42 FIG Chapters 



10 

I 

12 

I 

16 

I 

25 

1 

28 



i 

36 



I 

38 

I 

41 



Volume VII, No. 4 



FORTH Dimensions 



Now You Can Add 

^\ ARTIFICIAL 
INTELLIGENCE 

To Your Programs Using a Powerful Combination 




By Elliot Schneider & Jack Park 



Heres Your Chance to Profit by being on 
the Forefront, Write 5th Generation Software 



Learn How To: 

• Create Intelligent • 

Programs 

• Build Expert Systems • 

• Write Stand Alone License 

Free Programs • 

Write Intelligent Programs 

• Home Use • 

• Robotics • 

• Medical Diagnosis • 

• Education 

• Intelligent CAI • 

• Scientific Analysis • 

• Data Acquisition • 

Extended Math Functions 

• Fast ML Floating Point & Integer Math 

• Double Precision 2E+38 with Auto. Sci Not. 

• n^e^ Logx Loge Sin Cos Tan SQR 1/X... 

• Matrix and Multidimensional Lattice Math 

• Algebraic Expression Evaluator 



Construct 
Rule Bases 
Do Knowledge 
Engineering 
Use Inference Engines 

For: 

Data Analysis 
Business 
Real Time 
Process Control 
Fast Games 
Graphics 

Financial Decisions 



SUPERFORTH 64+AI 



BA5.IC 
I ORTRAN 



Other 



6x 



SF64 1x 



Power of Languages Constructs 
SiiperForth 64 is more 
powerful than most other 
computer latnguages 



Programming Time 

SuperForth 64 Saves You 
Tmw and Money 



Easy Graphics & Sound Words 



• Hires Plotting 

• Windows 

• Split Screen 

• Printer/Plotter Ctrl 

• Sprite & Animation 
Editor 

Easy Control of all I/O... 

• RS232 Functions 

• Access all C-64 Peripherals 

Utilities 

• Interactive Interpreter 

• Forth Virtual Memory 

• Full Cursor Screen Editor 

• Full String Handling 

• Trace & Decompiler 

• Conditional Macro 
Assembler 



Great Documentation 

• Easy to Read 350 pg. 
Manual with Tutorials 

• Source Screen Provided 

• Meets all MVP Forth-79 
Industrial Standards 

• Personal User Support 

A Total 
Integrated Package 
for the Commodore 64 



Turtle Graphics 
Koala Pad Graphics 
Integrator 

Hires Circle, Line, Arc 
Music Editor 
Sound Control 

Interrupt Routines 



Interactive Compiler 
Romable Code Generator 
40K User Memory 
All Commodore File Types 
Conversational User 
Defined Commands 




Ordering Information: Check, Money 
Order (payable to MOUNTAIN VIEW 
PRESS, INC ), VISA, MasterCard, 
American Express COD s S5 00 extra 
No billing or unpaid PO's California 
residents add sales tax Shipping costs 
n US included in price Foreign orders, 
pay in US funds on US bank, include 
for handling and shipping 510 

° Parsec Research 

Commodore 64 TM of Commodore 



SPECIAL 
INTRODUCTORY OFFER 



only 



^99 



00 



203'» Value 
Limited Time Offer 



Call: 
(415) 961-4103 

MOUNTAIN VIEW PRESS INC 

P.O. Box 4656 
Mt. View, OA 94040 

Dealer for 
PARSEC RESEARCH 

Drawer 1776. Fremont. CA 9453S 




Multiply, Divide and Conquer 

Dear Marlin, 

I enjoyed Craig Lindley's Forth 
spreadsheet {Forth Dimensions VII/ 1, 
2) with his application of Michael 
Stolowitz's algebraic parser (VI/6). He 
has aptly demonstrated how Forth con- 
cepts readily lend themselves to exten- 
sions. 

However, the double number multi- 
ply and divide he offered on screen 30 
are, in fact, mixed operators. Not only 
is the naming of these operators techni- 
cally incorrect, but a limitation has 
also been introduced. The limitation is 
that mixed operators cannot be used in 
formulas to operate on data from two 
elements, since all data is stored as 
double numbers. I.e., a[ 1 A * 2 a ]a 
would fail. 

I have enclosed code with double 
number operators. Using these 
operators will require that all numbers 
used in formulas will have to be ex- 
pressed as double numbers. E.g., a[ 3 
A * 5. ]a 

Zafar Essak, M.D. 
Vancouver, B.C. 
Canada 

In Praise of Libraries 

Dear Editor, 

I attended the recent FIG convention 
in Palo Alto. It was a wonderful 
chance to listen to professional Forth 



programmers, as well as to meet with 
others in various stages of understand- 
ing. I enjoyed meeting with many 
Forth celebrities: the energetic Ting, 
the pleasant Hall and the felt-hatted 
Moore. 

There is one point, however, I feel 
must be raised. It seems to me that all 
over the world, Forth programmers are 
coding such things as: full-screen ed- 
itors, turtle graphics, string words, 
floating point and extended addressing 
versions of Forth. While it is certainly 
an excellent learning experience to 
write such programs, why not make 
some of the best versions readily avail- 
able to the public through FIG? The 
difficulty in obtaining such programs 
forces programmers to constantly "re- 
invent the wheel." Forth needs to 
progress continually. Once there is a 
common point for exchange of pro- 
grams, people can concentrate on de- 
veloping new applications, rather than 
reiterating old ones. 

Lawrence Forsley, the convention 
banquet speaker, claimed the reason 
BASIC, Pascal and C have become so 
popular is that inexpensive versions 
were offered to schools and universities 
early. I envision a full-function pack- 
age for Forth to rival GWBASIC, 
Hirbo Pascal and C. Why not? Forth is 
a better language than any of the 
others. 

This package would come complete 
with a full-screen editor, floating-point 



support, graphics, music and program- 
ming tools such as a cross-reference 
utility (how many people out there 
know such a program already exists in 
the pubhc domain?). This Forth would 
use extended addressing (on PCs) to 
give the programmer the use of all 
available memory without the corres- 
ponding loss of speed associated with 
thirty-two-bit Forths on sixteen-bit 
machines. Some people at the F83 
meeting asked to see a Forth program 
that took more than 64K. My reply is 
that once you load the full-screen ed- 
itor, the programming tools, turtle 
graphics and floating point (preferably 
done on a math chip hke the 8087), 
there is Httle room for programs. In- 
deed, I have already had trouble with 
overwriting the system that way. Some 
of these words, Hke the editor vocabu- 
lary, could reside in another segment 
and pop down only when necessary. 

This package, or Hbrary, would be 
developed in the public domain, there- 
fore satisfying universities' need for 
software in microcomputer labs that 
they can offer freely to students. 
(Many are doing this with programs 
such as PC Write and PC File.) Since 
Forth-83 is the new standard, and 
because it is such a clean implementa- 
tion, FIG should adopt Leixen and 
Perry's F83 as the main version for this 
package. F83 is also well documented 
and so is perfect for students. Such an 
investment in education would yield 



( DHt Dl Double nuiber SSOBOSz) DECIHAL 


( DH/HOD D/ DHOD Double nuiber BSOOOSz) 




: DH/HOD ( dl,u— drei,dquot) 


: DHt ( di,u— dprod) 


SHAP OVER /HOD >R SNAP UH/HOD >R R> R> ; 


DUP ROT t ROT ROT U«» ROT + ; 






: D/ ( dl,d2-drei,dquot) 2DUP D< >R 


: Dt ( dl,d2--dprod) 


2DUP DABS SHAP DROP 


2DUP D< >R DABS 


IF Re 


DABS >R >R 2DUP R> DHI 


IF >R >R DNEGATE R> R> DNEBATE 


R> ROT ROT >R >R DHt 32768 DHt 2 DHI 


THEN SHAP >R /HOD R> SHAP >R 


R> R> D+ R> IF DNEBATE THEN ) 


M S->D D» D- R> S->D 




ELSE R8 




IF >R >R DNEBATE R> R> 




THEN DROP ABS DH/HOD 




THEN R> IF >R >R DNEBATE R> R> THEN ; 




: DHOD ( dl,d2--drea) D/ 2DR0P ; 



r 



Volume VII, No. 4 



FORTH Dimensions 



high rewards in the use and acceptance 
of Forth in the future; it would benefit 
Forth programmers everywhere. Even 
the vendors would benefit, because as 
students found the need for the in- 
creased speed of Forths implemented in 
assembler, as well as target compilers, 
they would seek out FORTH Inc., or 
Laboratory Microsystems or one of the 
other vendor-supported Forths. 

One interesting idea discussed at the 
meeting was the possibility of a FIG 
bulletin board to distribute Forth pro- 
grams. This is an excellent idea which 
should be implemented as soon as 
possible. Yet, many programmers have 
no access to modems and could not 
benefit. Why not add to FIG's mail 
order service? BASIC programs (as 
well as programs in some other lan- 
guages) are distributed by organiza- 
tions like PC-SIG. Why should Forth 



lag behind? Let other programmers 
know how good Forth is — display 
your quality programs! 

ForthfuUy yours, 

Mark Smiley 
Montgomery, Alabama 

A CASE of Pairs 

Dear Marlin, 

Despite the valiant efforts of Henry 
Laxen ("YACS," Forth Dimensions 
VI/6 and VII/ 1), the case of CASE by 
Dr. Charles Eaker achieved what you 
may call a "semi-standard" status. 
Recent evidence is provided by the 
"Forth Spreadsheet" by Craig A. 
Lindley. Besides, many Forth imple- 
mentations include the earlier CASE 
among their system extensions. In par- 
ticular, my TI Forth system provides 



such an example. But quite often one 
would Hke to have a case statement 
which is more powerful than the stand- 
ard usage of Dr. Baker's CASE. And 
for many reasons, I do not Hke un- 
necessary expansions of my system. 
But the situation is far from being 
hopeless. 

Let me show that the old CASE is 
much more flexible than it appears at 
first glance. The point is that OF ex- 
pects on the stack a pair of numbers. If 
they are the same, then both will be 
consumed and a whole clause between 
OF and ENDOF will be executed, fol- 
lowed by ENDCASE. Otherwise, the top 
value will be dropped and execution 
will continue with the statement past 
ENDOF. Nothing prevents us from sup- 
plying the numeric pair for OF during 
run time. This simple remark extends 
enormously a range of appHcations. 
Using the above as a guiding principle, 
let's rewrite an example provided in 
"YACS, Part Two" (VII/1, p. 39). 
Please refer to the code in figure one. 

Actually, for range classifications 
like the one presented here, I prefer a 
slightly different approach. Instead of 
checking an original condition, one 
may use a negation of it. So the flag 
will be zero if the original one was 
satisfied, and some non-zero value 
otherwise. Therefore, OVER + will 
provide a numeric pair suitable for OF. 
See figure two for a demonstration of 
this. 

The demonstrated technique, though 
impUcit in the definition, does not 
seem to be very well known. 

Sincerely yours, 

Michael Jaegermann 
Edmonton, Alberta 
Canada 

Errata 

In our last issue (VII/3), the illustra- 
tions for figures one and two on page 
thirteen were accidentally switched. 
Our apologies go to Professor Yngve 
and to readers who may have been 
confused by the error. Also, as author 
Schmauch points out in his "Pseudo- 
Interrupts" article in the same issue, 
his code is in Forth-79 and not 
Forth-83, as it was labelled. — Ed. 



HEX 

1 caNSTANT TRUE \ system dependent 

: BELOWl SWAP DROP \ drop flag from the Drevious test 

OVER > TRUE ; ( n flag limit -- n -flagl flag2 ) 
: CLASSIFYl ( byte — ) 





CASE 


\ leave dummy 


f 1 ag on 


20 


BELOWl 


OF . 


" Control character' 


ENDOF 


30 


BELOWl 


OF . 


" Punctuation" 


ENDOF 


3.A 


BELOWl 


OF . 


" Digit" 


ENDOF 


41 


BELOWl 


OF . 


" Punctuation" 


ENDOF 


5B 


BELOWl 


OF . 


" Upper Case Letter' 


ENDOF 


61 


BELOWl 


OF . 


" Punctuation" 


ENDOF 


78 


BELOWl 


OF . 


" Lower Case Letter' 


ENDOF 


7F 


BELOWl 


OF . 


" Punctuation" 


ENDOF 


80 


BELOWl 


OF . 


" Control character' 


ENDOF 








" Not ASCII character" 



ENDCASE DROP j \ drop an original value; unused 
\ flag removed by ENDCASE 

Figure One 

: BEL0W2 ( n limit — n m ) OVER 1+ < OVER + x 
: CLASSIFY2 ( byte — ) 
CASE 



20 


BEL0W2 


OF . 


" Control character" 


ENDOF 


30 


BEL0W2 


OF . 


" Punctuation" 


ENDOF 


3A 


BEL0W2 


OF . 


" Digit" 


ENDOF 


41 


BEL0W2 


OF . 


" Punctuation" 


ENDOF 


5B 


BEL0W2 


OF . 


" Upper Case Letter" 


ENDOF 


61 


BEL0W2 


OF . 


" Punctuation" 


ENDOF 


7B 


BEL0W2 


OF . 


" Lower Case Letter" 


ENDOF 


7F 


BEL0W2 


OF . 


" Punctuation" 


ENDOF 


80 


< TRUE 


OF . 


" Control character" 


ENDOF 








" Not AS.CII character" 





ENDCASE ! 



Figure Two 



FORTH Dimensions 



6 



Volume VII, No. 4 




Leaders' Edge 

We recently received a call from 
Dennis Wilson, the local FIG Chapter 
Coordinator in Phoenix, Arizona. He 
asked if we would communicate to all 
concerned that Charles Moore, the 
inventor of Forth, is scheduled to 
speak at a dinner and conference at the 
Arizona Biltmore Resort on December 
6th. If you plan to be in the area and 
would like more information, call Den- 
nis at 602-957-0469. 

It has become apparent that, at least 
to a few, there is still some confusion 
between the Forth-83 Standard and 
F83. For those who aren't absolutely 
clear as to the distinction, here goes: 
Forth-83 is the set of standard Forth 
words arrived at by the Forth Stan- 
dards Team. That team is composed 
of various vendor representatives, sys- 
tems and application programmers 
and, generally. Forth experts. Their 
opus became the fundamental instruc- 
tion set that is Forth-83 and was in- 
tended as an improvement over 
Forth-79 and the earlier fig-FORTH. 
This word set had to be defined at a 
level of generality which covers all 
computers, and thus could not include 
anything specific to any single piece of 
hardware. It is comprised of specific 
operators and does not touch on, for 
example, extensions such as an editor, 
graphics or even cursor positioning; it 
does include all the principle operators 
and what their effects must be, but not 
how they should work internally. 

F83, by contrast, is the name of a 
public-domain implementation based 
on Forth-83 and was developed by 
Henry Laxen and Michael Perry. It 
also contains a number of non-stand- 
ard words and extensions, but no sup- 
port. Whether these make F83 usefully 
complete with tools and source code, 
or overly complex and memory inten- 
sive, appears to be a matter of personal 
taste and system constraints. Some 
people, unfortunately, have come to 
believe that F83 is the only implemen- 
tation of the Forth-83 Standard. This 
is not the case, as there are systems 
available commercially, with full ven- 



dor support, that comply with 
Forth-83 (e.g., Laboratory Microsys- 
tems and MicroMotion). 

When it gets down to the nitty-gritty, 
often there are logical choices about 
how to implement any language — a 
standard only requires that the words it 
contains behave in standard ways, but 
does not address how an implementor 
makes them perform in that manner. 
The differences among implementa- 
tions are in part the natural result of 
developers making decisions based on 
their own priorities, convictions and 
techniques. Along with documenta- 
tion, support and price, the result is 
healthy competition between vendors 
in the growing Forth market. Which, in 
turn, should result in continually 
improving products and services. 

The Forth Interest Group has not 
endorsed any Forth implementation 
since those old days when the only way 
to get the language onto a microcom- 
puter was to order a fig-FORTH listing 
and install it manually. Nor has FIG or 
the Forth Standards Team yet under- 
taken to certify systems as conforming, 
or not, to the standard. But with dili- 
gent comparison of the Forth-83 Stan- 
dard document (available on the FIG 
order form) and a particular Forth 
system's documentation, and by using 
vendor-provided support channels, 
an educated consumer can determine 
whether an implementation operates in 
accordance with the standard, and can 
estimate closely whether it will meet the 
requirements of a particular operation 
or project. 

There are probably fifty or more 
Forth vendors, of which about a half 
dozen are leaders in the field. They 
represent a wide variety of business 
and programming practices which 
serve the diverse needs of the market- 
place. And how that marketplace has 
changed over the years! Forth may 
have been something of a novelty in the 
beginning, appealing mostly to lan- 
guage buffs and people trying to hack 



their way out of pure assembly code, 
but evolution continued and Forth 
sHpped through the doors of the For- 
tune 500. Now it appears that profes- 
sionals are in the majority, using Forth 
in corporations that sometimes treat it 
like a trade secret, a hidden advantage 
over their competitors. We find Forth 
at IBM, AT&T, Kodak, Hewlett-Pack- 
ard and Lockheed, among many other 
notable companies. 

Sometimes we all need to step back 
and get a large view of where we stand 
in relation to the world around us. This 
is a time of opportunity in which al- 
most anything can happen. Bill Rags- 
dale, FIG's founding president, often 
speaks of leadership and its importance 
to vendors' success. That trait applies 
at the level of the individual as well. 
And what is a leader but someone with 
a vision of the broad scheme of things, 
the flexibility to adapt to changing 
conditions without becoming dogmat- 
ic, the imagination to see the hidden 
potential in anything and the courage 
needed to define and achieve specific 
goals? 

Think of the Forth Interest Group as 
an association of actual and potential 
leaders. The possibilities are immense! 

— Marlin Ouverson 
Editor 



Volume VII, No. 4 7 FORTH Dimensions 



Application Tutoriai 

Wordwrapping Tool 



Michael Ham 
Santa Cruz, California 



Forth vendors must steer a course 
between the Scylla of an absolutely 
minimal system and the Charybdis of a 
full-blown maximal system. In the 
minimal system, the Forth contains as 
little beyond the standard requirements 
as is necessary to have a system that 
runs at all. The amount of free memo- 
ry is enormous, but the user must 
create the entire range of developmen- 
tal tools. The maximal system, on the 
other hand, includes every conceivable 
tool a user could want, but available 
memory shrinks to the size of a pea. 

Most vendors approach the solution 
by including in the core system the 
factored-out essentials for a variety of 
useful tools, and providing as optional 
extensions or overlays those more com- 
prehensive facilities likely to be useful 
in some, but not all, applications. 
Double-precision and floating-point 
operations, for example, are often pro- 
vided as separate files; a screen editor 
and graphics operators might be sup- 
plied as precompiled overlays, loaded 
only when needed. 

In my current project, I am using 
PC/Forth (Laboratory Microsystems, 
Inc.). As the name implies, this is a 
Forth specifically designed to exploit 
the powers and peculiarities of the IBM 
PC and its clones. To that end, PC/ 
Forth provides, in addition to the 
Forth-83 Standard word set, various 
tools that make the developer's life 
easier in this particular environment. 

Some of these are complete overlays, 
such as the DOS interface, which al- 
lows the developer to read and write 
regular DOS files, in addition to the 
words that permit the usual Forth oper- 
ations (BLOCK, FLUSH, UPDATE, etc.) On 
DOS-formatted screen files. Others are 
proto-tools: for example, variables 
that can be used in the creation of 
various helpful tools. The variable 
COMMQ, for example, gives the pro- 
gram a way to know whether the com- 
puter is a Compaq or not, which can be 
useful in controlling the screen display. 



The variable out in PC/Forth tells 
you how far you have gone in the 
output line. This is useful in various 
situations. For example, you might 
type something whose length you can- 
not predict, but from which you need 
to tab to another specific location. 
PC/Forth's word .FILENAME, for ex- 
ample, prints the name of a file. In 
PC/MS-DOS, however, the length of a 
filename can vary considerably, par- 
ticularly when (in PC-DOS 2.x and 
later) the name printed by .filename 
includes a long string of directories and 
subdirectories: FORTH DEVEL EA 
MAIN. SCR is a not-too-fanciful ex- 
ample. 

By using OUT, however, you can 
readily create a word that will tab to a 
specific position on the line, even after 
output of unpredictable length: 



; TAB ( n — ) ( tabs to designated 
position ) 
OUT @ - SFWCES ; 



(The PC/Forth SPACES includes, in 
effect, a MAX so that negative argu- 
ments produce no spaces.) OUT is incre- 
mented by all the output words (EMIT, 
TYPE, SPACE and SPACES), updated 
whenever the cursor is repositioned, 
and zeroed by CR. The user can alter as 
well as examine OUT, should that prove 
useful in some situation. You can read- 
ily define OUT in other Forths by redef- 
ining the appropriate words: 



VARIABLE OUT 

: TYPE ( a # ) DUP OUT + ! TYPE ; 

: CR OUT OFF CR ; 



etc. The definitions in PC/Forth are, 
of course, written in code for speed. 

Here is a slightly more ambitious 
application of the use of OUT: 
CAREFULTYPE, a version of TYPE that 
observes a specified margin, does not 
break words, and indents each line a 



specified amount. The definition uses 
another vendor-supplied tool word, 
SCAN. 

SCAN searches for the first occur- 
rence of a given character in a string (in 
this case BL, a constant equal to the 
ASCII value for a blank). Given the 
address and the length of a string, 
SCAN searchs for the first instance of a 
specified character and returns the ad- 
dress of the character and the remain- 
ing length of the string. If the character 
is not found, the address returned is of 
the byte immediately following the 
string and the length returned is zero. 

Two different high-level definitions 
of SCAN are shown. (PC/Forth's SCAN 
is in code for compactness and speed.) 
One definition uses a countdown loop 
based on the length as index; the other 
definition uses an indefinite loop and 
avoids the use of a variable at the cost 
of some stack-thrashing. (Because PC/ 
Forth is 83-Standard, the LEAVE in the 
first definition jumps to the end of the 
loop; this action can be mimicked in 
79-Standard systems with an if ELSE 
THEN construct.) 

In writing a definition dealing with 
strings, most of us aren't sure whether 
a given index is okay as is, or whether it 
should be bigger or smaller by 1. In 
writing the first definition of SCAN, for 
example, I didn't know offhand 
whether the value left on the stack 
should be I, or 1 less than I, or 1 
greater. The nice thing about Forth is 
that such questions can be more quick- 
ly and more easily (and, for me at least, 
more accurately) answered through ex- 
periment than through analysis. The 
use of experiment is especially straight- 
forward in the case of SCAN, which was 
written to mimic an existing word. The 
same method also worked in defining 
CAREFULTYPE to arrive at the 1- in lines 
9 and 13 and the subtraction in line 10 
(where I didn't know at first whether 
the difference itself was the number I 
wanted, or whether I needed to adjust 
it by 1 in one or direction or the other). 
In both words, in fact, my initial guess- 
es were wrong, but I readily corrected 
the definitions on the spot. 



FORTH Dimensions 



8 



Volume VII, No, 4 



Which definition is faster? Such 
questions are again best resolved 
through a quicic experiment. A couple 
of test loops will provide the answer 
for your own system. 

The WHILE clause in CAREFULTYPE 
contains the actions needed to set the 
loop up for another repetition (in this 
case, the action is to increment the 
address to point SCAN at the address of 
the byte immediately following the 
blank it found the previous time). 

Because SCAN returns the bytes re- 
maining in the string, the 1- in line 10 
of CAREFULTYPE' s definition decre- 
ments the bytes remaining, thus direct- 
ing scan's attention one position to the 
right. CKMARGIN uses OUT to determine 
where we are, and to start a new line if 
the current word would have taken us 
past the right margin. The various 
stack manipulations jockey the ad- 
dresses and the counts to the appro- 
priate positions. Because SCAN finds 
each blank, a series of multiple blanks 
in the input are faithfully reproduced 
in the output, as shown by the demon- 
stration. 

The word " used in TESTSTR of the 

screen is delimited by the following " 
and stores the defined string in the 
dictionary, preceded by a count byte. 
When the word TESTSTR is executed, 
the address of the count byte is left on 
the stack. Other Forths have other 
ways of defining strings; for this de- 
monstration, you need only find some 
way to put the address and count on 
the stack. 

Any particular user, of course, will 
always want the vendor to steer a bit 
closer to Charybdis and include the 
special feature the user wants. For 
example, I would like to have a word 
LEFT? that would put a true flag on the 
stack if the last loop were exited by 
LEAVE and a false flag if the loop ran to 
completion. LEFT? would obviate the 
need for such variable switches as seen 
in the definition of SCAN. But vendors 
certainly know by now that users — 
particularly Forth users — are never 
satisfied. Forth's particular strength is 
that dissatisfied users can seek satisfac- 
tion by adding their own commands to 
the language. 




! 

2 
3 
4: 
5 
6 
7 
8 
9: 
10 



( High-level SCAN, definition 1 Ham 11.1509/12/55 

VARIABLE TSW ( F if loop exited via LEAVE ) 

: SCAN ( adr len char — char-adr len-remaining ) 
TSW ON 

ROT DO OVER C<a OVER = ( same as char? > 

IF DROP ( char ) I ( len remaining ) TSW OFF LEAVE 
THEN SWAP 1+SWAP ( incr address ) 
-1 +LOOP ( deer length remaining ) 
TSW @ IF DROP ( char ) 6 ( not found ) THEN , 



0: 
1 

2 
3 

4: 
5: 
6: 
7 
8; 
9: 



( High-level SCAN, definition 2 ROD 23:49 03/04/85 ) 

( adr len char — adr' len' ) 

: SCAN >R ( adr len count ) 

BEGIN 2DUP <> ( adr len count flag ) 

3 PICK C@ ( inspect char from string ) 
R@ <> ( check for match ) 

AND ( or string exhausted ) 

WHILE 1 + ROT 1 + ROT ROT ( no, inc count&adr ) 
REPEAT R> DROP - ; { return adr' len' ) 



2 

3: 
4: 
5: 
6 
7 
8 
9 

10: 

1 1 

12 

13 

14: 

15: 



; string printing word 



Ham 1 1:11 09/1 1/85 ) 



5 CONSTANT INDENT ( amount each line indented ) 
70 CONSTANT RTMARGIN 

CKMARGIN ( * -) OUT @ + RTMARGIN > IF CR INDENT SPACES THEN , 

: CAREFULTYPE ( adr * - \ adr=lst char of string, *=its length ) 
BEGIN 2DUP BL SCAN ( leaves adr and amount of string left ) 
DUP IF ( inside string ) I - ( move past the blank ) THEN 
ROT OVER - ( gives count of word+blank ) 

DUP CKMARGIN ( CR if needed ) 

3 ROLL SWAP TYPE ?DUP ( any string left? ) 
WHILE SWAP I + SWAP ( move adr past the blank ) 
REPEAT DROP ( adr ) , 



Ham 1 6:08 09/ 1 1 /85 ) 



( Demonstration of CAREFULTYPE 

1: 

2: : TESTSTR " This is a string long enough to wrap around Don't 
3: forget that strings longer than 256 need special treatment; the 
4: count here is limited to a byte", 



TESTSTR COUNT ( produces Lurrect adt & count > CAREFULTYPE 



Volume VM, No. 4 



9 



FORTH Dimensions 



Word Indexer 




Mike Elola 
San Jose, California 



Users of programming languages 
often make use of programming aids. 
One such aid automatically locates all 
ocurrences of a specified variable 
throughout a program. Since Forth 
variables are not very different from 
Forth procedure calls, just one utility 
could be used to perform two func- 
tions: locate references to a target word 
within all other application words, and 
locate references to a target variable 
within application words. The words 
CALLOUT and CALLOUTS provide func- 
tions similar to these for the Forth lan- 
guage. They are defined in the three 
accompanying screens and adhere to 
the Forth-79 Standard, so should work 
"as is" on most Forth systems. 

The uses I have found for these 
words are numerous; many were not 
even anticipated. If you wish to locate 
all the words which make use of a non- 
standard Forth word, you can do so. If 
you wish to see any of the places you 
may have used slow or tricky words 
like DEPTH or PICK, you can do so. If 
you would like an example of the usage 
of an unfamiliar word, you can query 
the words already in the dictionary. 
And even if you would just like to 
change the name of a word, you can 
locate the places where corresponding 
changes are required. 

Originally, I wanted to see how the 
effects of a substantial change to a low- 
level word would ripple through a com- 
pleted application. I needed to know 
how many other words would be im- 
pacted by the change. Rather than 
search for ocurrences of the word in 
Hstings of my application, I used 
CALLOUT. You might want to use these 
aids for still other purposes, e.g., 
streamlining applications and enhanc- 
ing documentation. 

CALLOUTS can help you to break 
down an application into discrete com- 
ponenets. Leo Brodie introduces the 
concept of components in his recently 



published Thinking Forth. Document- 
ing the components in your application 
can be a valuable exercise, especially if 
you want to be able to make changes 
later. 

The elective words not referenced by 
your application are good candidates 
for removal. CALLOUTS shows these 
words as well as those that are referen- 
ced. It can also show where elective 
words are used in other elective words. 
While you might know that a partic- 
ular elective is being used, you may not 
know the other electives it may rely up- 
on. 

Even the words in the non-elective 
part of Forth can be analyzed with 
these utilities. This provides you with 
additional documentation regarding an 
implementation of the Forth language. 
Once you know the components within 
your implementation of Forth, you can 
more deliberately avoid or engage them 
in your own program. 

Those components you cannot com- 
pletely avoid, you can prepare to for- 
get. Identify the words you wish to 
preserve and include definitions of 
them at the start of the new applica- 
tion. Then you can safely "forget" the 
larger component from which they 
came. 



How It Works 



Word cross-references are found by 
searching a certain portion of the Forth 
dictionary for the code field address 
(CFA) of the query word, or current 
query word. The search starts at the 
top of the dictionary and proceeds 
down to the query word itself, so that 
recursion is detected. In the case of 
CALLOUT, the query word is the word 
you specify. However, with CALLOUTS, 
the query words are those starting with 
the most recent dictionary entry and 
proceeding down to the dictionary 
word that you specify. 



Floor Enhancement 



Normal operation of CALLOUT and 
CALLOUTS can be modified through the 
use of FLOOR. FLOOR allows specifica- 
tion of an alternate search limit, rather 
than the query word itself. You specify 
the new search limit with an existing 
word. Thereafter, any references to the 
current query word are only recognized 
if made from the part of the dictionary 
above the "floor" word. Often, re- 
sponse time improves dramatically 
when you specify a floor word. 

Such a search limit is needed before 
you can request a report showing all 
the words which are directly referenced 
in your application. For example, if the 
first word loaded in your application is 
START, use the following commands: 



FLOOR START ok 
CALLOUTS ! 

CALLOUTS 

CALLOUT 

<CALLOUT> .. .CALLOUTS CALLOUT 
FLOOR 

etc. 



Assuming ! is the first word in the 
dictionary, all the words in the diction- 
ary eventually become query words, 
but only those instances of the query 
words that occur within START, and 
more recent words, will be reported. 

A similar report is obtained by using 
the first of any elective words as the 
argument to CALLOUTS, after you have 
set FLOOR as described above. Once 
CALLOUTS reaches the elective words, it 
reports them only if they are directly 
referenced from your application. 
(References to them that are not direct- 
ly made from your application are 
ignored.) 

To deactivate FLOOR, use FLOOR with 
! as its argument. The floor search limit 
is only active when it is higher than the 
current query word. So, the request 



FORTH Dimensions 



10 



Volume VII, No. 4 



FLOOR ! (presumably) sets a minimum 
floor value that no longer affects the 
functions of CALLOUTS and CALLOUT. 

To sum up, the utilities presented in 
this article allow you to easily find the 
interrelationships among dictionary 
words. Occurences of a given word in 
the definitions of other dictionary 
words can be found with CALLOUT. By 
using CALLOUTS with the FLOOR option, 
almost any subset of dictionary words 
can be located within other subsets of 
dictionary words — the most useful of 
which are listed following: 



• application words in context of 
other application words 

• application words against the en- 
tire dictionary 

• application words against them- 
selves and the electives only 

• elective words in context of 
other elective words 



SCREEN 
0) ( 
1) 

2) : 
3) 

4) : 
5) 

6) : 

7) 
8) 
9) 

10) : 
11) 

12) 
13) : 
14) 
15) 



t»60 

FLOOR* PREVNFA UPNFA UMAX DOTS LEADID. ) 
VARIABLE FLOOR' VARIABLE UPNFA 
PREVNFA ( HERE/NFA -- PREVNFA ) 

DUP HERE = IF DROP LATEST ELSE PFA 4-6 THEN 
UMAX DDUP U< IF SWAP THEN DROP ; 



FLOOR ( <WORD> 

-FIND 0= IF CR . ' 
THEN DROP FLOOR' 

DOTS ( COUNT - 

DO 46 EMIT LOOP 



( -- ) 

BAD WORD" ABORT 
I ; FLOOR ! 

-- ) 



LEADID. ( NFA -- NFA 

DUP ID. 20 OVER C@ 31 AND - 
4 MAX DOTS 5 



SCREEN #61 



> 



( CFA 



) 



0) ( <CALLOUT> 

1) : <CALLOUT> 

2) HERE UPNFA ! 

3) BEGIN 

4) UPNFA e DUP PREVNFA PFA DO ( 

5) DUP I 2- @ DUP [ ' <."> CFA 

6) IF < SKIP STRING DATA ) 

7) I DUP C@ + 1+ R> DROP >R 

8) THEN [ ' <LIT> CFA D LITERAL = 

9) IF ( TEST FOR PFA ) 2+ THEN 

10) I @ = IF < EUREKA ! ! ) 

11) UPNFA e PREVNFA ID. 2 SPACES 

12) LEAVE THEN ( CFA --) 

13) LOOP UPNFA DUP S PREVNFA SWAP ! 

14) UPNFA e OVER FLOOR' S UMAX U< 

15) UNTIL ( CFA -- ) DROP ; 



CFA -- ) 
3 LITERAL = 



SCREEN «62 

0) ( CALLOUT CALLOUTS ) 
1) 

2) : CALLOUT ( <WORD> ( -- ) 

3) -FIND 0= IF CR ." BAD WORD" ABORT 

4) THEN CR DROP DUP NFA 

5) LEADID. DROP CFA <CALLOUT> ; 
6) 

7) : CALLOUTS ( < BOTTOM . WORD > < -- ) 

8) -FIND 0= IF CR ." BAD WORD" ABORT 

9) THEN DROP CR CR NFA PREVNFA HERE 

10) BEGIN ( BOTTOM. NFA NFA -- ) 

11) PREVNFA DDUP U< WHILE 

12) LEADID. 

13) DUP PFA CFA <CALLOUT> CR 

14) REPEAT DDROP i 
15) 



Volume VII, No. 4 



11 



FORTH Dimensions 



F83 Word Usage 




C.H. Ting 
San Mateo, California 

How often various Forth words are 
used is a question interesting to most 
Forth programmers because this type 
of information can lead to better de- 
sign and to the optimization of Forth 
systems. Most frequently used words 
should be coded in machine language 
for execution speed. They should also 
be at the top of the dictionary to 
minimize the time for interpretation 
and compilation. 

A number of years ago, Don Col- 
burn mentioned at a FORML meeting 
in Hayward, California that he used an 
extra cell in a word's header to ac- 
cumulate statistics of word usage, 
either during compilation or during 
execution. He also mentioned that the 
most often used Forth word was ( for 
comments, which was rather unexpec- 
ted at the time. Since I haven't the 



VIEW FIELD 



LINK FIELD 



NAME FIELD 



CODE FIELD 



PARAMETER FIELD 



Figure One-Forth word layout in F83 



luxury of metacompiling my own sys- 
tem with that type of flexibility, this 
concept remained a distant curiosity 
tor me. 

After plunging into the F83 system 
produced by Mike Perry and Henry 
Laxen, I found a ready solution to 
analyze Forth word usage without 
much hard work. The secret is in the 
extra cell used in F83 to store the "view 
file" information. As shown in figure 
one, Forth words in F83 are laid out in 
the dictionary with five fields. 

The view field stores a file number in 
its upper four-bit subfield and a block 
number in the lower twelve-bit sub- 
field, allowing the source screen con- 
taining the word definitions to be re- 
trieved from the disk and viewed by the 
user. If I am not going to use the view 
field for viewing purposes, I am free to 
use it for whatever I wish to do with it. 
Why not use it to accumulate the statis- 
tics of Forth word usage? 

To use the view field for this pur- 
pose, I must do it in the following 
sequence: 



1 . Clear the view fields of all words in 
the dictionary. 

2. Build a word processor which will 
scan a screen of code and incre- 
ment the view field when the cor- 
responding word is found in the 
screen. 

3. Tabulate the statistics. 



The program shown in the accom- 
panying screens performs these func- 
tions. It looks extremely simple be- 
cause it utilizes many powerful and 
interesting F83 features which require 
some explanation. 

The most important feature I make 
use of is the vectored execution proced- 
ures, which allow me to assign a num- 
ber of tasks to a single word. For 
example, I want to scan the dictionary 
and clear all the view fields before 
analyzing word usage. After the statis- 
tics are collected, I want to scan the 



dictionary and print the contents of the 
view fields. The scanning operations in 
both cases are identical. The difference 
is the actions I have to take after 1 find 
a view field. Anticipating that different 
actions are to be taken, I defined a 
vectored word WORK as a DEFERred 
word, and use it in the definition of the 
scanning word WORKS, which follows 
the dictionary link to locate every word 
in the dictionary and perform WORK on 
each of them. 

WORKS is complicated by the fact 
that F83 hashes the dictionary linkage 
into four threads, and all four threads 
have to be scanned when traversing the 
dictionary. The definition is very simi- 
lar to the word DEFINED which does the 
dictionary search for the text interpret- 
er in F83. It scans all four threads and 
processes the one with the highest link 
field address. The process continues 
until all four link addresses are reduced 
to zero, indicating the end of the 
threads. The scanning is performed 
only on the FORTH vocabulary, in 
which all the primitive Forth words 
reside. (Usage of words in other vocab- 
ularies is much less frequent and the 
statistics are less significant than those 
of the words in the Forth vocabulary.) 

After INIT-VIEW is defined to clear the 
view field, given a link field address, 
we can zero the view field of all the 
words in the FORTH vocabulary by 
vectoring WORK to INIT-VIEW and exe- 
cuting WORKS. After the statistics are 
accumulated in all the view fields, we 
will vector WORK to PRINT-VIEW and 
then execute WORKS. This time, WORKS 
will print the contents of the view fields 
with the corresponding word names. 

ACCUMULATE in screen 19 is the 
word processor which processes source 
screens very much like INTERPRET. If a 
word is found in the dictionary by 
DEFINED, the view field of this word is 
incremented. If a word is not found in 
the dictionary (actually, in the FORTH 
vocabulary), it is simply skipped. I 
couldn't care less if it is a number, 
which will be ignored also, unless it is 
0, 1, 2 or 3, which are Forth words. 

In F83, LOAD is also a vectored word. 
I define [LOAD] to use ACCUMULATE to 



FORTH Dimensions 



12 



Volume VII, No. 4 



NEW MICROS, INC. announces its "Generic Target Computer"^ 
with new industrial-grade enclosure. 



FORTH IN A NEMA 12 BOX 




"Generic Target Computer"^*' with NEMA 12 Case - $116.00 

The NMIT-0012 "Generic Target Computer"^ " is a digital single board computer with 5 
parallel ports, 1 serial channel, 2 counter/timers, RAM, 3 JEDEC sockets, expandable, 
operating system and FORTH supported. Euro card format. The GTC is a minimum part 
configured version of the "100 Squared'"" 

Other processors and configurations available as low as $65. 

OEM Configured $230. OEM with case $255. (as shown above). 

Development configured $290. 




New Micros Inc. 
808 Dal worth 

Grand Prairie, Texas 75050 
214/642-5494 



VolumeVII, No. 4 



13 



FORTH Dimensions 



2 


EMPTY 




(CONVEY) 


- 


DOES— SI ZE 


79 






( " ) 


1 


UD. 


8 


B/FCB 




BL. K 


6 




10 


?DUP 


r 


MARK 


2 


. TO 




DOES-OP 


Z 






rrriMCTi ct 
L L/Unr 1 Lt J 




(UD. ) 




REC/BLK 


8 


VOL— L INI 


1 1^' 


*:BWAP 


2 


FLIP 


3 


HELLO 


2 


HOP 


2B 


LABEL 




C'ET"! ICC T \.)C 


'^Z 




1 3 


. R 




B/REC 


8 


WIDTH 


62 


2DUP 


19 


-ROT 


1 


BACKGROUND : 


3 


CONVEY-COPY 


2 


UT I L I TY . BLK 






1 1 -■ 




1 7 




1 2 


B/BUF 


4 


"TIB 


38 


.ziDROP 


41 


ROT 


1 


ACTIVATE 


3 


U/D 




CPU8086. BLK 


711 




1 2 


■^M T CCT T 

: n 1 as i No 




( . ) 


1 1 


^BUFFERS 


26 


CONTEXT 


15 




24 


NIP 


3 


SET- TASK 


5 


HOPPED 




EXTENDB6. BLK 






"t 


CRASH 




U. R 


5 


QUERY 


9 


WVOCS 


18 




7 


TUCK 


2 


TASK : 


1 


VIEW 




KERNELB6. BLK 






z. 


UUN 1 KUI_ 


7 


U. 


4 


TIB 


1 1 


CURRENT 




III T TLJ T hi 


100 


OVER 


1 


RESUME 


3 


3VIEW 


h 


VIEWS 




DOES 


o~i 






(U. ) 




EXPECT 




CSP 






153 


SWAP 


3 


DEBUG 




COPY 




V lEW— r 1 Ltb 




: CODE 








OCTAL 




CC-FORTH 


1 


LAST 




MAX 


242 


DUP 


1 


LISTING 




(COPY) 








( : CODE ) 


"^0 


L ITERAL 


1 4 


r\ f T M /vi 
UtL IriAL 




CC 




R# 




MIN 


109 


DROP 


5 


SHOW 


2 


ESTABLISH 


6 


FROM 




• USES 


48 


TMMFn T ATF 


1 3 


HEX 




DEL— IN 




DPL 








RP ! 


2 


(SEMIT) 


3 


L 




OP'EN 


50 


ASSEMBLER 




rnMPTi F 




#S 


31 


CHAR 


6 


WARN ING 






1 


RP3 


2 


C PAGE ) 




B 


1 


DEFINE 










68 






(CHAR) 


10 


S i ATE 




U > 


2 


SP! 


2 


FORM-FEED 


10 


N 


1 


B: 




REVEAL 






^ 


SIGN 




CR-IN 


4 


PRIOR 


1 3 


u< 


7 


BPS 


5 


PAGE 


1 




1 


A: 




HI DE 


=■? 




8 


#> 


*- 


P-IN 


1 4 


SCR 




:'NtbA 1 t 


7 


CMOVE> 


4 


»PAGE 


1 


MANY 


1 


DR I VE? 




"^CSP 


10" 




S 


<! # 




RES-IN 


28 


EM IT 


7 


^ ' 


26 


CMQVE 


3 


LOGO 


1 


TIMES 


1 


DIR 




1 CSF* 


28 


ALLOT 


7 


HOLD 




BACK-UF* 


9 


PR I NT I NG 


47 




18 


C ! 


2 


L/PAGE 


5 


«T1MEB 


1 


CREATE— F I LE 


53 






IN 1 tf\r rvc 1 


12 


NUMBER 


2 


(DEL-IN) 


1 1 


IN-FILE 


1 7 




58 


C2 


4 


FOOTING 


3 


WORDS 


^ 


MORE 


2 


" CREATE 




c?T£iTI IQ 

h3 1 H 1 


2 


(NUMBER) 


2 


BS- 1 N 


21 


F ILE 


5 


0!> 


145 




5 


INIT-PR 


5 


LARGEST 


9 


ROOT 




VIEW 






^ 


NUMBER? 


1 


BEEP 


15 


HLD 


14 


0< 


301 




4 


EPSON 


1 


IND 


3 


"Z r- 




WH I LE 








( NUMBERT*) 


5 


BACKSPACE 


1 4 


BASE 


40 


0= 


3 


(7LEAVE) 


2 


SEE 


3 


INDEX 


1£> 


+ THRU 


100 


ELSE 








LUNVtK 1 


22 


SPACES 


5 


OFFSET 


7 


UM/MDD 


3 


(LEAVE) 


5 


(BEE) 


3 


.LINED 


5 


THRU 




IF 




FIND 


4 


r\i~n »oi f~o 
UUUtlLL f 


33 


SPACE 


8 


#L I NE 


1 


U*D 


2 


J 


3 


ASSOCIATIVE! 




TRIAD 


7 


. ENUUbH 




REPEAT 


1 4 






DIGIT 


28 


TYPE 


1 5 


#nuT 


7 


UM* 


50 


I 


3 


CASE: 


4 


LIST 


9 




B 


AGA I N 




(FI ND) 


.^5 


LOAD 




CRLF 


^ 


DP 


21 


*~ 


14 


PAUSE 


2 


MAP 


3 


.SCR 


726 


(S 




UNT IL 








(LOAD) 


3 


(EMIT) 


6 


RPO 


25 


1 — 


241 


NOOP 


6 


OUT 


4 


?CR 


■ 15 


\ 




+LDOP 




V lEWi^' 




ntrcAi tl T 




(PR I NT ) 


' 


SPO 


45 


2+ 


1 


GO 


5 


DL 


3 


7LINE 


4 


L/SCR 




LOOP 








VIEW** 




PR— STAT 


6 


LINK 


61 


1 + 


7 


PERFORM 


1 


DU 


3 


RMARGIN 


37 


C/L 


1a 






^^WflMF 


7 


FLUSH 


86 


CR 


9 


ENTRY 


5 


8K 


7 


EXECUTE 


5 


DUMP 


4 


LMARGIN 


1 


RECURBE 




DO 






4 


SAVE-BUFFERS 


8 


KEY 


4 


TPS 


1 


U2/ 


14 


>NEXT 


2 


.HEAD 


5 


HIDDEN 





B 




THEN 








EMPTY-BUFFERS 


1 3 


KEY? 


1 


* / 


3 


2/ 


12 


BOUNDS 


2 


A 


1 


0< = 




Q 




^fpA^/F 




LINK' 




IN~BLOCK 


4 


(CONSOLE) 




*/MOD 


37 


2* 


4 


(?D0) 


3 


?.N 




0>= 


CI 


DUMP 






8 


NHnt. ^ 


1 2 


BLOCK 


^ 


(KEY) 


5 


MOD 


39 




4 


(DO) 


2 


DLN 


4 


>= 


19 


. ID 




LEAVE 


7 






(BLOCK) 


5 


(KEY?) 


6 


/ 


58 


2 


4 


(+LaOP) 


"2 


EMIT. 




< = 


4 


. S 








L '■'NAME 




BUFFER 


26 


BDQS 


10 


/MOD 


1 03 


1 


4 


(LOOP) 


3 


0.2 




U.> = 


4 


DEPTH 












(BUFFER) 




COMPARE 


26 


% 


24 1 




6 


?BRANCH 


2 


^ 2 


4 


u< = 




BYE 




?>RESOLVE 




FQRTH~S3 




M T T fklf 

ni sbl Nb 


2 


CAPS— COMP 


\ 


Ml 1 / Mnr^. 


30 




6 


BRANCH 


6 


A 


1 


MS 


3 


START 


1 4 








1 


DI SCARD 




COMP 


3 


M/MOD 


6 


ABS 


6 


(LIT) 


B 


SHADOW 


3 


FUDGE 


2 


OK 






7" 


1 r\Hvtrtsc. 


4 


UPDATE 


7 


-TRAILING 




*D 


7C' 




17 


UP 


3 


(WHERE) 




P ' 


4 


INI Tl AL 






-.i ■ 


\S 




HcbtN I ■' 


1 7 


PAD 


1 


DMAX 




NbbH 1 b. 


6 


UNNEST 


1 


FIX 


B 


PC ! 




COLD 




vc-ccni lie 


250 




2 


LATEST? 


73 


HERE 


1 


DM IN 


140 




15 


EXIT 


3 


EDIT 


2 


P3 




WARM 




29 




4 


CAPACITY 


3 


UPPER 




D> 


54 


OFF 


80 


FORTH ok 


2 


ED 


2 


PCS 


5 


BOOT 


9 


'LUNU 1 i lUN 


6 


^TYPE 


32 


DOS 




UPC 




D< 


27 


ON 






4 


DONE 


1 


MULT I 


B 


QUIT 


4 


ABORT 


1 1 


WORD 


13 


SWITCH 




MOVE 


4 


DU< 


1 


CTOGGLE 






15 


EDITOR 


1 


SINGLE 


6 


RUN 


25 




6 




4 


F ILE? 


1 


LENGTH 




D= 


1 


CRESET 






5 


DARK 


1 


. STOP 


65 


IS 


4 


1 ADDDT " 1 


6 


PARSE 




> FILE 


26 


COUNT 


6 


D0= 










10 


AT * 




WAKE 


^' 


(IS) 








KHnat— WUttU 




i<io T Tc .CI nr^L^ 

Wh 1 1 t— WLULK 


1 


BLANK 




7DNEGATE 


IS 








4 


-LINE 




SLEEP 


6 


IS 


I" 


idW^&F^ 


2 


cm iDr'C 


4 


ri f" /\ ihl ni nr^i.' 

KtHU— BLULK 


1 4 


ERASE 


5 


D— 










5 


BLOT 


4 


! L I NK 


16 


USER 


5 






/ cm IDr'C 1 




\l IDrSAXC 


4 


FI LL 


1 


D2 f 




WDT 






2 


REPLACE 


3 


S>L I NK 


6 


#USER 




FORGET 


9 






DI ICCCDM 


8 


CAPS 




D2*^ 


1 1 








5 


INSERT 


e 


LOCAL 


1 16 


CODE 




\ r UKot 1 ) 


5 


/b 1 h 






4 


BELL 




DABS 


51 


OR 






8 


DELETE 




INT# 




AVOC 






4 






.•^^BUr r tKb 


5 


BS 




S,>D 










7 


SEARCH 




RESTART 


4 


2VARIABLE 


4 


FENCE 




SKIP 




INIT-RO 


T2 


BL 


5 


DNFGATE 




ROLL 








SCAN- 1ST 




(PAUSE) 


2 


2C0NSTANT 


61 




1 


D.R 


8 


FIRST 




END? 


5 


D+ 


B 


P I Ck. 






4 


FOUND 


1 


UNBUG 


91 


DEFINITIONS 


67 




1 


D. 


4 


>SIZE 


4 


#TIB 


1 


2RrJT 


21 


Ra 






15 


TO 


5 


BUG 


21 


VOCABULARY 


4 




3 


(D. ) 


4 


LIMIT 


6 


SPAN 




4DUP 


50 


>R 






4 


CONVEY 




DOES"^ 


35 


DEFER 


4 


(. ") 


1 


UD.R 


10 


DISK-ERROR 


28 


> I N 


4 


3DUP 


59 


R> 







Figure Two 



analyze the contents of a screen. After 
LOAD is vectored to [LOAD], LOAOing a 

screen will accumulate counts to words 
which appear in this screen. THRU can 
be used to analyze a range of screens in 
a file. Running a large number of 
screens through, we can get fairly rep- 
resentative statistics for all the com- 
monly used Forth words. 

F83 is very large, consisting of many 
system and application programs. It 
serves very well as a data base for the 
purposes of statistical analysis. Using 
the above technique, 1 ran all the 
source screens through this word pro- 
cessor, including seven F83 source files 
with 230 screens of code. There are 555 
words in its FORTH vocabulary, and 
total occurrences of these words is 
10,603. The result is tabulated in figure 
two. The words which occur most 
often — those counted thirty or more 
times — are Hsted in figure three. 

The most obvious utility of the 
above analysis is that if we can arrange 
the dictionary so that the most fre- 
quently used words are at the very top, 
the speed interpretation and compila- 
tion will be significantly improved, 
because the dictionary searching time 
would be reduced. Another interesting 
observation is that comments were 
heavily used in the F83 system, using 
(S, \ and (. This is, of course, dictated 
by good programming style and in-line 
documentation. 



(S 


726 


CR 


86 




OR 


51 


5 


712 


FORTH 


80 




ASSEMBLER 


50 


- 


711 


VARIABLE 


79 




>R 


50 


\ 


475 


HERE 


73 




I 


50 


S> 


301 




70 




IMMEDIATE 


4B 


( 


250 


CONSTANT 


69 




= 


47 


DUP 


243 




68 




DO 


46 





241 


LOOP 


67 




2+ 


45 


N(30F=' 


241 




67 




ROT 


41 


IF 


^25 


C 


66 




0= 


40 


THEN 


223 


3 


65 




BEGIN 


4 


SWAP 


153 


IS 


65 




3 


39 




145 


2DUP 


62 




NOT 


38 


+ 


140 


1 + 


61 




2DR0P 


38 


CODE 


116 




61 




2* 


3 7 


7MISSING 


113 


AND 


60 




DEFER 


35 


DROP 


109 


R> 


59 




ASCI I 


35 


1 


1 03 


ca 


58 




SPACE 






1 03 


'-\ 


58 




DOS 




OVER 


100 


c. 


57 




CHAR 


31 


ELSE 


1 00 


OFF 


54 




>BODV 


30 


DEFINITIONS 


CREATE 


53 




+ 1 


30 




91 


Figure Three 




TRUE 


30 




ok 

18 LIST 19 LIST 












Scr # 18 


B 


: META86 . BLii 










\ Statistical 


analysis of words 






25JAN85CHT 


1 DEFER WORK (S 


link — , to do misc. works 


on 


vocabuai r y 


-Nior ds) 


2 ■■ NOOP I 


S WORK 












3 : WORKS 


(S - 


- , scan vocabulary and WORK 


on 


each word) 




4 CONTEXT 3 HERE #THREADS 2* CMDVE 








5 BEBIN 


HERE #THREADS LARGEST 


DUP 








6 WH I LE 


DUF 


WORK 3 SWAP ' 


REPEAT 


2DR0P : 




7 : INIT-VIEW 


<S link , clear a word c 


OLinter . ) 




8 2- OFF ; 












9 : PRINT- 


VIEW 


CS linV:: , print on tents 


of 


a word counte?r-) 


1 CR 


DUP 2-- 


3 6 -R 3 SPACES 


L >NAt1E 


. ID 






11 EXIT 














12 ' INIT-VIEW IS 


WORK WORKS ( 


I ni t i ai i ^ e 


al 1 wor d counters"' 


13 ' PRINT- 


VIEW I 


S WORK WORKS < 


Print all 


word counters) 





14 
15 

Scr 

1 



6 
7 
B 
9 
10 
1 1 
12 
13 
14 
15 
ok 



# 19 B:META86.BLK 

\ New load -for statistics 23JAN85CHT 
: ACCUMULATE (S , text interpreter to increment counters) 

BEGIN DEFINED IF >VIEW 1 SWAP +! ELSE DROP THEN 

FALSE DONE? UNTIL s 
-. CLOftD] (S n — , interpret block n, like LOAD ) 

FILE 3 >R BLK 3 >R >IN 3 >R 

64 >IN ! ( Skip 0th line to avoid wrap-around.) 
BLK ! IN-FILE 3 FILE I ACCUMULATE R> >IN ' R> BLK '. 
R> ! FILES J 
EXIT 

' CLOADI IB LOAD 
CAPS OFF 
OPEN <-fiIe> 
1 10 THRU 



PR I NT- VIEW IS WORK 



( Use lLOADI to do the WORKS) 
( Do case sensitive compare and counting.) 
( Select a source file to analyze.) 
( Accumulate word statistics.) 
( Repeat for all source files.) 
WORKS ( Print results.) 



VolumeVII, No. 4 



15 



FORTH Dimensions 



Synonyms and Macros, R 

Benchmark 

Victor H. Yngve 
Chicago, Illinois 

One of the most frequently used 
timing benchmarks is the Eratosthenes 
Sieve program for calculating the 
prime numbers between three and 
16,384. This program provides a con- 
venient test bed for illustrating the use 
of the synonyms and macros presented 
in the previous articles in this series'. 
There are a number of special circum- 
stances where synonyms and macros 
should be used instead of colon defini- 
tions. Two of these special circumstan- 
ces will be illustrated in this article, 
which focuses on trying to improve the 
readability of the Sieve program. 

The Sieve program operates with an 
array of byte flags initialized to true to 
represent the odd numbers in the given 
range. Starting with the flag for 3, a 
prime, the program tests each flag in 
succession. When it finds a flag that is 
true, that number is a prime. For each 
prime found, the program sets the flags 
to false for all succeeding odd multi- 
ples of that number, to indicate that 
they are not prime, and it then incre- 
ments a counter that accumulates the 
total number of primes found. This 
total is then printed. Benchmark times 
are usually given for ten iterations of 
this program. 

Screen 14 shows a Forth program for 
this benchmark that has been widely 
circulated outside of the Forth com- 
munity, it having appeared at least 
twice in BYTEP^'^. Call this version A. 
Please examine this program carefully. 
Note that even with the above explana- 
tion of what it is supposed to do, it 
would generally be judged as rather 
unreadable, if not opaque, even by 
someone with a knowledge of Forth. If 
you don't think so, try to find where to 
place a print word to print out the 
successive primes. 

The reason for the obscurity of the 
program is not hard to find: It has been 
optimized for speed at the expense of 
readability. It transgresses the usual 
canons of good Forth programming 
style. In the interest of speed it puts 
everything in the one long word DO- 
PRIME, instead of using a number of 



art 3 

Readability 

shorter nested definitions carefully 
named to indicate their function in the 
program. With examples of Forth pro- 
gramming like this being widely circu- 
lated to the computing pubHc, it is little 
wonder that Forth has sometimes been 
accused of being an unreadable lan- 
guage. In reality, when written in the 
recommended style that optimizes 
readabiUty, it is among the most 
readable of languages. 

A general method for writing read- 
able Forth programs is to program the 
algorithm in words chosen to bring out 
how it works, thus words which refer 
to the concepts of the algorithm rather 
than to the details of its implementa- 
tion in Forth. These application-spec- 
ific words are then defined ultimately 
in terms of standard Forth words on 
earlier screens. This separates the pro- 
gram into an algorithmic part pro- 
grammed largely in its own vocabu- 
lary, and an implementation part or 
preamble, which specifies how the 
named application-relative words are 
realized in terms of the Forth givens. 

Please look now at screen 50, in 
which the benchmark is rewritten in 
words selected to indicate their func- 
tion in executing the Sieve algorithm. 
This screen would undoubtedly be 
judged as quite readable by people 
curious to see what Forth code looks 
like. The preamble giving the Forth 
implementation of these words is on 
screen 49. Note that PRINT-PRIME can 
be changed from DROP to a print word 
for debugging purposes. This is version 
B. 

For many programs we would be 
done at this point, but in this case we 
run into a special circumstance. There 
is the problem that version B will not 
run, as it contains errors. The defini- 
tions for GET-FLAG, PRIME and FIRST- 
MULTIPLE will not work as intended 
because the word l that they contain 
cannot be used to obtain the loop index 
when something else has been placed 
on the return stack, here the return 
from a colon definition. In fact, FIRST- 
MULTIPLE finds two returns covering up 
the index on the return stack. 

To make the program work, these 
definitions must be deleted or com- 



mented out as shown on screen 54, and 
the words they contain returned to 
their original place in the loop, as 
shown on screen 55. This moves back 
into the loop some of the confusing 
low-level clutter that we had been 
trying to clear out, and consequently 
compromises its readability. But this 
version will run. Call it version C. 

Or the words GET-FLAG, PRIME, 
FIRST-MULTIPLE and CANCEL-MULTIPLES 
could be coded as macros instead of 
colon definitions. Simply replace the 
colon in each by MACRO and the semi- 
colon by END-MACRO. This is one of the 
reasons for using macros: to allow 
removing material from a loop in a 
way that will not add a return to the 
return stack. We will code these words 
as macros in version D. 

Of course version C will also run 
slower because of the nesting and un- 
nesting involved in calling the colon 
definitions. On a 4 MHz Z80 system it 
run in 106 seconds instead of the 71 
seconds for version A, the original 
benchmark program, about 50% slow- 
er. This is a large difference for a speed 
benchmark. The program would have 
run even slower if we had been able to 
retain all of the colon definitions — 
about 60*Vo slower than version A. This 
is a powerful disincentive operating 
against the use of good Forth program- 
ming style. 

Something can be done, however, to 
overcome the slowness. This is the 
second special circumstance where syn- 
onyms and macros are useful. Suppose 
we replace the rest of the colon defini- 
tions on screen 49 by equivalent syno- 
nyms and macros, as shown on screens 
56 and 57. This is version D. Version D 
runs in 71 seconds, the identical timing 
for version A, the original unreadable 
benchmark program. This is because 
version D compiles run-time code that 
is identical to that compiled by version 
A. 

This means that a judicious use of 
synonyms and macros allows one to 
optimize simultaneously for speed and 
for readability — they provide both the 
speed of in-line code and the readabil- 
ity of colon definitions. This is another 
important use of synonyms and mac- 



FORTH Dimensions 



16 



Volume Vii, No. 4 



FOR TRS-80 MODELS 1 , 3, 4, 4P 
IBM PC/XT, AT&T 6300, ETC. 



Screen § 1 4 

( Eratosthenes sieve benchmark program 
1 

2 81 90 CONSTANT SIZE 

3 CREATE FLAGS SIZE ALLOT 



VERSION A 



4 
5 
6 
7 
8 
9 
10 
1 1 
12 
13 
1 4 
1 5 



DO-PRIME 



FLAGS SIZE 1 
SIZE 

DO FLAGS I 

IF I 



FILL 



I + C@ 
I DUP + 
BEGIN 
WHILE 
REPEAT 



3 + DUP I + 
DUP SIZE < 
OVER FLAGS 
DROP DROP 1 + 



+ C! OVER + 



1 0-TIMES 



THEN 

LOOP 
, " Primes " ; 
1 DO DO-PRIME LOOP 



Screen # 49 

( Colon sieve 1 



PREFACE VERSION B *errors* 2/23/85 vhy ) 



1 


8190 CONSTANT SIZE 


CREATE 


FLAGS SIZE ALLOT 


2 




FLAG-LIMIT SIZE ; 






3 




FIRST-FLAG ; 






4 




OCOUNT ; 






5 




INC-COUNT 1 + ; 






6 




PRINT-COUNT . ; 






7 




SET-TRUE ( 


addr — ) 


SIZE 1 FILL 


8 




GET-FLAG ( 


-- flag ) 


FLAGS I + C@ 


9 




PRIME ( 


— p ) 


I DUP + 3 + 


10 




PRINT- PRIME DROP 






1 1 




FIRST-MULTIPLE ( 


p -- p m ) 


DUP I + 


12 




SIZE< { 


m -- m f ) 


DUP SIZE < 


13 




SET-FALSE ( 


m -- m ) 


OVER FLAGS + C! 


1 4 




NEXT-MULTIPLE ( 


p m — p m' 


) OVER + 


15 




DROP-MULTIPLE DROP ; 





( error ) 
( error ) 

( error ) 



Screen # 50 

( Colon Sieve 2 



1 
2 
3 
4 
5 
6 
7 
8 
9 
1 
11 
1 2 
13 
1 4 
15 



ALGORITHM VERSION B *errors* 2/23/85 vhy ) 

CANCEL-MULTIPLES ( prime — prime ) 
FIRST-MULTIPLE ( error ) 

BEGIN SIZE< WHILE SET-FALSE NEXT-MULTIPLE REPEAT 
DROP-MULTIPLE ; 

DO-PRIME FLAGS SET-TRUE OCOUNT 
FLAG-LIMIT FIRST-FLAG 

DO GET-FLAG ( error ) 

IF PRIME CANCEL-MULTIPLES PRINT-PRIME INC-COUNT THEN ( " ) 
LOOP PRINT-COUNT ." Primes " ; 

1 0-TIMES 10 DO DO- PRIME LOOP : 



1 



Screen # 54 

( Colon sieve 

1 8190 CONSTANT SIZE 
FLAG-LIMIT SIZE 
FIRST-FLAG ; 
OCOUNT ; 
INC-COUNT 1 + ; 
PRINT-COUNT . ; 
SET-TRUE 
GET -FLAG 
PRIME 

PRINT-PRIME 
FIRST-MULTIPLE 
SIZE< 
SET-FALSE 
NEXT-MULTIPLE 
DROP-MULTIPLE 



2 
3 
4 
5 
6 
7 
8 
9 
1 
1 1 
12 
13 
1 4 
15 



PREFACE VERSION C 
CREATE FLAGS 



SIZE ALLOT 



2/23/85 vhy 



DROP 



addr -- ) 


SIZE 1 FILL 


— flag ) 


FLAGS I + C@ 


- p ) 


I DUP + 3 + 


p -- p m ) 


DUP I + 


m -- m f ) 


DUP SIZE < 


m -- m ) 


OVER FLAGS + C! 


p m -- p m ' 


) OVER + 



DROP 



COMMERCIAL 

SOFTWARE 
DEVELOPERS 

and 
INDIVIDUAL 
PROGRAMMERS 

appreciate MMSFORTH for its: 

• Power 

• Flexibility 

• Compactness 

• Development speed 

• Execution speed 

• Maintainability. 

When you want to create the 
ultimate: 

• Computer Language 

• Application 

• Operating System 

• Utility, 

BUILD IT In 

(Unless we have it ready for you now!) 

Bull< Distribution Licensing© $500 
for 50 units, or as little as pennies 
each in large quantities. 
(Corporate Site License required.) 

The total software environment for 
IBM PC/XT, TRS-80 Model 1, 3, 4 
and close friends. 

• Personal License (required): 

MMSFORTH V2.4 System DM $179.9S 

(TRS-dO Model 1 requires lowercase, DOEN, 1 40-trBck drive.) 

• Personal License (additional modules): 

FORTNCOM communications module .... $ 49.95 

UTILITIES «9.95 

GAMES 39.9S 

iXPERT-2 expert system 89.95 

DATAHANDLER 59.95 

DATAHANDLER-PLUS (PC only, 12BK red ) 99.95 

FORTHWRITE word processor 99.95 

• Corporate Site License 
Extensions (K>m»i,ooo 

• Bulk Distribution . . . from $500/50 units. 

• Some recommended Forth books: 

STARTING FORTH (prograraffling) 

THINKING FORTH (technique) 15.95 

BEGINNING FORTH (re lUIMSFORTH) . . . 15.95 
Siijpping/tiandling & tax extra. No returns on software. 

Ask your dealer to show you the world of 
MMSFORTH, or request our free brochure. 

MILLER MICROCOMPUTER SERVICES 
61 Lake Shore Road, Natick, MA 01760 
(617)653-6136 



Volume VII, No. 4 



17 



TOTALCONTROL 

with LMI FORTH'" 




For Programming Professionals: 

an expanding family of 
compatible, high-performance, 
Forth-83 Standard compilers 
for microcomputers 

For Development: 

Interactive Forth-83 Interpreter/Compilers 

• 16-bit and 32-bit implementations 

• Full screen editor and assembler 

• Uses standard operating system files 

• 400 page manual written in plain English 

• Options include software floating point, arithmetic 
coprocessor support, symbolic debugger, native code 
compilers, and graphics support 



For Applications: Forth-83 Metacompiler 

• Unique table-driven multi-pass Forth compiler 

• Compiles compact ROMable or disk-based applications 

• Excellent error handling 

• Produces headerless code, compiles from intermediate 
states, and performs conditional compilation 

• Cross-compiles to 8080, Z-80, 8086, 68000, and 6502 

• No license fee or royalty for compiled applications 



Support Services for registered users: 

• Technical Assistance Hotline 

• Periodic newsletters and low-cost updates 

• Bulletin Board System 

Call or write for detailed product Information 
and prices. Consulting and Educational Services 
available by special arrangement. 

mMn^KS Laboratory Microsystems Incorporated 

mMmMMPost Office Box 10430. Marina del Rey. CA 90295 
M^trmm Phone credit card orders to: (213) 306-7412 

Overseas DIstrlbulors. 

Germany Forth-Sysieme Angelika Flesch, D-7820 Tilisee-Neustadi 
UK: System Science Ltd . London EC1A 9JX 
France: Micfo-Sigma S A R L., 75008 Pans 
Japan: Southern Pacific Lid , Yokohama 220 
Australia. Wave-onic Associates, 6107 Wilson, W.A 



res: They should be used in place of 
colon definitions in programs or parts 
of programs where speed is critical and 
where the extra memory requirements 
over colon definitions are of secondary 
importance. A speed benchmark pro- 
gram is a prime example. Other ex- 
amples are the time-critical parts of 
programs that spend most of their time 
in inner loops. 

How much extra memory is needed? 
Often it does not matter, because many 
Forth programs never find themselves 
bumping their heads against a memory 
limit. But sometimes it does matter. 
Exclusive of the 8190 bytes ALLOTted 
for the array, the original benchmark 
program, version A, compiles in 162 
bytes. Version B, the one with colon 
definitions that doesn't run, compiles 
in 455 bytes. The difference of 283 
bytes, about 175% extra, represents 
the memory cost of readability for 
examples such as this. It amounts to an 
overhead for each extra colon defini- 
tion of seven bytes plus the number of 
characters in the name, and an extra 
two bytes for each time the definition is 
used. It is the small cost that we usually 
gladly pay for the advantages of clarity 
of style, ease of programming, ease of 
checkout, ease of making modifica- 
tions, self-documentation, and so on. 
Version C, which runs, compiles in 391 
bytes, a difference from version A of 
229 bytes, about 140% extra. 

Now how much extra memory is 
needed for version D, the version with 
macros and synonyms? This version 
compiles in 493 bytes, giving an in- 
crease of only forty-eight bytes or 11% 
over version B, the equivalent version 
with colon definitions (that does not 
run). This is the approximate extra 
memory cost of using synonyms and 
macros instead of colon definitions in 
programs like this where no macro is 
used more than once and the macros 
are nested no more than two deep. 

As can be calculated from the infor- 
mation given in the earlier articles, the 
cost of a synonym is two bytes less than 
the cost of a colon definition with one 
word in it, and the cost of a macro 
definition in an eight-bit system is one 
byte less than a colon definition, but 
each use of a macro costs an additional 



amount equal to two bytes less than the 
number of bytes needed for compiling 
the words in the macro. 

Thus, for compactness one would 
normally use synonyms in place of 
colon definitions with one word in 
them, and for other words, one would 
normally use colon definitions instead 
of macros. Macros should be used in 
place of colon definitions where their 
benefits of speed and noninterference 
with the return stack are particularly 
important. 

A programming style that separates 
the algorithmic part from the imple- 
mentation part of a program has other 
advantages besides readabihty. Note 
how easy it would now be to change the 
program, for example to try a 16K 
array, or a bit array, or the use of 
variables instead of the stack to see 
how much slower they would be, or to 
try some of the schemes that have been 
suggested for speeding up this bench- 
mark. 

The use of comments is often recom- 
mended to improve the readability of 
programs, and they can be helpful. But 
note that version D is quite readable 
without any comments except the stan- 
dard stack diagrams. This shows off 
the self-documenting ability of Forth. 

The word "readability" is actually 
misleading because it may lead one to 
think of it as an absolute attribute of a 
programming language. In reality it is 
a relation between a particular pro- 
gram and a particular reader, and it 
depends on both. For example, the 
definitions in the implementation pre- 
amble of version D may be eminendy 
readable by Forth programmers who 
understand how the algorithm is being 
implemented, but they are probably 
not as readable by members of the 
wider computing public who know 
Httle about Forth. The algorithm part, 
however, is readable to the larger audi- 
ence because it does not require as 
much knowledge of Forth, but only of 
the Sieve algorithm. And it is more 
readable to Forth programmers as well, 
because its understanding requires 
primarily a knowledge of the Sieve 
algorithm, and not of the particulars of 
how it happens to be mapped onto 
Forth. 



FORTH Dimensions 



18 



Volume VII, No. 4 



Scree 
( 
1 

2 : 

3 
4 

5 
6 

7 : 

8 

9 
10 
1 1 
1 2 
13 

1 4 : 

1 5 



n # 55 
Colon sieve 2 



ALGORITHM VERSION C 
prime ) 



2/23/85 vhy 



CANCEL-MULTIPLES ( prime 
( DUP I + ) 

BEGIN SIZE< WHILE SET-FALSE NEXT-MULTIPLE REPEAT 
DROP-MULTIPLE ; 

DO-PRIME FLAGS SET-TRUE OCOUNT 
FLAG-LIMIT FIRST-FLAG 
DO FLAGS I + C@ 
IF I DUP + 3 + 

DUP I + CANCEL-MULTIPLES PRINT-PRIME INC-COUNT THEN 
LOOP PRINT-COUNT ." Primes " ; 

1 0-TIMES 1 DO DO-PRIME LOOP ; 



Screen # 56 

( Macro Sieve 1 PREFACE VERSION D 

1 8190 CONSTANT SIZE CREATE FLAGS 
SYNONYM FLAG-LIMIT SIZE 
SYNONYM FIRST-FLAG 

SYNONYM OCOUNT 
SYNONYM INC-COUNT 1+ 
SYNONYM PRINT-COUNT . 
MACRO SET-TRUE 
MACRO GET-FLAG 
MACRO PRIME 

SYNONYM PRINT-PRIME 
MACRO FIRST-MULTIPLE 

12 MACRO SIZE< 

1 3 MACRO SET-FALSE 

1 4 MACRO NEXT-MULTIPLE 



2 
3 
4 
5 
6 
7 
8 
9 
1 
1 1 



addr -- 
flag 
) 



( 
( 

( — P 
DROP 
( p — 
( m -- 
( m -- 
(pro — 



1 5 SYNONYM DROP-MULTIPLE DROP 



p m 
m f 
m ) 
p m 



) 



SIZE ALLOT 



SIZE 1 FILL 
FLAGS I + C@ 
I DUP + 3 + 

DUP I + 
DUP SIZE < 
OVER FLAGS 
OVER + 



2/23/85 vhy ) 



+ C! 



END- 
END- 
END- 

END- 
END- 
END- 
END- 



■MACRO 
•MACRO 
■MACRO 

■MACRO 
■MACRO 
■MACRO 
-MACRO 



ALGORITHM VERSION D 



Screen # 57 

( Macro Sieve 2 
1 

MACRO CANCEL-MULTIPLES ( prime — prime ) 
FIRST-MULTIPLE 

BEGIN SIZE< WHILE SET-FALSE NEXT-MULTIPLE REPEAT 
DROP-MULTIPLE END-MACRO 



2/23/85 vhy ) 



2 
3 
4 
5 
6 
7 
8 
9 
10 
1 1 
12 
1 3 
1 4 
1 5 



DO- PRIME FLAGS SET-TRUE OCOUNT 
FLAG-LIMIT FIRST-FLAG 
DO GET-FLAG 

IF PRIME CANCEL-MULTIPLES PRINT-PRIME INC-COUNT THEN 
LOOP PRINT-COUNT . " Primes " ; 

10-TIMES 1 DO DO-PRIME LOOP : 



Actually there is a moveable line 
between the algorithm and the imple- 
mentation part of a program, and it 
can be moved to accommodate the 
intended audience for the program. 
Our published examples of Forth code 
should be optimized for readability by 
a wider audience. This means that we 
should be more strict in removing the 
details of the Forth implementation 
from the algorithm section than in a 
program written for our own consump- 
tion. As in prose writing, one should 
write for one's audience. For example, 
FLAG-LIMIT FIRST-FLAG DO adds to the 
readability of the above program for 
the general computing public, but for 
Forth programmers familiar with ar- 
rays and the order of loop arguments 
in Forth, SIZE DO might be quite 
acceptable instead. 

Perhaps someone would like to chal- 
lenge other languages to a comparison 
of readability benchmarks. Forth 
would come out quite well. The prob- 
lem is, of course, that subjective judg- 
ments are involved, and such judg- 
ments depend strongly on what other 
languages the reader is already familiar 
with. But any argument that Forth has 
an unfair advantage because synonyms 
and macros are not part of the stan- 
dard language, would be overlooking 
an important feature of Forth, its ex- 
tensibility. And any argument that 
SYNONYM, MACRO and END-MACRO real- 
ly constitute new system words like 
colon and semi-colon, and therefore 
are not fair, overlooks another impor- 
tant feature of Forth — the lack of a 
strong or impenetrable wall between 
the system program and the user pro- 
gram. SYNONYM is programmed in 
standard Forth-83; and the macro fac- 
iUty, though implementation specific, 
is the sort of thing that any average 
Forth programmer can easily add to a 
system. Unlike most other program- 
ming languages, Forth is a dynamically 
evolving language Hke Enghsh. And 
unlike some other programming lan- 
guages. Forth does not erect barriers 
nor provide a single prescriptive way of 
programming that would limit freedom 
and discourage creativity. 



References 

1. Yngve, Victor H. "Synonyms and 
Macros," parts 1 and 2. Forth 
Dimensions VII/3 (September/ 
October 1985). 

2. Gilbreath, Jim. "A High-Level 
Language Benchmark." BYTE 
Vol. 6, No. 9, p. 180 (September 
1981). 



3. Tello, Ernie. "polyFORTH and 
PC/FORTH." BYTE Vol. 9, No. 
12, p. 303 (November 1984). 



Volume VII, No. 4 



19 



FORTH Dimensions 



The 



TM 

ForthCard 



STAND ALONE OPERATION 



STD BUS INTERFACE 

EPROM/EEPROM 
PROGRAMMER 

RS-232 I/O 

PARALLEL I/O 

ROCKWELL FORTH CHIP 




Evaluation Unit 

$299 

Part #STD65F11-05 includes: 
ForthCard, Development 
ROM, 8Kbyte RAM, Manuals 



OEM Version as low as 
Part #STD65F 11-00 $400 
does not include 
memory or manuals 



The Forthcard provides OEMs and end 
users with the ability to develop Forth and 
assembly language programs on a single 
STD bus compatible card. 

Just add a CRT terminal (or a computer 
with RS-232 port), connect 5 volts and you 
have a self contained Forth computer. 

The STD bus interface makes it easy to 
expand. 

Download Forth source code using the 
serial port on your PC, Use the onboard 
EPROM/EEPROM programming capability 
to save debugged Forth and assembly 
language programs. Standard UV erasable 
EPROMs may also be programmed with 
an external Vpp supply. 



NEW! Options and Application Notes 

Electrically Eraseable PROMs (EEPROMs) 

FREEZE the dictionary in EEPROM (save in 
non-volatile memory, to be restored on 
power up) 

Download Software for your IBM PC or CP/M 

Non-Volatile CMOS RAM with battery 2K, 
8K, optional Clock/calendar 

Fast 2MHz clock (4MHz crystal) 

Disk Controller Card (5V4") 

Self Test Diagnostics 

Parallel printer interface 



Ask about our ForthBox™ 

A complete STD bus oriented system including 
the ForthCard, Disk Controller, Disk Drive(s), 
STD Card Cage, Cabinet and power supply. 



CALL TODAY FOR COMPLETE INFORMATION! 

[}{]DT©©[b [i(o][ii]D[p)[]TfD©[A]ft (Sm\p®m^mij^ 

9560 Black Mountain Road 
San Diego, CA 92126 

(619) 566-1892 



VISA 



FORTH Dimensions 



20 



Volume VII, No. 



4 



FORTH INTEREST GROUP MAIL ORDER FORM 

P.O. Box 8231 San Jose, CA 95155 (408) 277-0668 

MEMBERSHIP 

IN THE FORTH INTEREST GROUP 



107 - MEMBERSHIP in the FORTH INTEREST GROUP & Volume 7 
of FORTH DIMENSIONS. No sales tax, handling fee or 
discount on membership. See the back page of this order 
form. 

The Forth Interest Group is a worldwide non-profit member-supported 
organization with over 5,000 members and 80 chapters. FIG membership 
includes a subscription to the bi-monthly publication, FORTH Dimensions. 
FIG also offers its members publication discounts, group health and life 
insurance, an on-line data base, a large selection of Forth literature, and 
many other services. Cost is $20.00 per year for USA, Canada & Mexico; 



all other countries may select surface ($27.00) or air ($33.00) delivery. 

The annual membership dues are based on the membership year, which 
runs from May 1 to April 30. 

When you join, you will receive issues that have already been circulated 
for the current volume of Forth Dimensions and subsequent issues will be 
mailed to you as they are published. 

You will also receive a membership card and numberwhich entitles you to 
a 10% discount on publications from FIG. Your member number will be 
required to receive the discount, so keep it handy. 



HOW TO USE THIS FORM 

1. Each item you wish to order lists three different Price categories: 

Column 1 - USA, Canada, Mexico 
Column 2 - Foreign Surface Mail 
Column 3 - Foreign Air Mail 

2. Select the item and note your price in the space provided. 

3. After completing your selections enter your order on the fourth page of this form. 

4. Detach the form and return it with your payment to The Forth Interest Group. 



FORTH DIMENSIONS BACK VOLUMES 


514 


- 6502/SEPT 80 


$15/16/18 


515 


- 6800/ MAY 79 


$15/16/18 


The six issues of the volume year (May - April) 




516 


- 6809/JUNE 80 


$15/16/18 


101 - Volume 1 FORTH Dimensions (1979/80) $15/16/18 


517 


- 8080/ SEPT 79 


. , , $15/16/18 


102 - Volume 2 FORTH Dimensions (1980/81) $15/16/18 


518 


- 8086/88/MARCH 81 


$15/16/18 


103 - Volume 3 FORTH Dimensions (1981/82) $15/16/18 


519 


- 9900/ MARCH 81 


$15/16/18 


104 - Volume 4 FORTH Dimensions (1982/83) $15/16/18 


520 


-ALPHA MICRO /SEPT 80 


$15/16/18 


105 - Volume 5 FORTH Dimensions (1983/84) $15/16/18 


521 


- APPLE ll/AUG 81 


$15/16/18. 


106 - Volume 6 FORTH Dimensions (1984/85) $15/16/18 


522 


- ECLIPSE/OCT 82 


$15/16/18 _ 




523 


- IBM-PC/MARCH 84 


$15/16/18 




524 


- NOVA/MAY 81 


$15/16/18 


ASSEMBLY LANGUAGE SOURCE CODE LISTINGS 


525 


- PACE /MAY 79 


$15/16/18 


Assembly Language Source Listings of fig-Forth for specific CPUs and 


526 


- PDP-11/JAN 80 


.., $15/16/18 


machines with compiler security and variable length names. 


527 


- VAX /OCT 82 


$15/16/18 


513 - 1802/MARCH 81 $15/16/18 


528 


- Z80/SEPT 82 


$15/16/18 









Volume VII, No. 4 



21 



FORTH Dimensions 



BOOKS ABOUT FORTH 

200 - ALL ABOUT FORTH $25/26/35 

Glen B. Haydon 

An annotated glossary for MVP Forth; a 79-Standard 
Forth. 

205 - BEGINNING FORTH $17/18/21 

Paul Chirlian 

Introductory text for 79-Standard. 

215 - COMPLETE FORTH $16/17/20 

Alan Winfield 

A comprehensive introduction including problems with 
answers. (Forth 79) 

220 - FORTH ENCYCLOPEDIA $25/26/35 

Mitch Derick & Linda Baker 

A detailed look at each FIG-Forth instruction. 

225 - GORTH FUNDAMENTALS, V. 1 $16/17/20 

Kevin McCabe 

A textbook approach to 79 Standard Forth. 

230 - FORTH FUNDAMENTALS, V. 2 $13/14/16 

Kevin McCabe 
A glossary. 

232 - FORTH NOTEBOOK $25/26/35 

Dr. C. H. Ting 

Good examples and applicatoins. Great learning aid. 
PolyFORTH is the dialect used. Some conversion advice 
is included. Code is well documented. 



233 - FORTH TOOLS $19/21/23 

Gary Feierbach & Paul Thomas 
The standard tools required to create and debug Forth- 
based applications. 

235 - INSIDE F-83 $25/26/35 

Dr. C. H. Ting 

Invaluable for those using F-83. 

237 - LEARNING FORTH $17/18/21 

Margaret A. Armstrong 

Interactive text, introduction to the basic concepts of 
Forth. Includes section on how to teach children Forth. 

240 - MASTERING FORTH $18/19/22 

Anita Anderson & Martin Tracy (MicroMotion) 

A step-by-step tutorial including each of the commands 



of the Forth-83 International Standard; with utilities, 
extensions and numerous examples. 

245 - STARTING FORTH (soft cover) $20/21/24 

Leo Brodie (FORTH, Inc.) 

A lively and highly readable introduction with 

exercises. 

246 - STARTING FORTH (hard cover) $24/25/29 

Leo Brodie (FORTH, Inc.) 

255 - THINKING FORTH (soft cover) $16/17/20 

Leo Brodie 

The sequel to "Starting Forth". An intermediate text on 
style and form. 

265 - THREADED INTERPRETIVE LANGUAGES $23/25/28 

R.G. Loeliger 

Step-by-step development of a non-standard Z-80 Forth. 

270 - UNDERSTANDING FORTH $3.50/5/6 

Joseph Reymann 

A brief introduction to Forth and overview of its 
structure. 



FORML CONFERENCE PROCEEDINGS 

FORML PROCEEDINGS - FORML (the Forth Modification Laboratory) is an 
informal forum for sharing and discussing new or unproven proposals 
intended to benefit Forth. Proceedings are a compilation of papers and 
abstracts presented at the annual conference. FORML is part of the Forth 
Interest Group 

310 - FORML PROCEEDINGS 1980 $25/28/35 

Technical papers on the Forth language and extensions. 

311 - FORML PROCEEDINGS 1981 (2V) $40/43/45 

Nucleus layer, interactive layer, extensible layer, 
metacompilatlon, system development, file systems, 
other languages, other operating systems, applications 
and abstracts without papers. 

312 - FORML PROCEEDINGS 1982 $25/28/35 

Forth machine topics, implementation topics, vectored 
execution, system development, file systems and 
languages, applications. 

313 - FORML PROCEEDINGS 1983 $25/28/35 

Forth in hardware. Forth implementations, future 
strategy, programming techniques, arithmetic & floating 
point, file systems, coding conventions, functional 
programming, applications. 

314 - FORML PROCEEDINGS 1984 $25/28/35 

Expert systems in Forth, using Forth, philosophy, 
implementing Forth systems, new directions for Forth, 
interfacing Forth to operating systems. Forth systems 
techniques, adding local variables to Forth. 



ROCHESTER PROCEEDINGS 

The Institute for Applied Forth Research, Inc. is anon-profit organization 
which supports and promotes the application of Forth. It sponsors the 
annual Rochester Forth Conference. 

321 - ROCHESTER 1981 (Standards Conference) $25/28/35 

79-Standard, implementing Forth, data structures, 
vocabularies, applications and working group reports. 

322 - ROCHESTER 1982 

(Data bases & Process Control) $25/28/35 

Machine independence, project management, data 
structures, mathematics and working group reports. 

323 - ROCHESTER 1983 (Forth Applications) . $25/28/35 

Forth in robotics, graphics, high-speed data acquisition, 
real-time problems, file management. Forth-like 
languages, new techniques for implementing Forth and 
working group reports. 

324 - ROCHESTER 1984 (Forth Applications) . $25/28/35 

Forth in image analysis, operating systems. Forth chips, 
functional programming, real-time applications, cross- 
compilation, multi-tasking, new techniques and working 
group reports. 

325 - ROCHESTER 1985 

(Software Management and Engineering) $25/28/35 

Improving software productivity, using Forth in a space 
shuttle experiment, automation of an airport, 
development of MAGIC/L, and a Forth-based business 
applications language, includes working group reports. 



FORTH Dimensions 



22 



Volume VII, No. 4 



THE JOURNAL OF FORTH APPLICATION & RESEARCH 

A refereed technical journal published by the Institute for Applied Forth 
Research, Inc. 

401 - JOURNAL OF FORTH RESEARCH V.I #1 $15/16/18 

Robotics. 

402 - JOURNAL OF FORTH RESEARCH V.1 #2 $15/16/18 

Data Structures. 

403 - JOURNAL OF FORTH RESEARCH V.2 #1 $15/16/18 

Forth Machines. 

404 - JOURNAL OF FORTH RESEARCH V.2 #2 $15/16/18 

Real-Time Systems. 

405 - JOURNAL OF FORTH RESEARCH V.2 #3 $15/16/18 

Enhancing Forth. 

406 - JOURNAL OF FORTH RESEARCH V.2 #4 $15/16/18 

Extended Addressing. 

407 - JOURNAL OF FORTH RESEARCH V.3 #1 $15/16/18 

Forth-based laboratory systems and data structures. 



REPRINTS 

420 - BYTE REPRINTS $5/6/7 

Eleven Forth articles and letters to the editor that have 
appeared in Byte magazine. 

421 - POPULAR COMPUTING 9/83 $5/6/7 

Special issue on various computer languages, with an 



in-depth article on Forth's history and evolution. 

DR. DQBB'S 

This magazine produces an annual special Forth issue which includes 
source-code listings for various Forth applications. 



422 -DR. DOBB'S 9/82 $5/6/7 

423 -DR. DOBB'S 9/83 $5/6/7 

424 -DR. DOBB'S 9/84 $5/6/7 



HISTORICAL DOCUMENTS 

501 - KITT PEAK PRIMER $25/27/35 



One of the first institutional books on Forth. Of his- 
torical interest. 

502 - FIG-FORTH INSTALLATION MANUAL . . $15/16/18 

Glossary model editor - We recommend you purchase 
this manual when purchasing the source-code listings. 

503 - USING FORTH $20/21/23 

FORTH, Inc. 



REFERENCE 

305 - FORTH 83 STANDARD $15/16/18 

The authoritative description of 83-Standard Forth. For 
reference, not instruction. 

300 - FORTH 79 STANDARD $15/16/18 

The authoritative description of 79-Standard Forth. Of 
historical interest. 

316 - BIBLIOGRAPHY OF FORTH REFERENCES 

2nd edition, SepL 1984 $15/16/18 

An excellent source of references to articles about 
Forth throughout microcomputer literature. Over 1300 
references. 



MISCELLANEOUS 

601 - T-SHIRT SIZE 

Small, Medium, Large and Extra-Large. 

White design on a dark blue shirt. $10/11/12 

602 - POSTER (BYTE Cover) $15/16/18 

616 - HANDY REFERENCE CARD FREE 

683 - FORTH-83 HANDY REFERENCE CARD FREE 

SELECTED PUBLICATIONS 

The following publications are NEW additions to the Forth Interest Group 
Order Form as selected by the FIG Publications Committee. 

FORTH NOTEBOOK by Dr. C. H. Ting. 

Good examples and applications. Great learning aid. PolyFORTH 
is the Forth dialect used. Some conversion advice is included in 
this book. Code is well documented. The first part has 10 games 
written in FORTH. It includes some tools for control applications. 
There is a section on image processing and then other forms of 
utilities. It includes a general tutorial on Forth which may be 
shown on an overhead projector and used with lecture notes. 
INSIDE F-83 by Dr. C. H. Ting 

Invaluable for those using F-83, this is the only documentation 
for the F-83system. The book includes 4sections; 1) atutorial to 
the F-83 system; 2) detailed discusion of the Forth kernel; 3) 
Program run utilities; and 4) 8086 specific utilities. This edition 
was published in June, 1985. 

1984 ROCHESTER CONFERENCE PROCEEDINGS 

(Software Management and Engineering) 

The fifth annual Rochester Forth Conference was held June 12-15, 

1985 at the University of Rochester in New York. The Proceedings 
appear as a special 266 page issue of Volume 3 of the Journal of 
Forth Application and Research. A focus of the conference was 
on how to improve software productivity. Invited papers discuss 
the use of Forth in a space shuttle experiment, using Forth in the 
automation of an airport, Forth in the development of MAGIC/L 
and a Forth-based business applicatoins language. The Proceed- 
ings incudes 50 papers and working reports. 

JOURNAL OF FORTH APPLICATION AND RESEARCH V. 3. #1 

This is the latest issue of the Journal and features Forth-based 

laboratory systems and data structures. 

FORML CONFERENCE PROCEEDINGS. 1980 through 1984 

Prices as shown on this order form will increase by $5.00 as of January 

1. 1986. Order now and save on items 310 - 314. 



PUBLICATIONS SURVEY 

If you would like to suggest any other publication for review by 
the FIG Publications committee for inclusion in the Forth Interest 
Group Order Form, please complete the information below and 
return to FIG. 

Title: 

Author; Publisher: 

Comments: 



Your comments on any of the publications we currently carry are 
most welcome, please complete information below. 

Title: 

Comments: 



VolumeVII, No. 4 



23 



FORTH Dimensions 



FORTH INTEREST GROUP 



P.O. BOX 8231 



SAN JOSE, CALIFORNIA 95155 



408/277-0668 



Name 



Company- 
Address _ 
City 



State/Prov. 
Country — 
Phone 



ZIP- 



By. 



OFFICE USE ONLY 

_ Date Type. 



Shipped By 
UPS Wt. 



USPS Wt . 
BO Date _ 
By 



Date. 
Amt.. 
Amt.. 



Wt. 



Amt. 



ITEM 

# 


TITLE 


AUTHOR 


QTY 


UNIT 
PRICE 


TOTAL 


107 










SEE BELOW 























































































































□ Check enclosed (payable to: FORTH INTEREST GROUP) 

□ VISA □ MASTERCARD 

Card # 

Expiration Date 

Signature 



SUBTOTAL 



10% MEMBER DISCOUNT 
MEMBER # 



OA. RESIDENTS SALES TAX 



HANDLING FEE 



$2.00 



MEMBERSHIP FEE $20/27/33 
□ NEW □ RENEWAL 



TOTAL 



PAYMENT MUST ACCOMPANY ALL ORDERS 



MAIL ORDERS 

Send to; 

Forth Interest Group 

P.O. Box 8231 

San Jose, CA 95155 



PHONE OROERS 

Call 408/277-0668 to place 
credit card orders or for 
customer service. Hours: 
Monday-Friday. 9am-5pm 
PST. 



PRICES 

All orders rnust be prepaid. Prices are 
subject to change without notice. Credit 
card orders will be sent and billed at 
current prices. $15 minimum on charge 
orders. Checks must be in USS, drawn 
on a US Bank. A S10 charge will be 
added for returned checks. 



POSTAGE & HANDLING 

Prices include shipping. A 
$2.00 handling tec is 
required with all orders. 



SHIPPING TIME 

Books in stock are shipped 
within five days of receipt 
of the order. Please allow 
4-6 weeks for out-of-stock 
books (delivery in most 
cases will be much sooner). 



SALES TAX 

California deliveries 
add 6%. San Francisco 
Bay Area add 7%. 



11/85 



FORTH Dimensions 



24 



Volume VII, No. 4 



Extending the Multi-Tasker 

Mailboxes 




R. W. Dobbins 
Columbia, Maryland 

The multi-tasker presented by H. 
Laxen^ is an excellent way to harness 
the full power of Forth, particularly 
for real-time applications. It is also an 
adequate starting point for more com- 
prehensive multi-tasking schemes. A 
need often arises in such systems for 
independent tasks to exchange infor- 
mation. In this article, some ideas are 
presented on how the multi-tasker can 
be extended to incorporate inter-task 
communication and cooperation. 

Communication by Mailboxes 

Tasks can communicate in various 
ways. The most obvious method is to 
have one or more common variables 
which tasks use to pass information. 
This would be analogous to using vari- 
ables rather than the stack to pass pa- 
rameters between words. Apart from 
negating much of the true usefulness of 
Forth, this approach causes other dif- 
ficulties: words are difficult to test or 
modify, since dependencies buried in 
the data may be obscure. With multi- 
tasking, these problems become even 
more significant, so a more structured 
approach must be sought. 

The method chosen here uses "mail- 
boxes" to allow tasks to communicate 
in a simple and straightforward fash- 
ion. Assume that a mailbox is initially 
empty and that task A wants to send 
messages to a receiving task B. Ideally, 
each time A sends a message the mail- 
box is empty, while there is always a 
message in the mailbox when B at- 
tempts to fetch one. Unfortunately, 
things rarely work out this well in prac- 
tice. Either A will produce messages 
faster than they can be consumed by B, 
or B will try to fetch messages faster 
than A can produce them. Let us con- 
sider how each of these problems can 
be dealt with. 

If B finds the mailbox empty, it must 
somehow wait until a message arrives 
from A. This is where the original 
multi-tasker comes into play, since we 
can make use of the word PAUSE to 
have B temporarily relinquish control 



until A has deposited a message in the 
mailbox. 

What if A finds a message already in 
the mailbox when wanting to send 
another message? There are several 
possible ways to deal with this prob- 
lem: 

• the sending task pauses until the 
mailbox is cleared 

• the new message replaces the old one 

• messages are stacked in the mailbox 

Each of these strategies may be valid 
in a particular situation and there is no 
clear choice as to which one is "cor- 
rect." However, we will describe the 
first method, since there are some im- 
portant advantages, viz. : 

• simplicity, as demonstrated by the 
Usting 

• efficiency; especially if rewritten in 
assembly language, the overhead 
involved in polling the mailbox is 
very small 

• no elaborate data structures, just a 
single word in memory, so the 
technique can be easily apphed in 
many different situations, even in 
the direct control of I/O devices 

In short, the Forth approach has 
been adopted. Implementations of the 
other schemes are straightforward ex- 
tensions of the basic method. 



: MAILBOX ( define a mailbox variable 
and initialize it ) 

CREATE , DOES> ; 
: SEND ( n MAILBOX ) 

BEGIN PAUSE DUP 

AT 0= UNTIL ! ; 
: RECEIVE ( MAILBOX n ) 

BEGIN PAUSE DUP AT 

?DUP UNTIL ROT ! ; 



MAILBOX is really just a variable 
which holds the message, initially zero. 
SEND waits until the mailbox has been 
cleared, then deposits the new 
message. RECEIVE examines the mail- 
box and waits until a (non-zero) mes- 



sage has arrived before returning with 
the message on the stack. Note that a 
message is "removed" from the mail- 
box, not simply read, so it is not 
possible for a task to mistakenly read 
the same message twice. 

Now, to see these words in action 
consider the following simple but rep- 
resentative problem. You are to sample 
an eight-bit analog-to-digital converter 
(ADC) ten times per second and collect 
approximately 10,000 readings on disk. 
Assume that the word READ has al- 
ready been defined to fetch a value 
from the ADC after a 100 millisecond 
delay. First of all, the following single- 
task solution will not work correctly, 
which is why we are considering multi- 
tasking in the first place. 



1 CONSTANT DATA ( disk block to 

Store data ) 
10 CONSTANT LAST ( last disk 

block ) 
: SAMPLER 

LAST 1+ DATA DO I BLOCK 

1024 OVER + SWAP 

DO READ I C! 

LOOP UPDATE LOOP ; 



The difficulty with this solution is 
that at the end of the loop, data has to 
be written to disk. Quite likely, this will 
take longer than the required 100 mil- 
lisecond sampling period. In fact, 
worse still is that since READ has a 
built-in delay, this solution only works 
if the disk access requires 
approximately zero time! So it is 
apparent that some data will be lost 
with this method and another 
approach must be found. 

In the multi-tasking solution, one 
would have a task to sample the ADC, 
while a second task would handle the 
formatting and writing of the data to 
disk. Th"is approach does not suffer 
from the above problem because while 
the WRITER is busy updating the pre- 
vious disk block, SAMPLER is gathering 
the next sample in parallel: 



Volume Vll, No. 4 25 FORTH Dimensions 



ATTENTION FORTH AUTHORS! 

Author Recognition Program 

To recognize and reward authors of Forth-related articles, the 
Forth Interest Group adopted the following Author Recognition 
Program, effective October 1, 1984. 



Articles 

The author of any Forth-related article published in a periodi- 
cal or in the proceedings of a non-Forth conference is awarded 
one year's membership in the Forth Interest Group, subject to 
these conditions: 

a. The membership awarded is for the membership year 
following the one during which the article was published. 

b. Only one membership per person is awarded in any year, 
regardless of the number of articles the person published in 
that year. 

c. The article's length must be one page or more in the 
magazine in which it was published. 

d. The author must submit the printed article (photocopies 
are accepted) to the Forth Interest Group, including identifica- 
tion of the magazine and issue in which it appeared, within 
sixty days of publication. In return, the author will be sent a 
coupon good for the following year's membership. 

e. If the original article was published in a language other 
than English, the article must be accompanied by an English 
translation. 

f. Articles are eligible under this program only if they were 
first published after October 1, 1984. 



Letters to the Editor 

Letters to the editor are, in effect, "mini-articles," and so 
deserve recognition. The author of any Forth-related letter to an 
editor published in any magazine except Forth Dimensions, is 
awarded $10 credit toward FIG membership fees, subject to 
these conditions: 

a. The credit applies only to membership fees for the mem- 
bership year following the one in which the letter was 
published. 

b. The maximum award in any year to any person will not ex- 
ceed the full cost of the membership fee for the following year. 

c. The author must submit to the Forth Interest Group a 
photocopy of the printed letter, including identification of the 
magazine and issue in which it appeared, within sixty days of 
publication. The author will then be sent a coupon worth $10 
toward the following year's membership. 

d. If the original letter was published in a language other 
than English, the letter must be accompanied by an English 
translation. 

e. Letters are eligible under this program only if they were 
first published after October 1, 1984. 



PRIIVIE FEATURES 

• Execute DOS level commands 
In HS/FORTH, or execute DOS 
and BIOS functions directly. 

• Execute other programs under 
HS/FORTH supervision, 
(editors debuggers file managers etc) 

• Use our editor or your own. 

• Save environment any time 
as .COM or .EXE file. 

• Eliminate headers, reclaim 
space witiiout recompiling. 

• Trace and decompile. 

• Deferred definition, 
execution vectors, case, 
interrupt handlera 




FORTH 



• Full 8087 high level support. 
Full range transcendentals 

(tan sin cos arctan logs exponentials) 

• Data type conversion and 
I/O parse/format to 1 8 
digits plus exponent. 

• Complete Assembler 

for 8088, 801 86, and 8087. 

• String functions - 

(LEFT RIGHT MID LOG COMP 
XCHG JOIN) 

• Graphics & Music 

• Includes Forth-79 and Forth-83 

• File and/or Screen interfaces 

• Segment Management 

• Full megabyte - programs or data 

• Fully Optimized & Tested for: 
IBM-PC XT AT and JR 
COMPAQ and TANDY 1000 & 2000 
(Runs on all true MSDOS 
compatibles!) 

• Compare 
BYTE Sieve Benctimark jan 83 
HS/FORTH 47 sec BASIC 2000 sec 
with AUTO-OPT 9 sec Assembler 5 sec 
other Forths (mostly 64k) 55-1 40 sec 

FASTEST FORTH SYSTEM 

AVAILABLE. 
TWICE AS FAST AS OTHER 
FULL MEGABYTE FORTHS! 

(TEN TIMES FASTER WHEN USING AUTO-OPT!) 

HS/FORTH, complete system only: $270. 
Visa Mastercard i9fe> 



HARVARD 
SOFTWORKS 

P.O. BOX 69 
SPRINGBORO, OH 45066 
(513) 748-0390 



FORTH Dimensions 



26 



Volume VII, No. 4 



MAILBOX SAMPLE 
400 TASK: SAMPLING 
400 TASK: WRITING 
: SAMPLER 

SAMPLING ACTIVATE 

BEGIN READ SAMPLE SEND 

AGAIN ; 
: WRITER 

WRITING ACTIVATE 

LAST 1 + DATA 

DO I BLOCK 

1024 OVER + SWAP 

DO SAMPLE RECEIVE 

I C! LOOP UPDATE 

LOOP STOP ; 



Another benefit of multi-tasking lies 
in the fact that each task can be run 
separately in typical Forth modular 
style, and can thus be tested more easi- 
ly. We can run the SAMPLER to make 
sure that it reads samples correctly, by 
examining the value in SAMPLE from 
the keyboard. Next, WRITER could be 
run and tested on its own. Dummy 
data could be supplied from the 
keyboard and the correct disk access- 
ing could be observed and checked. 
Finally, we can connect the two work- 
ing tasks together via the mailbox and 
we have a working system. Contrast 
this with the original version of 
SAMPLER, which would have been more 
difficult to verify. Bear in mind that 
this is a rather trivial example. In a 
more realistic application, the benefits 
of multi-tasking in the testing and 
debugging process would become even 
more marked. 



References 

1. Laxen, H. "Multi-tasking," Forth 
Dimensions V/4,5 (November/De- 
cember 1983 and January/Febru- 
ary 1984). 

2. Brinch-Hansen, P. Operating Sys- 
tem Principles, Prentice-Hall, 
1973. 




TaskFORTH. 

The First 
Professional Quality 
Full Feature FORTH 
System at a micro price* 

LOADS OF TIME SAVING 
PROFESSIONAL FEATURES: 

★ Unlimited number of tasks 

★ Multiple thread dictionary, 
superfast compilation 

★ Novice Programmer 
Protection Package tm 

★ Diagnostic Tools, quick and 
simple debugging 

★ Starting FORTH, FORTH-79, 
FORTH-83 compatible 

★ Screen and serial editor, 
easy program generation 

★ Hierarchical file system with 
data base management 

★ Starter package $250- Full package $395. 
Single user and commercial licenses available. 

If you are an experienced 
FORTH programmer, this is the 
one you have been waiting for! 
If you are a beginning FORTH 
programmer, this will get you 
started right, and quickly too! 

Available on 8" or 5V* " disk 
In various formats under 
CP/M 2.2 or greater and 
5 'A" MS-DOS 

FULLY WARRANTIED, 
DOCUMENTED AND 
SUPPORTED 



DEALER 
INQUIRIES 
INVITED 



Shaw Laboratories, Ltd. 

24301 Southland Drive, i 216 
Hayward, California 94545 
(415) 276-5953 




©1' ©Mm 



SOTA 

Computing 
Systems 
Limited lets 
you choose 
between either 
the versatile 
(igFORTH model 
or the 
popular 
79 Standard 
Each version is 
available lor a 
number ot pop 
ular computer 
systems 
including 
the IBM PC, 
XT and AT 
(or compa- 
Ubles). the 
TRS-80 
Model I, III 
and 4/'iP, 
or any 
computer system 
running CP/M 
(version 2 x) 
or CP/M Plus 
(version 3 x) 
Whats more, 
SOTA doesn't 





TRS-BO 



the basic FORTH 
system, you are 
'ree to make as 
many copies 
of the com- 
piled FORTH 
system as 
you please 
and 
distribute 
them as 
you wish 
FORTH 
trom 
SOTA IS the 
FORTH of 
choice lor both 
the novice and 
experienced 
programmer 
Make It your 
choice nowi 
Order your 
copy today 

boUi ttae fig 
complete 
at no 



require you 
to enter into 
any awkward 

When you order Irom SOTA 
model and 79 standard come 
with tlie following extra features 
additional charge 

• full featured string handling • assembler • 
screen editor • floating point • double ujurd 
eHtension set • relocating loader ■ beginner's 
tutorial • coinprehensiue programmer s guide 

• eKhaustiue reference manual • unparalleled 

• technical support • source listings • 
• unbeatable price • 



ORDER FORM 



GENTLEMEN: Rush me myor<3eri 

□ Enclosed is my □ check □ money-order 

□ Please till my □ V ISA □ MasterCard I 

for $89 95 I 

Please send me. □ 79 Standard FORTH □ figFORTH model 
for the: 

□ IBM PC DXT DAT (and compatibles) 

□ TRS-80 Model I □ Model III □ Model 4 O Model 4P 

□ CP/M Version 2 X □ CP/M Plus (Version 3 x) 

For CP/M versions please note 5 1/4" formats only and 
please specify computer type 



nflniE: 

STHEET: 

CITY/TOWD: 

STATE: 

CARD TYPE:. 
CARD nO: 



_ZIP: 

.EXPIRY: 



SIGHRTURE: 



ORDER 
TODAY 



213-1Q80 Broughton Street 
IVancouver, British Columbia 
I Canada • V6G 2AB 



Order bu Mail or Phone 

(B01J BBH-5D09 * 



St«t« of th« ^tt since 1981 




Computingjy stems Limited 



IBM, TRS-80 9ivi CP/ri ar* regiffteied tradpmerJtB ol Internetn^rwl 
Business Machine Corporation. Radio Stisck and Digital Rp^parch 



Volume VII, No. 4 



27 



FORTH Dimensions 



Atari Painting Forth 



Stephen James 
Ventura, California 

Paint with, the power of Forth. 
Splash vivid hues with your Atari. 
Create alien worlds and magical king- 
doms — fast and colorful. With the 
Forth source code in this article, you — 
the computer artist — will draw and 
paint beautiful graphics in Atari modes 
3, 5 and 7. Soon you'll find yourself 
composing multicolored displays for 
an adventure game, slide show or ar- 
cade screen. The Forth code includes 
various pens and brushes for designing 
complex graphic art. Pens sketch fine 
lines and brushes add color texture, in 
an infinite variety of color combina- 
tions. 



Where's the Tip? 

Instead of using a camel-hair brush 
to compose dungeon scenes or space 
art, you use the computer's cursor and 
a joystick plugged into port one. An 
artist sets up his drawing board and 
places his pens and brushes in a favor- 
ite spot. Similarly, as you turn on your 
computer easel, the cursor lies in the 
upper left-hand corner of the monitor, 
coordinates 0,0. If this location is not 
handy, change the coordinates in the 
code. 

After setup, the artist might sketch 
or paint a mountain peak in the back- 
ground and a wind-swept lake in the 
foreground. But always, at some point, 
the artist lifts the tip of the pen or 
brush from one spot and moves it over 
the art to another spot. If he didn't lift 
the tip, the picture would be ruined. 
Likewise, your computer tip, displayed 
as a cursor, must sometimes be seen 
but not felt. In other words, you must 
be able to see the tip and move it on the 
monitor, but it must not leave any 
marks. 

This is accomphshed by plotting the 
tip's position with a non-background 
color to visibly locate the tip's posi- 
tion. Before the tip moves to its new 
position, its old position is erased: the 
original color is restored. 



This type of plotting/erasing works 
as long as the plotted color is not the 
same as the position's original color. 
But this is not always the case. When 
the plotted color duplicates the color of 
an underlying forest, stream or build- 
ing, the tip's position hides. 

A flashing technique eliminates this 
problem. Plotting the tip's position 
with one color, then another, and so 
on, produces multiple blinking colors. 
Therefore, it doesn't matter what the 
original color is, because at some time 
during the flashing cycle the cursor's 
color does not match the underlying 
color or texture. 

With the tip's position being com- 
pletely defined, now you can answer, 
"Where's the tip?" TVpe in the Forth 
word TIP. Use the joystick to move the 
tip across the monitor without leaving 
a trace. Then, like an artist, find a spot 
to draw that lake, and set the tip down 
by pressing the joystick's button. 



A Fine Line 

Although it belongs with your art 
supplies, TIP does not draw. But its 
code serves as a seedling for the Forth 
word PEN, which lets you draw with a 
fine line. 

You draw by plotting the tip posi- 
tion, as previously explained, but with- 
out erasing any position to which it 
moves. That way, the plotted color 
remains. By using the joystick, you 
sketch various scenes with vivid color. 
However, as your artistic talent comes 
to life, there will be an abundance of 
color on the screen, making the pen's 
position invisible. 

If you stop drawing for a moment, it 
is hard to determine where the pen is. 
Though you see the moving pen, the 
pen hides when at rest — especially if it 
intersects a Une of the same color. 
Therefore, even PEN uses the flashing 
technique to show the cursor's posi- 
tion. 

In graphic modes 3, 5 and 7, you 
draw with four colors stored in the 
computer's color registers. These are 
accessed by pen. Precede pen with reg- 



ister number 0, 1, 2 or 3, remembering 
that register zero controls background 
color. 

With PEN, you soon find yourself 
drawing monsters and space stations. 
Like TIP, PEN disengages when you 
press the joystick trigger. 

A Wider Spread 

As a computer artist, you fill in 
oceans with shades of blue, grass with 
shades of green and hills with shades of 
brown. But filling shapes with a fine 
line is too slow. A wider spread is 
needed. 

With Forth, you simply trade PEN 
for BRUSH, and splash paint on the el- 
ectronic canvas, using wide strokes. By 
expanding pen into brush, scenes fill 
in fast. Four pixels (the tiny points of 
light on a tv screen) are plotted, instead 
of only one. Thus, BRUSH leaves a trail 
the size of four pixels: two pixels high 
and two pixels wide, twice the width 
and height of the pen line. Note that 
pixel size varies with each graphic 
mode, so fastest filling is done in mode 
3. 

Holding your brush with the key- 
board, you now fill your palette with 
various textures or color patterns. You 
create each texture by placing different 
plot structures within a matrix of pix- 
els, the patterns ranging from subtle to 
vibrant. The images in Figure One 
show sample combinations, although 
an infinite variety is available. 

Along with differing texture struc- 
tures, numerous combinations of the 
four available hues add variety: 



Combination 

1 
2 
3 
4 
5 
6 



Color Values 

and 1 
and 2 

and 3 

1 and 2 

1 and 3 

2 and 3 



Thus, if green is stored in color value 
1 and brown is stored in 2, a color mix 
of green/brown squeezes out of a 
Forth paint tube. 



FORTH Dimensions 



28 



Volume VII, No. 4 



SAMPLE 



THE ERASER 





VERTICAL 
(VBRUSH) 




HORIZONTAL 
(HBRUSH) 




BLOCK 



To experiment, type 1 2 XBRUSH 
while in graphic mode 3, and examine 
the texture. Next, press the joystick 
trigger and examine the texture in other 
modes. Then change the color registers 
preceding XBRUSH. After you have seen 
various color combinations, replace 
the Forth word XBRUSH with VBRUSH 
or HBRUSH to see other textures. 

Solid color spreads are also possible. 
They are a subset of textures, since 
painting with one hue requires a tex- 
ture Forth word. However, the color 
combination consists of duplicate 
colors: 

Combination Color Values 



9 
10 



and 

1 and 1 

2 and 2 

3 and 3 



For example, typing 2 2 XBRUSH 
spreads a solid color consisting of the 
hue stored in color register 2, whereas 
typing 3 3 XBRUSH produces pure regis- 
ter 3. 

Besides solids and two-color tex- 
tures, combining three or four colors 
with unique pixel matrices gives your 
art an added touch. There are endless 
possibilities, only one of which is 
shown in Figure Two. 

The Eraser 

Unlike a water colorist, you will 
erase not only pen marks, but brush 
strokes, too. This is an added benefit 
of computer painting. Just type PEN 
and use the joystick to erase details; 
otherwise, use XBRUSH to erase 
large sections. 



NGS FORTH 

A FAST FORTH, 
OPTIMIZED FOR THE IBM 
PERSONAL COMPUTER AND 
MS-DOS CXMPATIBLES. 



STANDARD FEATURES 
INCLUDE: 



•79 STANDARD 

•DIRECT I/O ACCESS 

•FULL ACCESS TO MS-DOS 
FILES AND FUNCTIONS 

•ENVIRONMENT SAVE 
& LOAD 

•MULTI -SEGMENTED FOR 
LARGE APPLICATIONS 

•EXTENDED ADDRESSING 

•MEMORY ALLOCATION 
CONFIGURABLE ON-LINE 

•AUTO LOAD SCREEN BOOT 

•LINE & SCREEN EDITORS 

•DECOMPILER AND 

DEBUGGING AIDS 

•8088 ASSEMBLER 
•GRAPHICS & SOUND 
•NGS ENHANCEMENTS 
•DETAILED MANUAL 
•INEXPENSIVE UPGRADES 
•NGS USER NEWSLETTER 

A COMPLETE FORTH 
DEVELOPMENT SYSTEM. 



PRICES START AT $70 



KEW<«>HP-150 & HP-110 
VERSIONS AVAILABLE 

m 

NEXT GENERATION SYSTEMS 
P.O.BOX 2987 
SANTA CLARA/ OA. 95055 
(408) 241-5909 



Volume VII, No. 4 



29 



FORTH Dimensions 



The 

FORTH 

Source^"" 

The computer 
language for 
increased. . . 
EFFIOENCY 

reduced 

MEN\ORY 

higher 

SPEED 

Send for your 

FREE 
CATALOG 

Largest selection 
of FORTH. . . 

Books 

Manuals 

Source Listings 

Software 

Development 
Systems 

Expert Systems 

Call or write 

MOUNTAIN VIEW 
PRESS 

PO BOX 4656 
Mountain View, CA 94040 
(415) 961-4103 



Paint Source Code 



With the Forth Paint source code 
listings, you have the foundation for a 
digitized Rembrandt. Venture beyond 
the limits. 

Screen 10 defines various joystick 
constants. Instead of using actual 
numeric values, constants are used to 
increase speed. Lines 2-12 correspond 
to the direction values seen in joystick 
hardware register 632. Push the joys- 
tick up while fetching the value from 
632, and the result will be 14. 

Screen 1 1 defines words that will au- 
tomatically fetch values from the com- 
puter. Even-numbered lines from 2-8 



fetch values related to a joystick's 
column — what direction it leans. 
Odd-numbered lines from 3-9 fetch 
numbers that determine whether or not 
the respective joystick triggers are 
pressed. 

Screen 12 sets a time delay. MSEC 
equates to a fraction of a second. Line 
3 enables the time delay to be a func- 
tion of a user-supplied value placed on 
the stack. Execute 25 MSEC and then 
250 MSEC, and you should be able to 
notice the difference in time delay. 

Screens 13 and 14 provide input for 
updating the x,y coordinates of a joys- 
tick. When this data is any number 
other than zero, the cursor — tied to 
the joystick — moves. Line 3 places a 



Scr 


# 


10 













( 


stick constants 






) 


1 
2 


15 


CONSTANT 


STOP 








3 


14 


CONSTANT 


FD ( 


forward 


) 


4 


14 


CONSTANT 


UP 








5 


13 


CONSTANT 


BD ( 


backward 


) 


6 


13 


CONSTANT 


DN 








7 


7 


CONSTANT 


RT ( 


right 


) 


Q 

o 


1 1 


CONSTANT 


LT ( 


left 


^ 
J 


9 


6 


CONSTANT 


FDRT ( 


f wd-r ght 


) 


10 


5 


CONSTANT 


BDRT ( 


bck-rght 


) 


11 


10 


CONSTANT 


FDLT ( 


f wd-lef t 


) 


12 


9 


CONSTANT 


BDLT ( 


bck-lef t 


) 


13 














14 














15 














Scr 


# 


11 













( 


joystick 


utilities 


) 


1 
2 


» 


OSTICK 


632 C@ 








3 


• 


OSTRIG 


644 C@ 








4 




ISTICK 


633 C@ 








5 


• 


ISTRIG 


645 C@ 








6 


« 


2STICK 


634 C@ 








7 


• 


2STRIG 


646 C@ 








8 




3STICK 


635 C@ 








9 


• 
• 


3STRIG 


647 C@ 








10 














11 














12 














13 














14 














15 















FORTH Dimensions 



30 



Volume VII, No. 4 



fetched joystick value on the Forth 
return stack. Line 4 checks for a joys- 
tick that is in the straight-up position. 
This indicates to the computer that the 
operator wants the cursor movement to 
halt. Thus, when this condition is true, 
the next input for processing is 0,0. 
The cursor moves neither left, right, up 
nor down. Line 5 checks for a forward 
joystick movement. If valid, the y 
coordinate changes so that the cursor 
moves straight up the screen. 

Continuing on screen 14, lines 2-8 
are like the conditional statements of 
screen 13, except diagonal directions 
are checked. Lines 9-10 end the IF 
ELSE statements. Finally, the original 
joystick value is pulled off the return 
stack and dropped. 



Screen 40 defines the paint variables. 
In lines 2-3, STKX and STKY corres- 
pond to the x,y coordinates of the 
joystick's position. They are set to 
X = and y = when the screen is first 
loaded. Lines 5-6 define CLRA (color 
A) and CLRB (color B). CLRA is the vari- 
able which stores the value of the 
chosen pen color. CLRB is a variable 
which stores the second color when 
multi-colored brush textures are used. 
Line 8 defines the variable LOCCLR 
(color location). It stores the value of 
the color pixel that the tip is over. 
Then, when the flashing tip moves to 
another pixel, the original pixel color 
returns. Line 10 defines the word that 
will place the cursor in the upper-left 
corner of the screen. It is a good idea to 



Scr 


# 12 











1 






2 


: MSEC 




3 


( ) DO 




4 


LOOP • 




5 






6 






7 






8 






9 






10 






11 






12 






13 






14 






15 






Scr 


# 13 







( fetch joystick 


coordinates ) 


1 


2 


: OSTKXY ( 


X y ) 


3 


OSTICK >R 


4 


R STOP = IF 





5 


ELSE 




6 


R FD = IF 


-1 


7 


ELSE 




8 


R RT = IF 1 





9 


ELSE 




10 


R BD = IF 


1 


11 


ELSE 




12 


R LT .IF -1 





13 


ELSE 




14 






15 








PolyFORTHII 



the operating system and 
programming language for 
real-time applications involving 
ROBOTICS, INSTRUMENTATION, 
PROCESS CONTROL, GRAPHICS 
and more, is now available for. . . 

IBM PC* 

PolyFORTH II offers IBM PC 
users: 

• Unlimited control tasks 

• Multi-user capability 

• 8087 matfiematics co- 
processor support 

• Reduced application 
development time 

• High speed interrupt 
handling 

Now included at no extra cost; 
Extensive interactive GRAPHICS 
SOFTWARE PACKAGE! Reputed 
to be the fastest graphic package 
and the only one to run in a true 
multi-tasking environment , it 
offers point and line plotting, 
graphics shape primitives and 
interactive cursor control. 

PolyFORTH II is fully supported 
by FORTH, Inc.'s; 

• Extensive on-line 
documentation 

• Complete set of manuals 

• Programming courses 

• The FORTH, Inc. hot line 

• Expert contract programming 
and consulting services 

From FORTH, Inc., the inventors 
of FORTH, serving professional 
programmers for over a decade. 

Also available for other popular 
mini arid micro computers. 
For more information contact: 

FORTH Inc. 



2309 Pacific Coast Hwy, 
Hermosa Beach, 
CA 90254 
213/372-8493 
RCA TELEX: 275182 
Eastern Sales Office 
1300 N. 17th St. 
Arlington, VA 22209 
703/525-7778 

*IBM PC is a registered trademari< of International 
Business Machines Corp. 




VolunneVII, No. 4 



31 



FORTH Dimensions 



FIG-Forth for the Compaq, 

IBM-PC, and compatibles. $35 

Operates under DOS 2.0 or later, 
uses standard DOS files. 



Full-screen editor uses 1 6 x 64 
format. Editor Help screen can be 
caiied up using a single keystroke. 

Source included for the editor and 
other utilities. 

Save capability aliows storing Forth 
with ail currently defined words 
onto disk as a .COM file. 

Definitions are provided to allow 
beginners to use Starting Forth 
as an introductory text. 

Source code Is available as an 
option 



A Metacompiler on a 

host PC, produces a PROM 
for a target 6303/6803 
Includes source for 6303 
FIG-Forth. Application code 
can be Metacomplled v^ith Forth 
to produce a target application 
PROM. $280 

FIG-Forth in a 2764 PROM 

for the 6303 as produced by 

the above Metacompiler. 
Includes a 6 screen RAM-Disk 
for stand-alone operation. $45 

An all CMOS processor 

board utilizing the 6303. 
Size: 3.93 x 6.75 inches. 
Uses 11-25 volts at 12ma, 
plus current required for 
options. $240 - $360 

Up to 24kb memory: 2kb to 16kb 
BAM, 8k PROM contains Forth. 
Battery backup of RAM with off 
board battery. 

Serial port and up to 40 pins of 
parallel I/O. 

Processor buss available at 
optional header to allow expanded 
capability via user provided 
interface board. 



Micro Computer 
Applications Ltd 

8 Newfield Lane 
Neviftown, CT 06470 
203-426-6164 



Foreign ordwi add $6 thipping and handling. 
Connecticut residents add sales tax. 



use ZERO after initializing any grapliic 
mode. 

On screen 41, FLASHSTK flashes the 
tip's position on the monitor. Line 2 
gathers the color that the tip is over by 
using the BASIC-like command 
LOCATE. This color is stored in the vari- 
able LX>CCLR. Lines 3-9 plot a dif- 
ferent color after a twenty-five mil- 
lisecond delay (see msec defined in 
screen 12). This delay is necessary, 
otherwise the color change would be 
too fast for the eye. Lines 10 - 12 en- 
sure that before flashstk ends, the 
original color stored in LOCCLR is 



returned (plotted). That way, when 
you exit from any paint routine, the 
original color is not altered. 

Screen 42 defines tip (tip position), 
which moves the tip on the monitor, 
corresponding to the joystick. Line 3 
begins a loop which will continue UNTIL 
(line 8) the trigger is pressed (line 7). 
FLASHSTK flashes the tip's position, as 
already defined. Line 5 fetches the last 
position of the tip. OSTK leaves the 
latest joystick values on the stack. Line 
6 rotates the stack values for ease of 
manipulation and stores the new joys- 
tick coordinates in STKX and STKY. 



Scr 


# 14 









( continue 




; 


1 








2 


R FDRT = IF 1-1 






3 


ELSE 






4 


R BDRT = IF 1 1 






5 


ELSE 






6 


R BDLT = IF -1 1 






7 


ELSE 






8 


R FDLT = IF -1 -1 






9 


THEN THEN THEN THEN 


THEN 




10 


THEN THEN THEN THEN 


R> DROP 


• 


11 








12 








13 








14 








15 








Scr 


# 40 









( Paint variables 




) 


1 








2 


VARIABLE STKX 






3 


VARIABLE STKY 






4 








5 


VARIABLE CLRA 






6 


VARIABLE CLRB 






7 








8 


VARIABLE LOCCLR 






9 








10 


: ZERO 






11 


STKX ! 






12 


STKY I ; 






13 








14 








15 






— > 



FORTH Dimensions 



32 



Volume VII, No. 4 



Screen 43 defines PEN. Graphic 
modes 3, 5 and 7 give four colors from 
which to choose. This allows four color 
pens for drawing. Note: the color 
value, 0-3, must be placed on the 
Forth stack prior to execution of PEN. 

Screen 44 is left blank, for growth 
purposes. Add your own texture words 
here. 

Screen 45 defines the first textured 
brush stroke, XBRUSH. Instead of one 
value required on the stack (as with 



PEN) two values are needed prior to 
executing XBRUSH. Line 1 stores the 
colors in the associated variables CLRA 
and CLRB. Lines 2-15 consist of a 
loop. Lines 3-10 plot the two colors in 
alternating sequence, flash the brush's 
position and update the joystick's posi- 
tion for movement. All this is perform- 
ed UNTIL the trigger is pressed (lines 14 
and 15). 

Screen 46 is left intentionally blank, 
like screen 44. 



Scr 


# 41 



1 


( flashing stick's position ) 


2 


: FLASHSTK 


3 


STKX ^ STKY LOG LOCCLR ' 


4 


1 COLOR STKX & STKY & PLOT 

X \> XJ V/ Iv tj X A. A \^ lJ X iV X ^ X XJ \J X 


5 


25 MSEC 


6 


2 COLOR STKX & STKY & PLOT 


7 


25 MSEC 


8 


3 COLOR STKX & STKY & PLOT 


9 


25 MSEC 


10 


LOCCLR @ 


11 


COLOR STKX @ STKY @ PLOT 


1 2 


25 MSEC ; 


13 




14 




15 




Scr 


# 42 



1 


( moving tip without marking ) 


2 


: TIP 


3 


BEGIN 


4 


FLASHSTK 


5 


STKX @ STKY @ OSTKXY 


6 


ROT + <ROT + STKX ! STKY ! 


7 


OSTRIG = 


8 


UNTIL ; 


9 




10 




11 




12 




13 




14 




15 


— > 



BRYTE I 
FORTH] 

INTEL I 
8031 

MICRO- 
CONTROLLER! 




FEATURES 

— FORTH-79 Standard Sub-Set 
—Access to 8031 features 
—Supports FORTH and machine 

code interrupt handlers 
—System timekeeping maintains 
time and date with leap 
year correction 
—Supports ROM-based self- 
starting applications 



COST 

130 page manual — $ 30.00 
8K EPROM with manual— $ 100.00 

Postage paid in North America, 
Inquire for license or quantity pricing 



Bryte Computers, Inc. 

P.O. Box 46, Augusta, ME 04330 
(207) 547-3218 



Volume VII, No. 4 



33 



FORTH Dimensions 



Screens 47 - 48 are similar to each 
other and to xbrush, but each 
produces different color textures: 
horizontal and vertical, respectively. 
HBRUSH differs from XBRUSH in the 
absence of lines 5 and 9. VBRUSH dif- 
fers from XBRUSH in the color used in 
lines 7 and 9. 



Let's Paint 

To paint, first load the screen and 
initialize an Atari graphic mode. Type 
ZERO to place the cursor in the upper- 
left corner of the screen. Type TIP and 
move it around with the joystick. 
When finished, press the trigger. Now 
execute 2 pen or another color para- 
meter, and draw on the screen. Again, 
press the trigger when finished with 
this mode. By typing 1 3 XBRUSH, 2 1 
VBRUSH or 2 3 HBRUSH, you can experi- 
ment with the various textures. 

Create worlds filled with fantasy and 
bewilderment. Use the Forth art tools 
as a springboard, and develop new 
color patterns. Expand and imagine! 



Scr 


# 


43 





1 


( 


drawing with a pen 




2 


• 
• 


PEN ( color 


) 


3 


( 


# ) CLRA ! 




4 


CLRA @ COLOR 




5 


BEGIN 




r 





STKX @ STKY @ PLOT 




7 




FLASHSTK 




8 




STKX @ STKY @ OSTKXY 




9 




ROT + <ROT + STKX ! 


STKY ! 


10 


OSTRIG = 




11 


UNTIL ; 




12 








13 








14 








15 








Scr 


# 


44 













1 








2 




( INTENTIONALLY LEFT 


BLANK 


3 








4 




( FOR FUTURE GROWTH ) 


5 
6 








7 








a 








Q 
















1 1 

J. X 








1 2 








13 








14 








1 5 








Scr 


# 


45 







• 
• 


XBRUSH ( clrA clrB 




1 


( 


# ) ( # ) SWAP CLRA 


! CLRB 


2 


BEGIN 




3 




CLRA @ COLOR 




4 




STKX @ STKY @ 


PLOT 


5 




CLRB @ COLOR 




6 




STKX @ 1 + STKY @ 


PLOT 


7 




CLRB @ COLOR 




8 




STKX @ STKY @ 1 


+ PLOT 


9 




CLRA @ COLOR 




10 




STKX @ 1 + STKY @ 1 


+ PLOT 


11 




FLASHSTK STKX @ 


STKY @ 


12 




OSTKXY 2 * SWAP 2 * 


SWAP 


13 




ROT + <ROT + STKX ! 


STKY ! 


14 


OSTRIG - 




15 


UNTIL ; 





FORTH Dimensions 



34 



Volume VII, No. 4 



ocr 




46 






n 










J. 










L 




( INTENTIONALLY LEFT 


BLANK 


o 
J 










1, 
c 




( FOR FUTURE GROWTH ) 


D 

6 










7 










8 










9 










10 










1 1 










12 










13 










1 /. 










i D 










O 


# 


47 






n 


• 
• 


VBRUSH ( clrA cIrB 




1 

X 


( 


# ) ( # ) SWAP CLRA 


! CLRB 


2 


BEGIN 






■J 




CLRA @ COLOR 






A 




STKX @ STKY § 




PLOT 






CLRB @ COLOR 






6 




STKX @ 1 + STKY @ 




PLOT 


7 




CLRA @ COLOR 






8 




STKX @ STKY @ 


1 


+ PLOT 


9 




CLRB @ COLOR 






10 




STKX @ 1 + STKY @ 


1 


+ PLOT 


11 




FLASHSTK STKX 


@ 


STKY @ 


12 




OSTKXY 2 ♦ SWAP 2 


» 


SWAP 


13 




ROT + <ROT + STKX 


! 


STKY ! 


14 


OSTRIG - 






15 


UNTIL ; 







— > 



DASH, FIND 



Our company, DASH, FIND & ASSOCI.ATtS, 
is in the busmess of placing KORTH Program- 
mers in positions suited to their capabilities. 
We deal only with FORTH Programmers 
and companies using FORTH, If you would 
like to have your resume included in our 
data base, or if you are looking for a 
FORTH Programmer, contact us or 
send your resume to; 

DASH, FIND & ASSOCIATES 
808 Dalworth, Suite B 
Grand Prairie TX 75050 
(214) 642-5495 



Committed to Excellence 



Scr 


# 48 







: HBRUSH ( clrA clrB 




1 


(#)(#) SWAP CLRA 


! CLRB 


2 


BEGIN 




3 


CLRA @ COLOR 




4 

5 


STKX @ STKY @ 


PLOT 


6 


STKX @ 1 + STKY @ 


PLOT 


7 


CLRB @ COLOR 




8 
9 


STKX @ STKY @ 1 


+ PLOT 


10 


STKX @ 1 + STKY @ 1 


+ PLOT 


11 


FLASHSTK STKX @ 


STKY @ 


12 


OSTKXY 2 * SWAP 2 » 


SWAP 


13 


ROT + <ROT + STKX ! 


STKY ! 


14 


OSTRIG - 




15 


UNTIL ; 





Volume VII, No, 4 



35 



FORTH Dimensions 



Time-Saving Debugger 

Redefining Words 




Phil Koopman, Jr. 
FPO San Francisco, California 

One of the biggest time wasters in 
writing large Forth programs is the 
compiling delay that occurs whenever a 
word defined near the beginning of the 
dictionary must be changed. The re- 
compilation of the dictionary after a 
redefinition can often take several min- 
utes for a large application. Numerous 
methods have been tried to reduce this 
delay, typically addressing methods to 
speed up the Forth compiler. Most 
methods involve large numbers of ex- 
tra word definitions and significant 
changes to the dictionary structure of 
Forth. 

This article discusses a simple meth- 
od to eliminate the time-consuming 
recompile step after making a minor 
change. Only one screen of source code 
is used, and absolutely no changes to 
the Forth compiler or dictionary struc- 
ture are required. 

The Method 

When a small bug is corrected (us- 
ually involving the definition of only 
one word) all that is needed to make 
the entire program correct is to compile 
the revised definition and somehow 
ensure that all references to the old 
definition are changed to reference the 
revised definition. 

The first way that comes to mind to 
compile the new word is just to compile 
it to the end of the dictionary. This will 
mean that any new word defined will 
use the revised definition, but no previ- 
ously defined words will do so. This 
method fails when the word being 
revised is used by any previously com- 
piled word. 

Another method might be to compile 
the revised definition directly into the 
memory used by the old definition in 
the dictionary. This eliminates all need 
to change words that use the revised 
word, since the location of the defini- 
tion does not change. This method 
works fine unless the revised definition 
is larger than the original definition, 
and therefore will not fit into the dic- 
tionary in the old definition's spot. 



The solution presented in screen 180 
is a combination of the two above 
methods. The technique used is to 
define the revised word at the end of 
the dictionary, then modify the old 
definition so that it merely executes a 
jump to the revised definition. 



How It Works 

The redefinition process is in three 
steps: using redefine to alert the sys- 
tem that a word is to be redefined, 
redefining the word and then using the 
word PATCH to actually put the new 
definition into effect. 

REDEFINE alerts the system that a 
word is about to be redefined. It is used 
in the format 

REDEFINE <name> 
where <name> is the word name to 
be redefined. It saves the PFA of the 
old definition of <name> in the 
variable patchaddr. 

The second step of the redefinition 
process is to define the revised defini- 
tion of < name > . This is usually by 
means of a LOAD, but any means may 
be used. Note that no special words 
within the definition are needed, and 
no editing of screens is required. 

The third step of the redefinition 
process is to use the word PATCH to 
actually patch the old definition to 
point to the revised definition, patch is 
used in the format 

PATCH < name > 

where < name> is the name of the 
revised definition. The name used with 
PATCH is usually the same as the name 
used with redefine, but does not have 
to be. PATCH uses the factored word 
MAKE-PATCH to compile the run-time 
action word < PATCH > into the first cell 
of the old definition's parameter field. 
The PFA of the revised definition is 
stored in the second cell of the old 
definition's parameter field. 

At run time, the word < PATCH > is 
executed by the old definition. 



< PATCH > removes the pointer to the 
old definition from the return stack 
and replaces it with a pointer to the pa- 
rameter field of the revised definition. 
This ensures that any remaining words 
in the parameter field of the old defini- 
tion are ignored, and that the return 
stack is not cluttered up with another 
return address (in case the revised word 
uses an unusual exiting technique or is 
otherwise expecting certain values on 
the return stack). 

Screen 181 shows a very simple test 
that illustrates the ease of use of this 
redefinition facihty. First, the words 
ATEST, BTEST and TEST are defined and 
used. Then the word ATEST is redefined 
and incorporated into the dictionary 
without having to redefine BTEST and 
TEST. Note that the return stack con- 
tents are identical for both the old and 
new versions of ATEST. 



Limitations 

First, this facility is not designed to 
be very "smart." It will be perfectly 
happy to crash if the exact sequence of 
REDEFINE . . . LOAD . . . PATCH is not 
properly used. Also, it only works for 
high-level definitions and will not work 
for code words, constants, variables or 
the like. 

Another limitation is that the word 
redefined must have at least two cells in 
its parameter field. This means that a 
null definition cannot be redefined 
with this system (a null word is in the 
form : NULL ; ). Only one word may 
be redefined in any REDEFINE . . . LOAD 
. . . PATCH sequence. 

FORGETting the redefined word with- 
out also FORGETting the original defin- 
ition can cause the system to crash. 

< PATCH > may have to be redefined 
on systems that pre-increment the IP 
instead of post-incrementing it. The 
change is simply: 



: < PATCH > 
R> 2 + 

@ >R ; 

for a sixteen-bit cell size. 



FORTH Dimensions 



36 



VolumeVII.No. 4 



On the Bright Side 

The words REDEFINE and PATCH pro- 
vide a very quick way to change a word 
definition and examine its results with- 
out recompiling the whole dictionary. 
No change is made in the dictionary 
structure. When the application is fully 
debugged (or when a substantial num- 
ber of bugs have been corrected), the 
application can be recompiled one time 
to clean it up and free the extra space 
used by word redefinitions. Addition- 
ally, multiple redefinitions of the same 
word can be written and quickly tested 
in the context of the entire system 
without recompiling. 

Summary 

The words REDEFINE and PATCH pro- 
vide an extremely simple yet effective 
way to practically eliminate recompile 



time during debugging. This technique 
has provided substantial time savings 
while developing a hotel cash reg- 
ister/control system. The program was 
developed on ECS MVP/FORTH (a 
Forth-79 compatible system) running 
on a well-known 8088-based personal 
computer system. 

Further investigations of redefining 
words might include greater safeguards 
against accidental misuse and simul- 
taneous multiple-word redefinitions. 



Editor's note: This technique is some- 
times referred to as "hotpatching" and 
must be used very carefully, due to the 
problems that can arise when the 
source and object code versions of a 
program differ. 



SCREEN #180 

\ DEBU66ING PATCH WORDS P. KOOPMAN JR. 28DEC84 

1 DECIMAL \ DEFINITIONS IN THE PUBLIC DOMAIN 

2 VARIABLE PATCHADDR \ PFA FOR REDEFINE, USED BY PATCH 

4 : < PATCH > ( -> ) ( ACCEPTS IN-LINE PFA FROM DICTIONARY ) 

5 R> 3 >R ; 
6 

7 : MAKE-PATCH ( PFA-NEW PFA-DLD -> ) 

8 ' < PATCH > CFA OVER ! 2+ ! ; 
9 

10 ! REDEFINE < -> ) ( USA6E: REDEFINE name ) 

11 t COMPILE 3 ' PATCHADDR ! ; 
12 

13 : PATCH ( -> ) ( USABEs PATCH name > 

14 C compile: ' PATCHADDR S MAKE-PATCH j 
15 

SCREEN #181 

\ TEST SCREEN FOR PATCHING PJK 28DECB4 MVP FORTH 

1 DECIMAL 

2 I ATEST . " TOP OF RETURN STACK=" R3 U. CR ; 

3 : BTEST ." BTEST IS AN UNCHANGING WORD IN DEFINITION" CR ; 

4 : TEST CR CR ATEST BTEST CR ; 
5 

6 TEST 
7 

8 REDEFINE ATEST 

9 : ATEST ." THIS IS A REDEFINED ATEST. RS)'=" R® U. CR ; 
10 PATCH ATEST 

11 

12 TEST 
13 

14 
15 



1986 
Rochester 

Forth 
Conference 

June 10-14, 1986 
University of Rochester 
Rochester, New York 

The sixth Rochester Forth 
Conference will be held at 
the University of Rochester, 
and sponsored by the Institute 
for Applied Forth Research, 
Inc. The focus will be on 
RealTime Artificial Intelli- 
gence, Systems and Applica- 
tions. 

Call for Papers 

There is a call for papers on 
the following topics: 

•Real-Time Artificial Intelligence 

•Forth Applications, includ- 
ing, but not limited to: real- 
time, business, medical, 
space-based, laboratory and 
personal systems; and Forth in 
silicon. 

•Forth Technology, including 
meta-compilers, finite state 
machines, control structures, 
data structures. Forth imple- 
mentations and hybrid 
hardware/software systems. 

Papers may be presented in either plat- 
form or poster sessions. Please submit 
a 200 word abstract by March 31st, 1986. 
Papers must be received by April 30th, 
1986, and are limited to a maximum of 
four single spaced, camera-ready pages. 
Longer papers may be presented at the 
Conference but should be submitted to 
the refereed lournal of Forth Application 
and Research. 

Abstracts and papers should be sent to 
the conference chairman: Lawrence P. 
Forsley, Laboratory for Laser Energetics, 
250 East River Road, Rochester, New 
York 14623. For more information, call 
or write Ms. Maria Cress, Institute for 
Applied Forth Research, 478 Thurston 
Road, Rochester, New York 14619 
(716) 235-0168. 



Volume VII, No. 4 



37 



FORTH Dimensions 



A Proposal 

Forth Component Libraries 



John S. James 
Santa Cruz, California 



Forth' s greatest need is for a clean 
way to transport large pieces of pro- 
grams from one developer or installa- 
tion to another. For example, if you 
want to support a particular local-area 
network, or need a file editor, or a 
quicksort, or a B-tree implementation 
for a database, you should be able to 
buy these packages off the shelf. They 
should run identically on Forth-83 or 
Forth-79 or on any system from any 
vendor; and they should be as efficient 
as hand-coded versions, load in a com- 
pletely standard way with no 
"funnies," and never require you to 
see or know their internals. 

This article outlines one approach 
toward this goal of interchangeable 
Forth components. It looks not only at 
sharing code within Forth, but also at 
having Forth programs cooperate with 
those written in other languages, such 
as C. It sketches not only a technology, 
but also standards and conventions 
and business planning necessary to get 
from here to there. 

Readers should note that this article 
presents new work subject to change, 
not a finished product. We consider 
only source-code modules; object-code 
systems such as virtual execution are 
beyond the scope of this article, al- 
though nothing presented here would 
prevent their use. Readers should also 
note that this system is not technology- 
intensive; rather, it uses a little technol- 
ogy to support social conventions and 
practices, which do the main job. 

Technical Basis: Three Legs of a 
Tripod 

The three main technical compon- 
ents of this system are: 

1 . I/O redirection and pipes, provid- 
ed by standard operating systems. 

"Pipes" allow the standard output 
stream of one program to become the 



standard input stream of another. In- 
put or output can come from or to 
another program, or from a file or 
from the terminal, with no change to 
the program. Developers can use pipes 
to string together small programs into 
useful systems, even if the programs 
are written in different languages. 

UNIX has long used pipes as a major 
basis for the library of modules and 
tools which has been largely respon- 
sible for its success. More recently, 
MS-DOS for the IBM PC and 
compatibles has added redirection and 
pipes (version 2.0 and greater). This 
facility can help us not only to 
modularize Forth programs, but also 
to use the great body of software 
already available in other languages. It 
can support development and testing 
even when the final product will run in 
a target environment without an 
operating system. 

Forth offers important advantages 
within non-Forth environments. Com- 
pared to C and other general-purpose 
languages, Forth allows software de- 
velopers to get results faster and less 
expensively. The programs are highly 
efficient and reliable. Interactive ac- 
cess, fast development speed, and com- 
plete control of the system at low or 
high levels give Forth important ad- 
vantages for the job of combining the 
often-incompatible pieces of existing 
software into useful systems. 

2. A module compiler which elimi- 
nates heads not used outside the 
module. 

To start with the smallest advantage, 
eliminating heads saves memory with- 
out the need for target compilation. 
It's just not true that because chips are 
cheap, memory efficiency doesn't 
count any more. Many developers are 
still running up against memory limita- 
tions, for all sorts of reasons. 

This module compiler also helps by 
reducing the confusion caused by too 
many names in the dictionary. When a 
program reaches the size of a thousand 
words or so, it becomes hard to keep 
track of them all, and hard to read 



listings of software which might use 
almost any of them. Using modules 
cleans up glossaries by eliminating 
most of these words, helps standardize 
some of the words which do remain, 
and makes listings more readable by 
controlling the proliferation of names 
which programmers must remember. 

But most important of all, removing 
unwanted heads forces developers to 
think through exactly what facilities 
they want to provide to their users. 
They must offer a complete, explicit set 
of capabilities for some purpose, since 
users will not normally make any 
changes to the source or even look at it. 
No longer can programmers get away 
with half-baked software which re- 
quires tinkering to do anything useful, 
or even to load on someone else's 
system. 

The module compiler separates the 
interface to the world from anything 
that happens inside. The interface must 
be fully documented in a spec sheet for 
the module. Usually this spec sheet will 
be identical for all CPUs, and for all 
versions of Forth and all vendors' 
systems. But within each implementa- 
tion, the developer has complete free- 
dom to use all facilities available to get 
the most efficient code, as long as the 
results match the specifications. 

Modules can call other modules, of 
course. Any such dependencies must be 
documented in the spec sheet. 

3. Generic software design when ap- 
propriate. 

Forth encourages "generic" mod- 
ules which can operate on any data 
structures. For example, a generic 
quicksort can take as arguments the 
address of a Compare operation, the 
address of an Exchange operation, and 
the number of items to be sorted. It can 
then sort any data whatever on which 
these operations can be defined, with 
no change at all to the program. The 
generic design completely separates the 
quicksort logic from everything else — 
the data structures, the operations on 
them, memory management, and so 
on. 



FORTH Dimensions 



38 



Volume VII, No. 4 



This particular example, the generic 
quicksort, is good enough for most 
sorting tasks on randomly-accessed 
data. (MS-DOS and other operating 
systems already have sort utilities for 
text files with variable-length records, 
for which it would be hard to define 
efficient Compare and Exchange oper- 
ations.) The Forth quicksort can hand- 
le any data types in key fields and 
subfields; sort in ascending, descend- 
ing, or mixed sequences; and sort data 
on disk as well as in memory. Thanks 
to the module compiler, this useful 
facility only adds one word, SORT, to 
the dictionary. 



the module is to run on standard sys- 
tems. Instead, the developer can do 
anything for performance — including 
use of code, of course. It may be 
convenient to follow the standard 
when feasible, in order to ease or 
ehminate any changes required to 
make the module run on different 
vendors' implementations of the stan- 
dard. It may also be convenient to 
define a standardized library of code 
modules as they are needed, so that 
most other modules will not need to 
use any code and can be CPU indepen- 
dent without loss of performance. 



but sometimes a particularly valuable 
one because it can give interactive ac- 
cess to software not otherwise interac- 
tive. I believe it will be more productive 
to use standard linkers to combine 
Forth with software components writ- 
ten in other languages, rather than 
providing separate compilation of 
Forth modules into relocatable object 
programs. 



The Library in Business: 
Getting from Here to There 

Forth differs from other program- 
ming languages in that it has only 
rarely had significant institutional 
backing, either from academic or com- 
mercial institutions, but has kept grow- 
ing on its own. Much of the existing 
body of work has been contributed to 
the public domain, often by computer 
professionals working on Forth as a 
sideline or by academics in depart- 
ments other than computer science. 
Often this work has good quality in- 
side, but lacks full development as a 
product. Hence the hobbyist image 
which has hindered Forth; hobbyists 
don't mind chewing on unfinished 
work, because they don't put a price on 
their time. 

Meanwhile, vendors find it hard to 
make much profit on the sale of Forth 
systems. Many users who would gladly 
pay for productization and support 
choose public-domain systems instead, 
in order to get complete source code 
and control of their tools, with no 
strings attached. The lack of profit to 
vendors further impedes the develop- 
ment of polished, easily-used tools, 
completing a vicious circle which has 
slowed the development and accep- 
tance of Forth. 

A module library system can help us 
break out of this dilemma. It allows 
developers to sell application support 
to a larger potential market than other- 
wise, because their work can run 
uniformly and with no tinkering on 
anybody's Forth system. It allows ven- 
dors to compete in the tools and com- 
ponents for building applications, in- 
stead of competing either in raw Forth 



Overcoming the Dialect Problem 

Despite the Forth-83 Standard, the 
fact is that not all Forths are the same. 
And since the standard doesn't cover 
everything, there can be incompatibil- 
ities even within it. 

Of course, the module Hbrary cannot 
abolish these difficulties. But it can be 
independent of them in every major 
way. Each important module in the 
library will have to be modified for 
each different Forth system: Forth-83 
and Forth-79 and, for optimum per- 
formance, for each vendor's system 
and CPU. Usually only minor changes 
will be required; the developer of the 
module, the Forth system vendor, or a 
user can make them. The library, 
which will exist as a set of files, will 
have a different version for each sup- 
ported Forth system; whoever orders a 
module (or the whole library) will need 
to specify which Forth they want it for, 
admittedly an inconvenience. 

But what counts more is that almost 
all modules will have exactly the same 
behavior across all different Forths. 
Each module will have only one spec 
sheet, identical for all kinds of Forth, 
blind to all versions or variations. The 
module compiler separates the inter- 
face from the insides of the module; it 
lets developers hold the interface con- 
stant, while at the same time coding the 
internals for maximum efficiency. 

The internal coding of a module 
need not follow any standard, even if 



On Separate Compilation 

Forth provides separate compilation 
of program components in a way dif- 
ferent from most languages. Normally, 
a compiler produces relocatable mod- 
ules, and a Hnker combines them into 
an object module. Separate compila- 
tion saves compile time, enforces sepa- 
ration between a module's interface 
and its internals, and allows modules 
written in different languages to be 
combined into one program. 

Forth with a module library provides 
these advantages in a different way, 
without the inconvenience and over- 
head of Unking relocatable modules. A 
compiled Forth module does not be- 
come a relocatable file, but instead it 
becomes part of the system itself and 
can be saved with the system, to be 
loaded automatically with it in the 
future. The disadvantage is that you 
cannot rearrange modules into a new 
system without going back, to the 
source code. The advantage is that the 
system which includes the compiled 
module can be an interactive environ- 
ment which can continue to grow. 

Programs written in different lan- 
guages can be combined in several 
ways. Code subroutines in Forth have 
always been common. Pipes and com- 
mand files (batch files) can combine 
separate programs written in different 
languages. And Forth itself can look 
like an ordinary assembly-language 
program to the operating system and 
call subroutines written in other lan- 
guages — not yet a common practice, 



VoiumeVli.No. 4 



39 



FORTH Dimensions 



systems or in finished end-user pro- 
ducts, which is not the right business 
for everyone. 

I'm leaning toward the following 
three-tier pricing structure for a soft- 
ware-component library. The module 
compiler itself (about five screens of 
source code), and perhaps some basic 
support for pipes and I/O redirection, 
should be public domain, so that ven- 
dors can distribute it freely to their 
existing and future customers. These 
parts of the Hbrary will need some 
systems work to interface them to ex- 
isting Forth implementations. The ven- 
dors are in the best position to main- 
tain that code, so it should be as easy as 
possible for them to do so. Forth 
vendors usually own all parts of their 
systems; few would change this policy 
and build in a piece of code owned by 
someone else. 

At the next price level would be a 
package of short, immediately-useful 
modules such as a quicksort, string 
handUng, good file-and-directory sup- 
port, and general interface to other 
operating-system facilities such as 
clock/calendar, or obtaining multiple 
arguments from the program's com- 
mand line. These modules will handle 
the oddities of the operating system, so 
that users will not need to know about 
them. This package of routines would 
be low priced, perhaps in the fifty to a 
hundred dollar range to the end user 
and with no charge for distributing 
object code, so that it would be avail- 
able to hobbyists and also as an out-of- 
pocket purchase by professionals not 
yet able to justify a significant expense 
to their managements. It could be lic- 
ensed and distributed by vendors, and 
would usually serve as the introductory 
package to the library. Forth might 
develop a standard library of tools 
available across different implementa- 
tions, Hke the standard library of C. 

At the high-price end would be pro- 
fessional, apphcation-oriented mod- 
ules such as support for a particular 
local-area network, an optimized 
B-tree or relational database-access 



system, or comprehensive support for 
the special features of a new computer. 
Each of these modules might cost sev- 
eral hundred dollars, with hcensing 
available for unHmited site use, or for 
per-copy or unlimited distribution of 
object code. 

Potential customers for these pack- 
ages will know what they want, have a 
commercial need for it, be able to get 
complete information from the spec 
sheet, and be able to try out the soft- 
ware at a reasonable cost. Note that 
anyone could develop and sell these 
modules directly to users, with or with- 
out going through Forth system ven- 
dors or any central library administra- 
tion. 



If you have any suggestions and/ or 
want to be included on a mailing list 
for news about this system as it devel- 
ops, write to me at P.O. Box 486, 
Santa Cruz, California 95061 USA. 



Advertiser's Index 

Bryte 33 

Dash, Find & Associates 35 
Forth Interest Group 21-24, 26, 44 

Forth Inc. 31 

Forth Institute 37 

Hartronix 2 

Harvard Soft Works 26 

HiTech Equipment 20 

Laboratory Microsystems 18 

MCA 32 

Miller Microcomputer Services 17 

Mountain View Press 30 

New Micros 13 

Next Generation Systems 29 

Parsec Research 4 

Shaw Labs 27 

SOTA 27 



NEW FIG T-SHIRT! 




ORDER YOURS TODAY 1 




ORDER FORM ON PAGE 23 




FORTH Dimensions 



40 



Volume VII, No. 4 



1985 Forth National Convention 



The Forth Interest Group held its 
seventh annual National Convention 
on September 20-21, 1985. The theme 
of the event was "The Forth Elements: 
Earth, Aerospace, Fire and Water." 
Of particular interest to the more than 
five hundred attendees were presenta- 
tions focusing on the current use of 
Forth in space exploration and re- 
search, and in fusion technology. 

The convention began with a panel 
whose members outlined the exciting 
uses of Forth in the aerospace industry. 
Elizabeth Rather of Forth Inc. first 
approached the FIG program commit- 
tee with the idea for this panel, then 
coordinated the speakers with the assis- 
tance of Mary Lindsay and chaired the 
very successful session. Interestingly, a 
large percentage of the audience had 
used Forth professionally within the 
aerospace industry. 

Robert Wood spoke at some length 
during the aerospace portion of the 
program about his training as a space 
shuttle "programmer in space." 
Forth's interactive nature and useful- 
ness in process control has been key to 
the successful completion of certain 
experiments on past shuttle missions, 
and the mission on which he is sched- 
uled to fly will benefit from the im- 
mediacy of having a Forth programmer 
in orbit with the experiments. While 
the exact nature of the mission is 
confidential, positive results are expec- 
ted to make financially feasible the 
production of specific substances too 
costly to obtain in quantity on the 
earth's surface. We will be counting 
down with Robert this Spring, and 
wish him a successful flight. 

Fellow panel members included Hen- 
ry Harris, a missions design and 
operations manager at the Pasadena- 
based Jet Propulsion Laboratory, and 
Greg Schmidt, whose Forth expertise 
has been put to use on the space tele- 
scope. Mr. Harris, who also spoke at 
this year's Rochester Forth Confer- 
ence, detailed a ground-based opera- 
tion controlling instrumentation in the 



space shuttle's cargo bay, principally 
the Shuttle Imaging Radar. The project 
used Forth on six IBM XTs linked via 
Ethernet to provide integrated control 
of the mission. The speaker credited 
Forth as essential to operating in de- 
manding conditions and adjusting 
quickly to critical hardware failures, 
and pointed to the success of the mis- 
sions as a testimony to Forth. When 
the future brings a manned scientific 
platform in space, its roots will at least 
partly He in this important work. 

Paul Heckel, president of Quick- 
View Systems and author of The Ele- 
ments of Friendly Software Design, 
intrigued convention attendees with the 
new software metaphor he has devel- 
oped. His "Zoomracks" concept at- 
tempts to bring to the microcomputer 
industry an infusion of vitality much 
like that created by the "electronic 
spreadsheet" metaphor some years 
ago. Like many fundamentally new 
concepts, this one lures the casual ob- 
server to get hands-on experience, to 
develop a "feel" for the idea's utility. 

A featured event of every year's 
National Convention is the evening 
banquet. This year's keynote speaker 
was Lawrence P. Forsley, editor-in- 
chief of The Journal of Forth Applica- 
tion and Research and computer sys- 
tems group leader at the Laboratory 
for Laser Energetics, where he and the 
staff have used Forth for over nine 
years. He spoke at length on the con- 
trol of a twtenty-four beam laser used in 
fusion research, and showed how Forth 
can be managed on large-scale 
projects. He went on to address Forth's 
viability. Larry pointed out, in 
particular, that Forth's continued pop- 
ularization in coming years will depend 
to a great extent on its penetration into 
academic settings. Others have echoed 
his sentiment that a full-featured Forth 
package should be made available to 
colleges, in particular to engineering 
departments, at a reasonable price. 
Forth has always excelled in such en- 
vironments (witness Stanford Univers- 
ity's engineering course using Forth) 



but it will require a concerted effort to 
reach the needed scale. 

At the same banquet, FIG Secretary 
Kim R. Harris presented the annual 
FIGGY award. Previous recipients of 
the award selected Thea Martin as the 
individual whose volunteer work on 
behalf of the Forth community during 
the year most deserve FIG's recogni- 
tion and gratitude. Thea is the publish- 
er of The Journal of Forth Application 
and Research and serves as a member 
of the board of directors of the Forth 
Interest Group. 

In addition to the well-attended lec- 
ture series, special events at this year's 
convention brought together special 
users groups (e.g., F83, Forth Inc. and 
Mountain View Press), and small 
group discussions about FIG Chapters, 
Forth vendors and establishing Forth 
as a special interest group on a large- 
scale commercial data-base service. 
Frequent tutorials, vendor exhibits and 
hours of informal networking and 
technical discussions rounded out the 
two-day affair. 

— Marlin Ouverson 



Volume VII, No. 4 



41 



FORTH Dimensions 




U.S. 



• ALABAMA 

Hunlsville FIG Chapter 

Call Tom Konantz 
205/881-6483 

• ALASKA 

mbKodiak Area Chapter 

Call Horace Simmons 
907/486-5049 

• ARIZONA 

Phoenix Chapter 

Call Dennis L. Wilson 
602/956-7678 

lUcson Chapter 

Twice Monthly, 

2nd & 4th Sun., 2 p.m. 

Flexible Hybrid Systems 

2030 E. Broadway #206 

Call John C. Mead 

602/323-9763 

• ARKANSAS 

Central Arkansas Chapter 

Twice Monthly, 2nd Sat., 2p.m. & 
4th Wed., 7 p.m. 
Call Gary Smith 
501/227-7817 

• CALIFORNIA 

Los Angeles Chapter 

Monthly, 4th Sat., 10 a.m. 
Hawthorne Public Library 
12700 S. Grevillea Ave. 
Call Phillip Wasson 
213/649-1428 

Monterey /Salinas Chapter 

Call Bud Devins 
408/633-3253 

Orange County Chapter 

Monthly, 4th Wed., 7 p.m. 
Fullerton Savings 
Talbert & Brookhurst 

Fountain Valley 
Monthly, 1st Wed., 7 p.m. 
Mercury Savings 
Beach Blvd. & Eddington 
Huntington Beach 
Call Noshir Jesung 
714/842-3032 

San Diego Chapter 

Weekly, Thurs., 12 noon 
Call Guy Kelly 
619/268-3100 ext. 4784 

Sacramento Chapter 

Monthly, 4th Wed., 7 p.m. 
1798-59th St., Room A 
Call Tom Ghormley 
916/444-7775 



Bay Area Chapter 

Silicon Valley Chapter 
Monthly, 4th Sat. 
FORML 10 a.m.. Fig 1 p.m. 
ABC Christian School Aud. 
Dartmouth & San Carlos Ave. 
San Carlos 

Call John Hall 415/532-1115 
or call the FIG HotUne: 
408/277-0668 

Stockton Chapter 

Call Doug Dillon 
209/931-2448 

• COLORADO 

Denver Chapter 

Monthly, 1st Mon., 7 p.m. 
Call Steven Sams 
303/477-5955 

• CONNECTICUT 

Central Connecticut Chapter 

Call Charles Krajewski 
203/344-9996 

• FLORIDA 

Orlando Chapter 

Every two weeks. Wed., 8 p.m. 
Call Herman B. Gibson 
305/855-4790 

Southeast Florida Chapter 

Monthly, Thurs., p.m. 
Coconut Grove area 
Call John Forsberg 
305/252-0108 

Tampa Bay Chapter 

Monthly, 1st. Wed., p.m. 
Call Terry McNay 
813/725-1245 

• GEORGIA 

Atlanta Chapter 

Call Ron Skelton 
404/393-8764 

. ILLINOIS 

Cache Forth Chapter 

Call Clyde W. PhiUips, Jr. 
Oak Park 
312/386-3147 

Central Illinois Chapter 

Urbana 

Call Sidney Bowhill 
217/333-4150 

Fox Valley Chapter 

Call Samuel J. Cook 
312/879-3242 

Rockwell Chicago Chapter 

Call Gerard Kusiolek 
312/885-8092 

• INDIANA 

Central Indiana Chapter 

Monthly, 3rd Sat., 10 a.m. 
Call John Oglesby 
317/353-3929 



Fort Wayne Chapter 

Monthly, 2nd Wed., 7 p.m. 
Indiana/Purdue Univ. Campus 
Rm. B71, Neff Hall 
Call Blair MacDermid 
219/749-2042 

• IOWA 

Iowa City Chapter 
Monthly, 4th Tlies. 
Engineering Bldg., Rm. 2128 
University of Iowa 
Call Robert Benedict 
319/337-7853 

Central Iowa FIG Chapter 

Call Rodrick A. Eldridge 
515/294-5659 

Fairfield FIG Chapter 

Monthly, 4th day, 8:15 p.m. 
Call Gurdy Leete 
515/472-7077 

• KANSAS 

Wichita Chapter (FIGPAC) 

Monthly, 3rd Wed., 7 p.m. 
Wilbur E. Walker Co. 
532 Market 
Wichita, KS 
Call Arne Flones 
316/267-8852 

• LOUISIANA 

New Orleans Chapter 

Call Darryl C. Olivier 
504/899-8922 

• MASSACHUSETTS 

Boston Chapter 

Monthly, 1st Wed. 
Mitre Corp. Cafeteria 
Bedford, MA 
Call Bob Demrow 
617/688-5661 after 7 p.m. 

• MICHIGAN 

Detroit Chapter 

Monthly, 4th Wed. 
Call Tom Chrapkiewicz 
313/562-8506 

• MINNESOTA 
MNFIG Chapter 

Even Month, 1st Mon., 7:30 p.m. 
Odd Month, 1st Sat., 9:30 a.m. 
Vincent Hall Univ. of MN 
Minneapohs, MN 
Call Fred Olson 
612/588-9532 

• MISSOURI 

mbKansas City Chapter 
Monthly, 4th Tues., 7 p.m. 
Midwest Research Inst. 
Mag Conference Center 
Call Linus Orth 
816/444-6655 



St. Louis Chapter 

Monthly, 1st Tues., 7 p.m. 
Thornhill Branch Library 
Contact Robert Washam 
91 Weis Dr. 
EllisviUe, MO 63011 

• NEVADA 
Southern Nevada Chapter 

Call Gerald Hasty 
702/452-3368 

• NEW HAMPSHIRE 
New Hampshire Chapter 

Monthly, 1st Mon., 6 p.m. 
Armtec Industries 
Shepard Dr., Grenier Field 
Manchester 
Call M. Peschke 
603/774-7762 

• NEW MEXICO 
Albuquerque Chapter 

Monthly, 1st Thurs., 7:30 p.m. 
Physics & Astronomy Bldg. 
Univ. of New Mexico 
Call Rick Granfield 
505/296-8651 

• NEW YORK 
FIG, New York 

Monthly, 2nd Wed., 8 p.m. 
Queens College 
Call Ron Martinez 
212/517-9429 

Rochester Chapter 

Bi-Monthly, 4th Sat., 2 p.m. 
Hutchinson Hall 
Univ. of Rochester 
Call Thea Martin 
716/235-0168 

Rockland County Chapter 

Call Elizabeth Gormley 
Pearl River 
914/735-8967 

Syracuse Chapter 
Monthly, 3rd Wed., 7 p.m. 
Call Henry J. Fay 
315/446-4600 

• OHIO 

Athens Chapter 

Call Isreal Urieli 
614/594-3731 

Cleveland Chapter 

Call Gary Bergstrom 
216/247-2492 

Cincinatti Chapter 

Call Douglas Bennett 
513/831-0142 

Dayton Chapter 

TVice monthly, 2nd Tlies., & 

4th Wed., 6:30 p.m. 

CFC 11 W. Monument Ave. 

Suite 612 

Dayton, OH 

Call Gary M. Granger 

513/849-1483 



FORTH Dimensions 42 Volume VII, No. 4 



• OKLAHOMA 

Central Oklahoma Chapter 

Monthly, 3rd Wed., 7:30 p.m. 
Health Tech. Bldg., OSU Tech. 
Call Larry Somers 
2410 N.W. 49th 
Oklahoma City, OK 73112 

• OREGON 

Greater Oregon Chapter 

Monthly, 2nd Sat., 1 p.m. 
Tektronix Industrial Park 
Bldg. 50, Beaverton 
Call Tom Almy 
503/692-2811 

• PENNSYLVANIA 

Philadelphia Chapter 

Monthly, 4th Sat., 10 a.m. 
Drexel University, Stratton Hall 
Call Melonie Hoag 
215/895-2628 

• TENNESSEE 

East Tennessee Chapter 

Monthly, 2nd Tue., 7:30 p.m. 
Sci. Appl. Int'l. Corp., 8th Fl. 
800 Oak Ridge Thrnpike, Oak Ridge 
Call Richard Secrist 
615/693-7380 

• TEXAS 

mbAustin Chapter 

Contact Matt Lawrence 
P.O. Box 180409 
Austin, TX 78718 

Dallas/Ft. Worth 
Metroplex Chapter 

Monthly, 4th Thurs., 7 p.m. 
Call Chuck Durrett 
214/245-1064 

Houston Chapter 

Call Dr. Joseph Baldwin 
713/749-2120 

Periman Basin Chapter 

Call Carl Bryson 

Odessa 

915/337-8994 

• UTAH 

North Orem FIG Chapter 

Contact Ron Tanner 
748 N. 1340 W. 
Orem, UT 84057 

• VERMONT 

Vermont Chapter 

Monthly, 3rd Mon., 7:30 p.m. 
Vergennes Union High School 
Rm. 210, Monkton Rd. 
Vergennes, VT 
Call Don VanSyckel 
802/388-6698 



• VIRGINIA 

First Forth of Hampton Roads 

Call William Edmonds 
804/898-4099 

Potomac Chapter 

Monthly, 2nd Tues., 7 p.m. 
Lee Center 

Lee Highway at Lexington St. 
Arlington, VA 
Call Joel Shprentz 
703/860-9260 

Richmond Forth Group 

Monthly, 2nd Wed., 7 p.m. 
154 Business School 
Univ. of Richmond 
Call Donald A. Full 
804/739-3623 

• WISCONSIN 

Lake Superior FIG Chapter 

Call Allen Anway 
715/394-8360 

MAD Apple Chapter 

Contact Bill Horzon 
129 S. Yellowstone 
Madison, WI 53705 



FOREIGN 

• AUSTRALIA 

Melbourne Chapter 

Monthly, 1st Fri., 8 p.m. 
Contact Lance Collins 
65 Martin Road 
Glen Iris, Victoria 3146 
03/29-2600 



Sydney Chapter 
Monthly, 2nd Fri., 7 p.m. 
John Goodsell Bldg. 
Rm. LG19 

Univ. of New South Wales 
Sydney 

Contact Peter Tregeagle 
10 Binda Rd., Yowie Bay 
02/524-7490 



• BELGIUM 

Belgium Chapter 

Monthly, 4th Wed., 20:00h 
Contact Luk Van Loock 
Lariksdreff 20 
2120 Schoten 
03/658-6343 



Southern Belgium FIG Chapter 

Contact Jean-Marc Bertinchamps 

Rue N. Monnom, 2 

B-6290 Nalinnes 

Belgium 

071/213858 



• CANADA 

Nova Scotia Chapter 

Contact Howard Harawitz 
227 Ridge Valley Rd. 
Halifax, Nova Scotia B3P2E5 
902/477-3665 



Southern Ontario Chapter 

Quarterly, 1st Sat., 2 p.m. 
General Sciences Bldg., Rm. 312 
McMaster University 
Contact Dr. N. Solntseff 
Unit for Computer Science 
McMaster University 
Hamilton, Ontario L8S4KI 
416/525-9140 ext. 3443 



Toronto FIG Chapter 

Contact John Clark Smith 
P.O. Box 230, Station H 
Toronto, ON M4C5J2 



• COLOMBIA 

Colombia Chapter 

Contact Luis Javier Parra B. 
Aptdo. Aereo 100394 
Bogota 
214-0345 



• ENGLAND 

Forth Interest Group — U.K. 

Monthly, 1st Thurs., 
7p.m., Rm. 408 
Polytechnic of South Bank 
Borough Rd., London 
D.J. Neale 
58 Woodland Way 
Morden, Surry SM4 4DS 

• FRANCE 

French Language Chapter 

Contact Jean-Daniel Dodin 
77 Rue du Cagire 
31100 Toulouse 
(16-61)44.03.06 



• GERMANY 

Hamburg FIG Chapter 

Monthly, 4th Sat., I500h 
Contact Horst-Gunter Lynsche 
Common Interface Alpha 
Schanzenstrasse 27 
2000 Hamburg 6 



• HOLLAND 

Holland Chapter 

Contact: Adriaan van Roosmalen 
Heusden Houtsestraat 134 
48)7 We Breda 
31 76 713104 



FIG des Alpes Chapter 

Contact: Georges Seibel 
19 Rue des Hirondelles 
74000Annely 
50 57 0280 



• IRELAND 

Irish Chapter 

Contact Hugh Doggs 
Newton School 
Waterford 

051/75757 or 051/74124 



• ITALY 
FIG Italia 

Contact Marco Tausel 
Via Gerolamo Forni 48 
2016) Milano 
02/645-8688 



• JAPAN 

Japan Chapter 

Contact Toshi Inoue 
Dept. of Mineral Dev. Eng. 
University of Tokyo 
7-3-1 Hongo, Bunkyo 113 
812-2111 ext. 7073 



• REPUBLIC OF CHINA 
R.O.C. 

Contact Ching-Tang Tzeng 
P.O. Box 28 
Lung-Tan, Taiwan 325 



• SWITZERLAND 

Swiss Chapter 

Contact Max Hugelshofer 
ERNI & Co., Elektro-Industrie 
Stationsstrasse 
8306 Bruttisellen 
01/833-3333 



SPECIAL GROUPS 



Apple Corps Forth Users 
Chapter 

Twice Monthly, 1st & 

3rd Tues., 7:30 p.m. 

1515 Sloat Boulevard, #2 

San Francisco, CA 

Call Robert Dudley Ackerman 

■415/626-6295 

Baton Rouge Atari Chapter 

Call Chris Zielewski 
504/292-1910 

FIGGRAPH 

Call Howard Pearlmutter 
408/425-8700 



Volume VII, No. 4 



43 



FORTH Dimensions 



NOW AVAILABLE 




— - The Journal of 

Forth 

Application and 
Research 



VolLinic 3 Niiiiibei 2 1985 



Pioceedinys of the 
1985 Rochester Forth Conference 



$2000 

FROM THE FORTH INTEREST GROUP 



FORTH INTEREST GROUP 

p. O. Box 8231 

San Jose, CA 95155 



BULK RATE 
U.S. POSTAGE 

PAID 
Permit No. 3107 
San Jose, CA 



Address Correction Requested