FORTH DIMENSIONS FROM CLEPSYDRAS TO NEURAL NETS - ROBERT GARIAN 6 A water closet is a simple, on-off feedback control system much like that of neurons. This code models the system underlying a flushing toilet, implementingthe logic with embedded computations as a set of produc tion rules, a natural style for building complex causal models. SOVIET FORTH-INFO - DAVID KIPPING I1

The author visited the Soviet Union as part of a multi-disciplinary delegation. One study site was Forth-Info, a co- , op specializing in Forth. Like much in the U.S.S.R., nothing about this "private" company is simple, like profiting in a country with no copyrights! ARRAYS IN FORTH - LEONARD MORGENSTERN 13 In Forth, it can be easier to invent something that exactly suits one's needs than to conform to a standard method. But beginners often ask, "Why doesn't Forth have arrays?" Learn the common methods of defining arrays, and then some! FORST: A 68000 NATIVE-CODE FORTH - JOHN REDMOND I6 The "late binding" of deferred words lends flexibility to compiled code, but involves run-time decisions. Where these I can take place at compile time, try ForST's configurable, new "vectored word." This is the last of a five-part series. FORML XII: FORTH IN INDUSTRY - NEIL BAWD 20 Regular as the tides but far less predictable, FORML-goers gathered again in Pacific Grove, California last fall. Many of the typically belief-challenging, concept-stretching,water-testing, and otherwise mind-bending technical discus- sions were also marked by an upbeat mood about Forth's performance in today's marketplace. PENCIL-AND-PAPER ARITHMETIC - JJ. MARTENS 22 F83 users get an amusing glimpse at a floating-point experiment that really isn't. It exploits an innocent little word DPL and returns a surprising and interesting result--but it's not the real McCoy! INTERNATIONAL GENIE ACCESS - DENNIS RUFFER 26 GE Information Services is reaching into more countries, and so is its Forth RoundTable. Access information, sign- up fees, and connect charges are given here, as well as new cost-saving features that affect all users of the network. FORTH DAY 1990 - C.H. TING 30 Two enthusiastic chapters of the Forth Interest Group teamed up to host a local day-long Forth conference. The best and the brightest held forth to stimulate their audience and to share the latest. Here is a recap of the event.

METACOMPILATION MADE EASY - FRANK SERGEANT 31 That is, easier to understand and easier to implement. Most languages separate the compiler from its results. Forth is different, its compilers extend the current Forth system rather than creating an independent system. This author builds P on the work of crnFORTH. Editorial Advertisers Index Welcome New Members 4 27 39 President's Letter Reference Section FIG Chapters 5 28 42A3 Best of GEnie Author Recognition 24 38

VolumeXll. Nwnber 6 3 Forth Dimemiom Forth Dimensions Published by the Forth Interest Group Volume XII, Number 6 An important notice to each of yo* lective thanks for Bob's innumerable con- March/Aprill991 Beginning with the next issue, your tributions. Editor membership in the Forth Interest Group By the way, Mike Perry has agreed to MdiOuverson will be handled differently. If you re- serve again next year as FORML's pro- Advertising Manuger newed your membership late in previous gram chairman. This year's event was a hot Kent Safford years, the FIG office would send any ticket, and is recapped in condensed form in Design and Production issues you might have missed and your this issue by the inimitable Neil Bawd. Berglund Graphics membership would still expire at the end I * * * Circulation/Order Desk of April. The Board of Directors has Call for Authors! Anna Brereton elected to change that procedure; your We are looking for more Forth authors membership will now start with the next to share their discoveries, expertise, and issue to be printed after your dues are opinions with the rest of us. Many of our Forth Dimensions welwmes editorialmate- received, and will expire a year later. So long-time contributors are finding increas- rial, letters to the editor, and comments from its be sure to renew on time--€he only other ing opportunities to get published in gen- readers. No r,esponsibiity is assumed for accu- way to get our next issue will be to pay the eral computing magazines-a welcome racy of submissions. new cover price of $10. reminder that the public is interested in Subscription to Forth Dimensions is in- Along with the cover price, the cost of Forth-but we still need to keep Forth Di- cluded with membership in the Forth Interest membership has increased for the first Group at $40 per year ($52 overseas air). For time in five years. The Board of Ditors mensions' coffers full of interesting and challenging articles, too. So write to tell us membership, change of address, and to submit deemed it necessary in order to keep up items for publication, the address is: ForthInter- about your latest experiment, how to im- the standards of quality and service that est Group, P.O. Box 8231, San Jose. California press our C-going friends, or about an the Forth community needs so much. You 95155. Administrative offices and advertising improvement to a previous article's ap- should have received your renewal notice sales: 408-277-0668. proach (who has a better interrupt handler in the mail by now, offering (only to Copyright Q 1991 by Forth Interest Group, or DMA scheme, anyway?). Your work current members) a limited-time renewal Inc. The material contained in this periodical will be in good company, too-we are at last year's lower rates. But that offer (but not the code) is copyrightedby the individ- anticipating new contributions from some must expire before April 1, so be sure to ual authors of the articles and by Forth Interest of our favorite Forth authors of recent take advantage of it right away. (Or use Group. Inc., respectively. Any reproduction or years. the mail-order form in the centerfold.) use of this periodical as it is compiled or the ar- In addition to purely technical writing, We earnestly hope you will renew ticles. except reproductions for non-commer- we are looking for someone to collect andl cial purposes, without the written permission of now, and that you will help us to guide and or edit Forth-related news items for FD. Forth Interest Group, Inc. is a violation of the shape the Forth Interest Group this year. Are you plugged into the working Forth Copyright Laws. Any wde bearing a copyright And you won't want to miss the exciting, world? Do you know who got hired or notice, however. can be used only withpermis- upcoming issues of Forth Dimensions, promoted, what new product has just been sion of the copyright holder. either! * * * released, which company landed a juicy contract, and how many programmers it About the Forth Interest Group A new Board of Directors of FIG was really took to screw in that light bulb? We The Forth Interest Group is the association installed at the 1990 FORML conference. are looking for news sources, too, so even if of programmers. managers, and engineers who The new President--and a familiar name you don't want to author a column, send create practical, Forth-based solutions to real- to many FIG members-is John D. Hall. your latest scoop to the FIG office or to world needs. Many research hardware and soft- We wish him all the best in his position of MARLIN.0 on GE Mail. And include your ware designs that will advance the general state of the art. FIG provides a climate of intellectual responsibility. We know he is counting on own legible name, address, and telephone exchange andbenefits intended to assist eachof active participation and lots of input from number--on the record or off, we have to its members. Publications. conferences, semi- the membership, but you can read all confm items to be printed. nars, telecommunications, and area chapter about that in John's letter elsewhere in Finally, let me restate that FD is a meetings are among its activities. this issue. reader-created publication without inten- Robert Reiling, retiring as long-time tional technical biases or covert agendas. President and head of the FIG Business We are entirely shaped-every issue--by "Forth Dimensions (ISSN 0884-0822) is Group, will continue directing the the letters, articles, and programming published bimonthly for $34140146 per year by FORML conference. His steadying hand styles of our readers. I encourage you to the ForthInterest Group, 1330S. Bascom Ave., has guided FIG through some rocky wa- join us in the process of making the next Suite D. San Jose. CA 95128. Second-class ters over the years, and we are glad his year of FD the most relevant, important, postage paid at San Jose. CA. POSTMASTER: able direction will still be part of the and valuable one yet. Send address changes to Forth Dimemwns, scene. The entire corps of FIG volunteers --Marlin Ouverson P.O. Box 8231. San Jose. CA 95155." and other contributors expresses its col- I Forth Dimensions 4 Volume XII, Nwnber 6 I LETTERFROM THE PRESIDENT

kllow FIG members. I would like to take this opportunity to thank the members "...Beyond His Call to Duty" of the Board of Directors for their vote of confidence in electing me as your presi- The Forth Interest Group-being a volunteer organization means that people give dent. I will try my best to live up to the trust of their time and energy to support the organization. It is often expected and too often which has been placed in me. I am deter- unrewarded. Yet there are some who give beyond what is expected, some who seem mined to work diligently to provide the to not be satisfied with the normal, some who seek out the lost and provide help, some leadership necessary for FIG to continue to who provide for providing's sake without thought of reward. improve its services to you its membership, Each year since 1979, one person from the Forth community is selected to be to improve the image of the Forth commu- recognized from the many who are in the category of having "Contributed Beyond nity, and to expand the awareness of Forth. their Call to Duty" toward the support of the Forth Interest Group. The group of other I would also like to again thank Robert so-recognizedpeople, known as The FIGGY's, chooses to honor, and therefore drafts Reiling for the fine job he has done, and for into its ranks, the one who in their opinion conspicuously stands out in this category. the many hours of volunteer time he has The FIG RoundTable on GEnie has grown over the last five years and has donated over the past six years serving as provided another communication channel besides Forth Dimensions between FIG president. His work as president inspired members and others in the Forth community. The difficult and demanding part of many of the improvements we are now providing this form of communication is the job of being a Sysop. The energy and beginning to see emerge in the organiza- spirit of the Sysop is reflected directly in the energy and spirit of the network. The job tion. As aresult of these efforts, my job will on GEnie is so demanding that several Sysops are required, and the Sysops of GEnie be a little easier, yet I will have to workvery hold one of their own in great esteem. hard to fill the shoes he is leaving behind. So, for his tireless efforts as Sysop of the FIG RoundTable on GEnie, and for his Thanks again, Bob. patience for the last four years as producer and host of the Thursday nights "Figgy As for myself, I intend to use the Bars" on GEnie, The FIGGY's have selected and would like to present to you: President's Letter as a means to communi- cate to you what is going on at the interna- tional FIG Board and at the FIG business 1990 FlGGY of the Year meetings. Many decisions are made each month which affect all of you as FIG Gary Smith members and indirectly affect you as Forth users. It is important that you are made aware of the issues and take an active role in the decision-making process. You can much more back than you put in. who will be sympathetic and help cham- have an impact on these decisions, prefera- To start, a new Board of Directors has pion your ideas. bly by volunteering to serve on or chair a been formed and has begun its job of The Board of Directors is more diverse committee dealing with the issues you are reshaping the image of FIG. The board's geographically than it has ever been. Of the most concerned with, or at a minimum by job is to set the "tone," or as I call it the seven members, three are from northern providing feedback to me and the other "image," of the Forth Interest Group; but California-Silicon Valley; two are from officers or board members on these issues being the Board of Directors of FIG, they southern California; one from British Co- so that decisions can be made with a first- have the absolute final wordon its functions lumbia, Canada, and one from Boston, hand knowledge of what the membership and are the highest authority in FIG if you Massachusetts. Dr. C.H. Ting and David wants out of this organization. This is your need to appeal to them for action. Call them Petty are new Board members; Wil Baden, organization, ensure that it serves you by ' and pass on to them your ideas. Of the Dennis Ruffer, and John Hall have served getting involved; I guarantee you will get seven, you will certainly find one or several (Continued on page 38.)

Volume XII, Number 6 5 Forth Dimemiom FROM CLEPSYDRAS TO NEURAL NETS ROBERT GARIAN - ARLINGTON, VIRGINIA =

cans are known to have used water in crude \ From clepsydras to neural nets. 10122190 clocks. They would place a small, leaky \ Written in HSJForth 3.4, uses coprocessor h C6A canoe or similar object in a bowl of water so \ R. Garian. Forth Dimensions that its sinking marked a certain period of \ Requires the GRRPHICS and FLOATVAR extensions time, just like an hourglass. The clepsydra (invented around 250 B.C.) was a bowl or DECIHAL FINIT FLOATS pot, filled with water, that had a column of ( DIHENSIONS ARE IN INCHES AND SECONDS : 1 marks along the inside, so that the water i Length of tank 1 X 19.0 RBOVAR LENGTH level would act as an indicator of approxi- I Width of tank 1% 7.0 R80VAR WIDTH mate time. The first jewelled timepiece is ( Hax level 1 X 10.0 RBOVAR HZ thought to have been a clepsydra whose orifice was a precious stone with a hole i Rest level 1 X 7.0 RBOVAR HI drilled in it. i llin level 1 X 2.0 RBOVAR HO ( Full volure 1 X 0.0 RIOVAR FULL ( Flapper radius ) X 1.0 RBOVAR R 1 it is easy ... to build ( Grav. accel. 1 Z 0.0 RBOVAR G i Current level 1 X 0.0 HBOVAR H a logic circuit out of i Area of opening i X 0.0 RBOVAR AREA flush toilets. i Elapsed tine 1 X 0.0 RBOVAR TIHE ( Time step 1 X 0.0 RBOVAR DT i Current outflow 1 X 0.0 HBOVAR DUTFLDH The flush toilet may be a descendant of ( Current inflow 1 X 0.0 RBOVRR INFLOM the clepsydra. The modem toilet is little i Flapper leak ! X 0.0 RBOVAR FLAPLEAK changed from the ancient Roman ones ( Valve leak i X 0.0 RBOVAR VALVLEAK which had floats and stoppers. ( Current volume 1 X 0.0 RBOVAR VOLUHE A water closet or toilet system is actu- ( Tiee factor 1 X 0.0 RIOVAR ALPHA ally a simple control system (classified as i Height factor 1 X 0.0 RIOVARBETA an on-off feedback control system). The i Finishing tine 1 X 0.0 RIOVAR FINISH parts of a control system are: a sensor (a measuring device), a controller, and a plant i States 1 -1 VAH ON (the object that you want to control). The ( " i 0 VAR OFF idea is that the measuring device provides i " 1 -1 VAR UP the controller with the current value of i" 1 O VAR DOWN some plant variable so that it can generate a in 1 -1 VAR RISING corrective value to the plant. i " 1 0 VAR FALLING The chain of events that takes place in a i Objects 1 0 VAR FLOkT toilet system are automatic: once started, ( 1 O VAR FLAPPER the system cycles and resets itself. In con- " trol terms, the float is the sensor or measur- in 1 0 VAR VALVE ing device: its vertical position tells the valve (the controller) when to turn on and when to shut off. The lever, linkage, and

I Forth Dimensions 6 Volume XII, Nwnber 6 flapper are used to initiate the operational cycle of the toilet system. The cycle is over Time = 100.00000 Volume = 1216.3721 and the system reset when the valve has Flapper is down Valve is off shut off. At some point during the filling Time step = 1.0000000 part of the cycle, it will become possible to force an early cycle. In addition to the primary control sys- tem, there is another: the ovefflow pipe ! serves as both sensor and controller. The reference level is the height of the overflow pipe, and the correction is made by simply allowing the water above the opening of the pipe to be drained. / There is a strong resemblance between a flushing toilet system and a neuron. I believe that J.Y. Lettvin was the first to notice this analogy. The neuron consists of Flapper leak = 0.0000000 a cell body and an axon (a tube leading Valve leak = 0.0000000 away from the body). Inside the neural membrane, there are positive potassium ions and negative proteins; outside, there Time = 200.00000 Volume = 1330.2721 , are positive sodium and negative chloride Flapper is down Valve is off ions that create a resting membrane poten- tial of about -70mV. A mechanical, electri- Time step = 1.0000000 cal, or chemical stimulus can cause depo- larization of the membrane, allowing the / temporary cross-flow of sodium andpotas- 1 sium ions. The result is a rapid rise from the i negative resting-membrane potential to the / positive action potential. This localized I change in the membrane potential propa- 1 gates as the adjacent inactive region's I threshold is broken down by the resulting current flow. / Although we shouldn't take the analogy tm far. a flush is analogous to a depolariza- Flapper leak = .50000000 1 tion, and the period after a flush during Valve leak = 2.0000000 which it is not possible to initiate a new flush is similar to the refractory period of I the neuron during which it must rest and Time = 199.50000 Volume = 1227.9801 j restore the ion balance. The propagation of Flapper is down Valve is off : the action potential is similar to the dis- ; charge from the tank system, and the Time step = 1.5000000 t threshold for the action potential is similar to the minimum amount of force required to / activate the lever-linkage system that lifts the flapper in the hopper. It is easy, although impractical, to build a logic circuit out of a set of flush toilets. We can attach leaky tin cans to the lever or pull-chain system of the toilets, and run pipes from the flapper openings to the cans. Whenever a can fills sufficiently with the discharge from other flushes, another flush is triggered. The logic, which is threshold Flapper leak = 1.2000000 logic, is the same whether operative in Valve leak = .50000000 neural nets, flush nets, or gates in electronic circuits.

I Volume XII, Number 6 7 Forth Dimensions Threshold logic is based on a test for inequality. The rule is: Given a number called the threshold, T, if the input from the i Convert G to in/sec*sec X 12.0 X 32.0 F* IS 6 previous stage adds up to a number greater I I than T, then send out an output value. By i Compute BETA--pix~ls!inch Z 100.0 X 12.0 FI IS BETA varying T, it is possible to construct a logic I I gate. For example, if the inputs are meas- i Ned Resolution I C-320 MIPE 17 GROUND ( dark blue background 1 ured in units that can be normalized to 0and I I 1,and if T is 1, then any unit input will cause : DRAW-GRAPH i -- a unit output. If T is 2, then two or more sit 50 150 270 1 RECT inputs will have to deliver unit inputs to X 150.0 H? BETA F* F- F-?S DUP 50 SNAP 270 1 LINE cause a unit output If there are k inputs and X 150.0 H1 BETA Ft F- F-iS DUP 50 SWAP 270 1 LINE Tck, then an output will follow any input of X 150.6 H0 BETfl F* F- F-iS DUP 50 SWAP 270 i LINE Tor more units. This last case is sometimes 8 4 WCURSOR! .' HZu called majority logic if T=k/2 when k is 10 4 #CURSOR! ."Hi' even or T=(k+1)/2 when k is odd. ib 4 WCURSOR! .' HOE The accompanying source code models 20 9 WCURSOR! .' FiAPPER iEAK=VLAPLEAK F. the basic on-off feedback control system 21 9 WCUHSOR! VALVE LEA#=' VALVLELK F. underlying a flushing toilet. The interested .' 22 9 WCURSDR! PRESS F TO CONTINUE' ; reader may want to try his hand at con- ." structing the model before reading further. The program simulates the mechanical : INITIAi-CONDITIONS ( -- ) system by implementing the control logic LENGTH WIDTH F* H1 Ff IS FULL with embedded computations as a set of F=PI R R Ft Ft IS AREA production rules (condition 2 action). This DDWN IS FLAPPER programming style is natural for building OFF IS VALVE complex causal models because sequenc- H1 IS H ing is less important when most factors act FULL IS VELUWE concurrently. 1 (1.0 IS TINE Some of the inaccuracies in the model X 0.01 IS DT are due to the fact that it is a discrete model X 0.0 IS ALPHA ; and because it ignores physical properties such as the inertia of the float, variation in water pressure at the valve, the presence of objects in the tank which affect flow, and so : SELECT-PARAMETERS ( -- 1 on. However, it does account for the vary- CR ." Enter simulation time in seconds:" F#IN IS FINISH ing discharge rate from the flapper opening X 220.0 FINISH F/ IS ALPHA I pixelslsecond ) by applying a special case of Bernoulli's CR .'Enter amount of flapper leak in cu inlsec: ' F#IN IS FLAPLEAK Equation (obtained by Daniel Bernoulli in CR .' Enter amount of valve leak in cu intsec: "#IN IS VALVLEAK 1738) called Torricelli's theorem: velocity CR ."Enter tire step: ' FIIN IS DT ; = sqrt(2*G*H), for the velocity of water leaving an orifice at a distance H down from the water level. \ Velocity of water out of the flapper opening Experimentation is relatively easy, : VELOCITY { -- 6 H Ft X ?.it F* FSRHT ; since new rules can be added at any time to extend or restrict the model. The radical- shaped curves in Figure One show the time behavior of the system under both water- tight and leaky conditions. Under leaky conditions, the system tends toward three Robert Garian is a technical information and language specialist at the Library of states: overflowing, underfilling, or oscil- Congress, specializing in Soviet computing. He has a mathematics degree from lating. George Washington University and is the founder of Hibiscus Software and Word- ware, a software and information company in Arlington, Virginia. A member of the American Association for Artificial Intelligence, he has written an A1 program called Block Solver that automatically rearranges one multistack configuration of blocks into a specified goal configuration under consiraints. He has worked on automatic software verification and automatic code generation, and is interested in the simula- tion of complex systems, cellular automata, and genetic algorithms.

Forth Dimensions 8 Volume XII, Number 6 TETHERBALL IN THE : PLOT ( -- 1 NERVOUS SYSTEM ( row 1 % 150.0 BETA H Ff F- F->S The October 26,1990 issue of Science i col I TIREALPHAF*F-)S50+ ?PIX! ; contains several articles on the appli- cation of site-specific mutagenesis \ Assunp t ions: ("systematic changing of amino acids \ .6 is a guess at the drag coefficient for water leaving the opening. in proteins and studying the conse- \ 90.0 seconds is the total tire required for one cycle. quences") to the understanding of ion i Tank is 19x12~7, Hax water level is H? = 10 = height of overflow pipe. channels formed by pores in a nerve's : FLUSH ( -- I membrane. "Playing tetherball in the INITIAL-CONDITIONS nervous system" by Marcia Barinaga WIPE @p. 506-7) describes the results of SELECT-PARAKTERS this research. Building on the work of WIPE Clay Armstrong and Francisco Beza- DRAW-GRAPH nilla in the 1970s, Richard Aldrich, 3 1 WCURSOR! .' TIHE STEP=' DT F. Toshinori Hoshi, and William Zag- PLOT otta have obtained evidence for an UP IS FLAPPER unusual voltage-sensing inactivation method (i.e., a method for stopping BEG IN the flow of ions through a pore). FLAPPER UP = IF AREA VELOCITY Ft X .6 Ff IS OUTFLOW THEN "Imagine a protein tetherball, dan- FLGPPER UP = IF FALLING IS FLOAT THEN gling by a protein cord on the inside of RAPPER DOWN = IF RISING IS FLOAT THEN a nerve cell's outer membrane: while FLAPPER DOWN = IF FLAPLEAK IS OUTFLOW THEN the tetherball floats free, ions pass FLOAT FALLING = IF DN IS VALVE THEN into or out of the cell; but when the VALVE ON = IF FULL 1 90.0 FI IS INFLOW THEN ball pops into the mouth of a pore, the VKVE OFF = IF VALVLEAK IS INFLOY THEN ion flow stops." By stretching and H HO Fi= IF DOWN IS FLAPPER THEN inverting some of the concepts in- ii H1 F> IF OFF IS VALVE THEN volved, this remarkable molecular H Hl Fi IF ON IS VALVE THEN mechanism can be made to corre- H H2 F> IF VALVLEAK IS OUTFLOW THEN spond to the control system of our -1 IF VOLUHE OUTFLOW INFLOW F- DT Ff F- IS VOLUHE model if we allow the following simi- VOLUHE LENGTH WIDTH Ff Fi IS H PLOT THEN larities: tanknerve cell and smund- \ Update display: ing fluid, ion channel/pore:orifice, 1 1 WCURSOR! .VIHE=VTlE F, voltage-sensing mechanism:float, 1 20 WCURSOR! ."VOLUHE=" VOLUHE F. ball and chain:flapper and chain (here 2 1 WCURSOR! .' FLAPPER IS VLAPPER IF ."UP ' ELSE ."DOWNVHEN the flapper is normally open instead of 2 20 UCURSOR! ." VALVE IS VVkLVE IF ."N ' ELSE ." OFF" THEN closed), ion so1ution:water. The valve might be likened to the effects of os- motic pressure acting on the ion chan- TIHE DT F+ IS TIHE nel. Thus, simple control systems can TIHE FINISH F:) be found in astronomical quantities UNTIL even at the molecular level. KEY ASCII F = IF WIPE RECURSE ELSE BW80 EYE THEN ;

i Note: in HSiForth % and the F-words IF#IN,F. ,F>,F(=,FINlT,. ..I relate to floating point nurbers. VAR words are fast variables that don't need e. \ WCURSOR! is used to place the window cursor. and WIPE clears the screen.

Volwne XII, Nwnber 6 9 Forth Dimensions HARVARD SOFTWORKS NUMBER ONE IN FORTH INNOVATION (513) 748-0390 P.O. Box 69, Springboro, OH 45066

MEET THAT DEADLINE ! 1 ! WAI(E UP ! ! 1 HSlFORTH runs under MSDOS or PCDOS, or from ROM. Each level includes Use subroutine libraries written for Forth is no longer a language that of lower Ones. up@'ades: $25. plus price difference between levels. other languages! More efficiently! tempts programmers with "great code is in ordinary ASCII text files. Combine raw power of extensible expectations", then frustrates them languages with convenience of with the need to reinvent simple tools HS/FORTH systems s"pprt carefully implemented functions! expected in any commercial language. Or larger programs & and run faster than any 64k limited ones even Yes, it is faster than optimized C! without automatic optimization -- which Compile 40,000 lines per minute! HWFORTH Meets Your Needs! accepts almost anything and accelerates to Stay totally interactive, even while near assembly language speed. Optimizer, compiling! Don't judge Forth by public domain assembler, and tools can load transiently. Program at any level of abstraction products or ones from vendors Resize segments$ redefine from machine code thru application primarily interested in consulting - without recompiling. 79 specific language with equal ease they profit from not providing needed and 83 Standard plus F83 programs. and efficiency! tools! Public domain versions are PER8oNa LEVEL $299. Alter routines without recompiling! cheap - if your time is worthless. NEW' Fast direct to video Use source code for 2500 functions! & scaled/clipped/windowedgraphics in bit Useful in learning Forth's basics, they blit mono, cga, ega, vga, all Use data structures, control fail to show its true potential. Not to ellipsoids, splines, bezier curves, arcs, structures, and interface protocols mention being s-1-o-w. turtles; lightning fast pattern drawing even from any other language! with irregular boundaries; powerful Implement borrowed feature, often We don't shortchange you with parsing, formatting, file and device 110; more efficiently than in the source! promises. We provide implemented interrupt Use an architecture that supports functions to help you complete your high level from single step trace, decompiler; music; small programs or full megabyte quickly. And we ask you compile 40,000 lines per minute, stacks; ones with a single version! not to shortchange us by trying to file search paths; format to strings. Forget chaotic syntax requirements! save a few bucks using inadequate software floating pint, trig, transcen- Outperform good programmers public domain or pirate versions. We dental, 18 digit integer L scaled integer stuck using conventional languages! worked hard coming up with the ideas math; vars: A B * IS C compiles to 4 words, (But only until they also switch.) that you now see sprouting up in other l..4 dimension Val' arrays; automatic speed. Forths. We won't throw in the towel, optimizer for machine code HSlFORTH with FOOPS - The only but the drain on resources delays the PROFESSIONAL LEVEL 8989. full mu1 t i ple inher it ance introduction of even better tools. Don't hardware floating pint - data structures interactive object oriented kid yourself, you are not just another for all data types from simple thru language under MSDOS! drop in the bucket, your personal complex 4D var arrays - operations decision really does matter. In return, thru complex hyperbolics; Seeing is believing, OOL's really are well provide you with the best tools ~r~~~~~~~~~~~~~$e~~~ incredible at simplifying important money can buy. robin & intenupt driven multitaskers; parts of any significant program. So dynamic string manager; fde blocks, naturally the theoreticians drive the The only limit with Forth is your sector mapped blocks; x86&7 assemblers. idea into the ground trying to bend all own imagination! PRODUCTION LEVEL $499. tasks to their noble mold. Add on Metacompiler: DOS/ROM/dired/indire&, OOL's provide a better solution, but You can't add extensibility to fossilized threaded 'ystems at 200 only Forth allows the add on to blend compilers. You are at the mercy of Forth cores from 2 kbytes; drrP stmieures & &&+ compileq in as an integral part of the language that language's vendor. You can easily ~~h~~i~d~~-~~~~~~~~~hk~fibrary, and only HSE'0RTI-I provides true add features from other languages to 200 graphic/window functions, PostScript multiple inheritance & membership. HSIFORTH. And using our automatic style line attributes & fonts, viewports. optimizer or learning a very little bit ONLINE GLOSSARY 8 46. Lets define classes BODY, ARM, and of assembly language makes your PROFESSIONAL and PRODUCTION P ROBOT, with methods MOVE and addition zip along as well as in the LEVEL -SIONS: RAISE. The ROBOT class inherits: parent language. FOOPS+ with multiple inheritance $79. INHERIT> BODY TOOLS & TOYS DISK $79. HAS> ARM RightArm Speaking of assembly language, 266FORTH or 386FORTH $299. > HAS> ARM LeftAnn learning it in a supportive Forth 16 Megabyte physical address space or If Simon, Alvin, and Theodore are environment turns the learning curve virtual for Programs and data; robots we could control them with: into a light speed escalator. People DOS & BIOS fully and freely available; 32 bit addreedoperand range with 386. Alvin '8 RightArm RAISE or: who failed previous attempts to use ROMULUS HS/FORTH ROM $ 99. +5 -10 Simon MOVE or: assembly language, conquer it in a few FFORTRAN translator/mathpak $79. +5 +20 FOR-ALL ROBOT MOVE hours or days using HS/E'ORTH. Compile Fortran subroutines1 Formulas, NOWthat is a null learning curve! logic, do loops, arrays; matrix math, FFT, linear equations, random numbers. Shippinglsystem: US: $7. Canada: $19. foreign: $49. We accept MC, VISA, & AmJ3x

Forth Dimemions 10 Volume XII, Number 6

I SOVIET FORTH-INFO

------DAVID KIPPING - MENLO PARK, CALIFORNIA

Aspart of a "People-to-People*' pro- education, and one floor will contain the spected the documentation for a Forth lan- gram, I visited the SovietUnion from Octo- offices and laboratories of Forth-Info. One guage product (InfoForth or AstroForth). ber 9-22,1990. I was part of a delegation of wing will be devoted to about 30 apart- It has a complete description of language engineering, political, environmental, and ments, sufficient for all the staff of Forth- primitives in sufficient detail for an expe- business leaders who met with Soviet Info. In addition, there will be several spare rienced Forth programmer to proceed. The counterparts in their various areas of exper- apartments which are allocated for visiting text was in Russian, but all the Forthprimi- tise. As a member of the engineering dele- researchers. Forth-Info hopes to sponsor tives were in Roman characters and easily gation, I visited several Soviet businesses, exchange programs with U.S. businesses understood. institutes, and manufacturing facilities. At and institutions, and apartments for visitors InfoTransHemo. This program for I all of these, there was considerable interest are necessarv in the Soviet svstem. blood screening is apparently in wide- in compuhng, especially using IBM-com- spread use at soviet blood dcktion sta- patible personal computers. tions. One of the main difficulties was One of the businesses that was visited There is no copyright matching report formats and input require- by the engineering delegation was Forth- ments to existing procedures and forms. Info, a Soviet cooperative. They specialize protection for soft- (Probably, the problem was finding out in Forth-based software and hardware. My ware in the Soviet what these procedures and forms were!) professional background is in computer Forth development System. I got a software, with current interests in graphical Union. brief look at available development tools user interfaces for PCs. Previously, I spent for Forth. The editor, file control, and exe- seven years involved with Forth-based The main source of income for Forth- cution environment seemed quite ade- software, so I feel quite qualified to evalu- Info seems to consist of contracts with quate. ate the activities of Forth-Info. various ministries for custom software Infoweaver. This program for textile development. One such project is a system pattern design was quite impressive. It Forth-Info Business Structure for screening blood donors. Another proj- runs on aPC and uses a full-color graphical Forth-info is structuredasacooperative ect is a real-time control system for rail- interface. It seemed easy to use, and ap- business based in Leningrad. Cooperatives ways, which uses a Soviet fault-tolerant peared to provide the level of control that are a recent Soviet phenomenon, and are computer. Forth-Infoalso runs a school for a designer would want. Patterns and colors more-or-less like a U.S. private business. the Ministry of Education that teaches could easily be changed and the results The company was started in 1988 by Boris computer programming and operations to displayed immediately. Response was Katsev and his son Sergei Katsev. The grade school and high school students in a very fast. The output is a report which company has about 70 employeesand asso- hands-on laboratory. gives explicit set-up information for ciates. The actual number of employees is looms. In the Soviet Union, looms are about 30, with the rest operating on some Technical Activities manually set up, but automatic set-up in- kind of an independent-contract status. Although contract programming is the formation couldbe output on paper tape or Like all things in the Soviet Union, the ar- primary sourceofincome, themain interest floppy disk for looms that were so rangements are complex and interlocked. for the future is standard products. Since equipped. This product was up to U.S. [More information about the company is there is no copyright protection for soft- standards for look, feel, and functionality. presented in the accompanying sidebar, ware in the Soviet Union, making a profit Forth-Info provided a demonstration disk which was written sometime in 1989.1 on standard products is difficult. A six- of the product. Forth-Info is in the process of designing page product summary gives a description Info1816. 1 was able to spend a fair a building of its own. (It is now in rented of Forth-Info's activities and offerings. amount of time with this product. It is a and donated quarters.) The building will be Although I did not test or evaluate all these simulator and emulator for the Intel 8048 five stories (matching adjacent buildings) products, I believe they are real and operat- microprocessor, and runs on a PC inter- on land that will be obtained from the ing as described. I was able to evaluate faced to an in-circuit emulator. The user government on a 50-year lease. Two floors some of the products: interface consists of tiled windows for edi- will be occupied by the Ministry of Educa- tor, assembler, status, and output informa- tion, one floor will be devoted to computer Forth Language Description. I in- tion. Programs for the chip can be edited, I Volume Xll. Nwnber 6 11 Forth Dimemiom assembled, and run in a simulation, or actu- rooms. sign is about five years old and the ma- ally executed using the in-circuit emulator. Previously, we had visited a Soviet chines we saw were several years old. The bulk of the code is not dependent on the computer factory and suggested that they There seems to be no effort to produce a specific microprocessor, and Forth-Info is design and manufacture PC clones. They new design, or much interest in manufac- extending it for other Intel processors. This said it was not possible because comp turing and distributing this model. The product was up to U.S. standards for func- nents (chips, floppy drives, and hard disks) criticisms of this Soviet PC were that it had tionality and user interface. are not available and, besides, Soviet com- some compatibility problems, was not reli- I have no doubt that the other products puters are not reliable. At other businesses able, and was not up to date. Several people which are described in their literature are of and institutes, we were again told that the said they would prefer to have no computer equal quality and professionalism. Forth- Soviet Union does not manufacture any at all, rather than use the Soviet PC for de- Info is aware of the state of the art of U.S. PCs. velopment. They rejected the concept of and world developments, and is operating After visiting the student training room using the cheap and available Soviet PC for at a similar level. at Forth-Info, we went into another room initial development and using an expen- which contained several machines of the sive, imported PC to check compatibility Computer Education Activities same type. I asked what they were, and was and final functionality. Forth-Info has an arrangement with the told that they are Soviet-made PCs. In one Ministry of Education to provide training in corner, a woman was using one of them to Forth-Info Business Goals computers for school-age children. A ma- prepare a document (in Russian) using a Forth-Info is interested in publishing jor part of their facility is a large classroom word processor. their products in the U.S ., and of particular equipped with computers for student use. The machines consist of a small desktop promise are Infoweaver and Info1816. About 20 students (average age about 12 box (about 14 inches wide) for the system They recognize that the manual and pack- yews) were in the classroom, each with his unit and a similarly sized box for the two aging must be brought up to American own computer. By the time we had arrived, five-inch floppy disks. There was no hard standards, and that they will need an formal classes were over and the students disk in evidence. A standard monochrome American publisher and distributor. Our were all playing computer games! Tetris monitor and keyboard (Roman and Cyril- delegation offered to assist them in locat- and a road-racing game seemed to be the lic) completed the configuration. The de- ing these resources. most popular. The computer arrangement was rather interesting. Each student station consists of Forth-Info a system unit, display, and keyboard The cooperative Forth-Info starred its activities at the Leningrad University in (Roman and Cyrillic) with BASIC built early 1988. Programmers of the highest qualification from various Leningrad re- into ROM. The processor is an 8080 run- search enterprises are working here. Forth, a fourth-generation language, and hard- ning CP/M, and all the student stations are ware-software problems are their common area of interest. linked in a local area network to a master Forth-Info is now developing Forth-based commercial software for personal com- (instructor) station. None of the student puters, mini- and microcomputers, OEM. Forth systems for all computers that are stations has a floppy disk (or hard disk), but widely used in the U.S.S.R. have been created by members of the cooperative. Soft- the instructor station had floppy disks and a ware development systems and applications packages in Forth have been developed printer. The system seems to work quite and are on sale. A threaded-code processor, executing Forth code at the hardware well, because 12-year-olds had no trouble level, is now being designed as a single chip. getting their favorite games running. Forth-Info also propagates Forth and teaches people. Its members participated in Apparently, the education and training creating the first two Forth manuals published in Russian and in the U.S.S.R. A activities of Forth-Info are quite important translation of Leo Brodie's Starting Forth and Thinking Forth is being prepared for to the company and to the Ministry of Edu- publication under the editorial supervision of some members of the cooperative. cation. This explains the close connection Members of the cooperative give lectures on Forth toa wide range ofprogrammers, with the ministry with respect to Forth- paying special attention to programmers from industry. At the end of 1989, the Info's building plans. cooperative planned to organize an all-Union conference of Forth users in the U.S.S.R. Its aim is to exchange information and experience about Forth applications Soviet PCs Really Exist! and to start organizing an association of Forth users. Foreign participants were also Forth-Info was the last stop on our two- expected. week tour of businesses in the Soviet Un- The chairman of Forth-Info is B. Katsev. Leading specialists and authors of Forth ion. PCs are in great demand and are very software are I. Agamizian, A. Astonovsky, S. Katzev, V. Kirillin, A. Klubovich, N. expensive, since they are all imported and Nozdrunov, V. Patryshev, and S. Tovstolugsky. There are 28 specialists on the staff paid for with hard currency. Most of the of Forth-Info, 11 with Ph.D. degrees; 40 more work on contract. units we saw seemed to be manufactured in Forth-Info will support any contacts with the Forth community, both in the U.S. the Far East (Hyundai and Epson were two and in Europe. brands I recognized). The cost of a PC is equivalent to about ten years' salary for a Forth-Info Co-op, P.O. Box 279, 10a. 0.Koshevoy St., 197198, Leningrad, senior professional, which explains the U.S.S.R. Telephone (812)-233-34 10. Fort Knox-type security of all computer

Forth Dimensions 12 Volume XII. Nwnber 6 ARRAYS IN FORTH -- - LEONARD MORGENSTERN - MORAGA, CALIFORNIA

A natural question beginners often ask them canbe altered, thereby broadening the cost in run-time speed. The word is: Why doesn't Forth have features that are definition. 2 -DIMENSION is a dummy with no ac- standard in other languages, for example, A narrower definition is used by F-PC: tion, included for parallelism. This sort of arrays? The answer is, Forth is so facile at thing is sometimes contemptuously called creating new data types that it is often easier : ARRAY ( n -- ) ( -- a) "syntactic sugar," suggesting that it is to invent something that exactly suits one's CREATE 2* ALLOT ; (2) pleasant but unessential and even harmful. needs than to force a program to conform to Actually, it is like giving a box of fine some arbitrary standard. The upcoming This allots the same amount of space as the chocolates to someone you love: the bene- ANSI standard for Forth will not include previous definition, but at run time takes no fits far outweigh the cost. specifications for arrays, which is as it index, always returning the address of the should be, in my opinion. An exploration of origin. My prejudice is that this is not an Fields examples will explain why. array, but rather a work area, or buffer. But When using an array with long ele- It is important to recognize that Forth to avoid semantic controversies, I will use ments, it is useful to subdivide them into arrays are not the same as the abstract the terms indexed and non-indexed for the fields. In Screen Two, a defining word arrays of mathematics, on the one hand, or two kinds of arrays. FIELD creates a class of Forth words to the arrays of conventional computer lan- reference these. For instance, if each ele- guages, on the other. In mathematics, an ment of Fool (Screen One) represents a array is simply a set of numbers arranged in Many programmers node of a binary me, the six bytes can be a pattern. Conventional computer lan- subdivided into three fields: aright pointer, guages add an action: an index is accepted mistakenly believe it a left pointer, and data. The words .LEFT, and a quantity is returned. Arrays in Forth, is standard. .RIGHT, and .DATA pmvide access to as a rule, return the address where the data these. The "dot" syntax is copied from resides, but can return the data itself or Pascal. These are not just names: as with all perform an action; and arrays that do other An Array with Forth words, they have an action, which in things are easy to assemble, as we will see. Elements of Any Length this case is to increment the preceding ad- The following way of defining arrays is The first definition above is restricted to dress. For example, 3 FOO~.RIGHT economical and fast, and is so popular that elements of length 2 in one dimension. The specifies the address of the right pointer of many Forth programmers mistakenly be- word -BYTE -ARRAY (Screen One) ex- the third element of ~ool. lieve that it is standard: pands this to arrays with elements of any length in one or two dimensions. Two ex- Arrays of Bits : ARRAY ( n -- ) ( i -- a) amples are presented: a onedimensional We next proceed to describe something CREATE 2" ALLOT DOES> array named ~oolwith 200 six-byte ele- more complex: an array of bits. It uses a SWAP2*+; (1) ments, and a two-dimensional array named non-indexed array of bytes named MASKS F002 with 200 12-byte elements arranged (Screen Three) which contains powers of At defining time, two bytes of memory in ten rows and 20 columns. F002 takes a two, from one to 128. MASKS is initialized are allotted for each element of the array; at compound index consisting of two inte- by the useful technique of "comma-ing," run time, an index i is used to compute an gers, one for each dimension. The order of which is often superior to defining an address a where data can be fetched, stored, the two is the same as that used to declare empty array and then filling in the values. or otherwise manipulated. The index and the array. Therefore, il ranges from 0-9 Locating a bit requires two integer- the address are simple--that is, they each and i2 from 0-19. mask and a RAM address-representinga consist of one single-precision integer. I like the English-like syntax of compound address which can be used di- Each element occupies two bytes in dic- -BYTE-ARRAY. A purist might complain, rectly by Forth words that manipulate bits, tionary space, and the array has one dimen- but similar constructs are used a lot in such as CSET, CRESET, and CTOGGLE. sion. There is no range checking. I cite Forth, and the results can be elegant. The The address is computed by using the se- these features in detail because any or all of elegance is not always free: here, there is a quence:

Volume XII, Nwnber 6 13 Forth Dimensim ( \ Screen 1. A versatile array def her.

: -BYTE-ARRAY ( r c n -- ) ( r c -- addr; or c -- addr) CREATE DUP 20VER , , , ROT 1 MAX * * ALLOT DOES> DUP 2+ @ O= IF 0 -ROT THEN ( Fix stack if 1-dim) >RSWAPR@@*+R@4+@*R>6++;

: 1-DIMENSION ( c -- 0 C) 0 SWAP ; : 2-DIMENSION ;

\ Examples 200 1-DIMENSION 6 -BYTE-ARRAY FOOl 10 20 2-DIMENSION 12 -BYTE-ARRAY F002 \ Note that there must be a space before the first hyphen in \ -BYTE-ARRAY but not before the second.

8 /MOD ( 8 n -- rem quot) of 256 elements. (A programmer wounded and he thought so highly of the slogan that by a past encounter with Murphy might he made it the title of a book. The foregoing The quotient is added to the base address of check anyway.) Forth words are more ef- discussion suggests that, in Forth at least, the array, and the remainder is used to fetch ficient and easier to debug if their parame- there is no clear separation between data the mask from BYTES. ters are guaranteed correct. The word that and the algorithm. Using a bit array to manage an imagi- does the checking and takes corrective ac- nary lighting system is illustrated in Screen tion should, as a rule, precede the array Three. Other examples of arrays that return word and not be part of its definition. LeonardMorgenstern is a retiredpa- compound addresses are those situated in thologist and computer hobbyist.His virtual memory ( i -- ofs blk) or in ex- Forth vs. Other Languages interest in Forth goes back over ten panded or extended memory ( i - - seg Recently, I came across the following years. Currently, he is a sysop of the ofs). statement in a textbook: "Each language Forth RoundTable on the CEnie provides a limited number of elementary network. His son, David Morgen- Some Random Thoughts data types." I have become so accustomed stern, is also an author on computer- The indexed arrays discussed up to this to the power and flexibility of Forth's CRE- related subjects. point return an address, which may be ATE .. . DOES> that it was a shock to recall simple or compound. Thus, they do what how limited other languages can be. In Forth variables do, and may properly be Forth, as we have seen, new data types can regarded as "VARIABLE-like."If the con- be created and abandoned at the convenien- tents were returned instead, the designation ce--or even at the whim--of the prograrn- "VALUE-like"would be appropriate. Ar- mer. True, some Forth constructs are so rays that contain actions (CFAs) are widely useful that they have become official or de used, and are called "execution vectors" or, facto standards (CONSTANT and VARI- sometimes, just "vectors." And, of course, ABLE, for example) but it is more usual for a Forth array can contain a mixture of these a programmer to define what is needed in types. the most convenient way. As always, free- It is usual to construct arrays by means dom has its costs, one of which is a greater of defining words, but this is a convenience need for documentation. When you declare and not a necessity. The array MASKS was an array in BASIC, you describe its pur- created without one. A defining word is pose, but you do not have to describe what essential when several structures of the it is or how it works, as you must in Forth. same kind are wanted, but also can be Another source of subtle complications useful when defining a solitary example. is the fact that defining words not only al- For simplicity, I have omitted range locate memory for their contents, they also checking from the examples. Almost al- specify the action they will perform with or ways, this is a necessity. It may be omitted on those contents. In effect, the simplest only if the index cannot possibly be out of Forth program incorporates object-ori- range, as when a keystroke is masked by ented features. Niklaus Wirth claimed that 255~N~andisusedtoindexintoanarray algorithms + data structures = programs,

I I Forth Dimensions 14 Volume XU, Number 6 \ Screen 2. Defining subfields within array elements.

VARIABLE FIELD-OFFSET : FIELD ( len -- ) CREATE FIELD-OFFSET @ , FIELD-OFFSET +! DOES> @ + ;

FIELD-OFFSET OFF 2 FIELD .LEFT \ Define 3 subfields, each of length 2 2 FIELD .RIGHT 2 FIELD .DATA

\ Screen 3. A bit array.

CREATE MASKS 128 C, 64 C, 32 C, 16 C, 8 C, 4 C, 2 C, 1 C, \ In creating a bit array, len is the ceiling of the number \ of bits divided by 8.

: BIT-ARRAY ( len -- ) ( i -- m a) CREATE ALLOT DOES> SWAP 8 /MOD MASKS + C@ -ROT + ;

\ Creating a light controller for 24 lights. Uses a \ vocabulary named LIGHTS because we are redefining ON and OFF

3 BIT-ARRAY LIGHT \ 3 bytes = 24 bits VOCABULARY LIGHTS LIGHTS DEFINITIONS : ON ( n -- ) LIGHT CSET ; \ Set the bit : OFF ( n -- ) LIGHT CRESET ; \ Reset the bit

I : ON? ( n -- f) LIGHT C@ AND o<> ; \ Test the bit : ALLON ( -- ) 0 LIGHT 3 127 FILL DROP ; \ Turn on all bits 1 : ALLOFF ( -- ) 0 LIGHT 3 0 FILL DROP ; FORTH DEFINITIONS \ EXAMPLES LIGHTS \ Set the vocabulary ALLOFF 12 ON \ Turn on Light number 12

Volume XII, Number 6 15 Forth Dimensicnu Part Five FORST: A 68000 NATIVE-CODE FORTH - - - JOHN REDMOND - SYDNEY, AUSTRALJA m

Deferred words are well established The Compilation Record Arithmetic States in Forth, and they provide a simple means Before compiling a normal word, the There are far u>o many words in Forth, of achieving forward referencing and vec- ForST compiler looks up its code address and there is sense in trying to avoid further tored execution. The concept was otigi- (as an offset in the CFA) and fetches its op- unnecessary proliferation. When a float- nally developed for indirect-threaded code timization flags (from the FFA). In these, it ing-point package is available,for instance, systems, and it implicitly makes use of the has all that is necessary to compile a call to a number of new words appear to become headers which are present at run time. the code, or to expand it with optimization. necessary, e.g., FNUMBER, F ., F+, F-, To use a simple example: A deferred or vectored word also needs this F *, F/ , FMOD, FNEGATE, and FABS. information to specify completely its pres- They can be avoided at the user level by DEFER GREET ent status. To this end, its PFA points to an setting up the familiar number words : NICE eight-byte compilation record: (NUMBER, ., +, etc.) as vectored words, ." Good morning" ; with their compilation records in a state ' NICE IS GREET bytes 0-3: offset address of actual table. REALS and INTEGERS can then be code used as immediate words to manipulate its When GREET is executed, we get the bytes 4-7: FFA corresponding to this contents at compile time. This approach of "Good morning" message, of course. But, code overloading existing words makes it pos- because GREET is DEFERed, we can sible to write very clean code (Figure One). change its behavior: (This arrangement of fields was chosen so that code which uses ' (tick) and PER- Separating Compile-time and : GROAN FORM will operate in the usual way.) Run-time Activities ." YOU again!" ; When a deferred or vectored word is ForST enables the programmer to cre- ' GROAN IS GREET first defined, its compilation record is ini- ate completely independent application tialized to point to a NOOP. When it is code. To do this most effectively, it is All this is obvious-but what if we subsequently modified (by IS), the record necessary to separate compile-time code incorporate GREET into a higher-level is altered: and execution code-to unthread (or un- word? bind) some of the support we take for : GREETING HEAD GREET IS SAY-HELLO granted in a Forth System. GREET ; The compilation of suing literals is a HEAD returns the CFA of a word. Its use good illustration of the way compilation Now the run-time behavior of GREET - (rather than ') allows access to the neces- and execution functions are bound up: ING will depend on the state of GREET sary header fields of GREET and separates when GREETING is executing. Even if the activity of the vector word from the : . " GREETING is compiled when GREET is header of the vectored word. This header COMPILE (.") NICE, it will not stay friendly if it is made need not even continue to exist! (Note: in ,#I ,. IMMEDIATE to GROAN. ForST, ' still returns the address of code or This late binding of behavior lends data in the usual way.) When . " is encountered at compile great flexibility to compiled code but, be- Because they have no directly bound time, it has an immediate action of cause it involves decision making as run code, whenanumber of VECTOR words are compiling ( . " ) and then enclosing a time, it may not always be appropriate. For defined in sequence, their compilation rec- counted string in the compiled code. The those cases where we want the vectoring to ords will be located in adjacent memory roles of ( .") and ," are quite different, ' take place at compile time (early binding), with no intervening breaks. This my, a and take place at different times. There is, 1 ForST provides a new class of configurable state table, is a very concise summary of therefore, no reason for them to have a fixed I word---a vectored word: their present behavior and, as such, can be relationship in code space. saved to another array--or initialized from The real difficulty with this definition VECTOR SAY-HELLO one-by simple block moves. of . " is that therun-time code, ( . " ) ,must

I Forth Dimemiom 16 Volume XII, Number 6 \ Demonstration code to illustrate the use of \ arithmetic states and vectoring of . + and number input.

\ The code will print out sines of angles at 0.05 radian \ intervals, waiting for a key stroke after each step. NGS FORTH A FAST FORTH, \ The infinite loop is ended by pressing . OPTIMIZED M)R THE IBM \ Note that local constants and addresses are permitted PERSONAL COMPVTER AND \ because they occupy no code space. MS-DOS COMPATIBLES.

macros STANDARD FEATURES decimal integers INCLUDE :

: sines ( 1 reg angle 27 constant escape ) a79 STANDARD reals cr 0 to angle @FULL ACCESS TO MS-DOS begin FILES AND FUNCTIONS angle . angle sin . cr angle 0.05 + to angle @ENVIRONMENT SAVE & rnAD integers key escape = if leave then @MULTI-SEGMENTED FOR again ; LXRGE APPLICATIONS @EXTENDED ADDRESSING \ Simple trigonometric functions I OMDIORY ALIDCATION CONFIGURABLE ON-LINE decimal reals 355 113 / constant pi @AUTO UAD SCREEN BOOT pi 2 / constant pi/2 @LINE & SCREEN EDITORS pi 2 * constant 2pi @DECOMPILEFt AND DEBUGGING AIDS : (sin) ( 1 arg angle 2 locals square term ) M088 ASSEMBLER angle to term .GRAPHICS & SOUND angle angle * to square angle term square * to term term -0.1666667 * + term square * to term @DETAILED MANUAL term 0.0083333 * + term square * to term term -0.0001984 * + term square * to term @INEXPENSIVE UPGRADES term 0.0000028 * + ; oNGS USER NEWSLETTER

: sin { 1 arg angle 1 local sign } A CDMPLGTE mRTH DECrEU)PUENT SYSTEM. angle O< to sign angle abs to angle PRICES 8!l'ART AT $70 angle 2pi > if angle 2pi mod to angle then NEW+-150 & -110 angle pi > VERBION8 AVAILABLE if angle pi - to angle sign not to sign then angle pi/2 > if pi angle - to angle then angle (sin) sign if negate then ; NEXT GENERATION BYSTEM 1 (Continued on next page. PoOoBOX 2987 6ANTA CLARA, CAo 95055 Figure One. (408) 241-5909

Volume XII, Number 6 17 Forth Dimensions (Figure One, continued.) be defined before the immediate word, ." , can be defined. In other words, the com- : cos pi/2 + sin ; pilation code is compiled after the run-time code and, if we wish to generate free-stand- : tan dup sin swap cos / ; ing application code, we are forced to in- clude in it code which has absolutely no decimal integers ( default state) I run-time role. This difficulty can be avoided by the following:

VECTOR ( .") d-array: bsr create . .tt bsr over DELAY ( . " ) bsr comma ,tt ,. IMMEDIATE bsr mult bsr allot The internal code of . " is now a little bsr xdoes ;end of compile-time more complex, but specification of the code address and macro characteristics of ( ." ) comp rec: dc.1 offset (rtime) ;address of run-time can now be delayed until ." is needed in a code definition. (Note that another new word, dc.1 0 ;default FFA (no mac- POSTPONE, has essentially the same ac- ros) tion as COMPI LE .) rt ime : rts ;noop code unless de- When COMP I LE is used in the defini- fined after DOES> tion of . ", it fetches the CFA and FFA of ( . " ) and uses them to compile into .". Figure Two. When DELAY is used, on the other hand, a pointer to the compilation record is com- piled, together with appropriate code to access it. The record is outside the applica- : array { 2 regargs #rows #columns 1 tion code, and fetching of its contents is create #rows w, #rows #columns allot * delayed until ." is used in another defini- does> { 3 regargs row column address 1 tion (by this time, it should have been address inc w@ column * row + initialized by a word in the application address + ( return address) ; code). L I Figure Three-a. Delayed Defining Words For all their elegance, words using CREATE ... DOES> are traditionally the : d-array ( 2 regargs #rows #columns 1 most problematic in their binding of com- create #rows w, #rows #columns * allot pile-time and run-time activities. This can does> ; be avoided by giving them vectored behav- ior. To use a Starting Forth example: : doarray { 3 regargs row column address ) address inc w@ column * row + : ARRAY (#rows #columns -- ) address + ( return address) ; CREATE OVER , * ALLOT 1 I DOES> (row col -- address) Figure Three-b. DUP @ ROT * + + CELL+ ; Using a delayed DOES >, we can write: : D-ARRAY CREATE OVER , * ALLOT DOES> ;

At this point, the code for D-ARRAY looks something like that in Figure Two. (AR- RAY would differ by having the run-time code directly after the compilation record.) Later in the source code, we might write:

I Forth Dimensions 18 Volume XII, Nwnber 6 8 8 D-ARRAY BOARD < more code>

: DOARRAY DUP @ ROT * + + CELL+ ;

HEAD DOARRAY IS D-ARRAY

: HIGHER WORD 5 3 BO-ARD ;

In doing this we have used D-ARRAY to define BOARD without having specified its run-time action. BOARD, like all constants, variables, addresses, and other words defined with CREATE ... DOES>, is an immediate word in ForST. When it is used in the definition of HIGHER-WORD, it compiles theaddress of its own data area, then fetches the con- tents of a compilation record (embedded in ARRAY) and incorporates a call to, or a macro expansion of, the appropriate code (DOARRAY).If the contents of the compila- tion record had not been defined at this stage, a NOOP would have been compiled. In this way, D-ARRAY, a defining word, can be kept out of application code, and its run-time component initialized (at compile-time) from within the application code. The approach also allows the program- mer to vary the action of BOARD,say during a debugging session, but a more important advantage is that the coding elegance of CREATE ... DOES> Constructs can be used in application code without the penalty of June 18 -21,1991 including the defining code. University of Rochester Clearer and more efficient definitions of ARRAY and D-ARRAY, using register For more information, contact: variables, are given in Figures Three-a and Three-b. Note that the ARGS or REGARGS Lawrence P. Forsley for the run-time code must include the Conference Chairman implicit address on top of the stack. Institute for Applied Forth Research, Inc. 70 Elmwood Avenue John Redmond is an Associate Pro- Rochester, NY 14611 USA fessor of Organic Chemistry at Sydney's Macquarie University. He (716) 235-0168 (716) 328-6426far is a ". . .sometimes-evenings-when-1- EMail: GEnie ...... L.ForsIey have-time programmer" who wel- Compuserve . . .72050,2111 FD comes letters from readers: 23 Internet ...... [email protected] Mirool Street, West Ryde, NSW 2114, Autralia.

I Volume XII, Nwnber 6 19 Forth Dimensions FORML XI1 NEIL BAWD - GOAT HILL, CALlFORNIA m

TeTwelfth FORML Conference was held at Asilomar, Thanksgiving weekend, Report by EDWIN ALB 1990. The theme of the conference was at FORML XI1 "Forth in Industry," and the presentations gave ample evidence that Forth is doing At the 1989 FORML conference, an unoficial unFORML contest was held by the very well in this arena. Forth's fort6 is being participants and their guests. able to do things which no other language can do, given the particular environment. "Complete the following sentence: The conference began with GUYKELLY Programming is like Sex Because.. ." describing nine projects representative of The contest was conducted by the aptly named NEILBAWD, and the judge was an some of his experiences with Forth in expert in the subject--his wife. The contestants, except for the winners, were kept industry. GwGROTKE expanded with a few anonymous. The following entries were received. of his experiences, and RAY ST. LAW, This entry was rejected by the judge because "eunuchs" was misspelled: from New Brunswick, demonstrated that It isn't much fun to do with unix. Forth is equally potent north of the border. This entry was rejected because it was unsigned: JOHNWATERMAN, V.P. of Forth, Inc., spoke Programming is not like sex because I can still program. on event management in process control. KEN B~RFIELDshowed how he uses The Women's Entries Forth at Los Alamos to control serial You never know when to stop. devices. ANDREWScorr, in an impromptu Many users are satisfied without documentation. talk, told how he renamed Forth to be used Programming is not like sex because sex can't work with software. as a language for testing communication- Even with the best preparation, all efforts lead to frustration if the hardware is out line protocol. of order. The women's winning entry: It's never finished. ANNE EDGECOMB Forth is for profes- The Men's Entries The first three entries are from the same person. sionals doing real ap- I can never get enough of it. plications in real time. My wife doesn't want me to do either. When you do it professionally, it's not as much fun. After three days without it, life becomes meaningless. Some of these applications are quite Satisfaction is guaranteed with a steady relationship, patient endurance, and lots of glamorous, others less so, but all showed physical effort. that Forth has strength in dedicatedapplica- When I can't get to sleep I have to do one or the other. tions unmatched by any other language. Experience should improve the experience; when this is not the case one of the Forth is a language for professionals doing partners should change. real applications in real time. Safety is always rewarded-but then so is indulgence. Forth is a language for engineers. Dr. It keeps us up late at night making little extensions. RICHARDTURPIN told how he used Forth as Most of us use more than just three fingers. the language of design in a microprocessor When you make a mistake you end up supporting it for years. systems design course at a California col- The men's winning entry: lege, and Dr. RICHARDHASKELL matched it You can hear about it, you can talk about it, you can read about it, you can even with his account of the use of Forth in a watch it done by experts, but even with all the fumbling andmess, it's still more sat- required engineering course in a Michigan isfying to get personally involved with it. NICKGROSSMAN college. In other presentations, Dr. Haskell

I Forth Dimensions 20 Volume XiI, Nwnber 6 described the successful use of Forth for handicapping horse races, and the tribula- tions of porting eForth to the 68000. Proceedings of the 1990 All other computer languages, com- Rochester Forth Conference pared to Forth, are languages of bondage Over 70papers on the state of the art in Forth and discipline. FORML celebrates Forth's and threaded interpretive languages, including freedom. Dr. LEONARDMORGENSTERN comparisons of C, ADA and Fonh for em- "EMBEDDED showed how to implement safety nets for bedded systems, and eleven papers fiom the SYSTEMS error recovery and yet another object pro- Soviet Union gram in Forth. DEANSANDERSON'S discus- + ShBoom on ShBoom: A Microcosm of sion of managing dictionaries as packages Hardware and Software Tools was awarded first prize. MIKEELOLA Mr. Charles Moore, Computer Cowboys showed how to incorporate generic stack +Using Forth to Analyze and Debug operations. C. H. TINGexplained eForth- Kernel-less Embedded Systems the model, design, and implementation. Mr. Darrel Johansen, Orwnlnrments, Inc. Forth is a language for research and +Active Messages and Passive Objecb: development. S.Y .TANGws it for approxi- An Object Oriented View of Forth mate rational arithmetic, JOHNWAVRIK for Mr. Rod Crawford, MPE, LLtd the study of group theory, FRANKSERGEANT + The Forth System Behind VP-Planner: to investigate the use of a three-key key- Designing for Efficiency board for text input, ANDREW MCKEWAN in the Face of Complexity spoke on his use of Forth for 6805 develop- Dr. Kent Brothers, Stephenson Sofiware 12 ~TH,1990 ment on a budget and a multi-tasker for the +The Future of Forth in Astronomy JUNE - 1 UNIVERSITYOF ROCHESTER 68HC11, TOMZIMMER gave his thoughts on Dr. Arne Henden, Ohio State Univ. Forth for the 90's. Someone attending said that FORML +Ada and Forth: How Do They Stack Up? has become the forum for standardizing Dr. James D. Basile, Long Island Univ. Forth, and ANSI X3J14 the laboratory for modifying Forth. Mrrm BRADLEY'Sreport Jm I on the progress of ANS Forth gave reassur- Volume 6 Number 2 ance that the ANSI effort will ultimately be +The Cost of User-Friendly Programming: successful--even his proposal for stream MacImage as Example ID in Forth seemed fair and reasonable. Ferren MacIntyre, Univ. of Rho& Island The reason that I personally prefer FORML to other computer conferences is +Little Universe: A Self-referencing State Table that there is always something to take home Karl-Dietrich Neubert, Physiknlisch-Tech- and try myself. Presenters do not all just nische Bundesanstalt, Berlin, FRG say, "This is what I did." They say, "This is what I did, this is how I did it, and how you +A FORmula TRANslator for Forth can do it too." This year, besides much of J.V. Noble, University of Virginia the material above, there was GLEN *A Generalized EXIT HAYDON'Sself-teacher for musical ear Carol Pruitt, University of Rochester training, and ROBCHAPMAN'S technique for +Strings, Associative Access, an efficient hashing method. and Memory Allocation As good as the papers were, what makes N. Solntseff, McMarter University FORML great is what happens between the sessions. This cannot be explained; it has to be experienced. The paradox of the confer- Volume VI Subscri~tions Send name, full address and phone number. Check or money order in US funds, or, ence is that it is exhilarating and exhaust- Individual* Corporate VISA/MC # and exp. date to: ing. It is something for the entire family. If USA $60.00 $145.00 Institute for Applied Forth Research you bring some or all of your family, you CanadaNexico $65.00 $145.00 70 EImwood Avenue will see them only late at night and/or early EuropeJAsia $75.00 $160.00 Rochester, NY 14611 USA in the morning; but you all will be so busy 1990 Rochester Conference Procee- (716) 235-0168 (716) 328-6426fax that they won't miss you and you won't Embedded Systems $30 plus $5 S/H. EMail: GEnie ...... L.Forsley miss them. Compuserve . . . .72050,2111 The success of the conference was due, Internet ...... 72050.2111@ as always, to the organizational genius of compuselve.com (Continued on page 25.) I

Volume XII, Number 6 2 1 Forth Dimensiwu PENCIL-AND-PAPER ARITHMETIC J.J. MARTENS - KAUKANA, WISCONSIN rn

TeIdea for WHATS-IT.BLK came succeeding prompts with .I468 and .463 three more to add three extra places to the while I was reviewing an out-of-print and the result should look like this: quotient. book.* In a sense, the program shows that Forth can work with decimals, including Enter either number first Decimal Addition long division, in much the same way we ENTER NUMBER 263.42 * 12.4 = and Subtraction used to do it with pencil and paper. Let me 3266.408 When adding and subtracting decimals, explain. ENTER NUMBER .I468 * .463 = the pencil-and-paper method puts numbers Assuming that you have looked over the .0679684 one below the other, with the decimal code and have access to F83, let's go di- points aligned, and proceeds with implied rectly to MULTIPLY, the first of the three Note that in the first example, there are zeroes in the empty places to the right of the high-level words in screen five. Before two digits to the right of the decimal in the decimal point. The ADDMODE computa- entering anything, it's important to be multiplicand (.42) and one in the multiplier tion uses actual zeroes. aware of: (.4). Therefore, according to the rule for pencil-and-paper arithmetic, the product ok ADDMODE The Game Rules will have 2 + 1 = 3 digits to the right of the I decimal (.408). In the second example, the At the application's prompt (which reap- 1. All numbers must be entered with a program pads the product with a zero in pears after each entry), enter 1254.6200, decimal point somewhere. order to get seven digits to the right of the 129.3600,26375.8000,4.7530, 18.9654, 2. Theoretical limits for data input and decimal. -83.0000, and 0. successively, and the re- output are 2,147,483,647 to sult should look like this: -2,147,483,648. For practical use, the Decimal Division limits are &999,999,999. ok 2 DIVIDE ADDMODE 3. When multiplying: the number of digits 1254.6200 in the multiplicand plus the number of At the application's prompts (again, there 129.3600 digits in the multiplier must not exceed are two), enter 679.684 and 14.68 then 26375.8000 nine. follow succeeding prompts with 4.7530 4. When dividing: the dividend must have 7461.70000 and 56.83 and the result should 18.9654 as many or more places to the right of be: -83.0000 the decimal as does the divisor. TOTAL 27700.4984 5. When adding: All numbers must have Enter dividend first the same number of digits to the right of ENTER NUMBER 679.684 / 14.68 = * Handbook of Business Mathematics, the decimal. If any are short, fill with ze- 46.3 Wm. R. Minrath. D. Van Nostrand Co., roes. ENTER NUMBER 7461.70000 / , Inc. 1959.

The penalty for violating rule #1 is a JJ. Martens ran the family business In the first example, there are three system crash. Other penalties are usually for nearly three decades, then spent digits to the right of the decimal in the less severe. Caution is recommended. several self-employed years until his dividend (.684) and two is the divisor (-68). 'practical retirement.' His interest in Since we are now dividing instead of multi- We are now ready for a trial run. Forth and subsequent purchase of a plying, according to the rule for pencil-and- Jupiter Ace computer (and more Decimal Multiplication paper arithmetic, the program will subtract equipment later),was aroused in 1983 2 MULTIPLY instead of add, putting 3 2 = 1 digit to the ok - by Popular Computing, which he calls right of the decimal in the quotient (.3). The "...agood magazine, how extinct." At the application's prompts (there are second example illustrates adding a zero to two), enter 263.42 and 12.4 then follow the the dividend to satisfy game rule #4, and

Forth Dimensions 22 Volume XII, Number 6

BEST OF GENIE GARY SMITH - UTTLE ROCK, ARKANSAS rn

Mws from the GEnie Forth review our work. When we think we're the-shelf single-board computers with a RoundTable-Last issue we recapped done, our draft standard will be published variety of ROM language support. Some guest conferences with Robert Smith, for a four-month public review period. have C, some have BASIC, but all have "Floored Division and Floating Point"; We're required to respond in writing to all Forth, since that is our in-house develop- Phil Koopman, "Stack Machines"; Charles comments, and if we make changes as a ment language for custom projects. Curley, "A Minimalist View of Forth"; and result there will be an additional two-month John D. Hall, 'The Business of FIG." review. This cycle will repeat as many Wheeler: We have applications run- In this issue, we will continue our romp times as necessary. At the end, our govern- ning all the way from the SBC88 monitor- through guest conference memory lane by ing body will review both our standard and ing a couple of digital input bits, to net- checking back on visits with Elizabeth the process. Not only must the standard be worked boards monitoring several analog Rather, "X3J14 Chair Discusses the ANS clear (etc.), but the process must be proven and digital inputs in real time while com- Forth Effort"; Steve Sarns and Steve to be open and fair. municating with the user via LCD and Wheeler, "Vesta Technologies and Em- We welcome proposals from anyone. keypad on one board, with all boards using bedded Foe,Dr. John Wavrik, "Teach- The most useful are specific proposals to amulti-drop RS485 network to talk to each ing Forth"; Jim Tittsler and Allan Pratt of make explicit changes to BASIS. Less- other. The typical application anymore Atari F'roduct Development, "Hardware specific comments are also welcome and seems to be one board with a few analog Prototyping with Forth"; and Tom Almy will be taken under advisement, but are inputs, a number of digital inputs and out- from Tektronix, Inc.'s engineering, "User harder to act on and thus less effective. puts, an LCD and keypad for user interface, Interface for non-Forth Users." A standard should not try to innovate, and talking RS-232 to some kind of log- improve, or extend a technology. Insofar as ging station. Elizabeth D. Rather (January 1990) possible, we try to identify "common prac- President of FORTH, Inc. tice" and articulate it. Some compromise is Dr. John Wavrik (March 1990) Chair of ANS Forth Technical inevitable, particularly when there are con- University of California - San Diego Committee flicts in common practice. Mathematics Department In the fall of 1986, about a dozen people Dr. Wavrik's topic, "Teaching Forth," met at FORTH, Inc. to start an effort to Steve Sarns, Steve Wheeler (February quickly centered on how an effective stan- produce an ANSI standard for Forth. They 1990) dard can improve the ability to teach Forth included three major vendors (competi- Vesta Technology, Inc. and make the language more credible. tors!), users from large companies (IBM, Whether you agree or disagree with some MCI, etc.), and individual consultants/ Sarns: Five years ago, I founded Vesta of its points and conclusions, this tran- experts (including Chuck Moore). All of us in my living room. I was theonly employee. script should be required reading for any- agreed that an ANSI standard would im- I built the prototype of the product we now one involved in teaching or standardizing prove acceptance of the language, improve vend as the SBC88. The unit used Forth and Forth.--Gary our ability to hire programmers or get jobs had a Forth in ROM. I typed it in from the (depending on which side of the fence FIG listings, but made it ROM-able, and at My assigned topic is "Teaching Forth," you're on!), and make it easier to move the same time was debugging the wire- and I'd like to talk about why Forth is avery programs from one Forth to another. wrapboard. good language for work in mathematics, The ANSI process operates under very Radio Electronics published an article and discuss how to teach it. Having a lan- explicit, detailed rules designed to ensure in March 1984 that featured the board con- guage taught is essential for its spread. It broad participation in the development and trolling "smart homes." That three-month also has desirable side effects like estab- review of any standard. Anyone can be a series basically launched Vesta Technol- lishing notational conventions and writing member of the TC who has the time and ogy. In fact, we still get product inquiries styles (so that users of the language can money (mostly for travel--the fees are based on those articles! understand each others' programs). minor in comparison), and you don't need Nowadays, about half our business is Forth is a very good language to teach. to be a member to submit proposals or custom engineering, and we sell five off- It can be understood in terms of how it

Forth Dimensions 24 Volume XII, Nwnber 6 works--this is a powerful handle for learn- I consider Forth a reasonable tool for * * * ing anything. The only people who really a large class of problems-but it is just one have problems with it are those who think tool of many I may choose to use. I have to believe that the insights offered that a language must be defined by a BNF. in these guest conferences are the "stuff' Forth is very different from other lan- Pratt: I have a little less to say-I take that can make a significant differencein the guages-but not hard to learn if ap- over when Jim has brought up the hard- way Forth isperceivedandused. I willgrant proached on its own terms. ware. I don't use Forth any more, but I that interactive conferences can be trying, Forth is also a good language to use in guess I'm (in)famous for CFORTH, a because they lack the intimacy one-on-one teaching since so much can be made visible small, portable Forth interpreter with the conversations provide. On the other hand, which other languages hide. It can be used kernel written in C, not assembly. If you're when was the last opportunity you had to to help students gain insight into how using CFORTH, you should probably stop. talk to a Steve Sarns about an embedded computers represent data structures and Get a real Forth for your machine from the Forth application, or to gain an instructor's implement algorithms. It can even provide nice folks at FIG or someplace (like this keen perspective from Mahlon Kelly or an understanding of how conventional library),becauseCFORTHisso weird it'll John Wavrik? I suspect your only such languages work. warp you for life. On the other hand, it can opportunities are via the GEnie Forth I would be remiss, however, if I failed to help you grok the very low-level stuff in a RoundTable guest conferences, and if you mention that having Forth taught depends a Forth interpreter if you understand C and failed to participate in these your chance is great deal on whether the Forth community not assembly. probably forever lost. Won't you join us in makes it teachable. A language cannot be a forthcoming one and discover for yourself taught if it is made unteachable. Tom Almy what you have missed? Here is how to make a language un- Electrical Engineer, Tektronix, Inc. teachable: I have a deep concern with keeping * * * Forth so that the "average" person (one 1. Have no university-level texts. who is not computer literate) can make use Upcoming guests on GEnie's Forth 2. Make it impossible for anyone to write of the PRIDE CAD program without going RoundTable: a university-level text (see 3 & 4). nuts or having to get hold of me for each March 21 Roy Martens and Glen Ha- 3. Make the language unstable, e.g.: little problem. I also have taught Forth ydon, "The Status of MVP in a. change the language's standards classes to over 100 people, and have seen Today's Market" every few years, and where they have difficulties. Major April 18 Charles Johnsen, "Mutable b. split the language into multiple dia- changes in my system, some of which are Instruction Set Computers" lects. being adopted: May 16 Bradford Rodriguez, "ANSI: 4. Make the language non-portable. Ask Not for Standards Im- 5. Have no pool of (portable) basic appli- No screen files. provement" cation packages. Better number formats. June 20 Jan Shepherd, "The Forth 6. Make it impossible for such apool to be "To" variables. Interest Group" produced (see 3 & 4). All words, even control structures, work 7. Fail to provide support to education. in the interpret state so that one doesn't need to be concerned about being in a Allan Pratt, Jim Tittsler (April 1990) colon definition. Atari Product Design Graceful aborts on errors. Tittsler: Here at Atari, we have been Easy access to host 0s. using Forth to "bring-up" and debug new computer and peripheral hardware for The net result is that the users (mainly (Continuedfrom page 20.) many years. It has a few significant advan- scientists with little background with pro- tages over other methodologies: grmming) are able to write simple Forth BOBREILING, his hard work, and the hard The interactive, incremental nature of programs and issue commands without work of mKEPERRY and JA~sHEPH~R~. Forth allows the user to explore new hard- problems. Canada was represented by four atten- ware quickly and at the same time build on The result is that these users have no dees and a guest, Australia by RODN~. already-known components. fear of using Forth. Managers, of course, YOUNG,and Russia by IG~RAGA~. * Basic Forth literacy can be achieved still do but they are happy with the results. In the final hour of the conference, quickly by hardware engineers whose goal Namely, the designers are able to create wRnNTR~~~, WIL BADEN, GW GROm, is hardware verification, not software de- masks for ICs, hybrids-whatever their M~~ BRADLEY,and cHucK MOO^^ gave velopment. Job-in short time, using a program that their impromptu thoughts about the future The amount of hardware that has to be runs on a relatively inexpensive system, of ~~rth.ney differed in many things but correctly functioning to support a "signifi- and with little training. they all believe that Forth has a mature, cant" development-and-test environment strong, and immortal life ahead. is quite limited. - NEILBAWD

Volume XII, Number 6 25 Forth Dimemiom INTERNATIONAL GENIE ACCESS DENNIS RUFFER - DRUFFER ON GENIE rn

Despite some of the difficulties being satisfied, we will refund the monthly sub- following address: experienced within Fornet, the GEnie scription fee. leg is alive and expanding. In fact, GEnie is Effective 10/1190, we implemented a Telephone: 03-452-9800 running at its lowest cost in history. Since mandatory monthly subscription fee of NEC VAN Marketing Division the sign-up costs and user fees have $4.95 per month. After extensive research, Mita Kokusai changedrecently, I will explainbelow what users (both ours and our competition's) BIL. 5F 1-4-28 the latest information is. If you are not have indicated that they would prefer un- Mita, Minato-Ku Tokyo interested in this information, please disre- limited access to select services for a set Japan 108 gard it. For those of you who are not totally monthly fee. The most broadly accepted Att'n: Yutaka Fujii set against capitalism, I've got some good price point is $4.95 per month. Thus, the news for you. introduction of GEnie's unlimited access The current sign-up user number and Whatever method you use to sign up, servicesduring non-prime (local time) password in Japan is XJMl1719,GENIE drop by and say hello in the Forth hours-which include over 100 products and there is an 8000 yen sign-up fee. RoundTable (type FORTH at any main and services. menu). My GE Mail address is GEnie via D.RUFFER, drop mea note if you have any GEnie Services which do not incur addi- Public Data Networks problems. tional charges: GEnie can be accessed from any of the News, Weather, Sports (top stories), following countries by using the state- U.S.A. Travel reservation information (including owned Public Data Networks To sign up, have your modem call 800- Easysabre), Closing Stock Quotations 638-8369 using 300/1200/2400 baud. (U.S. markets only), Electronic encyclope- Australia, Belgium, Denmark, Finland, seven bits, no parity, and half duplex (i.e., dia, GE Mail (message send-and-receive France, , Ireland, Italy, Mex- local echo). After you connect, type HHH only), Leisure & ProfessionalBB's (just the ico, Netherlands, New Zealand, Norway, pausing slightly between the H's. GEnie BB, no RTC or SL's), Classic GEnie Philippines, Portugal, , South will respond with a U# prompt. If it does Games (single player games, not MP), Africa, South Korea, Spain, Sweden, Tai- not, hit return and it will. At the U# prompt, Shopping Services, Free subscription to wan, United Kingdom. type XJM11849,GENIE and hit return. Livewire (ten times per year, up from six You will be taken into the sign-up module times) In order to access GEnie through the that will ask for your credit information above-listed countries, one must follow the (Visa, Mastercard, Discover, American Canada procedures listed below (there is no sign- Express, or direct checking withdrawal) (All access numbers listed are tri-speed.) up fee): and will tell you the closest access number. Sign-up only: 800-387-8330 1. Connect to the local PDN (public data Your account should then be validated for Vancouver 604-253-8429 network) by joining the localPDN serv- your use with 24 hours. If you have any Toronto 416-858-1230 ice. problems, call 800-638-9636. Cah?ar~ 403-232-612 1 Montreal 514-333-1 117 2. Enter the following information all on Sign-up costs one line: Sign-up $0.00 The sign-up procedure and Client Serv- 3 136 (GE Information Services' Manual 12.95 optional ices telephone number is the same as for the DNIC) 9 (indicates PAD service) 00 Postape U.S.A. (See above.) (indicates asynchronous service) Net Cost $0.00 or $14.95 Japan Thw,enter: Plus, GEnie offers a money-back guaran- For information about signing up in , 3136900 tee! We're inviting users to try GEnie for a Japan, use the following number to reach or: month. After the first month, if they're not their Client Services or write them at the , 3 1369000000000

Forth Dimensions 26 Volume XII, Nwnber 6 if the PDN requires the full X. 121 d- Europe GE Information Service GmbH dress. Contact the PTT representative if As with the PDN countries,there is no sign- Robert-Bosch Strasse 6 there are any questions as to the correct up fee for GEnie Europe. A manual is not 5030 Huerth-Efferen, Germany addressing structure. GE Information included, but may be ordered for $28.95 49 (2233) 6091 Services will distinguish the access (which includes shipping and handling). Telex: 8 882 420 speed (300 bps or 1200 bps) automati- For information and local sign-up proce- cally. dures, call or write:

3. Follow the MARK*NET Service sign- Hourly Connect Charges on prompt U#= with the traditional user number and password: XJM11997,F'DN Prime U.S.A. $18 $6 Canada C$25 C$8 4. After the signup, a stamp package will Japan 5400 5400 (yen) be mailed. This includes a contract, $8 which we need signed and returned PDN countries* $20 EUmpe before the account can be validated. If $27 $18 can FAX the sign* you choase' *F'rices are in addition to the PDN charges. Prime time is in effect from 8 a.m. to 6 p.m. contract. (The fax's number appears on Eastern time (U.S.A.) on weekdays (i.e., Monday through Friday). Non-prime time is the contract.) all other hours, including GEnie holidays.

Total control with LMI FORTHTM Forth Interest Group...... 44 brProgramming Professionals: an expanding family of compatible, high- Harvard Softworks...... 10 performance, compilers for microcomputers For Development: Journal of Forth Application & Research ...... 21 Interactive Forth-83 InterpreterICompilers 032, for MS-DOS, and the 80386 Laboratory Microsystems .27 lbbit and 32-bit implementations ...... Full screen editor and assembler Uses standard operating system files 500 page manual written in plain English Miller Microcomputer Services ...... 29 Support for graphics,floating point, native code generation For Applications: Forth83 Metacompiler Next Generation Systems ...... 17 Unique table-driven multi-pass Forth compiler Compiles compact ROMable or disk-based applications Excellent error handling Produces headerless code, compiles from intermediate states, Silicon Composers ...... 2 and performs conditional compilation Cmsscompiles to 8080,280,8088,68000,6502,8051,8096, 1802,6303,6809,68HC11,34010, V25, RTX-2000 No license fee or royalty for compiled applications I Labomtoty Microsystems lncorpomted &st Olfice Box 10430, Marina del Rg! C4 90295 Phone Cmdif Card Olders to: (213) 3067412 FAX: (213) 301-0761

Volume XII, Nwnber 6 2 7 Forth Dimensions REFERENCE SECTION

Forth Interest Group ANS Forth programmers who need to become profi- The Forth Interest Group serves both The following members of the ANS cient in Forth in the least amount of time. expert and novice members with its net- X3J 14 Forth StandardCommitteeareavail- Telephone 2 13-306-74 12. work of chapters, Forth Dimensions, and able to personally carry your proposals and conferences that regularly attract partici- concerns to the committee. Please feel free On-Line Resources pants from around the world. For member- to call or write to them directly: To communicate with these systems, set ship information, or to reserve advertising your modem and communication software space, contact the administrative offices: Gary Betts to 300/1200/2400 baud with eight bits, no Forth Interest Group Unisyn parity, and one stop bit, unless notedother- P.O. Box 823 1 301 Main, penthouse #2 wise. GEnie requires local echo. San Jose, Califomia 95 155 Longmont, CO 80501 408-277-0668 303-924-9 193 GEnie For information, call 800-638-9636 Board of Directors Mike Nemeth Forth RoundTable Robert Reiling, President (ret. director) CSC (Forthhret link*) D~M~SRuffer, Vice-President 10025 Locust St. Call GEnie local node, then type M710 John D. Hall, Treasurer Glenndale, MD 20769 or FORTH Wil Baden 301-286-8313 SysOps: Dennis Ruffer (DRUFFER), Jack Brown Scott Squires (S.W.SQUIRES), Le- Mike Elola Andrew Kobziar onard Morgenstern (NMORGEN- Robert L. Smith NCR Medical Systems Group STERN), Gary Smith (GARY-S) 950 Danby Rd. MACH2 RoundTable Founding Directors Ithaca, NY 14850 Type M450 or MACH2 William Ragsdale 607-273-5310 Palo Alto Shipping Company Kim Harris SysOp: Waymen Askey (D.MILEY) Dave Boulton Elizabeth D. Rather Dave Kilbridge FORTH, Inc. BIX (ByteNet) John James 111 N. Sepulveda Blvd., suite 300 For information, call 800-227-2983 Manhattan Beach, CA 90266 Forth Conference In Recognition 213-372-8493 Access BIX via TymeNet, then type j Recognition is offered annually to a forth person who has made an outstanding con- Charles Keane Type FORTH at the : prompt tribution in support of Forth and the Forth Performance Packages, Inc. Sysop: Phil Wasson (PWASSON) Interest Group. The individual is nomi- 5 15 Fourth Avenue LMI Conference nated and selected by previous recipientsof Watervleit, NY 12189-3703 Type LMI at the : prompt the "FIGGY." Each receives an engraved 5 18-274-4774 Laboratory MicroSystems products award, and is named on a plaque in the ad- Host: Ray Duncan (RDUNCAN) ministrative offices. George Shaw Shaw Laboratories CompuServe 1979 William Ragsdale P.O. Box 3471 For information, call 800-848-8990 1980 Kim Harris Hayward, CA 94540-3471 Creative Solutions Conference 1981 Dave Kilbridge 415-276-5953 Type !GOFORTH 1982 Roy Martens David C. Petty SysOps: Don Colburn, Zach Zachariah, 1983 John D. Hall Digitel Ward McFarland, Jon Bryan, Greg 1984 Robert Reiling 125 Cambridge Park Dr. Guerin, John Baxter, John Jeppson 1985 Thea Martin Cambridge, MA 02140-23 11 Computer Language Magazine Confer- 1986 C.H. Ting ence 1987 Marlin Ouverson Forth Instruction Type !Go CLM 1988 Dennis Ruffer Los Angeles-Introductory and inter- SysOps: Jim Kyle, Jeff Brenton, Chir 1989 Jan Shepherd mediate three-day intensive courses in Rabinowitz, Regina Starr Ridley 1990 Gary Smith Forth programming are offered monthly by Laboratory Microsystems. These hands-on Unix BBS's with forth.conf (Forthhrei courses are designed for engineers and links* and reachable via StarLink nod

Forth Dimensions 28 Volume XII, Number 6 9533 on TymNet and PC-Pursuit node SysOp: Lance Collins This list was accurate as of February 199 1. casfa on TeleNet.) Forth RBS JEDI If you know another on-line Forth re- - WELL Forth conference Paris, France source, please let me know so it can be Access WELL via CompuserveNet 33 3643 15 15 included in this list. I can be reached in the or 415-332-6106 7 data bits, 1 stop, even parity following ways: Fairwitness: Jack Woehr Cjax) Max BBS (ForthNet link*) Wetware Forth conference United Kingdom Gary Smith 415-753-5265 0905 754157 P. 0.Drawer 7680 Fairwitness: Gary Smith (gars) SysOp: Jon Brooks Little Rock, Arkansas 72217 Sky Port (ForthNet link*) Telephone: 50 1-227-7817 PC Board BBS's devoted to Forth United Kingdom Fax (group 3): 501 -228-9374 (ForthNet links*) 44-1-294-1006 GEnie (co-SysOp. Forth RT and Unix - British Columbia Forth Board SysOp: Andy Brimson RT): GARY-S 604-434-5886 SweFIG Usenet domain.: SysOp: Jack Brown Per Alm Sweden uunet!ddi 1!lrark!glsrk!gars Grapevine 46-8-71-35751 501-753-8 121 to register NEXUS Servicios de Information, 501-753-6389 S. L. *Fortmet is a virtual Forth network StarLink node 9858 Travesera de Dalt, 104-106, Entlo. that links designated message bases SysOp: Jim Wenzel 4-5 in an attempt to provide greater in- Real-Time Control Forth Board 08024 Barcelona, Spain formation distribution to the Forth 303-278-0364 + 34 3 2103355 (voice) users served. It is provided courtesy StarLink node 2584 on TymNet + 34 3 2147262 (modem) of the SysOps of its various links. PC-Pursuit node coden on TeleNet SysOps: Jesus Consuegra, Juanma SysOp: Jack Woehr Barranquero [email protected] (preferred) Other Forth-specific BBS's [email protected] Laboratory Microsystems, Inc. barran (on BIX) 213-306-3530 StarLink node 9184 on TymNet PC-Pursuit node calan on TeleNet SysOp: Ray Duncan Knowledge-Based Systems Supports Fifth 409-696-7055 Druma Forth Board 5 12-323-2402 StarLink node 1306 on TymNet SysOps: S. Suresh, James Martin, Anne 1 Moore Non-Forth-specific BBS's with extensive Forth libraries DataBit Alexandria, VA 703-719-9648 PCPursuit node dcwas StarLink node 2262 SysOp=Ken Flower The Cave San Jose, CA 408-259-8098 PCPursuit node casjo StarLink node 6450 SysOp=Roger Lee

International Forth BBS's Melbourne FIG Chapter (03) 809-1787 in Australia 61 -3-809-1787 international

I Volume XII. Nwnber 6 29 Forth Dimensions I Sponsored by the Silicon Valley and North Bay FIG Chapters I NORTHERN CALIFORNIA FORTH DAY C.H. TING - SAN MATEO, CALIFORNIA m

November 17,1990 Mike reviewed the design of eForth. Its MHz clock rate, and the four high-speed 10:OO a.m. - 5:00 p.m. main feature is the separation of the user serial communication lines. Presentations interface from the system functions. The user interface is left out of eForth, because SCIForth for RTX and SC32 ANSI Forth Standard Review it can be handled much better by the host George Nicol John Rible and ANSI X3J14 members computer. Only the system functions are George reviewed the product line of Sili- Basis 14 will be released shortly. 1i is needed in eForth residing in a target CPU. con Composers. SCtForth has been imple- expected that the final draft will be com- It is something CPU board manufacturers mented across all products which run dif- pleted in the January meeting next year. might be interested in. If it is packaged and ferent CPUs, like the NC4000, RTX2000, John specifically clarified the concepts of promoted properly, it may become a sal- and SC32. The portability of a single lan- standard systems and standard programs in able product. guage model greatly eased product intro- the context of ANS Forth Standard. ductions and software development. The 80196 Target Forth newest product is a VME single-board Catch-Throw Error Handling Mike Mayo computer based on the SC32 processor. Mitch Bradley Mike was asked to repeat his presenta- 200,000 Forth systems have been tion from the October meeting. He pre- Mechanizing PowerlMod Computation shipped by Sun Microsystems, in the form sented many interesting diagrams showing Alfred Tang ofForth bootROMs. All Sun Sparc stations the functional parts in the 801% Target Alfred described a unique method to have Forth in them, and all S-Bus peripher- Compiler, relating to code development, reduce the computational load of raising a als are required to have Forth on board for target code testing, and debugging tools. big number to avery high power, and taking booting their drivers. Mitch claimed that S- He keeps a ten-byte record for every byte the modulus of the product. This method Bus will be the bus of choice for computer- compiled into the target, so that the host can can be very effective in building hardware ized hardware. support single-instruction-stepping and for the public key encryption-description CATCH-THROW requires only ten lines source-level debugging in real time. system based on the RSA algorithm. The of code for two Forth words. It is postfix math is fully disclosed. and requires no immediate actions. Fully YAOOP-Yet Another Object Oriented nestable, no hidden run-time code, imple- Program Programming Contest mentable in high level, and no metacompi- Leonard Morgenstern Contestants were given a text file con- lation implications. Usage and code ex- Only three Forth words are needed: taining Psalm 119, and were asked to count amples are also presented. CLASS, METHOD, and ATTRIBUTE. the number of words, the number of unique CLASS defines an object with a number of words, and to produce an alphabetically Safety Net Error Handling execution methods, which can be selected sorted list of all the unique words. The file Leonard Morgenstem at run time. It is very simple and highly is about 16K. There are about 1500 words This is another way to provide error portable. The only drawback is that it does and 500 unique words in it. The Most handling in Forth systems. You use SET- not support full inheritance. The full paper Honorable Cowboy Chuck Moore presided NET to initialize a net, which is a six-byte was presented at the Asilomar FORML as judge. array. FALL allows you to jump to a net Conference. Six braves entered the contest. Mitch when an error condition is asserted. It is Bradley brought a formidable Sparcl sta- nestable if additional words like PUSH- Transputer Forth tion fully loaded. He used Unix shells and NET and POP-NET are provided. It is also Bob Barr pipes to finish the counting and sorting in usable as coroutine, about which people The Forth for transputer is based on an eight minutes, but was asked togo back and disagreed on the definition and functional- F83-68000 implementation. A special write a program to do the job. Andrew ity. board was designed to support a solid-state McKewen completed the counting and disk emulator at Mass Memory Technol- sorting in 42 minutes, and Mitch completed Critique of eForth ogy. It takes advantages of the 4K internal his in 54 minutes. Andrew was awarded a Mike Elola memory, 32-bit data and address space, 20 (Continued on page 41 .)

Forth Dimensions 30 Volume XII, Number 6 METACOMPILATION MADE EASY FRANK SERGEANT - SAN MARCOS, TEXAS

Metacornpilation prowls the narrow alleys of Forth, lurking in the shadows, 16 CONSTANT TMAX-FILES ( allow room in tgt for 15 files,) ( but MUST be a power of 2) scaring the children. Does the monster really exist or is it just a legend? (Eerie 2 1 - CONSTANT TNB ( set number of disk buffers) music.) It's nearly midnight, wanna go out and look for it, huh? Get the flashlight, a VARIABLE RAM ( next system variable will go) fifth of Scotch, a 12 gauge shotgun and VARIABLE H' $8000 , ( relocation amount) come with me. Don'tbeafraid. Here, let me ( 1st cell is tgt's DP &) hold the shotgun. No, no, after you. ( 2nd cell is tgt's offset) The flashlight is all we need. Metacom- $8000 $2000 0 FILL ( initialize target space to zeroes) pilers can be monsters, but shining a little light on them should dispel the temr. We'll $8000 H' ! ( start target dictionary at $8000) take a look at them in general and also 3 13 THRU ( load the metacompiler extensions) discuss a specific, simple version from Pygmy Forth. But first.. . 17 80 THRU ( load the kernel)

- - - PRUNE ( relink the target dictionary)

cmFORTH's novel ( ( switch to target dictionary) and elegant method $8100 HERE SAVEM KERNEL.COM has just two vocabu- 1 ( switch back to host dictionary) laries. Figure One. Load screen for metacompiling a new kernel.

What Is A Compiler? These variables hold the address of the corresponding target run-time routines. These are A compiler is a program that lays down needed by the metawmpiler so it can compile the proper code. As each run-time routine is defined in the target, its address is stored into its corresponding variable. code and data that matches your source code. It is usually thought of as a translator VARIABLE WAR ( variable) VARIABLE TLIT ( literal) that converts source code into machine VARIABLE TCOL ( docol) VARIABLE TBRA ( branch) code. It might be more helpful, though, to VARIABLE TOBR ( zero branch) VARIABLE TEXIT ( exit) VARIABLE TFOR ( for) VARIABLE TNEXT ( next) think of it as something that steps through VARIABLE TARR ( array) VARIABLE TABORT ( abort") memory, byte by byte, filling in whatever VARIABLE TDOT ( dot") VARIABLE TNULL should be put there. Most languages have a compiler. Forth Figure Two. has many compilers. The most basic compilers in Forth are ("C-comma") and ("comma"). They The curly braces switch back and forth between the host and target spaces, by swapping the c, , dictionary pointers and relocation factors. This allows the regular comma. Ccornma, and take numbers from the stack and lay them to access both the host and target dictionaries. down at the next free byte or word in the dictionary (and then increment the diction- : { ( -) CIA @ HERE H' 2@ H ! dA ! H' 2! ; ary pointer). : ("colon") is the most com- :I (-)(; monly used compiler in Forth. It uses C, Figure Three. , and , to lay down bytes and words into the dictionary as it compiles new definitions. L Volume XII, Number 6 31 Forth Dimensions This is usually done in a number of steps. T-TE creates a header for a word in the target dictionary. It lays down a two-byte link with the help of various compiling words. field that points to the previous word's link field. Then it lays down a three-byte jump to the run-time routine for VARIABLE. This new word's link field address is stored in the vocabulary each of which does its part. For example, head (CONTEXT @ HASH). IF StXtS an IF .. . THEN StIUCtUre by laying down a conditional branch. THEN Definining words other than VARIABLE will uncompile those three bytes (with -3 ALLOT completes the branch. VARIABLE and etc.) and lay down a jump to their omrun-time routine. CONSTANTare other familiar Forth com- HEX pilers. Ultimately, they all rely upon , and : TCREATE ( -) C, to get those bytes laid down. ( 2byte link, counted name, & 3 byte jump to targets var) Metals TVAR holds var's addr as soon as we know it) ( Is HERE 0 I 20 WORD ( cur.lfa cur.nfa ) How Forth Different CONTEXT @ HASH ( lfa nfa vocab ) Most other languages completely sepa- 2DUP ( cur-lfa cur.nfa vocab cur.nfa vocab ) rate the compiler itself from the result of @ ( cur.lfa cur.nfa vocab cur.nfa prev-lfa) SWAP ( cur.lfa cur.nfa vocab prev-lfa cur.nfa) the compiler. You take source code, feed it 2 - ( back up) ( cur.lfa cur.nfa vocab prev.lfa cur.lfa) into the compiler, and get object code. The ! ( cur.lfa cur.nfa vocab) object code is later executed independently SWAP ( cur.lfa vocab cur.nfa) of the compiler. Forth is different in that, C@ ( cur.lfa vocab len) 1+ ALLOT ( coma in the entire name field) usually, its compilers extend the current ! ( make vocab point to this new word's link field ) Forth system rather than creating an inde- TVAR @ LJMP, ( lay down 3byte jump to dovar) ; pendent system. Your new definitions are Figure Four. added to the definitions that are already present.

What Is Metacom pilation? forget ( -) Smudges the name field of the most recently defined (target) word. making it temporarily un-findable in the dictionary. This is rarely needed. Simply put, metacompilation is the process of making Forth do what other CONSTANT ( n -) Defines a constant in the target dictionary. Its value cannot be used languages do all the time: generate an inde- directly during metacompilation pendent system. The fancy name probably VARIABLE ( -) Defines a variable in the target dictionary. contributes a lot to the confusion. When you extend the dictionary in Forth you call ARRAY ( a -) ( n -) ( n is a word. not byte, index) it compilation. When you generate an inde- Defines an array of 16-bit numbers in the target dictionary. pendent system with Forth you call it meta- DEFER ( -) Defines a word in the target dictionary that can be changed to execute compilation. (In most other languages, the different words by the word IS. only thing you can do is generate an inde- pendent system.) 1s ( pfa -) Stores the address a into the following DEFER'd word in the target dictionary. Come on, there's got to be more to it HEX than that, you say? Well, okay. The "meta" means self-referencing. In other words, forget CONTEXT HASH 2 DUP 20 XOR C! : ( -) @ @ + C@ SWAP ; when what you compile is another Forrh : CONSTANT ( n -) TCREATE -3 ALIX)T system, it's called metacompilation. Using BX PUSH, I, BX MOV, NXT, ; ( use "in-line" constants ) the same logic, if you used a C compiler to compile another C compiler you could also : VARIABXE ( -1 ( RAM @ CONSTANT 2 RAM +! for ROMing) call it metacompilation. (As an aside, you TCREATE 0 , ; don't often hear of that, do you? No! Forth- ers are almost the only people generally ARRAY a n n is a word, not byte, index) : ( -) ( -) ( willing to build their own systems. Of TCREATE -3 ALLOT TARR @ LJMP, t0 course, some might say we're the only ones : DEFER ( ) ( ...) TCREATE -3 ALLOT 0 #, AX MOV, AX JMP, ; who need to.) : IS ( pfa -) dA @ - ' 1+ ! ; Target Compilation Figure Five. Well, the above explains where "meta" originated, but it isn't the full story. An- other term, "target compilation" compli- cates things slightly. What if you want to generate an independent system that is not a Forth system, perhaps a short utility pro- gram? In that case, you might call it target compilation instead of metacompilation.

Forth Dimensiom 32 Volume XII. Number 6 What if you use your Forth system to gen- erate independent code designed to run on These words re-link the target dictionary so that the correct values will be present in the link fields. a different processor? Its "target" is the other processor, so clearly this would be SCAN ( Ifa - Ifa) Follows the link fields backwards to find the next one that is in the target compilation. But what if that inde- target dictionary space. pendent system, designed to run on the TRIM ( lfa new-lfa - new-lfa) other processor, is another Forth system? Is Converts the previous link field address from a physical address to a logical address and stores it target compilation, metacompilation, or it in the current word's link field, then unsmudges the current word's name field in case it is meta-target-compilation?I don't think this smudged. leads anywhere, so I suggest we just use the CLIP ( voc-head -) Goes through all the words in a vocabulary. TRIMing each one, word metacompilation for all cases where links the first word to the null word. an independent system is generated. PRUNE ( -) CLIPS each of the target's vocabularies. I Other Definitions By target system ordictionary, we mean : SCAN ( lfa - lfa) @ BEGIN DUP 1 $8000 WITHIN WHILE @ REPEAT ; the result of the metacompilation. By host : TRIM ( lfa new-lfa - new-lfa) DUP PUSH dA @ - SWAP ! POP system or dictionary, we mean our regular DUP 2 + DUP C@ SDF AND SWAP C! ( unsrmrdge) ; Forth system. By the way. in cmFORTH and Pygmy, \ is used instead of [cOM- : CLIP ( voc-head -) DUP BEGIN DUP SCAN DUP WHILE TRIM REPEAT P ILEI -it does not indicate a comment. DROP TNUU @ dA @ - SWAP ! @ , ; PUSH and POP are used instead of >R and : PRW ( -) { 8 HASH CLIP 6 HASH CLIP R>. TNULL @ OFF ( zero out its link field) { ;

Uses of a Metacompiler Figure Six. 1 I Here are the main uses I can think of for a metacompiler: Some regular words need to be re-named so we can still get to them after we have defined metacompiler versions of them. 1. Use your current Forth system to make a slightly changed version of itself FORTH' ( -) Sets CONTEXT to the host's FORTH vocabulary. to run on the current hardware. I COMPILER' ( -) Sets CONTEXT to the host's COMPILER vocabulary. I 2. Use your current Forth system to \ ( -) Compiles the following word in the input stream from the host's COMPILER make a new (perhaps drastically differ- vocabulary. ent) Forth system to run on the current : Starts a colon definition in the host's FORTH vocabulary. hardware. ( -) l a@- ( a - a ' ) Converts a target physical address to a logical address. 3. Use your current Forth system to make a new Forth system to run on a : FORTH' FORTH ; different processor or operating system. : COMPILER' COMPILER ; 4. Use your current Forth system to make a standalone utility or application COMPILER : \ * \ \ ; FORTH to run on your current hardware. ... ., . ,. 1 5. use your current ~~rthsystem to I I : a@- dA @ - ; ( this is used often ) I I make a standalone utility or application Figure Seven. to run on different hardware.

Problems There are only two main problems that metacompilers must solve: logical versus physical addresses, and arranging and searching the dictionary so the right word is found at the right time.

Logical vs. Physical Addresses Whereas the regular compiler merely extends the dictionary, the metacompiler

I Volume XII, Nwnber 6 33 Forth Dimensions needs to lay down code somewhere else, ( -) Compiles a 16-bit literal into the target. LITERAL n usually referred to as the target space or I ( 1. ( -1 is the metacompiler's colon compiler. It looks up the next word target dictionary. The address where this from the mput stream and does something with it. If the word is in the host's COMPILER, the code is laid down is not the address where word is executed. Else, if the word is in the target's FORTH, the word is compiled. Else, if the it will sit later, when it is executed. For ex- "word" is a valid number in the current base. it is compiled as a literal. Else, an error is reported. Sequence is everything. This approach, plus the ability to switch between host and ample, if you are generating code that will target spaces with [ and ) ,is the secret to the simplicity of the metacompiler. later be loaded at address zero, you might build it at address $8000 (or wherever you CCMP ILER enough free memory to hold it). : LITERAL ( n -) TLIT @ ,A , ; When it is an address that you are laying FORTH down, you have two things to consider: its physical address (where it is now, at com- : ] BEGIN 4 -' ( restrict execution to host's COMPILER) IF 6 -FIND ( restrict finding to target's FORTH ) pile time) and its logical address (where IF NUMBER \ LITERAL you plan for it to be later, when it actually ELSE ,A executes). Suppose we wanted to compile THEN ELSE EXECUTE the address of the following 16 bits into THEN address $8000. The physical address of the AGAIN ; word is $8002. But, later executed, what's at $8000 will be at $0000 (and what's at Figure Eight. $8002 will be at $0002); we must store $0002 into address $8000. Thus, the meta- compiler needs a method of converting between logical and physical addresses. \ ( -) compiles the following word from target's COMPILER. Metacompiler words to create target looping and branching structures withiin target colon Search Order definitions: When you want to compile a definition into the target space, where do you look for BEGIN ( - a) Saves the address to branch back to. UNTIL ( a -) Compiles a conditional branch to address a. the words, and what about duplicates? AGAIN ( a -) Compiles an unconditional branch to address a. Should the word be compiled or executed? THEN ( a -) Completes a branch started by IF ELSE etc. Suppose you want to define the following IF ( - a) Starts a conditional branch. WHILE ( a - a a ) Starts another conditional branch. word: REPEAT ( a a -) Completes a BEGIN WHILE structure. ELSE ( a - a) Starts the false part of an IF statement. : DO-NOTHING ( n - n) FOR ( a) Starts a FOR NEXT loop. - DUP SWAP DROP ; NEXT ( a -) Completes a FOR NEXT loop.

COMPILER Let's take the words left to right. You don't : \ 8 - ABORT" ?" ,A ; (F83's [COMPILE] ) want to use the host colon that compiles : BEGIN ( - a) HERE : : UNTIL ( a -) TOBR @ ,A ,A ; into the host dictionary. Instead you want to : AGAIN ( a -) TBRA @ ,A ,A ; find and execute the metacompiler version. :THEN (a-)HERECIA@- SWAP!; Then, you want to find DUP, SWAP, and 0 : IF ( - a) TOBR @ ,A HERE , ; DROP, not in the host dictionary, but in the :WHILE (a-aa) \'IF SWAP; : REPEAT ( a a -) \ ' AGAIN \ ' THEN ; target dictionary. And you want to compile : ELSE ( a - a) TBRA @ ,A HERE 0 , SWAP \' THEN ; them rather than execute them. For the : FOR ( h -) TFOR @ ,A \' BEGIN 0 , ; semi-colon, the metacompiler version from ( performs u times instead of u+l times ) the : NEXT ( h -) DUP \' THEN 2 + TNEXT @ ,A ,A ; host must be found and executed. FORTH There are various tricks for looking in the right place at the right time. It can also Figure Nine. be very simple. Getting this search order right is the heart of the metacompiler. Now let's look at a simple way of solving these problems.

cmFORTH and Metacornpilation Charles Moore invented a beautifully simple metacompiler in his cmFORTH for the Novix. I used this general approach in Pygmy Forth for MS-DOS machines. The words { and 1 (left and right curly

Forth Dimensions 34 Volume XII, Nwnber 6 braces) switch between the regular diction- ABORT" ( -) ( flag-) Compiles following error message. ary and the target space, e.g., I I I - iI -I1 ( - ( - Compiles following string to be typed later. 1 I { : ABC DUP SWAP DROP ; ['I ( -) Compiles pfa of following word from target's FORTH : CDE ABC ABC ; as a 16-bit literal. : FGH ABC CDE ; 1 FORTH ( -1 Sets CONTEXT to target's FORTH. COMPILER ( -) Sets CONTEXT to target's COMPILER. would compile those three words into the target space and then return the dictionary : ( -) Starts a colon definition in target dictionary. Note that it lays down pointer back to the regular dictionary. a jump (it's faster) and not a call. Rather than having separate pointers for ; ( - Ends a colon definition in target dictionary. the two spaces, and two versions of HERE (perhaps HERE and THERE),the curly braces switch the value stored at H (the HEX COMPILER dictionary pointer, called DP in some : ABORT" TABORT @ ,A 22 STRING ; Forths). By handling the change at this low . .11 TDOT @ ,A 22 STRING ; level, the need for separate versions of : ['I TLIT @ ,A ; comma, C-comma, and HERE disappears. FORTH Relocation of addresses is handled by : FORTH 6 CONTEXT ! ; the words dA and ,A. d~ C'delta-address") : COMPILER 8 CONTEXT ! ; is a system variable that holds the reloca- : : TCREATE -3 ALLOT TCOL @ LJMI?, tion factor. It is used by ,A ("comma- (lay down 3byte jumptodocol) forget ] ; address") both in the regular Forth system (when dA has a value of zero) and when metacompiling (when d~ has a value of / Fyl%;aet - POP DROP TEXIT @ ,A : I must be the last colon) / / ( .def in the rnetacompiler) I I $8000). I. The above takes care of the simple prob- lem of compiling code at one address to run Fjgure Ten. later at a different address. The more diffi- 1 I cult problem is search order: how do we find the correct word to execute or com- pile? In some metacompilers this gets very string for later printing, and the word . " in and 8 point to the target FORTH and COM- complex, with complicated switching of FORTH thatprints the string right now. This P ILER voc-heads. This is not strictly nec- vocabularies and testing for whether we are eliminates the need for the abomination . ( , essary, but makes it simpler to follow what in the target dictionary or not. Fortunately which some Forths use to print a string you are doing and to control exactly where there is a simpler method. while interpreting. you are searching. These extra two vocabu- Charles Moore solved the problem (and The vocabulary heads immediately laries are used only when metacompiling. some others) in cmFORTH with the novel precede the variable CONTEXT. Thus, in Look at the code for INTERPRET in and elegant method of having just two Pygmy Forth, CONTEXT 2 - is the address Figure Thirteen. It only searches host's vocabularies: COMPILER and FORTH. of the vocabulary head for FORTH and FORTH. If the word is found it isexecuted. Words in COMPILER are immediate. All CONTEXT 4 - is the address of the vocabu- No problem, and no confusion with words the other words are in FORTH. When inter- lary head for COMPILER. Since the Novix of the same name that have been compiled preting, words are looked for only in is a cell-addressed machine, instead of a into the target dictionary. This gives us FORTH. When compiling, COMPILER is byte-addressed machine, the offsets in access to our regular Forth system for sav- searched first. If the word is found, it is cmFORTH are 1 for FORTH and 2 for ing memory images to disk, for poking executed (it is an "immediate" word); else COMPILER,rather than 2 and 4 as in around in memory with DUMP, for editing, FORTH is searched and the address is Pygmy. examining the stack, etc. compiled. New words are linked into either cmFORTH uses just those two vocabu- The same search mechanisms such as FORTH Or COMPILER depending on the laries, both for regular and meta-compila- -FIND, ' , and -' that are used with the value of CONTEXT. Thus, there is no IM- tion. To make my life a little easier with host dictionary work fine without any MEDIATE word. Thus, you Can have two F'ygmy, I added two more. It has a FORTH changes with the target dictionary. versions of a word with the same name, one and COMPILER for the host dictionary and Look at the code for I (the in each of the vocabularies. One only works another set of FORTH and COMP ILER for metacompiler's colon compiler) in Figure when compiling and the other only when the target dictionary. Thus, offsets from Fowteen. Here we explicitly control the interpreting. For example, you can have the CONTEXT of 2 and 4 point to the host search. Within a colon definition we first word . " in COMPILER that compiles a FORTH and COMPILER VOC-headsand 6 search the host's COMPILER. This finds

Volume XII. Nwnber 6 35 Forth Dimemions group 811 the metacompiler definitions Start of the Pygmy Forth Kernel. 6 and 8 are the CONTEXT values for the target's FORTH and together in one place and then group all the CCMPILER vocabularies. target definitions in another, rather than boot ( -) is where the execution of the PYGMY.COM fie starts. It is made headerless interleaving them. by the -7 ALLOT. It initializes the two stack pointers and jumps to the word reset. The second approach, which is used in Pygmy, is to define variables to hold the $ ( -) is the "null" word. The dollar sign is not its real name. Its real "name" has a length of zero! It is named $. then the -2 ALUX erases the dollar sign and length of 1. The 0 addresses of those run-time words (Figure C, changes the length to zero. When null is executed it exits an endless loop. This happens, Two). Then we can go ahead anddefine IF. for example, when the input seeam is exhausted. for example, to fetch the contents of the variable T 0 BR and lay it down. At the time HEX we define IF,the address of the run-time 6 HASH OFF routine Obranch is not known. Then, in 8 HASH OFF the target definitions, as soon as we define ( to target) Obranch we store its address into T OBRA. Of course, either way we must not 100 ALLOT ( first 256 bytes are reserved for DOS) use the word IF in a target definition until -7 ALLOT ( align pfa of BOOT to $0100 ) after 0 branch has been defined! Figures FORTH ( sets context to 6 ) Five, Nine, and Ten show how the defining words use these variables. Figure Twelve CODE boot ( for now leave stacks & everything in one 64K seg) shows the target definitions for the run- FFOO #, BP MOV, ( initialize return stack) FEOO I, SP MOV, ( initalize parameter stk) time words var, Obranch, and branch 0 #, AX MOV, ( addr of reset - patch it later) and how their related metacompiler AX JMP, ( jump to "reset") END-CODE variables TVAR, TOBR, and TBRA get ini- tialized. HERE TNULL ! ( following is null word that will get renamed) CODE $ -2 ALLOT 0 C, SWITCH, SI POP, SWITCH, NXT, END-CODE cmFORTH has it a little easier. It doesn't call run-time routines, such as HERE dA @ - RAM ! Obranch and lit. Instead, these are laid 2A TNB 1+ 2* + ALLOT ( leave room for system variables) down as in-line machine code. Thus, they are known at the time IF, LITERAL, etc. Figure Eleven. are defined. As the target image is being compiled, the link fields contain physical addresses so the host system can find target words. When finished, before saving the target the words IF, ELSE, THEN, BEGIN, get dictionary. Thus, there is no danger of image to disk, these link addresses must be WHILE, REPEAT, ABORT", and such. In finding the host's version of that word by converted to the correct logical addresses other words, the immediate words. These mistake. If the word is not found in either by applying the relocation factor from d~ words are the metacompiler versions that host's COMPILER Or in target's FORTH, to them. SCAN, TRIM, CLIP, and PRUNE are defined in the host's dictionary. These then an attempt is made to convert it to a in Figure Six take care of this re-linking and words are executed. They affect the compi- number and compile it as a literal. If that a few other housekeeping details. lation, usually laying down special run- fails, an error message is displayed. time target code. They are not confused Let's take a closer look at how the Using It with the host's regular versions of these defining words such as IF, ELSE, Actually using the metacompiler in same words, even though they are also in LITERAL, ABORT", etC. work. They must Pygmy Forth is very easy. Just type 1 LOAD host's COMPILER because the metacom- be defined in host's COMPILER so they (Figure One) and a new kernel will be piler versions were definedafter the regular will execute during the definition of a target generated automatically. Screen One loads versions. Any of the regular versions of word to lay down a target run-time word the metacompiler and then loads the source words in either host's FORTH or COM- that hasn't been defined yet. How do we code for the Pygmy kernel, then re-links the PILER that might be needed later must be handle this impasse? target dictionary and saves the image to renamed. See Figure Seven for an example There are two general approaches. The disk as a .COM file. At this point you can of renaming FORTH, COMP ILER, /,and : fust is to sprinkle these defining words return to DOS with BYE and run the new so we can access them later, after the meta- throughout the target code. For example, kernel. All the code for the metacompiler, compiler versions with the same names are IFmust lay down the code for Obranch. the kernel, and the editor and assembler is defined. Note that with this system, only We could switch to the target dictionary in the single file PYGMY.SCR. those four need to be renamed. and define Obranchand then switch back Pygmy Forth (for MS-DOSmachines) If the word is not found in host's COM- to the host dictionary and define the meta- is available on disk from FIG or by down- P ILER, then we look in target's FORTH. If compiler version of IF that uses it. This is loading from GEnie or other bulletin found, its address is compiled into the tar- a very workable method, but I prefer to boards. Look for version 1.3. If you haven't I Forth Dimensions 36 Volume XII. Number 6 uied metacompiling, this is an easy way to Examples of target run-time code words. experiment with it. The first step is to type lit ( - n) is the run-time routine for a literal. It pushes the following 16-bit word to the 1 LOAD without making any changes, to I I data stack. get a feel for the process. Then start making minor changes to the kernel, such as the array ( n - a) is the run-time routine for an array. It pushes the address of the nth 16-bit entry of the array to the data stack. number of disk buffers or the default col- ors. As your confidence and experience var ( - a) is the run-time routine for a variable. It pushes the address of the variable to with it grows, you can tackle more adven- I I the data stack. turous changes. Obranch ( n -) If the top of stack is non-zero, the following in-line address is Well, we shined the light nearly every- skipped. If the top of stack is zero, a jump to the following in-line where and found no monster to fear. Let's address is taken. "zero branch" put on the safety on the shotgun and finish that bottle of Scotch. I I branch ( -) An unconditional jump to the following in-line address is taken. Following is how a variable is compiled into the dictionary: LINK, NAME, JMP ,VAZUE Franksergeant is a hardware andsoft- 2 ? 3 2 (# of bytes in each field) ware consultant specializing in busi- CODE lit ( -n) HERE TLIT ! ness and real-time systems. He is the BX PUSH, ( push TOS to SOS) author and implementor of Pygmy AX IDDS, ( ax <-- [IP], IPtt ) Forth. ( get in-line value, not addr) AX BX MOV, ( to TOS) NXT, END-CODE

CODE array ( n -a) HERE TARR ! ( nth word index into array ) 3 #, AX ADD, ( jump over 3 byte JMP) AX BX XCHG, 0 [BX] BX MOV, 1 X, AX SHL, ( mltiply by 2 to addr nth word) AX BX ADD, ( now TOS holds addr of nth word of array) NXT, END-CODE I CODE var HERE TVAR ! BX PUSH, ( push TOS to SOS) 3 #, AX ADD, ( jump over 3 byte JMP) AX BX MOV, ( put that addr in TOS) NXT, END-CODE

CODE Obranch HERE TOBR ! AX LODS, BX BX TEST, 0-, IF, AX SI MOV, THEN, BX POP, NXTr ENDCODE

CODE branch HERE TBRA ! 0 [SI] SI MOV, NXT, END-CODE Figure Twelve.

(Figures continued on page 41.)

I 1 Volume XII, Nwnber 6 37 Forth Dimemiam (Continuedfrom page 5.) Attention Forth Authors! as Directors before; and Mike Elola and Jack Brown are continuing Directors. The first meeting of the Board was held at AUTHOR RECOGNITION FORML, where new officers of the corpo- ration were elected and the Board decided to increase the membership fees to $40. The PROGRAM Board's next meeting was planned for January in southern California. [Afterpress time for this issue. --Ed.] To recognize and reward authors of Forth-related articles, the Forth Interest Group The officers-John Hall, President; (FIG) has adopted the following Author Recognition Program. C.H. Ting, Vice-President; Mike Elola, Secretary; and Dennis Ruffer, Treasurer- Articles have started to reshape the functions of The author of any Forth-related article published in a periodical or in the proceed- FIG. The officer's job is to cany out the ings of a non-Forth conference is awarded one year's membership in the Forth Interest directions of the Board of Directors, sem- Group, subject to these conditions: ing as leaders in carrying out those direc- a. The membership awarded is for the membership year following the one during tions and performing the day-to-day func- which the article was published. tions of running the corporation. One of the b. Only one membership per person is awarded in any year, regardless of the President's duties is to preside at the Board number of articles the person published in that year. of Directors meetings and the monthly c. The article's length must be one page or more in the magazine in which it business meeting; another is to appoint appeared. committees or individuals to perform d. The author must submit the printed article (photocopies are accepted) to the needed jobs or to explore the implications Forth Interest Group, including identification of the magazine and issue in of potential useful services to our members. which it appeared, within sixty days of publication. In return, the author will be Call me with ideas! sent a coupon good for the following year's membership. The monthly business meeting (held the e. If the original article was published in alanguage other than English, the article Tuesday evening before the fourth Satur- must be accompanied by an Engish translation or summary. day) is where the decisions of the day-to- day functions get made. The members of Letters to the Editor the Business Group consist of the officers Letters to the editor are, in effect, short articles, and so deserve recognition. The and other individual members who are in- author of a Forth-related letter to an editor published in any magazine except Forth terested in the business of FIG. The Busi- Dimensions is awarded $10 credit toward FIG membership dues, subject to these ness Group is open to all members, each of conditions: whom-on all decisions of the Business a. The credit applies only to membership dues for the membership year following Group-can participate equally. Call the the one in which the letter was published. FIG business office. Tell us you are com- b. The maximum award in any year to one person will not exceed the full cost of ing! the FIG membership dues for the following yiar. In the next Forth Dimensions, I want to c. The author must submit to the Forth Interest Group a photocopy of the printed explore issues that I feel need to be dis- letter, including identification of the magazine and issue in which it appeared, cussed. In the meantime, with your ideas, within sixty days of publication. A coupon worth $10 toward the following call me! year's membership will then be sent to the author. d. If the original letter was published in a language other than English, the letter -John Hall must be accompanied by an English translation or summary. 415-535-1294 (after 7:00 p.m. Pacifc time)

I Forth Dimemiom 38 Volume XII, Nwnber 6 WELCOMENEW MEMBERS

I The Forth Interest Group welcomes the new members who 1 joined us during the past year. including: Akademii Nauk SSSR Biblioteka Leningrad, USSR Mark Malmros Washington Crossing. PA Fejer Megyei Vizmuvek Szekesfehervr. HUNGARY Elliott R. Marsh. IBM Endicott. NY Hiradastechnika Szovetkezet Budapest, HUNGARY Robert Mayer Quakertown. PA IAPKA Satellite Library Riyadh. SAUDI ARABIA Richard G. McCord, Conpane Louisville, KY Maryland Procurement Office ~CGeorgeMeade. MD Industries. Inc. Mixer Systems. Inc. Pewaukee. WI Edwin Miller Bellaire, TX RAS Systems, Inc. Campbel1,CA Mike Mills Cmcinnatti, OH Schweitzer Soniment Munchen, GERMANY Fred Minetto Temple Hills. MD WFT Electronic Systems Denver-CO Lany Minthom. University of Iowa Iowa City. IA Steven Allard, W. Tombling Ltd. Spaloing, Lincs, ENGLAND J.T.P. Moule Isle of Man, BRITISH ISLES Eric C. Anderson Beavercreek, OH Paul Mrofchak Warren, OH Casey T. Bamwick, Jr. San Francisco. CA Patrick Newton. nView Corp. Newport News. VA Ray Bell Buffalo. NY Adorjan Noemi Budapest, HUNGARY Joseph H. Boutwell Atlanta. GA J. Ozegovic Split, YUGOSLAVIA Robert W. Brown Medina. OH Clinton B. Petry I1 Placentia, CA Paul Bunyan Rio Linda. CA Clyde Phillips, Access Express Oak Park, IL Matthew Burke. Computer Science Dept. Pullman. WA Brian Piercy, Harris Semiconductor Melbourne. FL David Cabana Tampa. FL Abdur Rahmaan, Noble Science Library Tempe. A2! Mark Christensen Lindon. UT R.M. Reynolds Geneva, NY Lee Cobum Lakewood, CO Franco Ricci Firenm, ITALY E. Coleman Los Gatos. CA Thomas Ritchey. Ritchey Engineering Chester Springs. PA Val J. Cooper Monmouth. OR David Ritchie Eaele. ID Bernard Coseil Lexington, MA William Robinson Jason Cunliffe, Mighty Dimension Inc. New York. NY Joel Rubin San ~&cisco, CA Federico Daneri Genova, ITALY Scott T. Schad Tulsa. OK David P. Dille, Cmtrolsoft Research St. Louis, MO Boris Schlensky Palo Alto, CA Aaron C. Dutton, Computer Sciences Corp. Baltimore, MD Conrad Schlundt The Colony, TX David Erbas-White El Tom. CA Tom Shaw Philadelohia. PA David Ferrara Santa Rosa. CA Delwin P. Stevens Chris Frank Garland, TX Robert Suess Indiana&lis. IN Gabriel Fugulin Montreal, PQ, CANADA Brian Sutton, Citrus Park Chiropractic Tam a, FL Richard Gallehr Boston, MA Alain Theroux, Logiciel Plus ~hegrde.W. CANADA David Garcia Staten Island, NY V.H. Vinerts Newark. CA Remy Gentis Wilmiigton. MA Richard C. Wagner, Naval Air Revere, PA Charles A. Gray Phoenix. A2 Development Center Emilio Guarise Milano, ITALY Steven A. Wallace Knoxville, TN David C. Haas, Owens-Coming Granville, OH Manfred Wolfle Berlin, GERMANY Tech. Center Charles R. Wollitz Buckeye. AZ J. Harhellier Eupen. BELGIUM Mark Wood. RSS. Inc. Costa ~ksa,CA Tim Heaps Agoura Hills, CA Edward Woodman Newbury Port, MA Daniel P. Hill Vanmuver. WA Bill Zimmerly St. Louis, MO Michael, Hillersuom. Dansk Hjallerup, DENMARK Patrick Dixon Hastings on Hudson. NY Data Elektronik Christian Beauregard Loretteville. PQ. CANADA Peter Hiltz Lake Orion, MI J. Klir, MCSL St. Albans, Herts, ENGLAND Charlie Holloway, H&N Instruments, hc. Newark. OH Peter Spencer Bothell, WA Andrew P. Houghton Columbus. OH Loy Spears Placentia, CA Mark Hum hries Daly City, CA Anthony Blazej. IBM Milford, CT Art Hyde, Rorida Drum Co. Pine Bluff, AR Jack Rausch Adel*, MD Brian Jackson Cleveland, MS Giorgio Kourtis Genoa, ITALY Woo-Jin Jang, Photone Research Ctr. Seoul, KOREA Thor-Bjom Bladh Lund, SWEDEN Hyun Jeong Tae. Korea Advanced Choone-Nam. KOREA Fred Tem le Plattsburgh, NY Energy Research Inst Edward &ss Plainview, MN William R. Jones Morgantown, KY Gavin Craig Mtn. View. CA Kun Katsumata, Nictrix Corp. San Jose, CA Hubert M. Schrnitter Jefferson. LA Martin Kees Pasco, WA Perer Hauser Taegenvilen. SWITZERLAND Robyn L. King. NASA Greenbelt. MD William Higinbotham, upton. NY David F. Klink Fort Collins, CO Brookhaven National Lab Amatt Klinsong Chicago, IL Richard Reichstadt Faimont, MN Chung-Cheng Li Kong. Ta Tong , Robert Nace Pleasant Hill. CA Book & Magazine Service Patrick Ness Rapid River. MI Choonu Lee, Photone Research Center Seoul. KOREA William H. Madden Livonia. MI John Longton Brooklyn, NY Paul Schumann Mesquite. TX Peter Lu Occidental, CA Michael Hubbard Boulder. CO Jacob Maier Toronto. ON, CANADA 1 Sandy Warshaw. Optisys Long Beach, CA

I Volume XII, Number 6 39 Forth Dimensions Gary Richardson Alameda. CA Nick Janow Vancouver. BC. CANADA Jim Polstra, Orbital Sciences Corp. Boulder. CO Bob Bruns Cam bell. CA R.W. Fergus, Astute Solutions Lombard, IL Michael Dorais an hego, CA John Spencer San Jose. CA Fomst Schomberg. USS/POSCO Antioch, CA Ferenc Kish, Robway Safety Systems Thebarton SA. AUSTRALIA Alan Tabur, NSWC Dahlgren, VA John Ott Brernen, IL Peter Blasberg, Boehringer Mannheim. GERMANY John Svae NORWAY Mannheim GmbH Javier Camp, Universidad de Zaragoza Zaraeoza. SPAIN Gabriel Mam Gros Zaragoza. SPAIN

A. Foord ~al&rn..~orcs. ENGLAND - - Dr. Pfuller, FORTecH Software GmbH Rostock, GERMANY JJ. Kent QLD, AUSTRA~A Saman Samimi Parramatta, NSW, AUSTRALIA Bill Stoddart, Teesside Polytechnic Middlesbrough. Clevld, ENGLAND U.S. Remote Controls San Francisco. CA John Dillon Stradord On Avon, Worcs. Jose E. Komeluk, Jr. W. Palm Beach. FL ENGLAND David Dan. Intel Tech. Far East Ltd. Taipei. Taiwan Steve Jacobs, Iomega Corp. ROY.UT Colin Connery ML Vernon. NY Rick Powers, Phoenix Inst. of Technology Phoenix. AZ Olaf Meding, Amtelco Madison, WI Gary Keen, War Veteran's Homes Mackay. QLD, AUSTRALIA B.M. Shann Freeland, Oxford. ENGLAND Philip W.Y. Kwng Aberdeen. HONG KONG Bengt Karlstrom, Mactec Control Kristianstad. SWEDEN Raymond N. Thomton Hackensack. NJ Deiter Weller gfield. OR Chris Mayne, Bernoulli Optical Boulder, CO David Aitkon, PC Systems Corp. 3'"'elville, NY Mike Budaji Cleveland, OH Robert W. Curry Rochester, NH David Zethmayr LaGrange, IL Garth Wilson Whittier, CA Thomas Schossig Gotha, GERMANY John J. Deering Tucson. AZ John Tse, Chrisma Technology SINGAPORE J.G. Woyka b ad ding ton, E. Lothian, John L. Brown Oakland. CA ENGLAND Robert Drap Mission Viejo, CA Dr. Howard Shapiro MDPC West Newton, MA B.A. Manobk Swindon, Wilts, ENGLAND Robert A. Hall Los Gatos. CA Randy Black, SCI Technology. Inc Huntsville, AL William Hickey. Fox Theaters Taft. CA Luther Huffman Dayton. OH Donald ~dn& Ottawa. ON. CANADA Bill Wood Crystal, MN Rob Miller. Greenlee Textron William B. Bunch Dallas, TX Dosatron S.A. Latresne, FRANCE David Vaughn Austin. TX Kouji Hori Saitama. JAPAN Roberto Dell' Aqua Milano, ITALY Greg Schmidt Richmond Hei hts. OH Sarah Comel, Mite1 Corp. Kanata, ON. CANADA Fabien Tuizat, Atelier de la Forge Royale paris. FRANck Edward Tylka San Diego. CA Raymond LaPorte Vancouver. BC. CANADA Lee Robertson Sandy, UT Jan Michaels Berlin, G- Hany L Spencer. Jr. Huntsville, AL Knute Johnson Sylmar,Houston. CA TX Roben Kennedy Elmhurst, IL Chih-Yu Chao, Altech Controls A.E.F. Coenen. Sweelinck Conservatory Amsterdam, Paul Chivers Bateman, WA. AUSTRALIA THE NETHERLANDS Alfred Oliphant Trinidad, CA Owen Ransen Milano. ITALY Ralph Stockhausen Milwaukee, WI Robert F. Orenstein ~etuchen,NJ Greg Bentz Richmond Hill, ON, CANADA Richard Silkowski Poughkeepsie, NY Robert Thorn on Haniesburg, MS Bruce Raymond Beavercreek, OH Michael ref Chadouesville. VA John Hall Wandwick. NSW, AUSTRALIA Cesar Clavell. Naval Ocean Systems Cenu:r San Diego. CA Yukinobu Miki Ibaraki, JAPAN Doug Baron Indianapolis, IN Yale Univ. Medical School New Haven, CT Robert Koponen Lakeland, FL Peter Peterson, MykroP.S.1. Salt Lake City, UT Paul 0. Lloyd, Microsemi Corp. Orange, CA Stephen Pierotti Broomfield, CO Gerald Childen East Hdden. ME Salil Donde Goose Creek. SC Gary Carner Jamesville. NY Hogan Lew, Synopics Mtn. View. CA Brian Howell, Shenandoah Products Cottonwood, AZ Communications, Inc. Klaus Malzahn Duesseldorf. GERMANY John W. Klay. M.D. Pittsburgh, PA John F. Dodds Newbury, OH Kenneth Pemsek Solon, OH Richard Carleton Augusta, GA Pablo Casado Pamplona. SPAIN Martin Marietta Library Piketon, OH Kenneth Frost, OEM Controls Shelton. CT Michael Hosmer Orem, UT Bruce Bales Benton, KS Ryon Root Glendora, CA Brian Rogoff Menlo Park, CA Knute Johnson Sylmar, CA Bob Burchsted, Aeonic Systems Billerica. MA

Forth Dimemions 40 Volume XII, Nwnber 6 I (Continuedfrom page 30.) (Continuedfrom page 37.)

set of FORML Proceedings, and Mitch got These are the regular Pygmy words that work in both the host and target dictionaries. There is an RTX2001A chip. Both winners agreed no need for special metacompiler versions of them. to present their programs in our December ( u - here t I pfa f) gets the next word from the input stream and looks it meeting. up in vocabulary u. -' I ' Chuck Moore's Annual ( - pf a) Looks up next word in input stream in active vmb. "tick" Fireside Chat / I INTERPRET ( blk# off set -) Until the input stream is exhausted, step through it, Chuck revealed his newest Forth engine looking up the words in FORTH and executing them design, MuP20. It is a 20-bit processor with if found or trying to convert them to a number. several coprocessors around it to handle I/ 0and memory transactions. The coproces- ( n - here t I pfa f) 32 WORD SWAP -FIND ; sors include a DMA processor, a video I processor, a UART, and three input lines : ' ( - pfa) CONTEXT @ -I ABORT" ?I' ; for a three-key keyboard. An internal clock I will allow it to run up to 200 MHz. : INTERPRET ( blk# offset -) >IN2! ( ) Chuck also conceded that Forth has BEGIN 2 ( ie search FORTH) -' never been successful in the mass-con- ( here true I pfa false) sumer market. He will probably concen- IF NUMBER ELSE EXECUTE THEN trate on developing highly customized AGAIN ; products using his special CAD system as Figure Thirteen. leverage. In the question-answer period, Chuck also commented on error recovery ("don't"), writing video drivers ("shorter These are regular Pygmy words, most of which work unchanged in both the host and target and shorter"), disk error ("turn the com- dictionaries. Special metacompiler versions of LITERAL and 1 are needed, however. puter off and walk away''), memory ("for- get disks, use RAM), files ("yesterday's 1 ~(n-1 Moves the dictionary pointer H by n (either forward or backward). problem"), the three-key keyboard ("most natural human interface'?, etc. , ( n - Stores 2-byte number n into the next free location in the dictionary and I advances H past it. "comma"

Banquet at Ritz Chinese C, ( c -) Stores 1-byte number c into the next free location in the dictionary and Seafood Restaurant I I advances H past it. "C-comma" I I (Authentic Chinese Banquet) ,A ( a -) Commas a 16-bit address into the dictionary. It is relocated by the value Ten-course dinner with cold plate, shark in dA. fin soup, walnut prawns, beef in nest, fresh green vegetable, crab in sauce, steamed COMPILE ( -) Compile the following word at this word's run-time. fish, sweet desert, etc., over lively conver- LITERAL ( n - ) Compile n so that at run time it will be pushed to the data stack. sations about computers, politics, the econ- It is DEFER'd. omy, and miscellaneous subjects. I ( -1 This is the heart of the colon compiler. It gets the next word from the input stream. If the word is in the COMPILER vocabulary it is executed. Else, if the word is in the FORTH vocabulary it is compiled. Else, if the word is a valid number it is compiled as a literal. Else, error. Figure Fourteen.

i I Volume XII. Nwnber 6 41 Forth Dimembns FIG CHAPTERS

The FIG Chapters listedbelow Orange County Chapter ILLINOIS MICHIGAN are currently registered as active 4th Wed.. 7 p.m. Cache Forth Chapter DetroitIAnn Arbor Area with regular meetings. If your Fullerton Savings Oak Park Bill Walters chapter listing is missing or incor- Huntington Beach Clyde W. Phillips. Jr. (3 13) 73 1-9660 rect, please contact Anna Brereton Noshir Jesung (714) 842-3032 (708) 713-5365 (313) 861-6465 (eves.) at the FIG office's Chapter Desk. This listing will be updated in each Sacramento Chapter Central Illinois Chapter MINNESOTA issue of Forth Dimemiom. If you 4th Wed.. 7 p.m. Champaign MNFIG Chapter would like to begin a FIG Chapter 1708-59th St.. Room A Robert Illyes (217) 359-6039 Minneapolis in your area, write for a "Chapter Bob Nash Fred Olson Kit and Application" Forth Inter- INDIANA (612) 588-9532 est Group, P.O. Box 8231, San Fort Wayne Chapter Jose, California 95155 San Diego Chapter 2nd Tues.. 7 p.m. MISSOURI Thursdays, 12 Noon UP Univ .Campus Kansas City Chapter U.S.A. Guy Kelly (619) 454-1307 B71 Neff Hall 4th Tues., 7 p.m. ALABAMA Blair MacDermid Midwest Research Institute Huntsville Chapter SUkon Valley Chapter (2 19) 749-2042 MAG Conference Center Tom Konantz 4th Sat., 10 a.m. Lmus Orth (913) 236-9189 (205) 881-6483 Applied Bio Systems IOWA Foster City Central Iowa FIG Chapter StLouis Chapter ALASKA (415) 535-1294 1st Tues., 7:30 p.m. 1st Tues.. 7 p.m. Kodiak Area Chapter Iowa State Univ. Thornhill Branch Library Ric Shepard Stockton Chapter 214 Comp. Sci. Robert Washam Box 1344 Doug Dillon (209) 93 1-2448 Rodrick Eldridge 91 Weis Drive Kodiak, Alaska 99615 (5 15) 294-5659 Ellisville. MO 63011 COLORADO Denver Chapter ARIZONA Fairfield FIG Chapter NEW JERSEY 1st Mon.. 7 p.m. 4th Day. 8:15 p.m. New Jersey Chapter Phoenix Chapter Clifford King (303) 693-3413 4th Thurs., 7:30 p.m. Gurdy Leete (5 15) 472-7077 Rutgers Univ.. Picataway Nicholas Lordi Arizona State Univ. FLORIDA MARYLAND (201) 338-9363 Memorial Union, 2nd floor Orlando Chapter Dermis L. Wilson MDFIG Every other Wed., 8 p.m. NEW MEXICO (602) 381-1 146 3rd Wed., 6:30 p.m. Herman B. Gibson JHUIAPL, Bldg. 1 Albuquerque Chapter (305) 855-4790 CALIFORNIA Parsons Auditorium 1st Thurs.. 7:30 p.m. La Mike Nemeth (301) 262-8140 Physics & Astronomy Bldg . Angeles Chapter Tampa Bay Chapter 4th Sat.. 10 a.m. (eves.) Univ. of New Mexico 1st Wed.. 7:30 p.m. Jon Bryan (505) 298-3292 Hawthorne Public Library Teny McNay (813) 725-1245 12700 S. Grevillea Ave. MASSACHUSETTS Boston FIG NEW YORK Phillip Wasson GEORGIA (213) 649-1428 3rd Wed., 7 p.m. Long Island Chapter Atlanta Chapter Bull HN 3rd Thurs.. 7:30 p.m. 3rd Tues.. 7 p.m. North Bay Chapter 300 Concord Rd., Billerica Brookhaven National Emprise Corp., Marietta Gary Chanson (617) 527-7206 Laboratory 3rd Sat. Don Schrader (404) 428-0811 12 noon tutorial, 1 p.m. Forth AGS dept.. bldg. 911. lab rm. 2055 Center St. Berkeley A-202 Irving Montanez Leonard Morgenstern (415) 376-5241 (5 16) 282-2540

I Forth Dimemiom 42 Volume XII. Number 6 Rochester Chapter Houston Chapter BELGIUM GERMANY Monroe Comm. College 3rd Mon., 7:30 p.m. Belgium Chapter Germany FIG Chapter Bldg. 7, Rm. 102 Houston Area League of PC 4th Wed., 8 p.m. Heinz Schnitter Frank Lanzafame users Luk Van hck Forth-Gesellschaft e.v. (716) 482-3398 1200 Post Oak Rd. Lariksdreef 20 Postfach 11 10 (Galleria area) 2120 Schoten D-80 Unterschleissheirn OHIO Russell Harris 031658-6343 (49) (89) 317 3784 Cleveland Chapter (713) 461-1618 e-mail uucp: 4th Tues., 7 p.m. Southern Belgium Chapter [email protected] Chagrin Falls Library VERMONT Jean-Marc Bertinchamps Internet: Gary Bergstrom Vermont Chapter Rue N. Monnom, 2 secretary@ admin.FORTH- (216) 247 -2492 Vergennes B-6290 Nalinnes eV.de D-8044 Unterschleis- 3rd Mon., 7:30 p.m. 0711213858 sheim Columbus FIG Chapter Vergennes Union High School (49) (89) 317 3784 4th Tues. RM 210. Monkton Rd. CANADA Munich Forth Box: Kal-Kan Foods, Inc. Hal Clark (802) 453-4442 FORTH-BC (49) (89) 725 9625 (telcom) 51 15 Fisher Road 1st Thurs., 7:30 p.m. Terry Webb VIRGINIA BCIT, 3700 Willingdon Ave. (614) 878-7241 First Forth of Hampton BBY, Rm. 1A-324 HOLLAND Roads Jack W. Brown Holland Chapter Dayton Chapter William Edmonds (604) 596-9764 or Vic Van de Zande 2nd Tues. & 4th Wed., 6:30 (804) 8984099 (604) 436-0443 Finmark 7 p.m. BCFB BBS (604) 434-5886 383 1 JE Leusden CFC. 11 W. Monument Ave. Potomac FIG #612 D.C. & Northern Virginia Northern Alberta Chapter ITALY Gary Ganger (513) 849-1483 1st Tues. 4th Thurs., 7-9:30 p.m. FIG Italia N. Alta. Inst. of ~&h. OREGON Lee Recreation Center Marco Tausel Tony Van Muyden Willamette Valley Chapter 5722 Lee Hwy., Arlington Via Gerolamo Forni 48 (403) 486-6666 (days) 4th Tues., 7 p.m. Joseph Brown 20161 Milano (403) 962-2203 (eves.) Linn-Benton Comrn. College (703) 47 1-4409 Pann McCuaig (503) 752-5113 E. Coast Forth Board JAPAN (703) 442-8695 Southern Ontario Chapter Tokyo Chapter Quarterly: 1st Sat. of Mar., PENNSYLVANIA 3rd Sat. afternoon June, and Dec. 2nd Sat. of Villanova Univ. Chapter Richmond Forth Group Hamacho-Kaikan, Chuoku Sept. Genl. Sci. Bldg.. RM 212 1st Mon.. 7:30 p.m. 2nd Wed., 7 p.m. Toshio Inoue McMaster University Villanova University 154 Business School (81) 3-812-2111 ext. 7073 Dennis Clark Univ. of Richmond Dr. N. Solntseff (416) 525-9140 x3443 (215) 860-0700 Donald A. Full REPUBLIC OF CHINA (804) 739-3623 R.O.C. Chapter TENNESSEE ENGLAND Chiig-Tang Tseng Forth Interest Group-UK East Tennessee Chapter WISCONSIN P.O. Box 28 London Oak Ridge Lake Superior Chapter Longtan, Taoyuan, Taiwan 3rd Wed., 7 p.m. 2nd Fri., 7:30 p.m. 1st Thurs., 7 p.m. (03) 4798925 Polytechnic of South Bank Sci. Appl. Int'l. Corp., 8th F1. 1219 N. 21st St., Superior RM 408 800 Oak Ridge Turnpike Allen Anway (715) 394-4061 SWEDEN Richard Secrist Borough Rd. SweFIG D.J. Neale (615) 483-7242 INTERNATIONAL Per Alm AUSTRALIA 58 Woodland Way 4618-92963 1 TEXAS Melbourne Chapter Morden. Surry SM4 4DS Austin Chapter 1st Fri., 8 p.m. SWITZERLAND Matt Lawrence Lance Collins FINLAND Swiss Chapter PO Box 180409 65 Martin Road FinFIG Max Hugelshofer Austin, TX 78718 Glen Iris, Victoria 3 146 Janne Kotiranta Industrieberatung 031889-2600 Arkkitehdinkatu 38 c 39 Ziberstrasse 6 Dallas Chapter BBS: 61 3 809 1787 33720 Tampere 8 152 Opfikon 4th Thurs.. 7:30 p.m. +358-31-184246 01 810 9289 Texas Instruments Sydney Chapter 13500 N. Central Expwy. 2nd Fri., 7 p.m. SPECIAL GROUPS Semiconductor Cafeteria John Goodsell Bldg., RM NC4000 Users Group Conference Room A LC19 John Carpenter Clif Penn (214) 995-2361 Univ. of New South Wales 1698 Villa St. Peter Tregeagle Mountain View. CA 94041 10 Binda Rd. (415) 960-1256 (eves.) Yowie Bay 2228 0215247490 Usenet 1 [email protected]

I Volume XII, Number 6 43 Forth Dimensions HURRY! For a limited time you can...

sAvE50%UP TO Offer good ONLY to current FIG members... As you may know, the Forth Interest Group's Board of Directors has authorized an increase in membership fees. This was needed in order to meet the rising cost of important member services like Forth Dimensions and our mail-order operations. But until April 1, 1991 current members can still renew at last year's rate. FIG depends entirely on the support of people like you, and every member's fee goes to keeping our doors open and the presses rolling. Without our magazine, source code listings, and other publications, the world would lose its major source of Forth education and information. So, please, take a moment right now to fill out the attached renewal form-your membership expires with FD issue XII/6!

Two more reasons to renew NOW.. . Other recent changes at FIG make it even more important that you renew on time. First, members who renew late will no longer automatically receive any issues they missed-they must order them separately as back issues, subject to availability, and at the new cover price of $10. From now on, each FIG membership will last for twelve months from the day it is received at the FIG office, no longer linked to the Forth Dimensions calendar year.

Three Ways to get $60 if purchased separately (6 issues x $10 each) Forth Dimensions $40' to members after April 1, saving 1/3! next year! $30"" to members renewing before April 1, saving 1/2!

$46 Canada. $52 other countries. " $36 Canada. $42 other countries. -

Forth Interest Group P.O.Box 8231 Second Class San Jose, CA 95155 Postage Paid at San Jose, CA