VOLUME IV. NUMBER 3 $2.50

I_.. ... INSIDE:

OPERATING SYSTEMS Forte’ .A FORTH-Based ...... John James ...... 5 A Standardized Microcomputer Operating System Interface .. Gary Feierbach ...... 6 A FORTH Based File Handling System ...... Dr . Donald Delwood ...... 8

FEATURES: Checksum for Hand-Entered Source Screens ...... Klaxon Suralis & Leo Brodie ..... 15 QTF .Quick Text Formatter ...... Leo Brodie ...... 16 The Sheer Joy of Clipping Recursively ...... Bob Gotsch ...... 21 DO LOOP-83 ...... Klaxon Suralis ...... 25

DEPARTMENTS: Letters ...... 3 Standards Corner ...... 24 A Techniques Tutorial ...... 28 Technotes ...... 31 Products Announcements/Reviews...... 32

OPERATING SYSTEMS Develop FORTH code for any target No dcrumbading - No trial PROM burning. 8080/280 system on your current 8080,280 This port-addressed RAM on your S-100 host '1 ror Cromemco CDOS based system is the f#OM of your target system ,

8080/280 METAFORTH WORD/BYTE WIDE ROM SIMULATOR 0 Simulates 16K bytes of memory (8K bytes for 2708 and 2758) 0 Simulates 2708, 2758, 2516, 2716, 2532, 2732, 2564 and 2764 PROMS e The simulated memory may be either byte or 16-bit word organized 0 No $100 memory is needed to hold ROM data 0 Driver program verifies simulated PROM contents 0 Price $495 each I CONSULTING SERVICES Inner Access provides you with Custom Software Design. We have supplied many clients with both Systems and Application Software tailored to their specific needs. Contact us for your I special programming requirements. FORTH WORKSHOPS ONE-WEEK WORKSHOPS - ENROLLMENT LIMITED TO 8 STUDENTS FORTH Advanced FORTH Advanced FORTH Fundamentals Applications Systems

0 Program Design 0 FORTH Tools 0 FORTH lnternals 0 Program Documentation 0 Engineering Applications 0 Assemblers and Editors 0 FORTH Architecture 0 Floating Point 0 Other Compilers 0 FORTH Arithmetic 0 Communications 0 Cross-Compilation Theory 0 Control Structures 0 Sorting & Searching 0 Romability, Multitasking, 0 Input/Output Project Accounting System Timesharing 0 The Vocabulary Mechanism 0 Process Control 0 File Systems/ 0 Meta-Defining Words 0 Simulations Database Systems OCT. 4-8 NOV. 8-12 NOV. 15-19 OCT. 11-15 JAN. 3-7 FEB. 7-11 FEE. 14-18 JAN. 10-14 $395 Incl. Text $495 Incl. Text $495 Incl. Text Instructors: LEO BRODIE, GARY FEIERBACH and PAUL THOMAS (For further information, please send for our complete FORTH Workshop Catalog.) Inner Access Corporation P.O. BOX 888 BELMONT, CALIFORNIA 94002 (415) 591-8295

FORTH Dimensions 2 Volume IV, NO. 3 Letters Cordic Erratum Holland Hobbyists Infecting the Mumps Dear FIG, Dear FIG, Dear FIG, Someone just pointed out an error in I am in charge of software distribu- I would appreciate receiving some my algorithm outline, shown in Vol. tion in our 150 + member Hobby Com- of your publications for book reviews IV, No. 1, page 14 (box], line 7: “begin puter Club here at Philips Data Sys- in the publications I edit. In addition ANGLE <-ANGLE-Z”.*; XLAST <- -Y; tems, in Apeldoorn, Holland, and we to being an editor for the MUMPS YLAST<- -X end; .” have decided to add FORTH to our Users Group (MUG) Quarterly, I am The minus sign in front of the “X” standard club-supported languages. softwarelfirmware editor for EDP should be deleted. The minus sign in Our current “PI” (!) is based on 2650 News Service, and manage the Soft- front of the “X” on line 9 is correct. processor, and we are now modifying ware Digest newsletter. I would like to Alan Furman an excellent 2650 FORTH implemen- begin getting information about Palo Alto, CA tation made by Dr.E. J. Hannivoort, FORTH into the trade news in the here in Holland. We are now busy computer industry on a regular basis. selecting a new CPU design for use Since December, I have been able to this year (probably 2-80), and will of accomplish the following: course be offering FORTH on the new - arranged for a full-day tutorial on Pushing Frontiers design too. FORTH at the Annual MUMPS Users Dear FIG, Interest in FORTH here in Holland Group in Denver; The Math Edition was one of the is well started - there was a local - arranged for George Shaw’s book review of Leo Brodie’s text to be best issues I have ever read. While the FORTH Interesse Groep (as we call it here in Holland!) meeting yesterday reprinted in the MUG Quarterly; commercial magazines have all turned under The0 van Lottum’s chairman- persuaded Bob Wickizer to include very one dimensional (business), yours - some paragraphs on his use of FORTH is still looking at new ideas and ship, and they are providing an excel- as a complement to MUMPS in his pushing the software frontier. ent range of information on FORTH. However, with more and more of our radiology system; Kenneth B. Butterfield planned for including future arti- Graduate Student members asking what FORTH actual- - cles on FORTH in the MUG Quarterly University of New Mexico ly can do in practice, I would like to ask your help in two areas, namely: and in Software Digest. Thanks for the feedback, Ken, we’ll try a) FORTH Training Course - We will Henry G. Heffernan to stay Four Dimensional. -Editor be organising a Training Course in Washington, D.. FORTH in our Hobby Club this autumn. While Starting FORTH is an excellent work book for such a course, we really need some more structured FORTH in College material for a 6 to 10 lesson introduc- Dear FIG, tion. Any ideas? FORTH Dimensions This Fall, I will be teaching an intro- b) Actual FORTH Applications - Published by FORTH Interest Group ductory FORTH course at San Diego Where can I get a few self-contained Volume IV, No. 3 State. I will be running a modification applications written in FORTH as ex- SeptemberlOctober 1982 of James’ PDP-11 fig-FORTH on our amples for our members? The screens EditoriallProduction Leo Brodie VAX in RSX-11 compatibility mode. given in FORTH Dimensions are fine, but I am looking for a few example Publisher (The modifications will be mainly to Roy C. Martens make the FORTH follow Starting Games, a Word Processor, a very basic FORTH.) It’s a bit strange to teach it BASIC, that sort of thing, just to show on a time-sharing system, but we are our members what they can expect from FORTH. FORTH Dimensions solicits editorial embarrassingly short of micros. There material, comments and letters. No will be some advantages, though: I will Looking forward to hearing from responsibility is assumed for accuracy be able to distribute materials and con- you, and receiving FORTH Dimen- of material submitted. Unless noted sult with students over the phone net sions regularly. otherwise, material published by the 1. M. Preston FORTH Interest Group is in the public more easily than if we were using a The Netherlands domain. Such material may be roomful of micros. reproduced with credit given to the Congratulations on the success of your I hope to have an article about my author and the FORTH Interest Group. club! As for the applications, any that Subscription to FORTH Dimensions experiences teaching FORTH in time is free with membership in the FORTH for your Teaching FORTH issue. we know of we’re publishing here. There were three games described in Interest Group at $15.00 per year Vernor Vinge ($27.00 foreign air). For membership, Dept. of Math Sciences IIU5, a “very basic BASIC” in 11116, I’m change of address andlor to submit San Diego State University including the code for my simplified material, the address is: FORTH word processor in this issue, and we Interest Group, P.O. Box 1105, San Good luck with your class. We’ll be expect Jots more applications to come. Carlos, CA 94070 looking forward to your article. -Editor -Editor i FORTH Dimensions 3 Volume IV. No. 3 Letters . . . (cont.) Freedom and Formatting technicians.” Our programming en- pretty low cost for even an incremen- Dear FIG, vironment must seek to do the best it tal improvement in readability.

Jq T. Currie has provoked me (as was can in an imperfect world. By now, I have seen about 100 his stated intention). His statements Our engineers and technicians have people start FORTH. None has ever ~ concerning the formatting of FORTH grown up on Pascal and BASIC and complained seriously about formatting source lines are not only provocative Assembler; the physicists are addicted requirements. Scores have bemoaned but outrageous, ignoring many of the to FORTRAN. They are used to “lines FORTH’s tendency to be a “write-only diverse user environments in which of code” and conventions of indenta- language.” As more of our code has FORTH is a useful tool and within tion. Novices look at a block of unfor- been formatted, the moaning of the which the “good” FORTH program- matted FORTH code the way I look at novices has decreased markedly. To mer” may find himself working. Bengali script - incredulity that me that’s important. I have used FORTH for many pur- squiggles speak of truth or beauty or Suppose that FORTH allowed poses on many machines in many user even the proper function of a time screens to be written backwards or environments since within a year of its digitizer. A screen made up of a hun- that spaces between words might be emergence from NRAO. For some dred or so terse words that look like omitted unless an ambiguity was types of problems and some user en- they were run through a trash compac- thereby created. The latter would cer- tor on their way to disk is a formidable tainly result in much more compact vironments it is a marvelous language. /I Lately I have been working with barrier that I see no point in imposing code. .ti daer ot nrael yllautneve thgim high energy physicists and their on our novices. I’m glad that FORTH secivoN But what’s the point? engineers and technicians. FORTH doesn’t insist that code for inner loops In designing a language, as in has been used to: 1) set up and check be indented three spaces from the next designing a government, building in a out an enormous data acquisition highest level, ecstatic that it allows me lot of freedom is good. In each case, system and the apparatus it is con- to insist on it. it is not always a virtue (or even kind nected to, 2) simulate, debug and At about the time a user starts to yourself) to use all of it. It’s a virtue monitor a very large special purpose advancing from Novice to Normal, I of FORTH that it leaves the user com- processor used in real time data selec- suggest, club in hand, that he adhere munity free to decide on formatting tion, and 31 check out and manage the to a short list of formatting conven- conventions appropriate to the task at operation of a multi-processor used for tions. Definitions start on the left and hand and the needs of the community. analyzing the data collected. are preceded by comments in plain There is no forthly imperative to hang Our users might be divided into English. Loops and conditionals are yourself just because FORTH gives three categories: 1) Novices, who use indented. Definitions do not (usually) you enough rope to do so. words already defined and restrict span screens. Screens that change Stephen B. Bracker extension of the system to temporary BASE when loaded must save and Fermilab Users Office simple lists of existing words; 2) restore it. Use of a word for different Batavia, Illinois Normals, who extend the system with functions in different vocabularies is permanent colon definitions and use strictly forbidden; in general, use of Charles Moore’s New Venture those definitions to solve their pro- non-default vocabularies is forbidden. Dear Fig, t blems; 31 Nuts, who may reassemble Words are to have clear mnemonic I wish to announce a new company the kernel, write code definitions to value whenever possible, even at some in the FORTH arena, Charles H. connect to new hardware, define new expense in brevity. Lots of empty Moore & Associates. Of the many defining words . . . space is left to make later amendment opportunities available in the growing At any one time, our users are about easy. FORTH community, we plan to spe- half novices and half normals with a This does not insure that the code cialize in custom applications. At the nut or two hanging around. It’s not written is good - cleanly factored, moment, that means software. But that the novices and normals are dull concise, fast, sufficiently general, easi- when the FORTH chip becomes avail- slobs who couldn’t get beyond that ly used for further extension. That will able, so will custom hardware. level; they are people who exercise come with time and training. What it Moore & Assoc. will be a distributed their creativity in other areas and use does do is to insure that most of our network of programmers linked to FORTH as one tool among many to get users and especially our inexperi- each other through their computers. a job done. enced and occasional users can use Thus half of the associates will be com- One might wish, indeed I do wish, and begin to understand the code as puters, and the others humans. Toge- that everybody learned FORTH in quickly as possible. Formatting is help- ther we will have the flexibility of grammar school. Until that happy day ful to most of our users, even when the working at home, at the customer’s arrives, I must work in an environ- code being studied is excellent. For site, or at the place of our choosing. ment where most of the users will badly written code (and there is lots of Anyone knowing of applications be non-experts (to say no more). A that around in our kind of environ- demanding more than one FORTH local prison warden, criticized for ment) it is yet more helpful. Unlike the programmer is invited to contact me: the appalling condition of his jail, deeper aspects of “good programming Charles H. Moore & Assoc., Drawer responded that things wouldn’t get practices,” the formatting rules can be CP-66, Manhatten Beach, CA 90266. better until they got a “better class of mastered and applied without serious I’ll keep you informed of develop- prisoners.” It makes no more sense for error within about five minutes of the ments. me to yearn for “a better class of time they are first explained. That’s a Charles H. Moore I FORTH Dimensions 4 Volume IV, No. 3 i c

Forte - A FORTH-Based Operating System

which may have been well tested by (F) If the system does not fit, a special John S. James use in dozens of different projects. In overaly technique may need to be CoIon Systems addition, the developers may only developed, and the modules may have want to release running modules, not to be changed to accommodate it. the source. Perhaps the modules can be rewritten Does FORTH need an operating This kind of modularity and trans- to use extended memory for data. system? If so, what requirements are portability (which UNIX [*] handles (G) Due to these problems, there is most important, and how can a system well, a large part of the reason for its no library of modules in widespread be designed to provide them? We success) is not available in stand-alone use. Each project is developed from believe that the answers to these ques- FORTH. Instead, most FORTH devel- scratch. tions are crucial to the future role of opment projects are written from (H) Even within the same installa- FORTH. scratch, except for routines which tion, it is difficult to use unchanged FORTH includes its own operating may have been copied (or more usu- source-program segments for different system, and for years most users have ally, adapted) out of listings and application systems. New projects been content to run it on a stand-alone retyped, or subroutine packages from often must recode or at least modify basis. The advantages of fast develop- a single source, usually provided as previous work. ment, transportability among different part of the system package. FORTH otherwise provides such a types of CPUs, interactive flexibility, Obstacles to Modularity powerful environment for fast devel- and reliable and efficient software What are the obstacles to inter- opment of correct programs that the development are available without any installation use of pre-developed soft- major penalty resulting from these dif- other operating system. But the one ware modules? These are presented in ficulties is often overlooked or found major capability which stand-alone the order in which they might affect acceptable. The opportunities which FORTH fails to provide is becoming a project. are lost because the FORTH environ- increasingly important - namely, an (A) Incompatible media formats. ment does not easily produce inter- effective mechanism for reusing soft- Available programs can help over- changeable libraries of large program ware components which may have come this problem by transmitting segments are not missed, because they been developed independently. Forte’ serially (see Grotke, G.T., have not been experienced. But in the is intended to answer this need. “Transfer of FORTH Screens by future, FORTH must increasingly Two Kinds of Transportability Modem, FORTH Dimensions, 111/5, compete with systems such as UNIX. While FORTH solves the problem of p.162), but such programs are not which do support this function. (For moving software between different widely used, probably because of the example, when UNIX is distributed. CPUs, there is another kind of other problems which are outlined hundreds of modules written by many transportability - moving modules below. different users at different installa- between different installations, each (B) Only source can be transported tions go with it.) with different teams of developers, dif- - if the developer will release it. What’s Needed? ferent conventions, tools and environ- (C) Stand-alone FORTH does not The most important requirements for ments. For example, suppose you are have directories or named files, so modularity are a file system, and a pro- developing a fairly large software screen ranges must be considered gram library. The entire operating system and realize that most of the when source modules are copied. The system can be smaller and simpler logic has already been coded by source may need to be edited to get it than most, since FORTH itself pro- others. You would like to tie together in a reasonable order. vides many of these functions. Several a number of FORTH routines from, (D) Any word-name conflicts must simplifying assumptions are used in say, ten different installations, which be resolved. These conflicts will usu- the Forte’ operating system: have developed them independently of ally involve words internal to the (A) We are assuming a single-user each other, without coordination. modules, which the developer who is system. Multitasking will be provided. Naturally you want to treat these using those modules should be able to but not inter-task protection. Many of modules as “black boxes” and not ignore. the micros on which FORTH is custo- make any changes to them. Treating (E) The final system may not fit in marily used do not have facilities for each module as a unit avoids the need memory. Even if more than 64K is real inter-user protection: instead. to learn the internals, and avoids the available, stand-alone FORTH is not protection should be provided at the risk of introducing errors in work automatically set up to use it. local-network level. Simple multitask- C2ri:z:k

VJ,.?e i k FORTH Dimensions 5 3 ing allows utilities such as printer or such as part number or customer A Standardized communication spoolers to be used by name; the data should always be cur- a single developer or operator. rent, and the user should not have to Microcomputer (B) The file system provides files of wait for batch sorts. Operating FORTH blocks, so that existing pro- The Program Library System Interface? grams which were not written for a We have chosen a simplified library file system can be run without modifi- mechanism, to keep down overhead, Gary Feierbach cation. Normal source code and con- by taking advantage of facilities The Institute of Electrical and Electronic ventional screen editors can be used. already available in FORTH. Engineers (IEEE)has an active commit- But under the operating system, all The goal is to support a library of tee PI55 dubbed MOSI which is char- disk access is invisibly constrained precompiled routines, called “mod- tered to define a set of programmatic within those files which the user is ules,” which can be called from other interfaces between microprocessor authorized to open. There is no error modules, from a main program, or based operating systems and that soft- message for attempting to access from the keyboard, in exactly the same ware which utilizes operating system unauthorized data; instead, there is no way. functions. Today we have what essenti- such thing as ’BLOCK’accessing out- Each module lives in a file in the ally amounts to chaos in this area with side of open files. Effective data pro- hierarchical directory. When run, the the exceptions of a few proprietary tection becomes especially important module may be identified by name or vendor packages which have become as non-removable hard disks replace pathname. If the module is not found defacto standard like CPlM and UNIX. floppies, because in many installations by a search starting in the “current” MOSI came out with a draft docu- a single micro will serve several users directory, other directories in a search ment (Rev 3.0) which is in the process who all keep data on line. vector may be checked automatically. of being revised and is soon to be (C) Not only is ’BLOCK’defined on Usually the search vector specifies released (Rev 4.0 in August or Septem- top of the file system; the file system program libraries. ber) as a proposed standard. The draft is defined on top of ’BLOCK’.Besides All modules have the same starting document reveals operating system or the obvious advantage of transpor- address in memory. If one calls ano- modules from 1 to 6. These capability tability of the operating system, this ther, the calling module is saved and modules span very simple environments design also isolates any complexity restored. Modules may or may not as in the case of dedicated controllers below ’BLOCK’ (such as support of dif- include headers. Those with headers to complex environments involving ferent types of devices, and support of link to the resident (“root”) dictionary. memory, clock, data and process man- the use of non-error-free media) from Modules normally communicate agement. the rest of the system. The operating with each other by the FORTH stack. The current draft (Rev 3.0) is quite system only sees sets of block-number Module calls can be used like other bulky covering 161 pages and Rev 4.0 ranges; since it can be configured for words in ordinary FORTH definitions, promises to be under 100 pages. The any ranges desired, it can organize as long as the modules themselves are MOSI committee is also bulky consist- only parts of disks if desired. available in a program library when ing of over 268 members (it was 600). The File System needed during execution. One would think such an effort was Allocation is dynamic and non- Summary doomed from the start to produce an contiguous. All files are created with Conventional FORTH systems do not dephantine monstrosity. A monstrosity length zero, and any access to a block effectively support libraries of sub- it is not. As a matter of fact the result, number allocates a block of blanks to routines larger than single definitions to this point, looks quite plausible. A it. If contiguous allocation is desired but smaller than complete programs. good part of the bulk is due to examples it can easily be forced. As a result, many software projects 3f using the OIS primatives from C, Hierarchical directories, and UNIX- cannot take advantage of previous BASIC and COBOL. They need some- style pathnames, are provided. Both work. me to provide examples from a FORTH require low overhead, and are increas- A file system and a library mecha- 2nvironment. ingly important for large disks. A nism for precompiled routines are the Furthermore, if anyone is up to the branch of the file hierarchy can be a essentials for extending FORTH’s Zhallenge, implementing a MOSI OIS (in dismountable volume. usefulness in the new environment of FORTH of course) would go a long way All files start with a header block, larger micros, larger projects, and in helping clean up problems in the pro- which contains the information neces- modular software development. Josed standard. Who knows, it may sary to restore the file. Therefore files Seplace CPIM or UNIX or both (or can be recovered even if directories ieither). are destroyed. *UNIX is a trademark of Bell Laboratories. To get on the MOSI committee con- A special file type important enough act Jack Cowan, Intel Corporation (MIS to be provided separately is the auto- John S. James is working for Colon DV2-210), 2402 West Beardsley Road, matically-sorted file, e.g., using B- Systems in San Jose, California, on the Phoenix, AZ 85027. trees. Many applications need to keep development of the Forte’ Operating The FORTH community should be online files of records sorted by fields System. nvolved in this effort. 3

FORTH Dimensions 6 Volume IV, No. 3 FORTHPROGRAMMING AIDS- from Curry Associates FORTHPROGRAMMING AIDS is TRANSLATOR provides a DECOMPILER generates a software package containing one-to-one translation of structured FORTH source code high-level FORTH routines that FORTH run-time code. from RAM and inserts program allow you to write more efficient control words (e.g,, IF, ELSE). programs in less development time. It is also useful for CALLFINDER finds calling SUBROUTINE DECOMPILER maintaining existing FORTH words, i.e. calls to a specific finds called words, i.e., words programs. The FPA package word. called by a specific word, to all includes four modules: nesting levels.

FORTHPROGRAMMING AIDS The DECOMPILER alone is control words such as IF, ELSE, enables you to: worth a second look. This is a THEN, BEGIN, etc. If you ask rn Minimize memory require true decompiler which converts FPA to DECOMPILE the nucleus ments for target systems by the FORTH words in RAM into word INTERPRET, you get the finding only those words used compilable, structured FORTH following Output displayed On in the target application. source code, including program your terminal within 3 seconds: rn Tailor existing words (includ- ing nucleus words) to specific ( NFABS:FFA: 475'6 4E31i) ) needs by decompiling the : I NTERFKET BEG IN -F I word to disk, editing, and ND IF STATE a3 <:. recompiling. IF CFA , rn Build on previous work by ELSE LFA EXECUTE extracting debugged FORTH THEI\I 3Sl-ACL. routines (including constants ELSE HERE PJCJMBEK PF'L .3 1 + and variables) from RAM to IF L COI'IF' 1LE 3 DL 1 TERAi disk. ELSE DKCIF' C COPIF'I LE1 L I TERAL THEN 7:'Sl ACL Patch changes into existing THEN compiled words in seconds. kL;AlN :

FORTHPROGRAMMING AIDS You can decompile one word, DECOMPILE is useful for look- comes with complete source or a range of words at one ing up words, or for obtaining code and a 50-page, indexed time - even the whole FORTH variations of words by decom- manual. system! This decompiled output piling to disk, editing, and may be sent by FPA options to recompiling. the console, printer, or disk.

System Requirements: FORTH nucleus based on the fig-FORTH model or 79-STANDARD; a minimum of 3K bytes and a recommended 13K bytes of free dictionary space. For more information, call Ren Curry 415/322-1463 or Tom Wempe 408/378-2811 ______------Yes, send me a copy of FORTH PROGRAMMINGAIDS, including all source code and the 50-page manual. 0 fig-FORTH model $1 50 Calif. residents add 6.5% tax. 0 FORTH-79 STANDARD (specify system) $1 50 Foreign air shipments add $15. 0 Manual alone (credit toward program purchase) $25 0 Send more information

0 Master Charge 0 Visa Account Number-- ~ ~- ~~ ~ Exp. Date

Name- ~~~ ~ ~~ -- ~~ ~ ~~ ~ Indicate disk format 0 8" sslsd fig-FORTH screens Company ~- - ~~ ~- ~~ 8" sslsd cP/M" 2 2 file 0 Apple 33 ~~ ~~ ~ -~ ~~ Street ~ ~ - ~ 0 PC FORTH

~- ~~~ City/State/Zip ~ ~~ 0 Other

Send to: Curry Associates, P. 0. Box 11324, Palo Alto, CA 94306 41 5/322-1463 or 4O8/378-2811

FORTH Dimensions 7 Volume IV, No. 3 A FORTH Based File Handling System

file rather than linking another screen RSXll and CPlM are very similar. A to the already widely disseminated block of memory called the File Dr. Donald Delwood batch of screens in the one-big-file Descriptor Block (FDB) is loaded with Columbia, Missouri system. In other words, clear, easy to the file name, device on which it use libraries would evolve. resides, and other useful information Operating systems revel in manipu- according to a system specified con- lating files. It seems sometimes that vention. Then certain action words or Introduction their only purpose to exist is to verbs, which will be introduced short- This article will discuss the topic of help with CREATEing, DELETEing, ly, associate a channel (a logical IIO file handling that has been developed COPYing, PROTECTing, MERGEing, pathway) with the file specified in the under the operating systems, TRll EXTENDing, DATEing, LISTing, and FCB. 110 from then on can be specified and RSXl1, with principles applying DIRECTORYing files. Since many simply by indicating which channel is to many others including CPIM. FORTH users run under an operating to be used in subsequent reads and Fig-FORTH inspired versions typi- system rather than stand alone, it writes. Thus, the minimal system re- cally use one large file in which to makes good sense to tap into this quires a word specifying the address store source screens of FORTH code. resource of well debugged and of the file descriptor block, FDB; a Even casual glances through FORTH sometimes even documented code. word that somehow packs the file Dimensions reveal screens labeled I will use examples from RT11, the specifications into the FDB, FILE; a into the thousands. Finding an appli- single-user operating system by Digital variable containing the currently ac- cation usually involves either wide Equipment Corp. for their PDP-11 tive channel, CHAN; and file active searches of screen ranges using the computers. It is quite mature, with a verbs, ENTER, LOOKUP and CLOSE. See INDEX word or the use of documen- fine repertoire of useful monitor calls. definitions below. tors or documentor screens (hopefully However, the same approach was FDB (-- addr) FDB returns the meticulously maintained). Further- used in development for RSXll and is starting address of the system specific more, this approach requires much being used for CPIM. file descriptor block. “housekeeping” as applications grow From the top down FILE (--) FILE can have many crowded requiring massive screen- A useful file system would use the forms as long as it fills the FDB with moves or fragmented multi-linked system’s specific naming convention, the proper information. This article screens. If several screens of code are be able to either find a pre-existing file will describe a FILE that expects a to be distributed, the whole large file or create a new one, and close the file string on top of the string stack that is must be given out, or other methods after access. That’s all that is really a standard RTll file descriptor. It then such as hardcopies or telephone trans- needed. Optionally, it might be useful parses it, converts it to RADSO and fers resorted to. Furthermore, large to delete, rename, as well as those shoves the letters into the proper posi- files are just less convenient to mani- other utilities listed above, but cer- tion in the FDB according to RTll pulate on the smaller floppy disk based tainly that can be done later by the requirements. systems. operating system outside of FORTH. CHAN (-- addr) CHAN is a The advantages of having an exten- The mechanics of file handling in variable that holds the value of the cur- sive files system under FORTH would the three operating systems RT11, rently active channel. be many. Each application or related Figure la applications could have a file. This is CLOSE ( close current File ) hardly novel, in fact it is the “usual” “ DK :ED I TOR. FTH ” ( file specification strins ) way of doing things in many other pro- FILE ( Pack strins into FDB ) gramming systems. A clearly named LOOKUP ( try to find and open the file ) IF ABORT” File Lookup Error“ THEN ( error handlins 1 file may be loaded by an even clearer 1 LIST set to work ) FORTH word. Specific applications Figure Ib may be passed among users with ease. Users of the same system at different CLOSE ( close current file ) times can each have their own file(s) “ DK:TEST.DAT” FILE ( fill FDB with file name TEST.DFIT ) LOOKUP IF ( does such a file exist? ) or environment. Generally useful 20 ENTER IF ( nope, so make one 20 screens ions ) words created during an application ABORT ( OPS, bis-time error ) development may be easily and clear- THEN THEN ly placed in the generally-useful-word ( Perform any output ) CLOSE ( close file )

FORTH Dimensions 8 Volume IV, No. 3 APPENDIX A, RTll Files Handling Source ENTER (n -- tf) ENTER will This was added to FORTH in assembly language simply because the RTll monitor calls are create a new file of maximum n basically macros and end up looking much prettier if left unexpanded. FORTH blocks in length. Returns a Note: The HEAD and NEXT macros used is exactly compatible with the FORTH PDP-11listing flag, tf, which is 0 if successful or 1 if distributed by FIG. unsuccessful. Note: Although CHAN is included, the readlwrite routines need to be taught to use CHAN LOOKUP (-- tf ) LOOKUP opens as well. As mentioned in the text, either don't use CHAN for now, or contact me. an existing file and returns an error flag similar to ENTER. HEAD 204.CHAN.240.CHANL.DOVAR .WORD 0 CLOSE (--) CLOSE closes the cur- rently open file. HEAD =03,FDB,302,XFDB,DOCCN .WORD FSB A listing of the code for the imple- mentation (as well as some interesting HEAD 206,LOOKUP,240.LOKUP : *+I(** LOOKUP 110v CHANL+Z,Rl ; GET ChANNEL FROM VARIABLE CHAN developments under the DEC o/s) is in CLR -(S) : ASSUP'E NO ERRORS the appendix. .LC~~UP#EMTSLK,Rl,#FDB i3cc 18 ; DONE IF NO ERROR An example of typical code to open I NC (5) ; PUT TRUE ON STACK FOR ERROR a file appears in Figure la. A defini- 1s: NEXT tion to open and write to a data file qEAD "JSrENTER.3Z2rEYTER : ***** ENTER appears in Figure 1b. MOU C!iANL+Z#Rl ; MOUE THE CHAhNEL TO R1 ASL (5) ; CONVERT FORTH-SLKS TO DEC-BL4S (Z*) Note: The RTll file specification is: .ENTER #EMTBLK,?l.#FDB. (S) device (DEV) which is a logical name CLR (S) ; CLEAR ElROR FLAG TO =ALSE t3CC 18 ; DOhE IF NO ERROR assigned to the random access mass IUC (5) ; PLT TRUE ON STACK FOR ER70R storage unit, followed by a maximum 6 letter file name, followed by an 1s: NEXT optional 3 letter extension, e.g., HEAD 205, CLOSE I 305 I CLOSE : ***I)* CLOSE DEV:FILNAM.EXT. MOV CHANL+Zr Rl ; GET CHANNEL FROM USER UARIA6LE CHAN .CLOSE R1 ; CLOSE CHANNEL Text continued on page 22 1s: NEXT Appendix B is on next page EMTBLK: .BLKW 6 ; EMT BLOCK FDB: .RADJO /DK FORTH DAT/ ; FILE NAME BLOCK DEFOULTS DK:FORTH.DAT

Ver. 2 For your APPLE II/II+ Version 2 For 2-80, CP/M ( 1.4 & 2.~1, The complete professional software system, that meets & Northstar DOS Users ALL provisions of the FORTH-79 Standard (adopted Oct. The complete professional software system, that meets 1980). Compare the many advanced features of FORTH- ALL provisions of the FORTH-79 Standard (adopted Oct. 79 with the FORTH you are now using, or plan to buy! 1980). Compare the many advanced features of FORTH- FEATURES OURS OTHERS 79 with the FORTH you are now using, or plan to buy!

79-Standard system gives source portability. YES FEATURES OURS OTHERS Professionally written tutorial & user manual 200 PG. 79-Standard system gives source portability. YES - Screen editor with userdefinable controls. YES Professionally written tutorial & user manual. 200 PG. - Macro-assembler with local labels. YES Screen editor with userdefinable controls. YES - Virtual memory. YES Macro-assembler with local labels. YES - Both 13& 16-sector format. YES Virtual memory. YES - Multiple disk drives, YES BDOS, BlOS & console control functions (CP/M). YES - Double-number Standard & String extensions. YES FORTH screen files use standard resident Upper/lower case keyboard input. YES file format. YES - LO-Res graphics. YES Double-number Standard & String extensions. YES - 80 column display capability YES Upperllower case keyboard input. YES - 2-80 CP/M Ver. 2.x & Northstar also available YES APPLE I I/I I+ version also available. YES - Affordable! $99.95 Affordable! $99.95 - Low cost enhancement option: Low cost enhancement options; Hi-Res turtle-graphics. YES Floating-point mathematics YES - Floating-point mathematics. YES Tutorial reference manual Powerful package with own manual, 50 functions (AM9511 compatible format) 50 functions in all, Hi-Res turtle-graphics (NoStar Adv. only) YES AM951 1 compatible. - FORTH-79 V.2 (requires CP/M Ver. 2.x). $99.95 FORTH-79 V 2 (requires 48K & 1 disk drive) $ 9995 ENHANCEMENT PACKAGE FOR V.2: ENHANCEMENT PACKAGE FOR V 2 Floating point $ 49.95 Floating point & Hi-Res turtle-graphics $ 4995 COMBINATION PACKAGE (Base & Floating point) $139.95 COMBINATION PACKAGE $1 39 95 (advantage users add $49.95 for Hi-Res) (CA res. add 6% tax COD accepted) (CA. res. add 6% tax: COD & dealer inauiries welcome) MicroMotion MicroMotion 12077 Wilshire Blvd # 506 12077 Wilshire Blvd. # 506 L A , CA 90025 (213) 821 -4340 z LA., CA 90025 (213) 821-4340 Specify APPLE CP/M or Northstar Specify APPLE, CP/M or Northstar Dealer inquiries invited Dealer inquiries invited

FORTH Dimensions 9 Volume IV. No. 3 FOR TRS.80 MODEL I OR 111 IBM PERSONAL COMPUTER APPENDIX B I Development of the word FILE and misc. Note 1: I'm sorry, but most DEC users must deal with RADSO. MORE INSTRUCTIONS Add YOUR commands 10 118 I9STANDARO.plua Inatruc. Note 2: This code uses the word WITHIN which is defined as follows: llon sail Far more comphla Ihnmoal Foflhs slngla h doubla : WITHIN ( n low high -- f ) (low < = n < high ) >Rl- OVER < preclsbn. an8 8, atrlng-handllng.clbck. graphlc8 (IBM lowns g~wsLW and 16 cotor or ZOO tint color dlaplayl SWAP R> c AND; %%n%%rebn Edllor. alruclufed h mwular programmlng Word uarcn ullllly THE NOTEPAD Iallef wrller Opllmhed lor your TRSW 01 I0M wllh keyboard repals. upparllowar Case dlsplay drwef. lull ASCII MORE POWER Fonh oparallng system +++*++ DK :FILES. FTH ***+*o+ 4 ***********+***+********* Concurrenl Inlerprelar AND Compilar I VIRTUAL in for vldw and prlnlar, dlsk and tape (1PM abyle hard dlsk avallablal Full 8% or WW Asaamblar aboard (ZW Assemblar also available lor TRSdOl ( Files routines - RAD50 conversion ) lnlarmlx 35. lo W4rack dlsk drlvIa IBM can raid. wrlla and run M 3 Dlsks octal M 3 can read. wrlle and run M 1 dlaks : >r50 ( ascii -- rad50 ) dUP 40 = if drop 0 else dup 44 = if drop 33 else dup 56 = if drop 34 else duP GO 72 within if 22 - else dup 101 133 within if 100 - else ." Illesal RADIX-SO character: 'I 42 emit emit 42 emit cr THE PROFESSIONAL FORTH SYSTEM then then then then then : FOR TRS.80 k IOM PC (Thousands 01 syslems In usa1 d e c i ma 1 MMSFORTH DIsk Syslam (requires 1 dlsk dwe 32K RAMI V2 0 For RadlO Shack TRSW Model 101 Ill sin 9s. ( basic routine to convert an character to RADSO V2 1 For I0M Penonel Computer ~0PcolScreen1 S248 9s' ASCII aiues error messase if try to conuert an illeeal character AND MMS QIVES IT PROFESSIONAL SUPPORT ) Source code Pfovldad MMSFORTH Newslelter Many demo ProgIamS aboard MMSFORTH User Groups Inexpons1ve upgrades to 1atest version ...... Programming slell can provide advice modilica1~onsand *+++++ DK:FILES.FTH +*+**++ 5 custom programs lo 111 YOUR needs MMSFORTH UTILITIES DlSKETrE mcludes FLOATING POINT MATH (0ASIC ROM roulmes plus Complex numbers Reclan ( Files routines - ROD50 conversion ) gular POI^^ coordlnale conversions Degrees mode morel a octal powerlul CROSS REFERENCER 10 list Forlh words by block ( j and line plus (TRS 801 a lull Forth 8Iyle 280 assembler : (1-502) rad50 -- ascii requires MMSFORTH V2 0 1 drive I 32K RAM1 139 95' d u P 0 = if drop 40 else FORTHCOM communiCal!ons packago provides RS 232 dup 33 = if drop 44 else driver dumb Iermlnal mode lransler 01 FORTH blocks end dup 34 = if drop 56 else host mode 10 operate a remote FORTHCOM systems (requires dup 36 50 within if 22 + else MMSFORTH V2 0 1 drlva I 32K RAMI ue 85' JUP i 33 within if 100 + THE OATAHANDLER 0 very Iasl dalabasa managemen1 ; system operable by non programmers (IeaulIeS MMSFORTH then then then then then V2 0 1 drive I 32K RAM) SW.9S. ( basic routine to convert RRDJO to ASCII ) FORTHWRITE la11 powerful Word Processof wIeasY keyslrokes Help screens manual Idemo llles Full propor : rS0> ( n -- asc3 asc2 ascl ) lionrl wnabs ouldanllng Include olhei blocks documents I 0 50 u/mod 0 50 u/mod keybosrd mpuls- ides1 for form Isllers (requires MMSFORTH (r50?) rot (r50>) rot (r50:>)Vot ; V2 0 2 drwes I 48K RAMI $115 00' ( converts a 1 word inteser in NAD50 to 3 ASCII characters ) MMSFORTH GAMES DISKETrE ,081 lime pI8phlCS Iboard d e c i ma 1 games WISOUICOcode Includes BREAKFORTH CRASH FORTH CRYPTWUOTE FREEWAY (TRSBOI OTHELLO I TICTACFORTH (requiresMMSFORTH V2 0 1 drlve 6 32K RAMI 13995' 0th~YYSFORW pmdusn und.r d.rrWnmnl

FORTH BOOKS AVAILABLE MMSFORTH USERS MANUAL wlo Appendices SlI 50' ( Files routines - RAD50 Conversion ) STARTING FORTH bas1' si5.95. octal THREADED INTERPRETIVE LANGUAGES advanced analysis ( ) 01 FORTH Inlernels Sl8 9s. : >radS0 addr -- n + do c@ PROORAM DESIGN ICONSTRUCTION lnUO I0 slruc1ured dup 3 swap i ?r50 1DOP programming gmd for Fonh 116.00' swap rot 50 + 50 * + ; FORTH 79 STANDARD MANUAL OllUIal relerence 10 70 ( converts 3 characters, i.e. bytes startins at addr 1 STANDARD word WI elc 8ll.W' ( word ) FORTH SPECIALISSUE BYTE Magulne(Au0 19801 AcoIIec into sinsle 1 inteser RRQ50 equivalent lor s Ifem lor Forth Users and beginners U.W' decimai * ORDERING INFORMATION SOIIw8Ie Drlces include : rad50? ( n ad.dr -- ) >rr5CZ r@ c! -rB 1+ c! r;' 2+ c! ( conuerts RAD-30 n into 3 characters. bytes, stsrtins at addr ) Send SASE lo, lree MMSFORTH lnforrnallon GWdealsrr Sought

Gel MMSFORTH prWuC1S from YOU, compular dealer or MILLER MICROCOMPUTER SERVICES (69) 61 Lake Shore Road. Nalick. MA 01760 1617)6538136

FORTH Dimensions 10 Volume IV. No. 3 Look to TIMIN tI ngrneerrng

for FORTH software of professional qua1ity,

( Print2 file 5~eci;ica:ions stored in 4 word block at adur i * ready to-run FORTH development systems

9 *application programs ins in FORTH

: Bf1:efiil ( addri add 2) i4 over c < store leiisth byte ) *Consulting services, 1+ 4 0 do including custom over i 2* + @ over radS0:. 2 + loop ZJrop : program deve I o p me nt

( if 4 word file specif cations berins at addrl ) ( will make a TSPEab 1 e trins at add2 ) 0u r I ates t product: DUAL TASKING FORTH Now you can run your process control programs in background while still

*it***+ DK:FILES.FTH Q*+**** g ...... using your FORTH system in the normal way.

( Files routines - file array ) Background and foreground tasks may : Ocilblk .:builds 8 * allot does> chan C 8 * + : 16 OfilblK chanblk each be written in high ( create a strins array to hold 16 file block specifations ) level FORTH. They can execute simu Itaneously and exchange data. The foreground task can

i Files routines - file block ~ack:ns i control the background task. : file ( $Cilspec -- 1 i puts f:.Le 5-e~into filS!k ) BSP @ 2+ ( ictrnr cs'er letter count 1 Available NOW: fi?bl% UP @ + swap Jc i set 'XP inJex ) 8" diskette $285 dup had50 i ! 3 + 2 /loop ! increment sdiir. acd loop j $drop drop i drop strins and filblk ) Write for our FORTH filbi!i chanblk 4 moue ; ( store tile name in array i information booklet

( primitiue routine^ - takes a strins in the for!n: i ( " DEVFILNAMEXT" ) ( on the ctrins stack. then packs it 11-8 Proper format ; 6044 Erlanger St. i into file s~ecificationblock )

(714) 455-9008

FORTH Dimensions 11 Volume IV, No 3 TEST-FLY As20MILLION JET ON AN APPLE? . YES. WITH MICROSPEED. At the Bethesda Naval Research Center, they’ve hardware math processing, fast hi-res graphics discovered the power of MicroSPEED The Navy’s and text, turtle graphics, print formating, two text engineers use this remarkable hardwarekoftware editors, unlimited data types, and incredible FORTH combination to “fly” an advanced fighter aircraft extensibility-all at speeds up to 100 times faster in real time-even making vertical landings on a than Basic. simulated carrier deck. A “crash” is merely another USER-FRIENDLY, EASY-TO-LEARN Starting with learning experience, and an opportunity to modify simple commands that are comfortable even for the research aircraft-inside the Apple-to improve non-programmers, MicroSPEED extends and builds, tomorrow’s combat planes. allowing you to create your own tailored application Surprised that such a sophisticated task is possible languages. The capability of your computer will on the Apple? So were the Navy’s officials, and many grow exponentially, as you work in an active part- others who have discovered... nership with the machine, exploring and develop- THE MICROSPEED DIFFERENCE This extraordinary ing new problem-solving facilities-creating, cor- Language System exploits the real potential of the recting, refining your increasingly powerful system. microcomputer for the first time. The difference DEMANDING JOBS AT LOW COST Developed between MicroSPEED and other programming lan- by a team of standout computer professionals, guages is that with MicroSPEED, there is virtually no MicroSPEED has been put to the test in fields as limit to what you can achieve. It may well be the diverse as medicine, the stock market, oceanography, iiltimate language for the Apple I1 and 111 (and soon and the arts. In even the most challenging appli- the IRM Personal Computer). MicroSPEED literally cations, MicroSPEED users have been unanimous combines the performance of a minicomputer with in their praise of the System and manual. Typical an exhaustive set of user-friendly capabilities: comments are: “Verv hi& marks,” Thomas Toich &D., Tosch Information Management. “The more I use MicroSPEED, the more I love it:’ Prof. James L. Hockenhull, University of Washington. “Great!.. .A joy to use:’ Henry Hzrris, Mission Designer, Cal Tech’s Jet Propulsion Lab. “If you plan to use the Apple or IBM Personal Computer for Eny demanding task, then we built MicroSPEED for y~:’ Sam Cottrell, President of Applied Analvtics. 111-1111111111111111111 I MicroSPEED requires the Apple or IBM Personal Computer with I I single disk. MicroSPEED I1 includes 2 MHz math processor. I I Micro SPEED I1 + includes 4 MHz math processor. I I Applied Analytics Incorporated I 18910 Brookridge Drive I I Upper Marlboro, Maryland 20772 (301) 627-6650 I I I’m interested! My computer is: I ,Please send me: I -MicroSPEED 11, $495.00 -160 Page Manual, 615.00 I -MicroSPEED I1 +, $645.00 -Detailed Information I I Name: I I I Company I I Address I I City State-Zip-Phone No.: ( ) I !Use this coupon to order, or for more information. I I I iMicroSPEEDI API’I E I A 1KAL)EMAKK OF APPLE COZll’l 1EK INC I Volume IV, No. 3 FORTH Dimensions 12 ~~-

Combining 7SlStandard FORTH with Existing Microcomputer Operating Systems

supports sharing resources with other BASIC, ala MICROSOFT disk BAS- software systems. ICS, or such first-generation systems John Arkley Another advantage is the easier ac- like APPLE DOS 3.X which is very The Software Works ceptance of FORTH by non-FORTH slow for large random access files due Palo Alto, California programmers still undergoing the to its linear index structure and its FORTHification process. unusual post-basic interface design. None of the common micro com- Implementation Considerations puter operating systems support files The actual cost of doing an operat- During our recent conversion of that the system will span across multi- ing system from scratch, as we have Software Works FORTH into 79-Stan- ple disk volumes. This problem can be done for the APPLE 11, is not as large dard FORTH, most of the problems of solved in the interface between as one would think. It only took 3 building a FORTH on top of several FORTH and the host system, thus weeks to create the 6502 FORTH, the existing microcomputer operating reducing the applications program- operating system, and a new disk systems were tackled and solved. This mer’s concern for disk capacities. driver for the APPLE disk controller. article briefly discusses the advantages FORTH can circumvent deficiencies This is largely due to two factors: most and disadvantages of our approach. in these operating systems. of FORTH can be written in itself, and Building FORTH upon a wide range A similar scenario applies to charac- 110 models that are simple but elegant, of different operating systems requires ter IIO. The best example of this is the and therefore easy to duplicate, were two virtual models for FORTH input/ two and a half character devices in used. output, one for character or device 110 CPIM. FORTH can easily interface IIO Most micro systems have the needed and one for disk IIO. Conveniently, through a vector table that allows random access facilities and can have 79-Standard FORTH defines these via patching in device drivers for 8 or 16 their disk file 110 interfaces mapped the words KEY, EMIT, EXPECT, and TYPE devices. directly to the 79-Standard FORTH for character 110 and BLOCK, BUFFER, Another example is found in device 1024-byte definition of a block. This and SAVE-BUFFERS, and EMPTY- paralleling, a means of directing the does result in not being able to use all BUFFERS for disk IIO. output stream to multiple output possible files that the host operating 79-Standard FORTH fails to address devices without having to put special- system could create, since 79-Standard the problems of directories, directory case code in an application. FORTH’s disk IIO design doesn’t pro- management, file creation, device defi- Disadvantages vide for partial block input or output. nition, device assignment, special Using an existing operating system is One possible solution for this problem driver linkages, keyboard mapping, not without some costs, some of which is to create a character driver for KEY function keys, and the like. The philo- affect performance. A good example and EMIT to provide sequential charac- sophical reason is that no one oper- can be seen in the difference between ter access to a disk file. ating system will ever do what is character at a time 110 with EMIT and The results of combining microcom- desired, and it usually hinders rather a line at a time IIO with TYPE. If the puter operating systems with 79-Stan- than supports the programming lan- overhead for an output request is very dard FORTH produces an environ- guage system. high, software that only uses EMIT ment that remains entirely FORTH Advantages could easily run 10 times slower than and at the same time allows real There are a number of advantages to if whole lines were TYPEed for most of transportability that is acceptable to using the native operating system, its output. Disk 110 speed can also suf- the large majority of existing micro- even though doing so increases the fer if the operating system is slow at computer users. The performance and size of the FORTH system. random access reads or writes. size costs to the resultant FORTH will, A primary advantage is the ability of The final disadvantage is encoun- no doubt, be hotly argued from differ- such a FORTH to co-exist on the same tered with operating systems that are ent views, but the bottom line, selling mass-storage volumes with other entirely useless for FORTH or too software products in volume, out- application software and languages. complex to support the simple needs weighs all possible technical perspec- Now that we’re seeing cheap high- of FORTH. The problem is solved by tives. We expect to see a much larger density storage, the usual FORTH using the directory format and disk acceptance of FORTH applications design (which can be summarized by allocation mechanism, and implemen- software as the result of this approach, the phrase ‘I own the whole disk’) is ting a subset operating system from particularly from the hardware an unacceptable one. The massive scratch that is sufficient to support manufacturers like OSBORNE and microcompuer market requires a dif- FORTH. This problem arises when the SANYO. 0 ferent FORTH approach, one which operating system is inside a disk

FORTH Dimensions 13 Volume IV, NO. 3 Now Available On

HARDWARE SOFTWARE

~~

The HP 9826A and 9836A are two of Hewlett-Packard’s HP 9826/36 Multi-FORTH newest and most powerful desktop computers. Each is based HP PRODUCT # 97030JA on the Motorola MC68000 microprocessor. Both machines Multi-FORTH was developed in 1979 by Creative Solutions, have full graphics capability and up to 2 full megabytes of Inc. The standard product has been substantially modified to user read/write memory. Both operate on 5%’’ flexible disc drives (the 9836A has two) which feature 264K bytes of take full advantage of the 9826/36 hardware features. mass storage. While the 9826A has an integral 7” (178mm) Multi-FORTH features CRT which makes it useful for computer-aided testing (CAT) 79 standard programming environment and control, the 9836A has a full 12.2“ (310mm) CRT Multitasking which makes it ideal for computer-aided engineering (CAE) Full screen editor applications. Each model features the following: In-line structured assembler Seven levels of prioritized interrupt I/O and graphics extensions Memory-mapped I/O Loadable H.P. floating point (IEEE format) Built-in HP-IB interface Extensive user manuals and documentation Standard ASCII keyboard with numeric keypad and Optional Features: international language options Meta compiler Ten (20 with shift) user-definable soft keys with soft labels Multi user Rotary-control knob for cursor control, interrupt generation Data access methods library and analog simulations This product IS part of HP PLUS - a program for locating user software. It has been developed by an independent software supplierto run on HPcomputer systems. It is System clock and three timers eligible for HP PLUS as determined by references from satisfied end users. Support Powerfail recovery option for protection against power lapses services are available only through the software supplier. Hewlett-Packard’s Seven additional interface cards responsibilities are described in the Responsibilities Statement below. - DMA controller (up to 2.4 mb/sec) Responsibilities Statement - 8/16 bit bi-directional parallel HP PLUS software was developed by an independent software supplier for operation on HP computer systems. The supplier is solely responsible for its software and - Additional HPlB interface support services. HPis not the manufactureror developerofsuch softwareorsupport. - Serial RS232/449 HPdisclaims any andall liabilities forandmakes no warranties. expressedorimplied, with respect to this software. Distribution of this pmduct or information concerning - BCD this product does not constitute endorsement of the product, the supplier. or support - Color video(RGB) 3 planes 512 x 512 8 color services. The customer is responsible for selection of the soflware it plrch~~.

For more information, please write Marvel Ross, Hewlett Packard Company 3404 East Harmonv Road. Ft. Collins, CO. 80525

~ ~~ ~~~ FORTH Dimensions 14 Volume IV. No. 3 Checksum for Hand-Entered Source Screens

c : WORD WORD HERE ; is blank or null, we’re at the end of the : >IN IN ; block. This test is made in the word Klaxon Suralis : NOT O= ; MORE. and For some systems you may need to If you feel a need to optimize this Leo Brodie predefine 32 CONSTANT EL. test for your system, make sure that a) The program will NOT work, you get the same results as published however, on FIG systems which don’t here, and b) you get the same result have disk buffers consisting of 1024 whether or not the final word in a For program exchange, the medium of bytes of contiguous memory. Sorry. block occupies the last bytes of the hard copy is cheap, convenient, and The program has been designed for block. machine-independent. Its primary transportability, at some expense of Further cautions: disadvantages are the time required speed. It depends on WORD to parse The program uses FORTH-79 WORD. for hand-typing the source code and groups of letters separated by spaces. It can’t handle comments longer than the possibility of human error in the Since certain details of WORD’s opera- 255 characters. process. Even if the screens LOAD tion vary from version to version, we The program uses unsigned ad- without error messages, some errors chose an algorithm that would cover dresses as LOOP parameters. As long as (omitted or transposed words, frin- all bases. WORD’s buffer doesn’t cross the 32K stance) may pass undetected until The main trick was the test to decide boundary, everything’s okay; other- run-time, when the system crashes when to end the outer loop. On wise you’ll have to alter DISPOSE. mysteriously. 79-Standard systems, when WORD hits Finally, we can’t guarantee that the This program can ameliorate the lat- the end of the block it returns a count CRC algorithm used in ACCUMULATE is ter disadvantage, although it does of zero; but on FIG systems, it returns the best on land and sea. It’s adapted nothing about the former. Given a a count of one. Therefore, a test for from a book, and seems to work. We’d screen number on the stack, VERIFY zero count isn’t transportable. like to hear about flaws or improve- calculates a 16-bit CRC value which The algorithm we chose was this: ments. may be printed above each screen’s keep DlSPOSing word-strings until the We hope that this routine will listing. The check value is NOT writ- next string parsed by WORD has a become a standard. We’d like to see ten into any block or buffer. count less than two (which covers zero FORTH vendors include some com- On the receiving end, VER is used to and one) and consists of an ASCII patible version of it in their systems. compute the check sum of the screen character less than 33 (which covers Perhaps embedded as an option as typed in. If the number differs from blank and null). Thus, in a FIG system, within LIST or TRIAD. that given on paper, something is if the count is one. but the character Good luck. definitely wrong; if the values are equal, chances are very good that the Screm 0 129 crc vw - 56445 program compiles as listed. 0 ( Checksum for had-mtaod source screens) 1 : CICCUWATE ( oldcrc\chu -- neucrc ) We’ve chosen to express the check- 2 2% 8 XOR 80 W WP O< IF 16366 XOR DUP + 1+ sum as an unsigned number; for the 3 ELBE DUP + THEN LWP 8 sake of standardization we suggest 4 : DISPOSE ( crcvalur\adr\lm -- neucrcvalur ) s OVER DUP CQ 40 = swi+ ca EL = RND OVER 1 - AND you do the same. By the way, VERIFY 6 IF ( comment; skip it) 2DROP 41 WORD DROP may take a second or two -be patient. 7 ELSE 1+OVER +swcIp W I CQnCCIJWLATE LWP 8 THEN ; ( careful? LOOP% on addresses) Note that comments are ignored in 9 : MORE ( -- adr f) BL WORD DUP Ca 2 < OVER 1+ W 33 < RND NOT 8 the CRC generation. Also, the number 10 of spaces between words makes no dif- 11 : VERIFY ( scr0 -- crcvalue) BLK Q >R >IN 3 M BLK ! 0 >IN ! 12 0 BEBIN HORE WHILE BL OVER CWNT + C! CWNT DISPOSE ference. You may rearrange source 13 REPEAT DROP R> >IN ! R> BLK ! ; words and changelomitladd com- 14 : VER SCR ;3 VERIFY U. ; ments without affecting the value 15 returned by VER and VERIFY. But a missing space will, as you’d expect, Screen # 130 crc vrr = 5038 0 ( Test scrwn) change the checksum. 1 For program exchange, the lrmdium of hard copy is chrap, The program runs on fig-FORTH 2 convenient, and machine-iodepmdent. Its primary disadvantages provided you make the following 3 are the time required fw had-typing the aaurce code and the redefinitions before loading this 4 possibility of human error in the process. Even if the screens 5 LOAD without error message^, some errws nay pars undetected application: 6 until run-time, nhen the system crashes mysteriously.

FORTH Dimensions 15 Volume IV, No. 3 QTF Quick Text Formatter - Part I technical manuals. And the enhanced just too nice a word not to use here. version will most likely become a If you think it’s a problem, either use Leo Brodie product. a separate vocabulary, or save this Chatsworth, California Another reason I’m publishing the definition for last, and only load this QTF here is this: if any authors of application when you’re formatting future FORTH Dimensions articles text.) were to use this application, it would For example: Like many other writers, I’ve become be extremely easy to transfer the text [ This string, which would appear in addicted to word processors. Trying to using any routine for transfering your source formatting block, would write any other way seems unimagin- FORTH screens. Eventually I’ll be able format this paragraph making the ap- ably tedious - like plucking your own to phone this directly to our typeset- propriate line breaks at the right chickens for dinner. ter, saving everyone a bit of work. margin. ] A year ago, when I left my full-time The final reason I’m publishing the Obviously, you can’t cross block job and word processor, I found QTF is because we need more pub- boundaries while inside text. myself writing at home, trying to cope lished FORTH applications. This one The word pp is a formatting com- with a medieval device called the elec- represents an interesting solution to a mand for starting a new paragraph; it tric typewriter. It was a nightmare; my real problem. causes the formatter to do two car- mistakes actually appeared on paper, The Approach riage returns. For instance, the source: the instant I made them! Corrections As I said, the approach takes some get- [ This is paragraph A. ] pp [ This is of a sort could be made, using a ting used to. The main surprise is that paragraph B. ] bizarre strip of tape coated with a flaky you don’t edit an image of the final would produce white chalk, or a pungent paint which output as it will be printed. Instead This is paragraph A. took three days to dry. (I have a dim you edit a string of formatting com- recollection of using the electric mands and text into a FORTH block. This is paragraph B. typewriter and its awkward accouter- The formatting occurs when you LOAD Essentially, in creating a document ments years before, only they hadn’t the block. That’s the key to the applica- you write a “program” to format the seemed so archaic. Must have been a tion’s simplicity: the formatter uses document, using this specialized previous lifetime.) FORTH’s interpreter. As an added language. Well, as soon as I got my IBM Per- boon, the word processor becomes The word cr does a single carriage sonal Computer and a version of fully extensible. return. Like pp it repositions the cur- FORTH, I proceeded to write a quick, Of course if you don’t like being sor (or printhead) at the left margin (set scaled-down word processor, using limited to 1K blocks of text, you can by the constant LMARGIN). the same syntax as that used at design the application to use block- The words tab, indent, and hang-ind FORTH, Inc. The formatter portion based files. But if you use the present allow you to get away from the left occupied three screens, and the editor system carefully, you’ll find it’s actual- margin in very convenient ways. portion nine screens - not terribly ly convenient to compose your text in You’ll find all these formatting com- sophisticated, but at least the flaky “modules,” each module being a block mands in the accompanying glossary tape and smelly fluid were back in the containing one or two paragraphs. To (Figure I). drawer. edit a paragraph, you edit the module What about editing? This two-part article features that - you don’t have to scroll through a If you’ve looked at the code for the for- simplified application, which I call long document to find the paragraph matting commands (Figure 3), you QTF, the Quick Text Formatter. For you’re looking for. It’s a “random may be saying “There’s nothing here! those of you who are running FORTH access” approach to text editing. This is useless.” . but don’t have an off-the-shelf word The Syntax Well, you’re half right. The other processor (whether because you don’t Let’s take a quick look at the syntax for half of this application, which I’ll write enough to justify it, or because the formatting commands. The main feature in Part 11, is the text editor that you can’t afford it this month), you formatting word is [ (left-square- you need to edit your text source. It’s may find this application quite bracket). This word indicates the impractical to use ordinary FORTH attractive. beginning of text, delimited by right- line editors, because they treat a block The basic approach takes some get- square-backet. You can think of it as like 16 lines of 64 characters. If you in- ting used to, but it has some definite a glorified .” that does carriage returns sert a character in the middle of line advantages aside from simplicity. In at the right margin, and formfeeds at 5, any text at the end of line 5 “falls fact, over the past several months I’ve the bottom of the page. off.” Instead we want it to wrap extended this approach to include (Yes, I know this conflicts with around to line 6. Also, we don’t want many features I need in producing FORTH’s own square bracket, but it’s to be editing inside a rectangle where

FORTH Dimensions 16 Volume IV, No. 3 Figure 1 words may appear to be cut in half if i?uick Text Fwnattw they happen to straddle a 64-character User ' s 61ossar y boundary. The QTF editor surmounts start sets everything up. Use at beginning. these problems and provides some ex- c begins setting trxt. There must be a space tra features especially useful in the between the "C" and thr first character to be printed. For example: prose-writing process. C This is your text.] So tune in next issue, and in the I ends setting text. Doesn't need a S~~CRpreceding. C sam~as C. but allows you to print strings with meantime let's look at some of the a 1 inside. benefits of the QTF approach. goes with C Formatting Extensibly does one carriage return. Returns to normal tab To illustrate how nice it is to have PP begins a paragraph (does two carriage returns). FORTH underneath you, Figure 2 crs does specified number of crs shows the formatting source that pro- neupage causes text to begin at the top of a neu page, leaving the rest of current page blank. duced the glossary in Figure 1. (Ac- tab tabs over to the position specified. relative tually Figure 2 is a reproduction of the to the left margin -- for the current line only. For example. "5 tab" tabs in S spaces display produced by the QTF Editor.) from the left margin. But if the text should Let's look at the source in Figure 2, continue to the next line below, it wili and see what it does: begin at the normal left margin. indent does a tab to position specified. and causes The document begins with a com- subsequent lines, up to the delimiter, to ment, just like a regular FORTH be indented to the same tab hang-ind does a tab to position specified and cau6es screen, useful in recognizing the text subsequmt lines, up to the delimiter, to when doing an INDEX. Naturally, the be indented three more spaces to the right. comment uses FORTH's ordinary This paragraph uses this format, which typesetters call "hanging indent: parenthesis. cen ter C like C. begins a string of text, but centers Next we find a FORTH definition! it on the page. We're defining the word means to do rC takes a number "n" off the stack. Like C, begins a string of text, but right-justifies it a hanging-indent at tab-position 15. in a field "n" wide. We'll see how this definition is used sub "subitem". Does a cr and a 5 hang-ind. Convenient for makinp certain kinds of lists, momentarily. including out 1i nes. After the definition comes the com- subsub "sub-subitem". Does a cr and a 10 hang-ind. mand start which initializes certain variables and moves the printhead To produce the following list: down several lines from the top of the page. Income Expenses Next we find the format command

1981 S10.32 S15.12 center[, following the text to be 1982 $328,543.21 S408.964.86 centered on the page. (The square-

we first defined: bracket is part of the word center[ to remind us that it also indicates the : year cr 5 tab ; beginning of some text.) : income 20 tab 14 ; : expenses 40 tab 14 ; After some more titles, we format the first word in our glossary, which then wrote happens to be the word "start," by pp income rC Income1 expenses rC Expenses1 cc year C 19811 delimiting it on both sides by square income rC S10.323 expenses rC S15.121 year C 19821 income brackets. Here is where our special rC S328,343.211 expenses rC S408.964.861 purpose word means comes in: it tabs over to the second column, the Figure 2 glossary description. Using this type of special-purpose 73 format command has definite advan-

( Fwuttw Qlmmuy) I aemm 13 hmg-ind # tages. Not only does it make the source mtut center1 Quick Text Formatter1 cr center1 Uur'm Qlmruyl easy to read ("this-command" means pp C mtutl amrnm C wtr evrrything up. Ume at beginning.] cr "that-action"), but it also lets us fiddle C C) memm C begin. utting text. There wmt be a space between the "C' and the firmt character to be printed. For rxuplrxl with the tabbing distance. Even after cr 20 tab C C Thim im your text.]) cr C 3) mernm C mdm wtting we've completed the entire document, text. Doemn't need a mpace prueeding.3 cr t (3 aeanm C mame we can shift the description column am C. but allan you to print mtringm with a 3 inride.) cr C >I means C gwr with C3 --> around by changing only one number, in the definition of means. My experience in using this ap- proach has taught me to use many such special-purpose formatting Continued

FORTH Dimensions 17 Volume IV, No. 3 Figure 3 words for each document. The idea is to describe the format of a document in logical terms, rather than pro- Screen P 33 crc ver = 53368 cedural terms. For instance, if you 0 ( Quick Text Formatter 08/09/82 ) begin each title of a chapter subsection 1 : FORHFEED 12 EMIT ; ( <-- write code for your own printer) 2 78 CONSTANT PAPER ( 80-column width) with the word 3 ( left, right, top and bottom margins:) subsection[ 4 10 CONSTANT LMARGIN PAPER 10 - CONSTANT RHARGIN or some such descriptive name, then 5 6 CONSTANT THARGIN 55 CONSTANT BHARBIN 6 VARIABLE DELIMITER ( current delimiter character) at any time you can change the defini- 7 VARIABLE XTRA ( amount to indent on auto cr’s) tion of subsection[ to print the section 8 VARIABLE ACROSS ( horizontal position; absolute) title in boldface, or perhaps to under- 9 VARIABLE DOWNWARD ( vertical position; absolute) 10 : SKIP ( n) DUP ACROSS +! SPACES ; line, or perhaps to begin the section on 11 : \line ( begin new line at appropriate left margin) a new page. 12 0 ACROSS ! CR 1 DOWNWARD +! LMARGIN XTRA i) + SKIP ; 13 -- > (When you do define special words, 14 there’s a peculiar caution that I almost 15 hate to bring up: some FORTH systems print a message such as “is Screen P 34 crc ver = 31098 redefined” or “isn’t unique” when a 0 ( Quick Text Formatter 08/09/82 ) 1 : start ( begin page at top margin; use at start of document) word is defined twice. [My personal 2 0 DOWNWARD ! THARGIN 0 DO \line LOOP ; opinion is that this test should be user- 3 : newpage ( begin next page) CR FORHFEED start ; switchable ...] On such systems, you 4 : cr ( begin next line; if at bottom, start new page) 5 DOWNWARD i) BHARGIN > IF newpage ELSE \line THEN ; can’t print the same document twice 6 : crs ( P of crs -- ) 0 DO cr LOOP ; without getting the error message in 7 : pp ( start new paragraph) cr cr ; the middle of your document, unless 8 : tab ( n) ( skip to position “n”, relative to left margin) 9 ACROSS i) LHARGIN - - 1 MAX SKIP ; you take some special measure. For in- 10 : indent ( n) ( tab and reset left margin, until next delim.) stance, you could define all your 11 DUP XTRA ! tab ; special formatting words in a separate 12 : hanq-ind ( n) ( indent; subsequent lines indent 3 more) 13 DUP tab 3 + XTRA ! ; block, and only load the block once. Or 14 --> you could define a dummy word 15 called tabs on the top of the text for- matter application, and begin each Screen # 35 crc ver = 13904 document with the phrase 0 ( Text Formatter 08/09/82 ) 1 : ?NEAR ( -- true: near right) ACROSS a RHARGIN > ; FORGET tabs : tabs ; 2 : ?WRAP ( -- true: at very edge) ACROSS a PAPER = ; or some such.) 3 : LETTER ( -- current char.) BLK a BLOCK >IN i) + Ca ; Text Management 4 : FLUSH-LEFT ( after a cr, don’t output a 2nd blank) 5 cr LETTER BL = IF 1 >IN +! THEN ; A few more words about working 6 : PCIRSE ( c) ( display text to delimiter “c“ within margins) with the block “modules”: 7 DELIMITER ! BEGIN LETTER 1 >IN +! DUP Since printing a document consists 8 DELIMITER i) = >IN i) 1023 = OR O= WHILE DUP EMIT 9 1 ACROSS +! BL = ?WRAP OR IF ?NEAR IF FLUSH-LEFT of LOADing a series of FORTH blocks, 10 THEN THEN REPEAT DROP 0 XTRA ! ; you can use any method that your 11 : C ASCII 1 PARSE ; 12 : C ASCII 1 PARSE ; system provides for doing that. If 13 --> you’re preparing a short document 14 (one or two pages), it’s fine to use a 15 series of blocks, linking one to the next with the word Screen # 36 crc ver = 54848 -- > O(Text Formatter Extensions 08/09/82 ) 1: sub cr 5 hang-ind ; But for longer documents, such as 2: subsub cr 10 hang-ind ; book chapters or long articles, it turns 3: centart ( center between margins) >IN i) RHARGIN LHARGIN - out to be much easier to provide a 4 5 + ASCII 3 WORD Ci) - 2/ tab >IN ! C ; 5: rC ( n) ( right justify in field ”n“ wide) >IN i) SWAP “load block.” This block contains the 6 ASCII 3 HORD CO - 0 MAX SKIP >IN ! t ; main title, and all the section titles, but 7: load LOAD 3 between section title will be a “load 8 9 statement” (e.g. 98 load). By sticking to 10 this approach, you give yourself a 11 12 directory to all the blocks in your 13 document. It’s easy to move sections 14 around, if necessary, by just changing 15 the load order. (The QTF Editor lets you move text strings from block to block, too.) Copyright 1982 Leo Brodie 09/01 182 Within each section, blocks can be

FORTH Dimensions 18 Volume IV, No 3 linked together by arrows, or alter- right away is print. It should take a TO HORSE! natively, you can define the word thru block number on the stack, direct your to load a range of blocks from the load computer’s output to the printer, LOAD block. the given block, then return output to Notice that you can format (load) your console. This is system-depen- any block at any time. You don’t have dent stuff, so I don’t show it here. to start from the beginning of the If you type it in... THE document. That’s the other advantage I’ve included checksum verifications of using a load block: you can review at the top of each screen. See the arti- the entire document by loading the cle on checksums elsewhere in this FORTH load block, or just sections by loading issue. the section blocks. This application is designed to run Sometimes it’s convenient to define on FORTH-79 Standard. To run it on the load-blocks to frequently-used a fig-FORTH system, you should CAVALRYTM documents as CONSTANTS. In fact, for predefine: my correspondence I have a block : VARIABLE 0 VARIABLE ; IS COMING! reserved for my return address. This : CREATE VARIABLE -2 ALLOT ; block is named as the constant address, : >IN IN ; so when I write a letter, I begin the : WORD WORD HERE ; block with Some systems may require that you start address load predefine: then continue with the date, the 32 CONSTANT BL COME TO YOUR addressee’s name, etc. Saves me from : ASCII having to remember where I live. BL WORD 1+ C@ Suggested Extensions [COMPILE] LITERAL ; There are a number of niceties I’ve left IMMEDIATE IBM Poco’s out of this published version. For one (where WORD is the 79-Standard thing, I wanted to keep it simple. For version) another, those niceties are reserved for Finally, remember that the Format- CALL! the product version (which I plan to ter will be frustrating to use until you sell for about $30). But I’ll give you have the Editor. Can you wait till the some hints - if you want to spend the next issue? time you can add them yourself. Notice Of course, there are all the obvious Permission to use this application is extensions, such as page numbering, granted for individual, personal use in REWARD! item numbering, automatic heading/ a non-commercial manner. All com- footing, justification, etc. mercial rights reserved. Perhaps less obvious additions are a Acknowledgements INCREASED user-switchable “log” facility, which I thank FORTH, Inc. for permission to PROGRAMMING optionally prints the corresponding use this syntax, which was originally block numbers beside the text in the invented by Charles Moore. The entire PRODUCTIVITY! formatted output. This makes later text of Starting FORTH was done on editing extremely easy. Also, an a word processor that used this escape from formatting the document general approach. during output can be very handy. And of course there are routines to Leo Brodie is an author, lecturer and BOUNTY take advantage of your printer’s consultant specializing in FORTH. He capabilities. My own verison, for the teaches the Advanced Systems Course of BENEFITS Epson printer, can print boldface at Inner Access Corporation, and has I words in the middle of normal text, or written system documentation for three to those who JOIN 1 lines or even paragraphs in double- FORTH vendors. He is also editor of width, compressed, or both at the FORTH Dimensions Magazine. He no same time, keeping the natural longer dances to ’50’s music but in- margins of the paper, and of course do stead listens almost exclusively to underlining. Steely Dan records. FORTH,Inc. A word you’ll definitely want to add Copyright 1982 Leo Brodie.

AVAILABLE AT SELECTED COMPUTER TRADING POSTS

1 FORTH Dimensions 19 Volume IV, No. 3 2-80@and 8086 FORTH PC/FORTH'" for IBM@Personal Computer available now!

FORTH Application Development Systems include interpreter/compiler with virtual memory management, assembler, full screen editor, decompiler, demonstration programs, utilities, and 130 page manual. Standard random access disk files used for screen storage. Extensions provided for access to all operating system functions.

2-80 FORTH for CP/[email protected] or MP/M ...... $ 50.00 8086 FORTH for CP/M-86 ...... $100.00 PCIFORTH for IBM Personal Computer...... $1 00.00

Extension Packages for FORTH systems Software floating point ...... $1 00.00 Intel 8087 support (PC/FORTH, 8086 FORTH only)...... $100.00 AMD 951 1 support (2-80, 8086 FORTH only)...... $100.00 Color graphics (PC/FORTH only) ...... $1 00.00 Data base management ...... $200.00

Nautilus Cross-Compiler allows you to expand or modify the FORTH nucleus, recompile on a host computer for a different target computer, generate headerless code, and generate ROMable code with initialized variables. Supports forward referencing to any word or label. Produces load map, list of unresolved symbols, and executable image in RAM or disk file. No license fee for applications created with the Cross-Compiler! Prerequisite: one of the application development systems above for your host computer. Hosts: 2-80 (CP/M 2.2 or MP/M), 8086/88 (CP/M-86), IBM PC (PC/DOS or CP/M-86) Targets: 2-80, 8080, 8086/88, IBM PC, 6502, LSI-11 Cross-Compiler for one host and one target ...... $300.00 Each additional target...... $100.00

FORTH Programming Aids by Curry Associates. Includes Translator, Callfinder, Decompiler, and Subroutine Decompiler. 40 page manual. Used with Cross-Compiler to generate minimum size target applications. Specify host system ...... $1 50.00

2-80 Machine Tests Memory, disk, console, and printer tests with all source code in standard Zilog mnemonics ...... $ 50.00

All software distributed on eight inch single density soft sectored diskettes, except PC/FORTH on 5'/4 inch soft sectored single sided double density diskettes. Micropolis and North Star disk formats available at $1 0.00 additional charge. Prices include shipping by UPS or first class mail within USA and Canada. Overseas orders add US$lO.OO per package for air mail. California residents add appropriate sales tax. Purchase orders accepted at our discretion. No credit card orders.

Laboratory Microsystems 41 47 Beethoven Street Los Angeles, CA 90066 (21 3) 306-7412

2-80 is a registered trademark of Zilog. Inc CPIM is a registered trademark of Digital Research, Inc IBM is a registered trademark of International Business Machines Corp

Volume IV. No. 3 FORTH Dimensions 20 The Sheer Joy of Clipping Recursively

Bob Gotsch

I’ve been wondering since I wrote the last article whether recursion would be useful for anything else but a study of recursion. That other thing turned out to be “clipping,” discarding those parts of the lines of a picture that lie out- side the specified “viewport,” so that plotting takes place only within the desired or useable portion of the display device. One strategy for clipping is to perform a binary search for the visible extremes of each line, then plot the segment between. Using the Sutherland-Cohen algorithm, 4-digit “out- codes” are assigned to the endpoints of a line according to where they lie, inside or outside the viewport.

0101

V V

+-t0001 P 0000 P 0010 Of all the possible locations of a line, entirely inside L R viewport, entirely outside, one end in, or crossing view- port, every situation is handled by trivial rejection, trivial acceptance, or successive middle divisions of the line until each of the segments of the line can be trivially accepted or trivially rejected. The binary search for the intersection -kVPB+1001 1000 1010 with viewport boundary terminates when the segment becomes so short that the midpoint in integer screen Inside is 0000. For an X-value to the left of (less than) coordinates coincides with one or the other endpoint. the viewport boundary, the rightmost bit is set (0001). I have chosen to save the three values for each endpoint, Below the viewport the leftmost bit is set (1001).The out- X-value, Y-value, and outcode together on the stack, with code for lower left is the logical OR of left and below the out-of-viewport point always topmost on the stack. Hence a true INVIEWPORT? condition is followed by BSWAP. (lOOl), etc. A line can be trivially rejected (no plotting at all) if it lies entirely to one side (outside) of the viewport. The other tests TRIVIALACCEPT?, TRIVIALREJECT?, and An efficient test for rejection, returning a true flag, is the COINCIDE? as well as calculation of MIDPOINT, assignment logical AND of the endpoint’s outcodes. A line may be of OUTCODE, and the graphics action PLOTLINE do just what trivially accepted and plotted as-is when outcodes for both they say and should be understandable from the forego- ends are zero. ing without listed definitions. These are incorporated in the recursive procedure I I REJECT? which uses the last outcode as true or false flag. If true, it returns to toplevel CLIPLINE having dropped one of the points, or at any lower level having droped off the half of the current line that is entirely outside of the viewport. Between MYSELFs is a test that drops the mid- point if it happened to be inside the viewport, so the search can continue onward for the other visible extreme of the line, conducted by the other MYSELF. If the actions of a recursive procedure are planned in advance, then the procedure-as-a-whole can be written to follow those rules, and each recursive call can be trusted to follow those rules. If REJECT? returns false, then CLIPLINE must plot the seg- ment represented by the two endpoints left on the stack. Continued

FORTH Dimensions 21 Volume IV, No. 3 : RETURN R> DROP ; BIBLIOGRAPHY : REJECT? ( 2x,2y,2oc,lx,ly,1oc 1. Foley, J.D. and Van Dam, A,, Fundamentals of Interactive Com- ___ puter Graphics, Addison-Wesley Publishing Company, 1982. 2x ,2Y 1 TF) 2. Newman, W.P. and Sproull, R.F., Principles of Interactive Com- ( --- ~xc~,~Yc~,~oc,~xc~,~Yc~,FF)puter Graphics, McGraw-Hill, 1979. TRIVIALREJECT? IF 3DROP RETURN THEN TRIVIALACCEPT? IF RETURN THEN Bob Gotsch is a graphics programmer for Time Arts, INVIEWPORT? Inc. and a teacher of graphic arts at the California IF 3SWAP (swap endpoints) College of Arts and crafts. He is interested in exploring MIDPOINT the use of computers as aids to artists. He uses FORTH- COINCIDE? WARE FORTH. IF >R >R 3DROP R> R> 0 RETURN THEN OUTCODE 3SWAP MYSELF DUP NOT IF 3SWAP 3DROP THEN MYSELF 3SWAP (swap ends back) ELSE MIDPOINT COINCIDE? IF >R >R 3DROP R> R> 0 RETURN THEN OUTCODE 3SWAP MYSELF DUP NOT IF 3SWAP 3DROP THEN MYSELF THEN ; : CLIPLINE ( l~,ly,2~,2y--- ) OUTCODE 5 ROLL 5 ROLL OUTCODE REJECT? DUP IF DROP 2DROP FORTH Based File Handling System ELSE STRIPOUTCODES PLOTLINE (continued from page 9) THEN ; The ability of having several channels active allows I find it unnecessary (and often almost impossible] to easy file to file transfer of information, or simultan- step thru all the levels in planning a recursive procedure; eous editing of several files. However, since it would if one reads the toplevel procedure as a “user” of the then be possible to have several blocks with the same action-of-the-wholeat each of its MYSELFs, or reads MYSELF block number yet on different channels, the routines as the typical interface between two levels, that should be like BLOCK need some very minor alterations to pre- enough for understanding. But how many levels deep vent confusion. If there is enough interest from might it actually go in the search for the viewport boun- readers, I will discuss these changes in a future arti- dary? To determine the risk of return stack overflow I cle. For now, I recommend that CHAN be ignored, and simulated a high-resolution (1024 wide) graphics display that all file IIO be performed on the default channel and clipped random lines from a large user space 30000 zero, and that files be opened, used and closed pixel units wide. Interestingly, and reassuringly, the depth sequentially. of recursive calls NEVER exceeded 17 - staying well Conclusion within both parameter stack and return stack limits. Of A FORTH that has the file handling capability has course a high-level recursive search is slow; the real effi- many advantages. The one illustrated is simple, ciency of this algorithm would be realized in assembler requiring only file string, FDB stuffer and three CODE, calculating the midpoints with two additions and verbs. Error recovery is as simple. Yet it clarifies two right shifts. FORTH program usage by making source code more To illustrate uses of clipping, I have included printouts modular and circumventing much code since there of a decorative title for this article and a frame from an is no need for documentors or auto-indexes. The animation sequence in which a bird and its reduced effort to add such to FORTH is trivial, due to the likeness fly into and out of large and small viewports modest amount of additional code. The gain is easy simultaneously on the screen. 0 file generation, be it FORTH source code, formatted text, target compiled FORTH object code or FORTH generated executable code. 0

FORTH Dimensions 22 Volume IV, No. 3 THE FORTH SPECIALISTS COLORFORTH AND PCFORTH

Quality figFORTH compilers need not be expensive.

COLORFORTH is a version of figFORTH for the TRS-80 Color Computer.It requires a minimum of 16K,but does not require Extended Basic. COLORFORTH has been customized for the Color Computer with special DUMP and PRINTER functions and a CSAVEM command for those owners without Extended Basic. When you purchase COLORFORTH, you receive both cassette and RS/disk versions, and the figEDITOR. This means no added expense when you upgrade your system. Complete: Both cassette and RS/disk versions with extensive manual. JUST ...S49.95.

PCFORTH is FORTH tailored for the IBM Personal Computer, You receive all the outstanding qualities of standard figFORTH compiler and editor, plus several additional words to customize it for the Personal Computer. PCFORTH requires a minimum of 32K and 1 disk drive (DOS). Complete with diskette and manual. OnIy... $89.95. DEALER & AUTHOR INQUIRIES INVITED All items are post paid in US...... Texas bskbnts add 5 percent Armadillo Int’l Softwar 1- VM P.0 BOX 7661 AUSTIN, TEXAS 78712 PHONE (512) 459-7325

-=-=-=-=- -i-=-=-8080/Z80 FIG-FORTH for CP/M & CDOS systems -=-=-=- -=-=-=-=- $50 saves you keying the FIG FORTH model and many published FIG FORTH screens onto diskette and debugging them. You receive TWO 8 inch diskettes (single sided, single density, soft sectored only). The first disk is readable by Digital Research CP/M or Cromemco CDOS and contains 8080 source I keyed from the published listings of the FORTH INTEREST GROUP (FIG) plus a translated, enhanced version in ZILOG Z80 mnemonics. This disk also contains executable FORTH.COM files for Z80 & 8080 processors. -=-=-=-=- The 2nd disk contains FORTH readable screens including a extensive FULL-SCREEN EDITOR plus many items published in FORTH DIMENSIONS, including a FORTH TRACE utility, a model data base handler, an 8080 ASSEMBLER and formatted memory dump and 1/0 port dump words. The disks are packaged in a ring binder along with a complete listing of the FULL-SCREEN EDITOR and the FIG-FORTH INSTALLATION MANUAL (the language model of FIG-FORTH, a complete glossary, memory map, installation instructions and the FIG line editor listing and instructions). -=-=-=-=- This entire work is placed in the public domain in the manner and spirit of the work upon which it is based. Copies may be distributed when proper notices are included. -I-=-=-=- USA Foreign AIR +-+ I I Above described package ...... $50 $60 +-+ +-+ I I +-+ Printed Z80 Assembly listing w/ xref...... $15 $18 +- + (Zilog mnemonics) I I Printed 8080 Assembly listing ...... $15 $18 +-+ TOTAL $- __ -=-I-=-=- Price includes postage. No purchase orders without check. Arizona residents add sales tax. Make check or money order in US Funds on US bank, payable to: Dennis Wilson c/o Aristotelian Logicians 2631 East Pinchot Avenue Phoenix, AZ 85016 (602) 956-7678 - =- =- =- =-

FORTH Dimensions 23 Volume IV, No. 3 ~ FORTH Standards Corner

tic for 16 bit numbers, Thus there is exit address for the loop on the return a smooth transition between -1 and 0 stack to be used by LEAVE. Klaus Robert L. Smith and between 7FFF and 8000 hex Schleisiek improved that by having (32767 and -32768 decimal). LEAVE be an immediate word. By using There are a variety of ways to imple- the return stack at compile time to ment the new loop, some of which re- store the addresses of “fixup” loca- A new form of the DO-LOOP has been main to be discovered. There are two tions, it is possible to avoid run-time accepted for the next FORTH stan- parts to the problem. One is to find a penalties when LEAVE does not occur dard, tentatively called FORTH-83. method of calculating the exit condi- in the loop. Bill Ragsdale has sug- The new DO will generally work as you tions, and the other is to allow LEAVE gested a simple but clever way of would expect for indices which repre- to work properly. The fastest method avoiding use of the return stack (ex- sent either addresses or signed or un- of determining the exit conditions re- cept as a very temporary storage signed arithmetic values. The index I quires that the actual value of I be place), since Klaus’s method may not covers a complete 65K range, the same calculated by an addition or subtrac- be compatible with certain systems. as in FORTH-79 but twice as much as tion. The items stored on the return Bill’s technique links the forward in fig-FORTH or poly-FORTH. An ad- stack (or elsewhere) are related to the references in a simple chain and then ditional advantage occurs with + LOOP: limit and the index, but are not resolves the chain when the LOOP or the sign of the increment can change necessarily the same. For machines +LOOP is encountered at compile time. within the loop without necessarily with a testable overflow bit the sug- As a result of his work, Bill has also causing an exit condition. The speed gested technique is to modify the limit suggested an alternative form of LEAVE, of the new form is faster than most and initial index so that the transition called ?LEAVE, which appears to be previous loops unless I occurs fre- will lie between 7FFF and 8000 hex. more useful than LEAVE itself. ?LEAVE quently. A feature of the new loop is The overflow bit is set whenever an takes the top element from the para- that when LEAVE is executed, control addition causes the result to cross the meter stack and terminates the loop if is passed to the end of the loop without 7FFF to 8000 boundary. Initially put the element is non-zero (i.e., true). Fur- intervening calculations. limit’ <-- limit + 8000 ther details will probably be presented The price to be paid for the general I’ <-- init - limit’ at the next FORML meeting. form of the new loop is that certain To calculate I, note that One interesting possibility for “side-effects” of the old form are miss- I = I’ + limit’ augmenting the new DO is to add a ing. Consider the simple definition: At +LOOP, function called, say, ?DO. When the : TEST 0 DO I . LOOP ; I’ <-- I’ + increment arguments to ?DO are equal, as in the Under the old form, -5 TEST would Then check for overflow. If the case 0 0 ?DO, then the loop is not execute exactly once. In the new form, overflow bit is set, continue to loop, executed at all. If that appears suffi- the loop continues until the index I else exit from the loop. ciently useful, then that function could crosses the boundary between limit For machines without an overflow be incorporated in DO itself, so that an and limit-1, In the above case, -5 TEST bit, such as the 8080, let additional word would not be needed. would print out: limit’ <-- limit It would require a slight amount of 0 1 2 ... 32767 -32768 -32767 ... I’ <-- init - limit’ additional time at the beginning of -8 -7 -6 For LOOP, merely increment I’ by 1and each loop, and would eliminate one To print only one value would require branch back if the result is non-zero. (admittedly rarely used) case from DO. 1 TEST. For another example, consider For +LOOP, one has to examine the 0 the following function: combination of the carry bit and the : CLEAR DO 0 I C! LOOP ; sign bit of the increment. Klaus Suppose that our base is hexadecimal Schleisiek suggests the following: use and we wish to clear memory between the RAR instruction to shift the carry 2000 and EFFF. With the new form of bit into the accumulator, then use XRA I I/- LOOP, we could simply type: with the increment value. Only the FOOO 2000 CLEAR sign bit of the result is of interest. If and the indicated area would be the result is positive, continue to loop. cleared. The routine would only clear If the result is negative, terminate the one byte with the FORTH-79 or the fig- loop. FORTH version of LOOP. There have been various suggestions

The new loop considers that the for implementing LEAVE. Bob Berkey’s Reprinted from Starting FORTH, by Leo Brodie, permission index I lies on a “number circle” based original suggestion involves having of Prentice-Hall. Inc. on the usual 2’s complement arithme- the run-time operator for DO place the

FORTH Dimensions 24 Volume IV. No. 3 FORTH-79 Compatible LEAVE for FORTH-83 DO LOOPS

+LOOP can run much faster than their with the dynamic boundary-crossing two-step predecessors. For another, exit criterion of the new LOOP and Klaxon Suralis the same looping word will work for +LOOP. Sunnyvale, California signed OR unsigned parameters. It’s Here’s why: there is no way to zap compatible with all earlier LOOPS those loop parameters on the return ! simultaneously, except in certain rare, stack to guarantee an overflow for unsavory cases. every possible increment +LOOP might Editor’s note: This paper originally That quirk: the new LOOPS lack any throw at us. For plain LOOP, it’s easy; appeared in slightly different form on common-sense conception of “less but in the general case, it’s impossible. the Northern California FORTH tele- thanlgreater than.” If you, mistakenly Two currenlty proposed solutions conference tree, July 21-22, 1982. or not, reverse the start and limit both require a drastic change in values, or make them equal, the new LEAVE’S function: It must discard the The major controversy over the pro- loop will promenade the long way loop parameters and jump straight- posed FORTH-83 DO..LOOP is the around the 64K number circle. Oh, away to the end of the looping struc- implementation of LEAVE. Allow me an well, that may sometimes be useful. ture. It sounds rather nice; LEAVE attempt to explain the problem, and to The overflow status in most CPUs would actually leave, instead of fool- outline the solution I prefer. (8080s can fake it) offers an efficient, ing LOOP I + LOOP into wrapping things The old LOOP and +LOOP operate in ready-made mechanism for detecting up. How comfortable and easy to two separable steps: first, add the in- our boundary crossings - provided teach! As orthodox as Pascal and apple crement to the index; then, compare the boundary is always 32, 767.5. The pie. that new index value to the limit. trick, then, is to make DO translate its Never mind an historical disconti- Static and easily understood, but the limit and starting values from “true” nuity impeaching every FORTH pro- differing flavors of numeric compari- external form to an adjusted internal gram ever written; only a very few son (signed < , unsigned U < , circular form, positioning the loop limit over occurrences of LEAVE will actually - 0<) beget a multitude of variations: the 32K overflow threshold and add- require a change in coding. You’ll 32K circular +LOOP, unsigned- ing an equal offset to the index. This find them as you go along. Concen- incrementing /LOOP, unsigned- is done only once when the loop is trate instead on how LEAVE will know decrementing \LOOP, and that horror entered. where to jump. These are the two of horrors, the FORTH-79 signed LOOP Later, when we hit LOOP or +LOOP, approaches: and +LOOP. we add the increment to the internal In one, LEAVE is IMMEDIATE. It com- What’s wild is: the same form of index and look for an overflow. No piles (LEAVE) and leaves space for a LEAVE works for all of ’em. FORTH- comparisons are necessary, and LOOP branch address which is filled in by 79’s LEAVE works by equating the can use the “increment memory” in- LOOP or +LOOP, much the way WHILE loop’s limit parameter to the current struction found on most processors. compiles OBRANCH and allots a dis- index. Thus I continues (pardon the Fast, simple, and no exceptions. placement later resolved by REPEAT. Of grammar) to return its expected value Of course, J and I must undo the course, we’ll want to allow multiple while execution proceeds normally translation by subtracting the offset. LEAVE’S - or none at all - within a until a LOOP or +LOOP is encountered. Thus, we still carry two loop parame- given LOOP structure. So, LOOP and At that point, loop termination is ters on the return stack: the adjusted +LOOP must be coded to handle this, assured (in nearly all practical cases), internal index, which changes; and possibly sharing their backfilling whether the increment is positive or the translation offset, which remains routine with REPEAT and UNTIL. It’s negative. constant. complicated, and it costs you extra The new LOOP and +LOOP fuse the Although this looping technique was memory every time you code LEAVE - addition and the comparison steps presented just last November at but at least there’s no speed penalty at into one indivisible calculation. The Asilomar by Robert Berkey, accep- run-time. flag for golno-go arises as a natural by- tance has been swift. It has been incor- The other technique keeps LEAVE product of adding increment to index. porated into the FORTH-83 Draft non-IMMEDIATE, as required by If, during any one transition, the index Standard. FORTH-83 Working Draft ‘A.’ The crosses the invisible boundary be- Now, if it weren’t for LEAVE, the pro- requisite jump address is available as tween limit and limit-1 (in either direc- posed FORTH-83 DO..LOOP would be a third parameter on the return (loop) tion, then the loop terminates. Else, too-good-to-be-true. The old LEAVE stack - not in-line as above. It is the you branch back for another go-round. mechanism - efficient, utterly duty of DO - (DO) actually - to set up What’s the payoff for all this confu- FORTH-like, and devoid of compile- that pointer at the same time it com- sion? For one thing, the new LOOP and time trickery - simply cannot work putes the translation offset and inter-

FORTH Dimensions 25 Volume IV, No 3 nal index. How does (DO) know what standards, however, should avoid Let’s compare LEAVE-flag loops ver- forward jump address to push? A concentrating on any one person’s sus immediate LEAVE loops in more single in-line displacement, reserved implementation. The individual imple- detail: by DO and resolved by LOOP or +LOOP. mentor of a standard system must (DO) executes only once to initialize There’s a little more execution-time have the freedom to use the peculiar- the loop. The added overhead of overhead here than above, but only ities of hislher CPUlenvironment to pushing a LEAVE flag can be ignored. within (DO), which does its thing just best advantage. LEAVE is rarely used, almost never once at the loop’s beginning. Perhaps The LEAVE flag needs only one bit, more than once within a given loop. more significant is the second but may be padded to byte or cell If we complicate it, nobody will method’s appetite for return stack width. For reentrancy’s sake, it must notice. space: six bytes per nesting level. reside on the return (or loop) stack, or (LOOP) stands to suffer the most from Folks could argue for weeks over on some stack of its own. Since there testing an extra flag. However, if we which of these approaches is better; are no naturally disallowed combina- put some extra functions into LEAVE, it’s quite an entertaining web of tions of internal index and translation we can eliminate any need for (LOOP) tradeoffs. A Standard specifying an offset, the flag cannot be encoded into to inspect that flag. In addition to set- IMMEDIATE LEAVE could allow either the four bytes already assigned to loop ting the flag, LEAVE must set the inter- implementation to comply, imposing parameters. nal index to 32,767 (65,535 on 8080s), a mere few extra dictionary bytes Thus, compatibility with old LEAVE and adjust the translation offset so that ( : LEAVE COMPILE LEAVE ; IMMEDI- costs us another byte or two on the I remains correct. Do this, and (LOOP) IATE ) on implementors who prefer the return stack for each level of nesting can be coded exactly the same as in second way. (unless you use ROR, ROL, and TST immediate-LEAVE implementations. But this is still profoundly incompat- instructions to implement a dedicated 1 and J will run equally fast in both ible with the way LEAVE has worked in one-bit-wide LEAVE flag stack some- systems. A LEAVE flag, if present, is fig-FORTH, polyFORTH, FORTH-79, where). On the other hand, dictionary irrelevant except perhaps in determin- and others. So I’m fueling the debate space requirements are eased com- ing return stack offsets for J. by presenting a completely different pared to the jumping LEAVES described It is (+LOOP) which bears the main solution. earlier. User programs are smaller impact of the LEAVE flag, testing it Remember the reason for messing because no forward-branch displace- every time. Even here, however, the up LEAVE in the first place; there was ments are embedded in the code - net effect is practically nil. For exam- no setting of those two 16-bit loop and the system is smaller ’cause it ple, the overall degradation of the parameters which would deliver the doesn’t need complicated IMMEDIATE unusually tight loop “DO I DUP ! 2 “call it quits” message to LOOP and words to mark and resolve them. +LOOP” is less than 6%. (This calcula- +LOOP in all conceivable cases. If you count clock cycles, loops tion is for my 6809 DTC FORTH, but We’d have to split LEAVE into two using LEAVE flags run slower than other CPUs should fall in the same words: +LEAVE, which would work equivalent ones running with im- neighborhood.) when the increment was known > 0; mediate LEAVE. While I can’t deny that I want boundary-crossing loops. For and -LEAVE, which would handle all a microsecond saved is a microsecond my personal taste, the complexity and negative increments. In addition to be- earned, I’ll show the price of com- incompatibility of a direct, jumping ing even less compatible with existing patibility with old LEAVE to be minimal. LEAVE are intolerable. Although code than the immediate LEAVE, it Here’s the real issue: assume you’ve flagged LEAVE can never match the old makes life miserable for programmers got a DO LOOP (or loops) which runs too LEAVE for simplicity and speed, it is who enjoy switching increment signs slow. How often will converting that something I can live with. within their +LOOPS. Anyway, neither loop from a LEAVE-flag implementation The existing LEAVE usage can work +LEAVE nor -LEAVE would leave cor- to an immediate LEAVE version give with the new DO..LOOP. We don’t have rectly for 0 +LOOP. you the improvement you need? Next to adopt a direct-jumping LEAVE in These same disadvantages prevail if to never, I’d say. Using a faster CPU, order to reap the benefits of boundary- we ban the word LEAVE and replace it going to DTC, or putting NEXT in-line crossing loop termination. If the im- with some kind of CHANGE-LOOP- after each system CODE definition mediate LEAVE is to become standard, LIMIT word. Ugh. would return more on your invest- let it do so strictly on the basis of its MY PROPOSAL, in its general form, ment. Anyway, if your loop is so tight own merits. I sez it LEAVES much to is to keep an extra piece of informa- and critical that the time eaten by be desired. tion on the return (or loop) stack: a (LOOP) or (+LOOP) bothers you, it’s pro- But which LEAVE do you prefer? LEAVE flag. This flag would be initial- bably worth translating into native Make up your mind, ’cause there’s not ized by (DO), set by LEAVE, and tested machine code. enough room in the standard for both by (+LOOP) (From this point of view, the new compatible and jumping versions. There is one quite elegant way to do DO..LOOP is more valuable for its dual Hey: Does the PascallFORTRANl this, which I’ll present at FORML signedlunsigned capability than for its COBOLlAda crowd ever have argu- Asilomar this Fall. A discussion of questionable performance increase.) ments over this kind of stuff?

FORTH Dimensions 26 Volume IV. No. 3 INTRODUCING P-FORTH PUTTING P-FORTH TO WORK SOFTWARE

The PFORTH Card is the key users interactively develop An interactive high-level member in a family of control applications through a combi- language following the systems cards offered by the nation of hardware and software. fig-FORTH model innovators at Peopleware These applications are automatic- A monitor for system checkout Systems, Inc. P-FORTH has four ally programmed into non- major advantages: volatile memory (EEROM). When "FORTH-type" screen editor for developing application i the applications are proven and 1. It is a versatile building block. functioning, a single switch programs The simple addition of a transforms the system from the A "FORTH-type" assembler for power supp~yand terminal developmental mode into the writing assembly language makes the P-FORTH card both a target system. routines low cost development system as well as a target system. High-level interrupt-linkage High-level communications 2. An integrated high-level protocol for down loading from interactive language allows for a host system. fast software development. HARDWARE 3. ADDlication DroQrams are stored automatically in non- 6801 microprocessor volatile memory. pE~p~cwn~eJYJT~MJ INC. 6K EEROM 5190 west 76th st. 8K FORTH firmware 4. The STD BUS interface allows 2K RAM the use of a variety of existing Mpls., MN 55435 USA STD BUS interface peripheral cards. (612)831-0827 TWX 910-576-1735 RS232 serial I/O 16 TTL I/O lines Programmable timer

CROSS-COMPILE FORTH ON APPLE OR ATARP

The 6502 version of Nautilus Systems Cross-com- piler is now available on Apple and Atari. The 6502 target may also be generated on any other host we support. The Nautilus Cross-compiler has been used on every major 8 and 16 bit micro computer. APPLE or ATARI version $300.00 (plus $5.00 shipping & tax where applicable) 6502 target for existing users $100.00

IBM PC and CP/M 86 versions available from LABORATORY MICROSYSTEMS. 79.Standard versions are avail- able from MOUNTAIN VIEW PRESS.

Nautilus Systems P 0 BOX 1098 SANTA CRUZ, CA 95061 Apple is a trademark of Apple Computer. Inc Atan isalrademarkolAlarl Computer CPlM IS a lrademark of Digital Research IBM PC IS a trademark of IBM InC

FORTH Dimensions 27 Volume IV, No. 3 A Techniques Tutorial

Defining Words 111

Fig. 1 for it is simply: Regular Tree Structure : ROOT CREATE 0, (Siblings) Henry Laxen 0 (Children) Root , Thus we have specified the compile time behavior of the word ROOT. Now we want to take a look at the run time. This is the third and final chapter in behavior of the word defined by ROOT. my series on Defining Words. In the Suppose we said ROOT COLOR. What is first episode, we saw how to use defin- it we want COLOR to do if we said ing words to define a simple “Adven- COLOR RED? Well, we want COLOR to ture’’ like interaction. It illustrated CREATE the word RED and then to link how defining words are used in most it somehow into the child field of col- real world examples. In the second only way trees can be drawn. Let me or. Furthermore, we want to initialize episode we saw how to create a defin- point out some of its disadvantages. It RED to have no children of its own. ing word that can define other defin- seems that each parent may have an Before we do this, let’s take a look at ing words. Unfortunately, this was arbitrary number of children. Unless Fig. 3 which describes the action of only done for 2 levels. This time we you have some kind of slick dynamic LINK. It is given an address and it will take a look at the ultimate gener- storage allocation handy, this can be inserts a new link into a linked list ality, namely iterated defining words. a real pain. Furthermore, with this after that address. Convince yourself When you read and understand this kind of structure it is very difficult to that the code in Fig. 3 performs the example, you can consider yourself a answer a question like, Who is my sibl- task depicted. This is the same LINK black belt defining words champion. ing? (I don’t want to be sexist and say I must admit that I have never actually sister.) used a construct like this in a real Figure 2 shows the same tree, but Fig. 2 world application, however I think it with a different representation. In- Different Tree Structure is a very good exercise in mental gym- stead of each node having an arbitrary nastics and the effort put into under- number of points, namely to each of standing this will be repaid a hundred its children, we make each node con- tain exactly two pointers. One to its i””’ When you read and under- next sibling, and one to its first child. stand this example, you can Note that as in Fig. 1, the leftmost consider yourself a black belt child of the root has 2 children of its defining words champion. own, and the rightmost child of the root has 4 children. This structure also times over in the many simpler exam- has some disadvantages. We can no ples that you will encounter in your Ionger answer the question: Who is the Note the trees in Fig. 1 and Fig. 2 are FORTH career. nth son of a node, as quickly as we equivalent. The problem I pose is the following, could with the structure in Fig. 1, for implement a Tree structure with defin- now we must search through a linked ing words such that each node in the list to find the answer. However now word we used in Defining Words I1 - tree is a word and when it is executed we no longer need a dynamic storage the CLASS example. Now then, armed it defines its children. The original allocator, and we can quickly find the with LINK, let’s continue our definition defining word will define the root of next sibling of a particular node. Life of ROOT by specifying the run time the tree. You will have to reread that is full of tradeoffs. We will use the behavior of its member word, namely 3 times at least. Before we descend to representation described in Fig. 2 for COLOR. FORTH code, let’s look at some pic- our solution. : ROOT tures. In Fig. 1 we see what we ordi- Now let’s try to figure out in English CREATE 0 , (Siblings) narily think of as a tree (inorganic). We what this beast is supposed to do. 0 , (Children) have a root with 3 children. The left- Starting at the top, the thing that DOES > most child has 2 children of its own, defines the root should set up the root CREATE (name of child) while the rightmost child of the root word so that it has no siblings and no 2+ LINK has 4 children. This is the kind of tree children. Put another way, we want to (into Children field of Parent) picture you see in many textbooks, create a defining word, called ROOT, 0, including Knuth, etc. However do not which initializes 2 pointers to empty. (Initialize my own Children field) be lulled into thinking that this is the That much is trivial. The FORTH code

FORTH Dimensions 28 Volume IV, No. 3 Fig. 3 Let’s take a close look at this. After ROOT COLOR, we have defined the word : LINK ( addr -- ) COLOR and set the contents of its PFA HERE OVER GZI , SWAP I ; and PFA + 2 to 0. The contents of the Action of LINK PFA points to the next sibling, and the Address A1 contents of the PFA + 2 point to the first child. Now when COLOR RED is Contents A2 executed, the first thing that happens A2 LINK is that DOES > supplies us the address Address A1 /A2 -HERE of the PFA of COLOR on the parameter Contents A2 HERE A3 stack. That’s what DOES> does, - remember? Next we execute the word CREATE, which will scan the input stream and make a dictionary entry Fig. 4 for the word RED. We still have the Scr 0 27 PFA of COLOR on the stack. The 2+ 0 \ Def~niiiqword for Trees ~SJULBZHHL increments it so that now it is pointing 1 : LINK (S addr -- ) at the Children field in COLOR, i.e., 2 HERE OVER 0 , SWAP ; 3 : ROOT PFA i2. We link our own PFA into 4 CREATE 0 , ( Siblings ) 0 , ( Children ) this field. Why is it our PFA that we 5 BEGIN are linking? Well, CREATE makes a dic- 6 DOES, CREATE 2+ LINK ( Siblings ) 0 , ( ChiIdre,, ) 7 AGAJN ; tionary entry for us, up to and includ- 8 ing the code field, but it did not do 9 10 anything to the parameter field. Thus 11 when LINK is executing, the PFA of 12 13 RED equals HERE, which is what LINK 14 will link into the list. Thus after the 2+ 15 LINK executes, the child field of COLOR will have a pointer to the PFA of RED, Fig. 5 and the sibling field of RED will have Scr I) ’.% the former contents of the child field 0 Display Tree in INORDER Sequence ZSJULBZHHL of color, namely 0. 1 : MYSELF (S -- Next, we execute the 0, which 2 LATEST PFA CFa . ; IMMEDIATE 3 VARIABLE INDENT simply initializes the child field of RED 4 .NAME (S PFA -- ) to null. Now let’s take a look at what 5 CR INDENT 3 SPACES NFA ID. ; 6 : INORDEH (S PFA -- ) happens if we said COLOR WHITE. Pretty 7 BEGIN 0 DUP WHILE DUP .N&ME much the same thing actually, except 8 3 INDENT +’ DUP 2+ MYSELF -3 INDENT +! some of the pointers have changed. 9 REPEAT DROP ; 10 : .TREE (S -- ) CREATE would make a dictionary entry 11 CR 0 INDENT I ’ DUP .NAME CR 2+ INORDER $ for WHITE, and the 2+ LINK code would 12 13 insert WHITE into the child field of 14 COLOR. But now, the child field of is COLOR contains a pointer to the sibling Fig. 8 field of RED, after all that is what RED put there. Thus COLOR will point to the Scr X 29 sibling field (PFA) of WHITE, which will 0 \ Sample Tree definition 25JUL82HHL point to the sibling field (PFA) of RED 1 ROOT POET 2 POET KEATS POET SHELLEY POET BYRON POET MILTON which points to 0. We have succeeded 3 KEATS ENDYMION KEATS NIOHTINaALE KEATS HYPERION in making RED and WHITE children of 4 SHELLEY ALfiSTOR SHELLEY ADONAIS SHELLEY PROMETHEUS 5 BYRON CHILDE-HAROLD BYRON MANFRED BYRON DON-JUM COLOR and siblings of each other. 6 MILTON PARADISE-LOST MILTON LYCIDAS MILTON ALLEGRO Notice that the entries in the tree are 7 ENDYMION GOOD NIGHTINGALE GREAT HYPERION OKAY in reverse order from how they are 8 ALASTOR GOOD ClDONAIS GREAT PROMETHEUS GOOD 9 CHILDE-HAROLD OKAY MANFRED GOOD DON-JUAN GREAT defined. Tough. 1(3 FARADISE-LOST OUTSTANDING LYCIDAS OUTSTANDING ALLEGRO GREAT Pretty slick so far eh? There is only 11 ( Everyone’s a critic ) 12 one problem, and that is that it only 13 works for one level. We can use COLOR 14 to define a bunch of colors, such as 15 OK:

FORTH Dimensions 29 Volume IV, No. 3 RED WHITE and BLUE, but the buck stops Fig. 7 completely arbitrary TREE. there. When RED executes, nothing POET In Fig. 5 we have some code that will much will happen. (Exercise: What print out the tree in indented form. exactly would happen if we executed MILTON Fig. 6 contains a sample Tree defini- RED with the above definition?) ALLE G R 0 tion, and finally Fig. 7 shows the result Well, let’s see what we want RED to GREAT of printing out the Tree defined in Fig. LYCIDAS do when executed. Suppose we said OUTSTANDING 6 with the code in Fig. 5. I will not RED ROSE. We would like to add ROSE PARADISE-LOST explain how and why the code in Fig. to the dictionary and link it into the OUTSTANDING 5 works, since in the next issue I will child field of RED. Isn’t that exactly BYRON talk about Recursion in FORTH, and what we wanted COLOR to do? Of DON- JUAN it is a pre-requisite for understanding course it is, so what we would really GREAT how INORDER works. like is to have all subsequent words MANFRED One final note. The code presented GOOD will work with either FORTH-79 behave exactly the same. What we CHILDE-HAROLD want is a (perish the thought) GOT0 OKAY systems or systems compatible with before the ; to go back to just before SHELLEY Starting FORTH. It will not work as the DOES > . Well for all you structured PROMETHEUS written with fig-FORTH. Feel free to programming fans who thought that GOOD enter it and try it out. Dumping the FORTH doesn’t have a GOT0 take a ADONA I S dictionary at various points and chas- look at the screen in Fig 4. It doesn’t GREAT ing down the pointers by hand will be have one, but it does. There isn’t really ALASTOH very illuminating. Best of luck until GOOD any looping going on here, I am EEATS next time, and until then, may the simply using the AGAIN to jump to the HYPER I ON FORTH be with you. 0 BEGIN before the DOES > . Now all of the OKAY many descendants of the word NIGHTINGALE originally defined by ROOT will behave GREAT Henry Laxen is a independant FORTH exactly the same, and we can build a ENDYM I ON consultant. GOOD

OK

1 proFORTH COMPILER 8080/8085,280 VERSIONS SUPPORTS DEVELOPMENT FOR DEDICATED APPLICATIONS INTERACTIVELY TEST HEADERLESS CODE IN-PLACE COMPILATION OF ROMABLE TARGET CODE MULTIPLE, PURGABLE DICTIONARIES FORTH-79 SUPERSET AVAILABLE NOW FOR TEKTRONIX DEVELOPMENT SYSTEMS - $2250

2 MICROPROCESSOR-BASED PRODUCT DESIGN SOFTWARE ENGINEERING DESIGN STUDIES - COST ANALYSIS ELECTRONICS AND PRINTED CIRCUIT DESIGN PROTOTYPE FABRICATION AND TEST REAL-TIME ASSEMBLY LANGUAGE/proFORTH MULTITASKING DIVERSIFIED STAFF

- FORTH Dimensions 30 Volume IV, No. 3 lechnotes

INPUT COMMANDS AS compiled before (.”). At run time (COM- similar word, rather than wasting two TEXT LITERALS LIT) jumps over (.”) diverts the input- bytes in each definition. The name COM- H.E.R. Wijnands stream to the string, interprets its con- LIT strikes me as inadequately meliflu- Rijswijk, Holland tents and finally restores the input- ous. Perhaps something like COMPILE” Here is a technique for literal com- I stream vector. would be better. DIRECT is very similar pilation to defer commands in the Purists who dislike the uselessness to Bill Ragsdale’s word ::, except that input-stream. Suppose we made a of (.”) in the object, can employ the DIRECT compiles the temporary code in definition that operates on a string in routine part on screen 1 which stores TIB, while :: compiles it at HERE. the input stream. For instance, a file the string. Care should be taken -Michael Perry system command FLlST which should because some FORTH implementa- be followed by a file name. The com- tions increment the return stack EXPONENTIATION mand FLIST gets the string, stores it in before returning, some after returning George Lyons a buffer and searches in the file direc- from subroutine. jersey City, New Jersey tory for a match, etc. The command COMLIT is perhaps the counterpart of Below (Figure 2) is a possible defini- FLlST is compilable but it always ex- DIRECT. DIRECT directly executes the tion for interger exponentiation, using pects its operand in the input-stream string following it, as if it were a repeated squaring of the argument, to on execution. Sometimes this is un- definition. This allows direct use of reduce the number of multiplications. wanted and we wish to execute on a non-direct words like the control operand inserted during compilation. structures IF, DO, etc. This does indeed run faster than its sim- Example: : HELP FLlST Helpfilename ; Example: pler DO . . . LOOP equivalent. Although Execution of HELP is meant to give a DIRECT 20 10 DO I LIST LOOP ; the 16-bit result will overflow for all but listing of a helpfile. The idea of DIRECT is not mine, but the the smallest exponents, single-length The new word COMLIT which I source on below 102 is. math lets the heart of the technique derived from compile literal does the show through. Thus its extension to trick. COMLIT compiles the sequence of This looks useful. I would suggest look- higher precision or floating point is characters as literals until it encoun- ing at how .” is defined and creating a readily apparent. --Klaxon Suralis ters the quotation mark. At run time it executes this sequence. The problem above is solved as: Figure 1 : HELP COMLIT FLlST Helpfilename” ; 0 ( COMPLETE SOURCE OF DIRECT FIND COPKIT ) Another example of delayed execution 1 (notice its order): 2 FORTH DEFINITIONS HEX : TEST .” testing ” 4 : (COMLIT) R> IN a >R >R R 3 + TIE a - I” >R IN ! 5 INTERPRET IN a R> - 5 + R> + R> IN ! >R i COMLIT TEST1 TESTZ” CR ; 6 : TEST1 .” one ” ; 7 : COMLIT 8 ?COMP COMPILE (COMLLIT) ‘ _‘I CFA EXECUTE 0 , ; IMMEDIATE : TEST2 .” and two” ; 9 Although TEST1 and TEST2 are not yet 10 : DIRECT ?EXEC DP a TIE a 40 + DP ! !C9p 3 INTERPRET 11 TIB a 40 + >R DP ! SMUDGE : in the vocabulary, TEST will be com- 12 piled. Executing TEST after compila- 13 14 tion of TEST1 and TEST2 gives: 15 ;s TEST testing one and two. Figure 2 OK 0 : tl ( x n -- x-to-the-n ) (Source of COMLIT is shown in Figure 1 >R 1 SWAP ( square repeatedly ) 1.) 2 BEGIN ( cumulatr ve prod.,lart factor 1 3 R 1 AND ( I. th bit of n ) To leave arguments on the stack for 4 IF ( apply and preserve factor ) further processing after the delayed 5 SWAP OVER t SWCIP THEN 6 R> 2/ ( next bit of n 1 -DUP execution, only the return stack is 7 WHILE >R DUP t ( new factor ) used by COMLIT. 8 REPEAT DROP ; 9 Operation of COMLIT is quite simple. 10 ( 2/ must be machine code shift ) During compilation it uses .” to store 11 ( extendable to higher precision 12 and floating point x’s ) the string in the parameter (.”) which 13 normally prints the string at run time. 14 This is not our aim since we want to 15 execute it. For this reason (COMLIT) is

Volume IV, No. 3 FORTH Dimensions 31 NEW PRODUCT ANNOUNCEMENTS COURSE REVIEW ATAFORTH Inner Access The FORTH computer language designed Corporation THE for the Atari home computers. ATAFORTH Advanced FORTH was written by Dan Bloomquist. FORTH The source text for the system is in- Systems Class cluded. Everything from the compiler core 6 /’I496 /I8 / 82 CAVALRY” up can be stripped off and be recompiled in less than one minute. This will allow you Reviewed by John Clark to modify or dedicate the system a+ will. San Jose, California Then the new system can be saved as the boot system. This is a great class! It will be very There is a files utility that allows you to easy to recommend this class to any- “take” sectors from the Atari Disk File one requiring a detailed knowledge of Manager, which then sees them as if in use. personalFORTH You can then read and write data directly the internals of FORTH or of the sev- for the IBM PC to these sectors. The directory is bypassed. ral uses of FORTH covered in this by FORTH Inc. The utility draws a sector map in graphics, class. The small class size was great. using different colors to show the status of Leo Brodie is very easy to talk with Mu1ti-tasking ,full screen each sector. and was always able to understand editor, floating point Our user’s manual is tutorial with numer- what we were having trouble with. He ous examples and is designed for the begin- support, DOS file handler, ner. All the standard FORTH words have also was able to jump right in and dig color monitor support, been used so there is no relearning. You out how FIG FORTH worked when turnkey compiler. work your way from adding numbers on we found out that FIG didn’t work like the screen to maintaining a mailing list and the system he was experienced with. $300 producing graphics. His use of the computer to illustrate Minimum system configuration: Atari 800/400 with 16K and disk. the operations going on inside of $75.00 for disk and manual. (California FORTH while words were being com- residents add sales tax.) If interested in a piled was very easy to follow and MULTI-TASK1 NG cassette version, contact Dan Bloomquist. made it much easier to understand Nova Technology P.O. Box 688 FORTH. FORTH Clearlake, CA 95422 8’ CPM@, Northstar & (707) 994-4649 994-1332 If there were more time, I’d like to see more on style, compiler security, Micropolis multitasking, and performance moni- A-FORTH by Shaw Labs, SEATTLE COMPUTER Ltd can make your micro PRODUCTS 8086 fig-FORTH oring tools. But if this course had operate like a mainframe. 8086 fig-FORTH modified to interface everything I wanted, it would take You can be printing, FORTH to SCP’s 86-DOS and also com- more than a week. patible with Microsoft MS-DOS and IBM sorting, and inter-actively PC-DOS, is available to anyone inter- inputing data all at the John Clark works for an international same time. Hardware ested in learning more about FORTH. computer firm with offices in San Jose, This version of FORTH is useable (I am permitting, you can even currently developing some applications California. have mu1ti-users operating. using it), but is not as complete nor as well-documented as a commercial product. $395 Additional changes to the source align definitions so that word pointers can Laxen & Harris, Inc. always be accessed in one bus cycle, add Terminate Operations code level array and string primitives, FORTH and support fetch and store operations Effective immediately, Laxen & Har- outside the memory segment occupied ris, Inc. is ceasing operations and no TUTORIAL SYSTEM bv FORTH. 9- more classes or services will be offered by Laxen 81 Harris, Inc. Typical execution times on the IBM directly by Laxen & Harris, Inc. Our Two 8’ CPlM disks with personal computer are comparable to 6 instructional disk set (working documentation and a copy MHz 2-80 benchmarks which have been of Starting FORTH by published. On the SCP system at 8 MHz, FORTH and Learning FORTH) will execution times are one-half to one- continue to be available under license Brodie. An inexpensive way quarter the Z-80 times. The Sieve of through Mountain View Press, P.O. to start learning and Eratosthenes benchmark (see FD 3:181) Box 4656, Mt. View, CA 94040; (415) programming in FORTH. runs in just under 34 seconds. Includes the assembly source, the 961-4103. $95 assembled system, and some FORTH Both Henry Laxen and Kim Harris screens (including the FIG editor and the will remain active in the FORTH com- Starting FORTH editor) on disks for any munity and will be offering consulting of the above systems or in CPM format, MOUNTAIN VIEW PRESS, INC. services. If you would like to contact P.O. Box 4656 for $35. them individually you will find them Joe Smith Mountain View, Calif. 94040 Univ. of PennJDept. of Chemistry listed under Consultants in the (415) 961 -41 03 34th 81 Spruce Streets Vendor’s List of FORTH Dimensions Philadelphia, PA 19104 magazine. (215) 243-4797

FORTH Dimensions 32 Volume IV. No. 3 THE FOURTH SOURCE'"

MVP-FORTH - A Public Domain Product MVP-FORTH contains a kernal for transportability, the FORTH-79 NEW FORTH PRODUCTS Standard Required Word Set, the vocabulary for the instruction book. 0 Personal FORTH for the IBM-PC by FORTH Inc. STARTING FORTH, by Brodie. editor, assembler, many useful routines, Multitasking, full screen editor, floating point support, DOS and utilities. file handler, color monitor support, turnkey compiler. $300 0 MULTI-TASKING FORTH CPIM. Northstar & Micropolis. MVP-FORTH PRODUCTS for CP/M@ IBM-PC@ and Applem A-FORTH by Shaw Labs, Ltd. can operate your micro like 0 MVP-FORTH Programmer's Kit including disk with a mainframe. Print, sort, and inter-activly input, all at the documentation, ALL ABOUT FORTH, and STARTING same time $395 FORTH. Assembly source listing versions. $1 00 0 FORTH TUTORIAL by Laxen & Harris. Two 8'CPlM disks 0 MVP-FORTH Disk with documentation. Assembly source with documentation and a copy of "Starting FORTH' by listing version. $75 Brodie. The easy way to learn FORTH. $95 0 MVP-FORTH Cross Compiler with MVP-FORTH source in 0 "And so FORTH" by Huang. An indepth how-to book FORTH. $300 about FORTH with a 280 implementation. Follows the fig- 0 MVP-FORTH Programming Aids for decompiling, FORTH model. $25 callfinding, and translating. $1 50 0 MVP-FORTH Assembly Source Printed listing. $20 0 ALL ABOUT FORTH bv Haydon. $20 *MVP-FORTH operates under a variety of CPU's, computers, and operating systems. Specify your computer and MORE FORTH DISKS operating system. * * * FORTH MANUALS, GUIDES & OOCUMENTS FORTH with editor, assembler, and manual. *Source provided. FORTH Encyclopedia by Specify disk size! 0 0 Starting FORTH by Brcdie. Derick & Baker. A complete Best instructional manual APPLE 11/11 by 0 + 0 PET@ by FSS $90 programmer's manual to fig- available. (soft cover) "1 6 MicroMorlon $1 00 0 TRS-8OII" by Nautilus FORTH with FORTH-79 0 Starting FORTH (hard APPLE II by Kuntze. $90 references. Flow charted, 0 Systems- $90 cover) $20 0 ATARP by PNS $90 0 6800 by Talbot 2nd Ed. $25 1980 FORML Proc. $25 0 METAFORTH by Cassady. 0 CP/W by $1 00 Microsystems $1 00 Cross compiler with 8080 MicroMotion 0 6809 by Talbot 0 I981 FORML Proc. code $30 0 CROMEMCOm by Inner Microsystems $1 00 2 Vol. $40 0 Systems Guide to flg- Access $1 00 0 280 by Laboratory 0 1981 Rochester Univ. FORTH $25 0 HP-85 by Lange. $90 Microsystems $50 Proc. $25 0 Caltech FORTH Manual$l2 0 lBM-PC@' by Laboratory 0 6088188 by Laboratory 0 Using FORTH $25 Invitation to FORTH $20 Microsystems $1 00 Microsystems $1 00 A FORTH Primer $25 0 p~p-11FORTH User's 0 Threaded Interpretive Manual $20 Enhanced FORTH with: F-Floating Point, G-Graphics, T-Tutorial, Languages $20 0 CPlM User's Manual, S-Stand Alone, M-Math Chip Support, X-Other Extras, 79-FORTH-79. 0 AIM FORTH User's MicroMotion $20 Specify Disk Size! Manual $12 0 FORTH-79 Standard $15 0 APPLE 11/11 + MicroMotion, 0 TRS-8011 or Ill by Miller 0 APPLE User's Manual $20 0 FORTH-79 Standard F. & 79 $1 40 Microcomputer Services, MicroMotion G. Conversion $1 0 CP/M by MicroMotion. F, X, & 79 $1 30 0 0 TRS-80 User's Manual, $19 0 Tiny Pascal in MMSFORTH F & 79 $1 40 0 6600 by Talbot Micro- fig-FORTH $1 0 0 H89R89 by Haydon. systems, T & X $250 T&S $250 0 280 by Laboratory Micro- 0 Installation Manual for fIg-FORTH, contains FORTH 0 H89lZ89 by Haydon. T $1 75 systems, F & M Each $1 00 model, glossary, memory map and instructions $1 5 0 8086188 by Laboratory Source Listings of fig-FORTH, for specific CPU's and computers. The InstallationManual is required for implementation. Each $1 5 0 PET by FSS, F & X $150 Microsystems' F&M Each $1 00 0 1802 0 6502 0 6800 0 AlphaMicro 0 8080 0 8086188 0 9900 0 APPLE II CROSS COMPILERS Allow extending, modifying and compiling for 0 PACE 0 6809 0 NOVA 0 PDP-111LSI-11 speed and memory savings, can also produce ROMable code. *Requires FORTH disk. 0 CPlM $200 0 IBM- $300 0 H89lZ89 $200 0 8086- $300 I 0 TRS-8011 $200 0 280. $300 Northstar" $200 0 6809 $350 Ordering Information: Check, Money Order (payable to MOUNTAIN VIEW PRESS, 0 INC.), VISA, Mastercard or COD'S accepted. No billing or unpaid PO'S. California 0 flg-FORTH Programming Aids for decompiling, callfinding, residents add sales tax. Shipping costs in US included in price. Foreign orders, pay and translating. $1 50 in US funds on US bank, include for handling and shipping by Air: $5 for each item under $25, $10 for each item between $25 and $99 and $20 for each item over flg-FORTH Model and Source, with printed Installation Manual and $1 00. Minimum order $1 0. All prices and products subject to change or withdrawal Source Listing. without notice. Single System andlor single user license agreement required on some products. 0 APPLE Ila .5'k 0 8O8O/Z80@JI8 DEALER & AUTHOR INQUIRIES INVITED 0 8086188. 8 0 H891289. 5% Each $65

MOUNTAIN VIEW PRESS, INC. PO BOX 4656 MOUNTAIN VIEW, CA 94040 (415) 961-41 03

FORTH Dimensions 33 Volume IV, No 4 a II

Start Your Own FIG Chapter FIG Whet is a FIG Chapter Chapter There are two kinds of FIG chapters: which can help you make professional local, and special-interest. Local contacts in the areas of your particular News chapters are centered in a city or interests. Potomac Chapter region. special-interest chapters may (C) FIG will occasionally supply At the August 3rd meeting, Joel be non-geographical; they focus on an material, such as meeting handouts or Shprentz described a keyboard and interest area such as an application tapes, which can serve as a discussion display controller written in FORTH. (e.g., robotics, telecommunication), or topic at local meetings. Multifield commands are entered on on FORTH for a particular computer. (D) FIG will supply its publications a thirteen-key keyboard (10 numeric All chapters must provide a contact at bulk rates; local chapters can sell and 3 control keys). As each field is point, and some form of regular them to raise money, and to provide entered it is displayed on a 4-digit LED public access (usually meetings). Non- immedite local access to the material. display. geographical chapters will normally (E) Chapters can apply to FIG for The 24 possible commands require provide other forms of access, such as one-time funding for activities. different combinations of fields. Most a newsletter or telecommunications, How to Start a FIG Chapter languages would force the program- instead of meetings. To be recognized as a chapter, a group mer to write either voluminous code Why Have a FIG Chapter? must have (1) a contact person, (2) or an elaborate table driven system. A chapter lets you share information regular public access (usually by With FORTH the code is simple and with other FORTH users in your meetings which are open to the direct; words controlling individual geographical or application area. In public), and (3) at least five members field input are combined in various addition, FIG provides several specific of FIG. If you don't know five ways to define higher level words benefits: members in your area, FIG can help which control groups of fields and (A) FIG will list your chapter in you contact them. If you want to start entire commands. FORTH Dimensions, so that others can a chapter, send a request for a FIG find your group. Chapter Kit to the Chapter coor- Other Chapters? (B) FORTH Dimensions will give dinator, FORTH Interest Group, P.O. priority to publishing chapter news, Box 1105, San Carlos, CA 94070. Let's hear from you!

List of FORTH System Vendors (e.g., A1 signifies AB Computers, etc.)

Processors Atari ...... M6, P2, Q1 1802 ...... C1, C2, F3, F6, L3 Cromemco ...... A5, M6 6502 (AIM, KIM, SYM). R1, R2, s1 DEC PDPILSI-11...... C2, F3, K1, L2, S3 6800 ...... F3, F5, K1, L3, M6, T1 Heath-89 ...... M6 6809 ...... F3, F5, L3, M6, T1 Hewlett-Packard 85 ...... 68000 ...... C4, El IBM PC ...... C2, F3, L1, M5, M6 8080185 ...... A5, C1, C2, F4, 15, L1, L3, M3, IBM Other ...... L3 M6, R1 Micropolis ...... A2, M2, S2 280189 ...... A3, A5, C2, F4, 13, K1, L1, M2, North Star ...... 15, M2, PI, S7 M3, M5, N1 Ohio Scientific ...... A6, B1, C3, 01, s6, T2 28000 ...... I3 Osborne ...... 8086188 ...... F2, F3, L1, L3, M6 Pet SWTPC ...... Al, A6, B1, C3, 01, S6, TZ, T5 9900 ...... E2, L3 TRS-80 I, 11, I11 ...... 15, M5, M6, S4, S5 TRS-80 Color ...... A3, F5, M4, T1

Operating Systems CPIM ...... A3, C2, F3, 13, L3, Ml, M2, M6 Other Products/Services Boards, Machine ...... F3, M3, R2 Computers Consultation ...... C2, C4, N1 Alpha Micro P3, S3 Cross Compilers ...... C2, F3, 13, M6, N1 ...... Products, Various CZ, F3, 15, S8 Apple A4, F4, 12, 14, Jl,L4, M2, M6, 02, ...... Training ...... F3, I3 03

Volume IV, No. 3 FORTH Dimensions 34 FORTH Vendors The following vendors offer FORTH systems, applications, or consultation. FIG makes no judgement on any product, and takes no respon- sibility for the accuracy of this list. We encourage readers to keep us informed on availability of the products and services listed. Vendors may send additions and corrections to the Editor. and must include a copy of sales literature or advertising.

FORTH Systems I 3. On-Going Ideas Boards 6 Machines Only see System Vendor Chart for others A 1. IDPC Company RD #1,Box 810 1. AB Com uters P.O. Box 11594 Starksboro, VT 05487 Controlex Corp. 252 Bethrehem Pike Philadelphia, PA 19116 602/453-4442 16005 Sherman Way Colmar, PA 18915 215/676-3235 P Van Nuys, CA 91406 2131780-8877 2151822-7727 2. IUS (Cap’n Software) 1. Perkel Software Systems 2. Acropolis 261 Arlington Avenue 1636 N. Sherman Datricon 17453 Via Valencia Berkeley, CA 94704 Springfield,.- MO 65803 7911 NE 33rd Drive, #ZOO San Lorenzo, CA 94580 415/525-9452 Portland, OR 97211 2. Pink Noise Studios 503/284-8277 415/276-6050 3. Inner Access P.O. Box 785 3. Advanced Technology Corp. 517K Marine View Crockett. CA 94525 Golden River Corp. P.O. Box 726 Belmont, CA 94002 415/787-1534 7315 Reddfield Court Falls Church, CA 22043 Clinton, TN 37716 4151591-8295 3. Professional Management- 4. Applied Anal tics Inc 4. Insoft Services Peopleware Systems Inc. 8910 Brookridrge Drive, #300 10175 S.W. Barbur Blvd., #202B 724 Arastradero Road, #lo9 5190 West 76th Street Upper Marlboro. MD 20870 Portland. OR 97219 Palo Alto. CA 94306 Minneapolis, MN 55435 5. Aristotelian Logicians 5031244-4181 4081252-2218 612/831-0872 2631 East Pinchot Avenue 5. Interactive Computer Q Zendex Corp. Phoenix, AZ 85016 Systems, Inc. 6398 Dougherty Road 1. Quality Software Dublin. CA 94566 6. Aurora Software Associates 6403 Di Marco Road 6660 Reseda Boulevard, #lo5 P.O. Box 99553 Tampa, FL 33614 Reseda, CA 91335 Cleveland, OH 44199 J R Application Packages Only e 1. JPS Microsystems, Inc. 1. Rehnke, Eric C. see System Vendor Chart for others 1. Blue Sky Products 361 Steelcase Road, West, Unit 1 540 S. Ranch View Circle, #61 Markham, Ontario, R.E. Curry & Associates 729 E. Willow Anaheim Hills, CA 92087 P.O. Box 11428 Signal Hill, CA 90806 Canada L3R 3V8 416/475-2383 2. Rockwell International Palo Alto, CA 94306 C Microelectronics Devices L Decision Resources Corp. 1. CMOSOFT P.O. Box 3669 28203 Ridgefern Court P.O. Box 44037 1. Laborator Microsystems Anaheim, CA 92803 Rancho Palo Verde, CA 90274 Sylmar, CA 91342 4147 Beetgoven Street 714/632-2862 213/377-3533 Los Angeles, CA 90066 5 2. COMSOL, Ltd. 213/306-7412 InnoS s Treway House 1. Saturn Software, Ltd. 2150 $hattuck Avenue Hanworth Lane 2. Laboratorv Software P.O. Box 397 Berkeley, CA 94704 Chertse , Surrey KT16 9LA Systems, inc. New Westminister. BC 4151843-8114 Englandl 3634 Mandeville Canyon Road V3L 4Y7 Canada Los Andes. CA 90049 3. Consumer Computers 213/472%995 2. Shaw Labs, Ltd. Consultation 6 Training Only 8907 La Mesa Boulevard P.O. Box 3471 see System Vendor Chart for others La Mesa, CA 92041 3. Lynx Hayward, CA 94540 714/698-8088 3301 Ocean Park, #301 415/276-6050 Boulton, Dave Santa Monica, CA 90405 581 Oakridge Drive 4. Creative Solutions, Inc 2131450-2466 3. Sierra Computer Co. Redwood City, CA 94062 4801 Randolph Road 617 Mark NE Rockville, MD 20852 4. Lyons, George Albuquerque, NM 87123 Brodie, Leo 280 Henderson Street 9720 Baden Avenue D Jersey City, NJ 07302 4. Sirius S stems Chatsworth, CA 91311 1. Datentec Kukulies 201/451-2905 7528 Oai Ridge Highway 213/998-8302 Heinrichsallee 35 Knoxville, TN 37921 M 61516934583 Girton, George Aachen, 5100 1753 Franklin West Germany 1. M & B Design 5. Software Farm, The 820 Sweetbay Drive Santa Monica, CA 90404 P.O. Box 2304 213/829-1074 E Sunnyvale, CA 94086 Reston, VA 22090 1. Emperical Research Group 2. MicroMotion Go FORTH P.O. Box 1176 6. Software Federation 504 Lakemead Way 12077 Wilshire Boulevard, #506 44 University Drive Milton. WA 98354 Los Angeles, CA 90025 Redwood City, CA 94062 206/631-4855 Arlington Heights, IL 60004 415/366-6124 213/821-4340 312/259-1355 2. Engineering Logic Harris, Kim R. 3. Microsystems, Inc. 7. Software Works, The 1252 13th Avenue 2500 E. Foothill Boulevard, #lo2 Forthright Enterprises 1032 Elwell Court, #210 P.O. Box 50911 Sacramento, CA 95822 Pasadena. CA 91107 Palo Alto, CA 94303 213/577-1417 Palo Alto, CA 94303 F 415/960-1800 4151858-0933 1. Fantasia Systems, Inc. 4. Micro Works. The 8. Supersoft Associates P.O. Box 1110 Laxen, Henry H. 1059 Alameda De Las Pulgas P.O. Box 1628 1259 Cornell Avenue Belmont, CA 94002 Del Mar, CA 92014 Champaign, IL 61820 714/942-2400 Berkeley, CA 94706 415/593-5700 2 17/359-2 112 415/525-8582 2. Fillmore Systems 5. Miller Microcomputer Services T 5227 Highland Road 61 Lake Shore Road Petri, Martin B. Minnetonka, MN 55343 Natick, MA 01760 1. Talbot Microsystems 15508 Lull Street 617/653-6136 1927 Curtis Avenue Van Nuys, CA 91406 3. FORTH, Inc. Redondo Beach, CA 90278 213/908-0160 6. Mountain View Press 2309 Pacific Coast Highway Redding Co. Hermosa Beach. CA 90254 P.O. Box 4656 2. Technical Products Co. 213/372-8493 Mountain View, CA 94040 P.O. Box 12983 P.O. Box 498 4151961-4103 Gainsville, FL 32604 Georgetown, CT 06829 4. FORTHWare 904/372-8439 203/938-9381 639 Crossridge Terrace N Orinda, CA 94563 3. Timin Engineering Co. Dr. Walter Schrenk 1. Nautilus Svstems 6044 Erlanger Street Postfach 904 5. Frank Hogg Laboratory, Inc. P.O. Box lb98 San Diego, CA 92122 7500 Krlsruhe-41 130 Midtown Plaza Santa Cruz, CA 95061 714/455-9008 W. Germany 408/475-7461 Syracuse, NY 13210 Software Engineering 315/474-7856 4. Transuortable Software, Inc. 0 P.O. Box 1049 317 W. 39th Terrace 6. FSS 1. OSI Software & Hardware Hightstown, N] 08520 Kansas City, MO 64111 P.O. Box 8403 3336 Avondale Court 609/448-4175 816/531-5950 Austin, TX 78712 Windsor, Ontario z Technology Management, Inc. 512/477-2207 Canada N9E 1x6 1520 S. Lyon 519/969-2500 1. Zimmer, Tom 292 Falcato Drive Santa Ana, CA 92705 2. Offete Enterprises Milpitas, CA 95035 1306 S “B” Street San Mateo, CA 94402

FORTH Dimensions 35 Volume IV, No. 3 FORTH WTEREST GRWP MAIL ORDER FOREIGN USA AR 0 Membership in FORTH INTEREST GROUP and Volume IV of $15 $27 FORTH DIMENSIONS (6 issues) 0 Volume III of FORTH DIMENSIONS (6 issues) 15 18 0 Volume I1 of FORTH DIMENSIONS (6 issues) 15 18 0 Volume I of FORTH DIMENSIONS (6 issues) 15 18 0 fipFORTH Installation Manual, containing the language model of 15 18 fig-FORTH, a complete glossary, memory map and installation instructions 0 Assembly Language Source Listing of fig-FORTH for specific CPU's and machines. The above manual is required for installation. Check appropriate boxes. Pric8 per each. 0 1802 0 6502 0 6800 0 6809 0 8080 fl 8086/8088 0 9900 0 APPLE I1 0 PACE 0 NOVA 0 PDP-11 0 ALPHA MICRO 15 18 0 "Starting FORTH' by Brodie. BEST book on FORTH. (Paperback) 16 20 0 *IStarting FORTH* by Brodie. (Hard Cover) 20 25 0 PROCEEDINGS 1980 FORML (FORTH Modification Lab) Conference 25 35 0 PROCEEDINGS 1981 FORTH University of Rochester Conference 25 35 0 PROCEEDINGS 1981 FORML Conference, Both Volumes 40 55 0 Volume I, Language Structure 25 35 0 Volume 11, Systems and Applications 25 35 0 FORTH-79 Standard, a publication of the FORTH Standards Team 1s 18 0 Kitt Peak Primer, by Stevens. An indepth self-study primer 25 35 0 BYTE Magazine Reprints of FORTH articles, 8/80 to 4/81 5 10 0 FIG T-shirts: 0 Small 0 Medium 0 Large 0 X-Large 10 12 0 Poster, Aug. 1980 BYTE cover, 16 x 22" 3 5 0 FORTH Programmer Reference Card. If ordered separately, send a FREE stamped, addressed envelope. TOTAL $

NAME MAIL STOP/APT ORGANIZATION (if company address) ADDRESS CITY STATE ZIP COUNTRY VISA # MASTERCARD # EXPIRATION DATE (Minimum of $10.00 on charge cards)

Make check or money order in US Funds on US bank, payable to: FIG All prices include postage. No purcham arders without check. California residents add sales tax.

ORDER PHONE NUMBER: (415) 962-8653 FORM INTEREST GROW PO BOX 1105 SAN CARLOS, CA 94070

1 I -BULK RATE FORTH INTEREST GROUP U.S. POSTAGE PO. Box 1105 PAID Permit No. 261 San Carlos, CA 94070 Mt. View, CA

Address Correction Requested