~~iiFURTH UlrnEnSlOnS

Forth Interest Group P.O. Box 8231 San Jose, CA 95155

VOLUME 111: Numbers 1-6 FORTH INTIRIST GROUP Volume Ill P.O. Box 1 105 Number 1 San Carlos, CA 94070 Price $2.00

2 Letters

4 Announcements

5 FORTH-79 Dialog

7 Technical Notes

10 Programming Aids

13 FORTH, Inc. News

14 Pa ramet e r Pass in g

15 Com pi ler Security

20 Userstack

23 A Stack Diagram Utility

33 C hapters/Meetings EDITOR'S COLUMN

The last edition of FORTH DIMENSIONS was the beginning of many changes in editorial policy and Published by Forth Interest Group format. All these changes are designed to make FORTH DIMENSIONS a practical and useful communications Volume 111 No. 1 MayIJune 1981 tod. Publisher Roy C. Martens This practical approach continues. In this edition Guest Editor C. J. Street you will find a number of utility programs that will make the task of implementing practical applications in Editorial Review Board FORTH easier and faster. All of these utilities have been contributed by FIG members who have found Bill Ragsdale them to be valuable tools. The editorial staff thanks Dave 8oulton these contributors and would like to encourage all FIG Kim Harris members to share their ideas and experience. John James Dave Kilbridge Ifyou have a progfamming idea or tool that you have Henry Laxen found useful, pleese send it to George Maverick Editor Bob Smith FORTH DIMENStONS John Bumgarner P.O. Box 1105 San Carlos, CA 94070 FORTH DIMENSIONS solicits editorial material. comments and letters. No responsibility is assumed for YOU DON'T HAVE TO BE A WRITER-me editorial accuracy of material submitted. ALL MATERIAL staff will provide whatever copywriting is necessary to PUBLISHED BY THE FORTH INTEREST GROUP IS IN make your ideas publishable. THE PUBLIC DOMAIN. Information in FORTH DIMENSIONS may be reproduced with credit given to On the aesthetic side. you will find this edition con- the author and the Forth Interest Group. tains several photographs and art illustrations. This is a FORTH DIMENSIONS' first and you con expect to see Subscription to FORTH DIMENSIONS is free with more in the future. Photographs and art illustr~ons membership in the Forth Interest Group at $12.00 per will be chosen and published on the basis of their year ($24.00 foreign arr). For membership, Ch8f~Qeof educational and human interest value. address and/or to submit material, the address is: This issue also introduces the charactw HEX who Forth Interest Group will be FORTH DIMENSIONS' official comic strip. You P.O. Box 1105 will find the HEX comic strip in future editions of San Carlos, CA 94070 FORTH DIMENSIONS. HEX'S adventures will be a com- bination of humor and education. Ideas for HEX comic strips are welcome. IXtSTORICAL PERSPECTIVE C. 3. Street Editor

FORTH was created by Mr. Charles H. Moore in PUBLISHER'S COLUMN 1969 at the National Radio Astronomy Observatory, Charlottesville. VA. It was created out of dissatisfaction Renewals and new members are coming in at a fast witn available programming tools, especially for obser- pace. We expect to climb to 3,000members in the next vatory automation. few monthsand to 5,000 within a year.

Mr. Moore and several associates formed FORTH, Both the Computer Faire in San Francisco and the Inc. in 1973 for the purpose of licensing and support of Computer Festival in Trenton, New Jersey were huge the FORTH and Programming Lan- successes We'li be in both again next year. (I'd like to guage, and to supply application programming to meet know of any other shows where. you think FIG should customers' untque requirements. exhibit.)

The Forth Interest Group is centered in Nwthem Good material is coming in for FORTH California. Our membership is over 2.400 worldwide. It DIMENSIONS. Keep it coming and send in your was formed in 1978 by FORTH programmerstto emur- comments. age use of the language by the interchange of ideas through seminars and publications. my Martens

Page 1 FORTH DIMEI9SU)"ON In/l Dear Fig:

LETTERS Thank you for the prompt and efficient rervice I have received. I realize that Dear Fig: you can't have much time left to look after the reat of the world, but without My company ir developing burinerr your interert it may never have reached ryrtemr using FORTH and we would be there rhorer. Spread the good WORD. intererted in caaanmicating with local FIGGIES as well as offering our input to J. Iluttley FST, FORM,, FIG and other applicable "F" u#IVERSIT!l OF AlXKLAND acronym since it ir obviourly in our 19 Duncan Avenue interert to promote the rpread and Auckland 8, acceptance of FORTH. We're alro confirmed New Zealand FORTH fanaticr. You are very welcome! - ad. David B. Man8 BUSINESS SYSTEMS SOFTWARE, IMC. 27 Eart Kings Highway Bditor'r note: Haddonfield, NJ 08033 (609) 429-0229 At the WEST COAST CUBPUTER FAIRE in California two verrionr of a FORTB bumper You are our kind of fanatic and m're rtrip were circulated: happy to put the word out for you Dave! -- ed . ?FORTH IF HONK THEN or alternately Dear Fig:

Re : "Born-again progra=er" and "Born- again FIGGER" in FORTH DIMENSIONS II/S. Just thought you ught like to know. -- My interest in FORTB as a programing ed . language does not envolve becoming mired down in the morass of a religion. It would be best to stay on rational groundr Dear Fig: in the development of FORTH and leave religion to those who are unable to think TGIF is .very interested in mapping without faith. listings with other Fig-FORTR groups. Our current lirtingr are 2 Decorpilere; Full f will not take part in a religious rcreen editor; CASE statement8 for 8080, group. Therefore I will not be renewing 280 and 6502; 6502 Arserbler. my membership. TGIF Larry R. Shultis lWRR1 INTEREST CROUP -- TULSA P.O. Box 218 Bsx 1133 Fontana, WI 53125 Tulra, OK 74103 Just goes to shav you that there is more Bow about rending them in to FORTH than one type of fanatic! Keep the faith, DIMENSIONS? - ed. Larry, (OOPS, sorry about that! I meant: Don't worry, Larry,) FIG is not envolving (your spelling) into a religious group. -- ed .

FORTH DXHENSIONS III/1 Page 2 Dear Pig: enough information should be provided so as to allow them to be adapted to I was lucky enough to attend one day of a different machine. the recent West Coast Computer Faire and to meet some of the mentors of FIG. I had 2. I will compile a draft of the pro- numerous questions and enjoyed talking to posed publication and submit it to a Bill Ragsdale and others about them. (By technical review cornittee for review the way, for those of you who couldn't and appropriate testing. This com- make it to the Faire, the FIG booth was mittee of FIG members (I am looking one of the most crowded. People were for volunteers) will scrutinize the standing there like no where else even as proposals (and alternatives if appro- the 5:OO closing approached. We all owe a priate), test them on a running FORTH thanks to the dedicated folks for their system, and make recommendations. time and effort in this endeavor, promoting and spreading the word of FORTH 3. I will then compile the final version and FIG. 1 and submit it to FIG for publication.

One of my questions to Bill was "How can I have set some timelines for com- we remote members contribute to FIG" in piling this compendium such that it ways other than articles for FORTH can be published by next year's DIMENSIONS. I got a number of project Computer Faire. Material should be ideas, for one of which I need tne help of sent in no later then 1 September the whole membership. So ?LEASE: NOW 1981 (please send them early and give HERE THIS! me a chance to get ahead). I will distribute the draft for review and I propose to assemble a book of utility testing by 15 October 1981. Finally program packages for publication by FIG. I will begin compiling the final I have a list of functions which I think version by 1 January 1982 and have it should be included. This covers such ready for publication by 1 February things as editors (both the current FIG 1982. line oriented editor and a video screen type editor), string processing, data This may seem like a long time structures, extended math (double prec- abuilding, but I want to provide ision as an example), math functions (sin, ample opportunity for the contribu- log, etc.), matrix operations, and float- tors to develop their ideas fully and ing point routines. No doubt there are conduct a fair amount of testing others to be considered and I solicit your themselves before submission, I also suggestions. want to provide a good review by the coormittee to provide the highest The plan I propose to compile and quality document for FIG. It will be publish such a document is as follows: worth it in the long run. Your con- tributions will be sincerely appre- 1. Members are asked to send their ciated, and though the publication, proposals for implementing utility as are all of FIG'S, Vill be in the packages to me at the above address public domain, credit will be given (or through FIG). These proposals to the authors and contributors. So should consist of well documented if nothing else, this is a chance to (lots of cooments) fig-FORTH source get your name in print, in an inter- code accompanied by complete instruc- national publication. tions for use, any known operating limitations, and a brief technical Sincerely, description or reference if appro- George 0. Young 111 priate. The programs should be as 617 Mark NE transportable as practicable; if Albuquerque, NM 87123 system unique routines are necessary,

Page 3 FORTH DIMENS IONS I II / 1 This is a great project. Our goals ANNOUNCEMENTS continue to be to decentralize FIG activities, and George's project of a published "Goodies Package" will be FORML CONFERENCE CALL FOR PAPERS helpful to all. Contributors should send a brief description to George and then Papers are requested for the three day prepare the full document. This will technical workshop to be held next a I. low co-ordina t ion of similar material . November 25th to 27th at the Asilomar -- ed. Conference Grounds in Pacific Grove, California (Monterey Peninsula).

Although registration for this con- ference is not yet open, attendance will be limited to 60 persons. Authors will be accepted before listeners, so if you want to attend, the only sure way is to write a paper. Please note: abstracts or propo- sals for papers or discussions must be submitted no later than September 1, 1981 for inclusion in the conference and its proceedings; completed papers by Sep- tember 15, 1981.

The purpose of this workshop is to dis- cuss advanced technical topice related to FORTH implementation, language and its applications. Potential authors should write for an author's packet for detailed instructions. Send all correspondence regarding the conference or papers to:

FORML CONFERENCE P.O. Box 51351 Palo Alto, CA 94303

FORTH WORKSHOPS

Beginners and advanced workshops in FORTH are being jointly sponsored by the College of Notre Dame and Inner Access Corporation both of Belmont, CA.

Beginners workshops start June 23 and advanced workshops start July 14. Classes meet every Tuesday and Thursday evening from 7:OO to 9:00 P.M. Registration is $135 for 3 weeks (12 hours). Spreading the fig-FORTH at the West Coast Computer Faire, April, 1981. For more information and registration Top : (1-r) Plichel Yannoni (FORTI! vendor), contact : Dave Boul ton and Martin Sthaaf (Answering the question: What's FORTH? 10,000 times) College of Notre Dame (415) 593-1601 Bottom: (1-r) Roy Flartens (FD Publisher), Anile & Bill Ragsdale (FIG prime movers). Order your T-shirt, like Bill's!

FORTH DIMENSIONS III/ 1 Page 4 piled are few and could easily be CONTINUING DIALOG ON handled by using the [COMPILE] operator. ON the other hand, syntax FORTH079 STANDARD errors and typos often result in mistaken attempts to compile ': Dear Bill: which, when it's an imnediate word, can be flagged by the compiler. We recently obtained a copy of the FORTH-70 Standard from FIG and are 4. The word CODE is defined as using the attempting to align our version of FORTH form: with it. The document is generally well done and in most cases clearly and con- CODE ...END-CODE c isely expressed. However, there are about a half dozen or so definitions that However, the word ;CODE says nothing seem to us somewhat ambiguous. about the corresponding form. Our version of FORTH rquires that code I am writing to you in the hopes that level action routines defined by you can clarify the word definitions in ;CODE also be terminated by the word question; or, that you can refer us to END-CODE. Is this compatible with someone who can. I am also interested in FORTH-79? knowing whether the FIG model has been aligned yet, if not, when it will be. 5. The words FIND, I,' ':I , etc., as defined in the Standard, indicated a My list of questions is enclosed and I search of C0I"EXT and FORTH only. Is would appreciate anything you can do to it considered an incompatibility if assist us in their resolution. the CURRENT vocabulary is also searched (if different)? The defini- Cordially, tion of VOCABULARY is not clear regarding the possibility of "sub- Robert D. Villwock vocabularies" such as ABC chained to MICROSYSTEMS, INC. Xm chained to FORTH. If this is 2500 E. Foothill Blvd., 1102 allowed, and, ABC is the CONTEXT Pasadena, CA 91107 vocabulary, is not ABC, XYZ, and FORTH searched? OPEN QUESTIONS FORTH-79 Standard 6. What is the mnemonic significance of the C words such as C!, CMOVE, 1. For the words / and */ does the etc.? Surely it doesn't stand for t e rmino logy rounded toward 2ero" "cell," does it? The term "cell" is essentially mean truncated? If not, defined on page 3 of the Standard to precisely what does it mean? be a 16-bit memory location. The word MOVE is defined on page 26 to trans- 2. The word SGIN is now apparently fer 16-bit words ("cells"), while the defined to be used "outside" of the word OW on page 20 is defined to <#, #>operators. What is the pre- move bytes (not "cells"). If the C cise definition of where the minus does stand for "cell" what is the sign character is to be stored? Why rationale? Why was the former stan- was this word changed from its former dard's B (for byte) replaced by the function between <# and #> ? mysterious C?

3. The word ':I is defined as a non- 7. I note that in the reference section precedence word. Is this a typo or of the Standard, the word DPL which is it intentional? If intentional, formerly used to handle both input could you explain the rationale? It and output "point" situations now seems that the number of occasions strongly emphasizes that input con- for which "colon" needs to be com- versations should not affect its pw5 FORTH DIMENSIONS III/ 1 value. What is the reason for this terminate in END-CODE. This is an restriction? How likely is it that unrcrolved area. this may become part of the Standard? 15. The standard wording was painstaking- 8. The definition for CREATE is not ly done regarding vocabularies. This clear. Does the second sentence is the most divergent topic among "When is subsequently uaers. all known methods can comply executed, the address of the first with the Standard, but it does less byte of 's parameter field is than all ryrtem. The rationale is left on the stack" mean that the word that you build CURRENT but you exe- CREATE alone is to function this way cute only from CONTEXT (and FORTH). or only when followed by ;CODE or No cbaining is recognized, beyond DOES) ? In other wordr, is it context leading to FORTE. This may intended that CREATE work as in the be physical links or logical (within FIG model or has its definition FIND). Again, position papers are changed? Taken literally, FORTR-79 errential to get a c-n, more says that CREATE will generate an advanced, conatruct. unsmudged header with the CFA point- ing to the run time procedure for 6. Charles Moore has used C for ten variables. Is this what is intended? years as a character (byte) prefix. Ignore (if you can) that a character COMMENTARY FROM THE FORTH DOCTOR is defined ar 7 bits in the Stan- dard. This was a hotly disputed 1. Some computers apparently (by Stan- point with FIG and the Europeans for dard Team comnent) round quotients "B"yte and FORTH, Inc. and a couple and remainders to smaller magnitude of others for "C" . Kitt Peak was (more negative). Trucation of nega- adamant before the meeting for "B" tive quotients would do this. If a and other uniformity improvements. correct representation is not possi- Their representatives made no defense ble, the result should be nearer of the issue. Historical precedence zero. Dave Boulton is more know wins this one. ledgeable on this point. 7. Reference Section is just left- 2. 'I Sign is to be used within <# and overs. Only one vote of any team #>. The user chooses where to store member was crufficient to maintain a the sign. Notice that no word gener- Reference word on the lirt. The ates the saving of the sign. In fig- Standard attempts to minimize system FORTH the only difference is the ROT variables. Increased usage of would be explicitly done just before special variables is unlikely. SIGN, rather than in SIGN. Things like DPS are delegated to applications. 3. FIG and the Europeans make : an he- diate word for error control. Other 8. The definition of CREATE is quite users, and FORTH, Inc. reject this clear. You have stated it and then level of error control-too bad! We correctly paraphrased it. Other need a technical paper presenting the defining words may be used before trade-offs (code needed and compila- DOES >which help build a parameter tion slowdown). Conversation at a field. DOES> rewriter the code field team meeting is insufficient to to its own code. change opinion8 developed over ten years. : CPU CONSTANT DOES) ; 4. These topics were barely touched on by the Team as CODE definitions are is equivalent to not portable. ;CODE probably should : CPU CREATE , DOES) ;

FORTH DIMENSIONS III/l Page 6 TECHNICAL NOTES, BUGS & FIXES Modifications to the fig-FORTB boot-up literals :

Dear Fig: 1. Backspace Character Character to emit in response to a I have recently brought up FORTH on a backspace entry. X'08' ( control-H ) 6800 system and find it to be a very easy is character FORTH respondr to for and powerful system for microcomputers. backspace function. Character to emit is terminal dependent and should I have a mini-computer with a cross- be defined in the user table. assembler on it which I used to assemble the source after keying it in. Naturally, This also allows use of a printable as soon as I got it working I wanted to character ( e.g. C'\' 1 to emit for change it. I feel that the EXPECT routine backspace for use on printing and backspace handling could be improved terminals. significantly by incorporation of the en- closed recomnendations. 2. Form Feed Character Character to emit to cause terminal I also experimented with the GLOSSARY ( or printer to advance to top of routine submitted by D.W. Borden in FORTH form. This is also device dependent DIMENSIONS, Volume 1, No. 4. I modified and should be in user table. it to handle the variable length name 1 field and changed the format slightly. 3. Form Feed Delay lumber of null characters to emit Keep up the good work. after issuing a form feed charac- ter. This is similar to CR/W delay Toby L. Kraft which is already provided. San Diego

Reconmendation :

Add variable 'BSTOF' to user table. X'BBFF' - two characters of data FF - form feed character ( X'OC' initial value 1 BB - back space character ( X'08' initial value 1

Add word 'BSTOF' to vocabulary to access this variable in user table. ( Similar to 'BASE'

Modify definition of current user varia- ble 'DELAY' to include formfeed delay in upper byte .

010 DCCIW Dw 3 I .CUE 011 F YY - cm I ID WUES Add word 'DELAY' to vocabulary to access 012 CW I )5I b R WUE 013 C4) I I TRAVLRT DU this variable in uoer table. 014 3 + b SPUE CR 013 I. I cw ' 016 ~mIiINU.IF WIT WIF 01' ELSE WIT WEY -IN Modify startup parameters and cold etart accordingly. Modify EXPECT to use user defined The 'under' symbol imparts a clear backspace character and to explicitly verbal and graphic representation of the generate bell code ( X'07'). Currently, ordering of the stack contents, and EXPECT tests for the beginning of the provides an elegant solution to a major buffer and subtracts the boolean flag problem encountered when transporting result from X'08' to generate the char- FORTH and source code. acter to emit in response to a back- space. Don Colburn Creative Solutions, Inc. Toby L. Kraft 4801 Randolph Road 7822 Convoy Court Rockville, MD 20852 San Diego, CA 92111 (714) 268-3390 Dear Fig: This really needs expansion and gener- ality. How about terminals that need an Some time ago I bought your Installation "escape sequence" to clear screen, i.e. Manual and the 6502 Assembly Listing. I form feed? Toby, HEX should be used have been studying both for quite a while, insteat of X' .--ed. and am also a charter member of the Potomac FORTH Interest Group (PFIG: Joel Shprentz and Paul VanDerEijk). Dear Fig: I have FORTH (cassette) for the I wish to convey a concept which has TRS80 up, and have just bought GEOTEC greatly increased the clarity of my FORTH FLEX-FORTH for my KIM, although I don't coding. It has to do with in-line docu- have my 16K ram card installed in KIM mentation of the contents of the stack yet. I do like FORTH!!! The PFIG has (comments within parathesis). been fairly inactive for some the due to lack of a meeting place, but Joel Shprentz Unfortunately, none of the existing has been conducting some Intermediate techniques (space, hyphens, brackets, or FORTH classes ($30 for six lessons) which ordinal suffix) provide the brevity and are ongoing, and very interesting - we are clarity that one becomes accustomed to well into , and will then go with FORTH. The technique which I have on to disking, etc. Ask Joel for details. devised provides both. It revolves around the backslash character '\I, which I refer I'm still planning to bring up FORTH on to as 'under' and the double hyphen I-' I the KIM from my own hand-assembled ver- which I refer to as 'leaves'. Using this sion, just to satisfy my own curiousity terminology, the following c-nt: about what makes FORTH tick. I do think I'm finally beginning to understand how ( address\count -- everything fits together.

is read "address under count leaves In this vein, I have a few comments to no thing, " and pass on from an (advancing) novice FORTH enthusiast. The first two comments regard ( Nl\N2 - N3 the above referenced Installation Manual and 6502 Assembly Listing. The last two is read "Number1 under Number2 leaves are ideas of my own which I offer for what Number3 ." they are worth. 1. There is a disparity in the Instal- lation Manual version of the 6502 memory map regarding the placement of the Disk buffer and User Area.

FORTH DIMENSIONS III/l Page 8 Indeed, there is disparity in the places code field. Anymore comnents .c 6502 Assembly Listing between what is should be directed to Chuck Peddle, 8t ) done near the front and what is actu- designer of 6502. tb ally implemented (per the installa- tion Manual). The Installation Keep up the good work. Manual puts the Disk buffer at the top of RAM with the User area just Edward B. (Ted) Beach below. Line 0051 of the assembly 5112 Williamsburg Blvd. manual says User area is top 128 Arlington, VA 22297 bytes, with disk buffer next (line 0052 1. CREATE assumes just the oppposite in both the Installation CORRECTION ON SEARCH Manual and Assembly Listing. (Editor by John James -- correct on all all points. The (Vol. I1 16) author was inconsistent.) When you are debugging or modifying a H program, it is often important to search 2. In screen 49 of the Installation the whole program text, or a range of it, Manual, I see no need whatsoever for for a given string (e.g. an operation a dedicated word such as ID. to move name). The 'SEARCH' operation given below the word name to Pad and then type it does this. out! The first 4 words are not needed, and neither are the words To use 'SEARCH', you need to have the " " I following - (PAD SWAP CMOVE FIG editor running already. This is I PAD). Just a waste of time and space because 'SEARCH' uses some of the editor 1 1 to bring the name to PAD and then operations in its own definition. The 1 type it out! (Editor -- this is not 'SEARCH' source code fits easily into a 1 so. If you have WIDTH set to less single screen; it is 60 short because it than 31, ID. is required.) uses the already-defined editing func- tions. Incidently, the FIG editor is 3. I would suggest a word ( Q that documented and listed in the back of FIG'S might be inserted into any type of Insta 1la ti on Manual. loop (Do/LoOP or BEGIN/AGAIN) to PI allow a timely exit when things go Use the editor to store the source code awry (as they do with Novices!). of 'SEARCH' onto a screen. Then when you It's very simple - : Q ?TERMINAL IF need to search, load the screen. (Of QUIT ENDIF ; MMS FORTH has this course if you are using a proprietary embedded into the code of " : " , but version of FORTH, it may have an editor I think that's overkill. But it sure and search function built in and auto- is nice to undo errors put into matically available when needed. This loops. (Editor -- this is terrible article-ette is mainly for FORTH users style. LEAVE is the correct way for whose systems are the ten-dollar type- it - tl a controlled termination. in-yourself variety). .(

4. This has specifically to do with the Here is an example of using 'SEABCR'. m Jump Indirect of the 6502 as used in We are searching for the string 'COUNT' in S both the Installation Manual and the screens 39-41; the source code of 'SEARCH' assembly listing. Having used the is on screen 40. The screen and line 6502 for better than 4 years, I have numbers are shown for each hit. Inci- yet to use the JMP indirect after dently, the search string may contain finding out about its shortcoming of blanks. Just type the first screen wrapping around within a page if low number, the last screen number, 'SEARCH' byte of address is SFF. I pretend followed by one blank and the target text this opcode does not exist. (Editor string. Conclude the line with return. -- CREATE on 6502 systems correctly The routine will scan over the range of

Page 9 FORTH DIMENSIONS III/l II screens doing a text match for the target string. All matches will be listed with the line number and screen number.

Happy SEARCHing!

240 440 440 540 840 OR

SCR I 40

0 SEMICII. OVER RIffif Or SCREEIS UFR) 1 BLClRAL 2 00 VAIIIAILE COUNTfR J : IUIIP < THE LINE WUNBER I10 HUlDLE WII(0 4 1 COUNTER +I COUNTLR S 5 '56 > IF 0 COUNTER I 6 CR CR IS MESSAGE I2 EN11 TMEN ; 7 : SEIRCH ( FROM, TO --- lllRGET 91R116 I I 12 Ell11 01 lEXT 0 COUWTER I P I+ SYIP DO FORTM I JCR 10 EDITOR 10) 11 IEGIM ILIWE IF 0 1 SCR ? tUIv THEN 12 1023 111 @ < UWlIL 13 LOOP : CR :SEIRW IS LOLDEB ;S 14 IS TYPICAL USE TO LOCATE 'KEY-YOID': 21 44 SWCH KW-W)

PROGRAMMING AIDS & UTILITIES

Kim Harris The following utility indexes 10 screens FORTHRIGHT ENTERPRISES at a time and is an excellent aid in P.O. Box 50911 searching. Palo Alto, CA 94383 HEX : +INDEX 113 0 DO In true ideal FORTE programning style DUP 10+ SWAP OVER INDEX the definitions contained within the KEY ?ESC IF LEAVE THEN LOOP; screens clearly designate8 their use.

The following utility was contributed by Sam Bassett and is an excellent program development aid that 8hows you what the current base is

: BASE? BASE @ DUP DECIMAL . BASE ! 9

FORTH DIMENSIONS III/1 Page 10 PRODUCT REVIEW Eere is ~II8daptation of George Shaw'r VIEW to use the word WHERE, which on my system invokes a full screeen editor that by C.H. Ting, Peb. 26, 1981 highlights the word pointed to by a block number and displacement. It certainly Thin-FORTH, frm Mitchel E. Timin Engi- helps pick out a word in dense code. neering Co., 9575 Genesee Ave., Suite E2, San Diego; CA 92121, (714) 455-9008. 8" single density diskette, $95.00

I was invited by Dr. Thin to compare his CP/H FORTH (FD 11/3, p. S6) with the 2-80 FORTH by Ray Duncan, Laboratory Hicrosystems (FD 11/3, p. 54; FD 11/5, p. 145) I ran the two FORTR systems on his home made 2-80 computer (S-100 , 6 Wiz) The results of a few bench marks were :

:-~momImP-~IDop;5.9 7.4

:~moDoIAlp*HIBLmP; 44.0 54.9

: /"L' 7EW O Do 7EW I / JXYP LDOP ; 74.3 88.6 : WIPE 120 61 Do I ClBARLmP ; 34.3 81.8

97 IMD ( faa hmdred eighty 9's 17.9 18.6 HELP WAlQTED \ Senior Level FORTH Progra~~3crr I was surprised that Thin-FORTH which is 8080 fig-FORTH ran faster than Z-80 Fr iends-Amis FORTH which uses the extra 2-80 registers 505 Beach Street for IP and W. Dr. Timin's opinion was San Francisco, CA 94133 that the 2-80 instructions using these Call: Tom Buckholtt extra registers are slower then the (415) 928-2800 simpler 8080 instructions. The word WIPE tests disc access time. Thin-FORTH accesses the disc by 1024 byte blocks, and it is twice as fast as 2-80 FORTH, which readdwrites by 128 byte sectors, as in Intermediate (5 Senior Level FORTH the fig-FOBTB model. Programers for Data Entry Applications The dictionary in Tidn-FORTH is about MSI Data 11 Kbytes, including an editor and an 340 Fischer Avenue assembler. The editor is the same as that Costa Mesa, CA 92627 of the fig-FORTH model. The assembler has Call: Joan Ramstedt all the 2-80 instructions. An interesting (714) 549-6125 word SAVE allows the whole system in- cluding application words to be preserved

Page 11 FORTH DIMENSIONS III/1 as a CP/M file which can be loaded back FORTH TELE-CONFERENCE IS NOW OPERATIONAL for execution. It maintains eight 1 Kbyte disc buffers. FORTU now has a dynamic, public access data base. By dialing into the FIG The documentation supplied with the CommuniTree ( tm, the CommuniTree Group) system is a 68 page booklet 'USER'S MANUAL you may access our tele-conferencing & TUTORIAL'. It is a very well done system. It was created by Figger John manual introducing users to the systems James to allow group interaction to build and to the FORTH language. However, upon our collective knowledge. source listings are not provided. The number is 415-538-3580. The system My overall impresssion was that this is runs 24 hours a day. Use a 300 baud modem a well rounded FORTH system suitable for and start with two "returns", the system engineering and professional applications. is self-instructing. This conference holds information on employment, vendors, applications, announcement calendar, Editors Comment -- FORTH Dimensions inquiries, books, etc. Information of the refrains from publishing timing benchmarks conference is organized in a tree struc- as this reflects processor speed more than ture, hence the name I' Conference Tree". effectiveness of problem solving. Now- ever, the above review points out that the Our hope is that half of the callers allegedly superior 2-80 runs these tests will review the available material and slower than the 8080. Our point is that then ask questions. The orher half should the user should evaluate all aspects of add answers to these questions. You problem solving: hardware characteris- simply find a topic or message and attach tics, language implementation and appli- your query/response. Users naturally cation technique. The Timin manual is organize their material in a form that sold separatly for $20.00. This price is facilitates retrieval. 3 not justified by the copy received for our evaluation. This system was written in Cap'n Software Version 1.7. Versions for other than Apple 11 are being developed. HELP WANTED h For availability contact: 0 FORTH PROGRAMER s The CoaDmuniTree Group 9 PDP-11 RSX Op Sys On Site ContracCor Box 14431 e San Francisco, CA 94119 e Micro/Temps E 790 Lucerne Dr. or call the original Tree: (415) R Sunnyvale, CA 94086 526-7733. id ( 408) 7 38-4 100 .h n

It In It 1s 18 1- !d

FORTH DIMENSIONS III/l Page 12 FORTH, INC. NEWS RECENT FORTH COMMERCIAL APPLICATIONS Pi Work has just been completed for MAJOR EXPANSION PLANS Raytheon Corporation on a terminal cluster (up to 32 terminals with a single concen- FORTH, Inc. is now entering a major trator). Each component of the system is expansion phase, according to President controlled by an 8085 processor, and all Elizabeth Rather. Appearing on a panel on are programed independently, using "Programming Languages for Small Systems" polyFORTH. This is a capability they've at the recent NCC in Chicago, Rather never had before -- to do custom prograrn- observed, "The level of excitement and ming and provide extensibility. Terminals t enthusiasm about FORTH in the industry is up to two miles away can be polled at a I tremendouus. We are increasing our number rate 30 times faster than the previous of OEM'S and we have been approached by protocol, which was written in assem- I several major silicon manufacturers bler. Dean Sanderson was the principal I desiring to obtain marketing rights for programer on the project. ! special versions of polyFORTH. Arrange- I ments are also being made to produce the The famous 200" Hale Telescope at Mt. I FORTH processor, and we expect this Palomar Observatory (near San Diego) has t project to start very soon.'' recently installed a polyFORTH system for 1 data acquisition and analysis using a i PDP11/44 and a Grinnell display proces- 1 LIFEBOAT REPRESENTATIVE VISITS sor. The Observatory has been using FORTH since the early 1970's, including a Masa Tasaki, Managing Director of miniFORTH system installed in 1975 and an Lifeboat , Inc., FORTH, Inc. '8 distributor early polyFORTH installed in the late 1 in Japan, spent two days at FORTH, Inc. 70's. Barbara Zinmerman, a programer at recently to discuss mutual marketing Cal Tech (which operates the observatory) plans. Lifeboat, Inc. is one of the few said, "I am extremely impressed by the I software distributors in Japan, and level of polish and sophistication in 1 polyFORTH is the top of their product polyFORTH, and the performance of this 4 line. Tasaki has installed over 40 systeiu is outstanding." The type of work I polyFORTH systems in Japan in the past done involves reading data from an 800 x I year, and plans to sell an additional 50 800 array of CCD sensors, integrating and 4 polyFORTH systems by the end of 1981. recording the data, and displaying it in II the Grinnell. Charles Moore installed the 1 system, which features a comprehensive 1 STARTING FORTH BOOK PREPRINTS AVAILABLE math package for analysis as well as I image-processing functions. STARTING FORTH, a 380-page book intro- I ducing the FORTH language and operating A by-product of this installation is tho, i system will be published by Prentice-Hall availability of polyFORTH in RK05 disk 1 this September in both hard and soft-bound cartridges. These are available with on- I editions. FORTH, Inc. is offering limited sit e ins ta 11 at ion. preprjnts to customers until then. The preprint, numbered and signed by both author Leo Brodie and Charles H. Moore SCHEDULE OF UPCOMING FORTH, INC. SEMINARS sells for $50.00 (plus 6% sales tax for AND WORKSHOPS : residents of California). You may reserve a copy of STARTING FORTH by calling Winnie Location Seminar Workshop 1 Shows at (213)372-8493. All orders must be pre-paid. Palo Alto June 4 June 5 1 Houston July 7 July 8 Tampa July 9 July 8 Irvine July 23 July 24 i

Page 13 FORTH DIMENSIONS III/1 strate its usage. Both MR8 (16 bit dump) PARAMETER PASSING TO DOES) and CDUMP (8 bit dump) share a corrmon structure with only a few inner words dif- fering. DUMPS is a new defining word used David McKibbin as a procedure for both DU?Q and CDUMP. S ygne t ron 2103 Greenspring Drive : U.R 0 !M!W D.R ; Timonium, MD 21093

Often in programing one runs into the case where several different processes share similar structures. Not wanting to waste time or space for redundant code, the programmer usually creates a sub- routine or procedure to execute the basic structure. Then the individual processes merely pass arguments to the prodecure to accomplish their task. Several schemes can be used to pass these parameters. In simple cases, the stack can be used directly. This is the typical act of programming in FORTH.

However, as the procedures get more com- plex it gets more and more difficult to keep track of the passed parameters espe- cially when the procedure itself is using What has been accomplirhed is akin to the stack heavily. Also many times it is passing procedureslfunctions as parameters necessary to pass not only numbers but in Pascal. I expect that there are other operators or words as parameters. One ways to do this FORTH beyond what has been means of accomplishing this is via (BUILDS proposed. DOES). Parameters will be stored in the parameter field of the newly defined word and accessed from DOES) via a new word FIG-FORTH UNDER OS-6SU { $ } . 1 $ will push the first parameter on the stack, 2 $ will push the second, Software Consultants has announced the etc. All parameters are 16 bits. Varia- availability of Fig-FORTH under OS-65U for ble R# is used to store the parameter base the Ohio Scientific Line. The package address. includes assembler and a terminal oriented editor and is available nwfor $79.95.

This version is said to support hard- dirk, multi-user systems and may even be run in one partition and BASIC in another.

For more information contact:

Software C6nSUltantS 7053 Rose Trail Now that the mechanics are explained the Memphis, TN 38134 I following example will more fully demon- (901) 377-3503

- ! FORTH DIMENSIONS IIt/l Page 14 COMPtCER SECURITY and could cause disastrous effects (i.e. a system crash) at run-time. The methods LI George W. Shaw I11 used by the compiler security system :I SHAW LABS, LTD. entail either checking a value on the top c4 17453 Via Valencia of the stack (to verify the proper nesting a San Lorenzo, CA 94580 of structures) or checking that the stack r! position is the same at the end of a defi- nition as it was at the beginning of the How it Works and How it Doesn't (Adapted definition (to ensure program structure from a section of the Acropolis A-FORTH completion). These two methods probably manual trap about ninety percent (90%) of the structural programming errors that a pro- There is much argument about parameter gramer might make. validation and error detection in FORTH. Many problems exist with many good solu- The first in each of the paired struc- tions. Fig-FORTH and its derivitives have tural compiler directives (i.e. pairs such taken one route of extensive protection in as IF THEN , DO LOOP , etc.) leave compiler directives and their associated on the stack at compile time a value which words. This is not an only solution in is checked by the ending structure to this area. Its extensiveness may not be ensure the proper nesting of structures. necessary. There may be better alterna- For example the word IF leaves, in tives. Read on, learn how fig-FORTH addition to the other data necessary to works, consider the options and then compile an IF , the value of two (2) on decide. Your opinion and ideas are the top of the stack. The words ELSE needed. and THEN remove a value from the top of the stack and check to see if it is a two Fig-FORTH and its derivitives provide a (2). If the value on the stack was not a type of compiler error detection referred two (21, a Conditionals Not Paired error to as "compiler security". Compiler ($19) results, and compilation is termi- security provides protection against nated (control returns to the keyboard). structural programing errors made by the If the value is a two (2) the remainder programer as well as insuring the proper of ELSE or THEN executes, removing the machine state and, in a very few in- necessary data from the stack to finish stances, the validity of parameters. the structure, and compilation continues Though it depends on the type of program- on to the next word. ming, the most common errors are struc- tural errors* , machine state errors, and Below is a table of the conditional then parameter errors, respectively. pairs for the current structural compiler directives, with the values placed on the (* structural errors may be caught stack open and the values removed from the internally by detecting parameter stack in parenthesis. Note that UNTIL errors. See text.) and END as well as THEN and ENDIF have the same effect. Only the former of -STRUCTURAL ERRORS each pair are presented here for clarity. The comoiler security system uses two BEGIN 1 UNTIL (1) methods to trap structural prograndng BEGIN 1 WHILE 4 REPEAT (1) (4) errors inside of colon-definitions. BEGIN 1 AGAIN (1) Structural errors are those caused by IF 2 THEN (2) incorrect program structure; either IF 2 ELSE (2) 2 TREN (2) improper nesting of structures or not Do3 LOOP (3) completing a structure inside of a defi- Do3 +LOOP (3) nition. Either of these conditions would Do3 /LOOP (3) cause the program to compile incorrectly Do3 +/LOOP (3)

FORTH DR3tlOSIONS III/l Note that ELSE tests and replaces the tional pairs. If ?PAIRS does not find a same value on the stack. Because of this matched set, it aborts with a Conditionals the current compiler security system Not Paired error (#19). If the values on cannot detect the presence of multiple the stack are paired, it removes them and ELSEs in a definition. For example, in returns. the definition: The above simple form of error checking is very effective, but as structures become more complex, manipulating and maintaining the stack values can become cumbersome and unwieldy. The above is also not yet complete. One more check if compiled , (and it will compile,) and must be executed to ensure that the then executed with a boolean value (zero structures in the definition have been or non-zero) on the stack, will execute completed. Since the above error checking without crashing the system. But the leaves data on the stack if a structure execution may not be what you expected. has not been completed, the simplest check If entered with a true flag (non-zero) the is that of the stack position. 5Jhen a "True Part 1" and the "False Part 2" will definition is entered : (colon) stores print, while if entered with a false flag the Current Stack Position in the user (zero) the "False Part 1" and "False part variable CSP . At the end of a defini- 3" messages will print. To borrow a tion, ; (semi-colon) executes ?CSP to phrase from Kim Harris, probably "Not- what compare the current stack position to the you had in mind!". value stored in CSP . If the values differ a Definition Not Finished error This is the only case I know of where (820) occurs indicating that either data the compiler security system plainly does was left on the stack or that too much not work, but there are probably more. data was removed fram the stack, i.e. that a programing structure was probably not How is this, apparently incomplete, completed. The word "probably" is used structure checking performed? Read on. here because other conditions, such as the improper or sometimes various proper uses The values on the stack is verified by of the word LITERAL , will cause the same ?PAIRS . For example the words ?PAIRS , error condition to occur. BEGIN and AGAIN are defined as follows: MACHINE STATE ERRORS : ?PAIRS - 19 ?ERROR ; : BEGIN ?COMP ?ERE 1 ; IMMEDIATE The loading and execution of a FORTH : AGAIN 1 ?PAIRS COMPILE BRANCH BACK program causes the system to enter several : IMMEDIATE different machine states. Three of these are loading, compiling, and executing. BEGIN first checks to make sure that it Each of these states is defined by its own is being executed in compile mode (inside set of parameters and some states may even a definition) with ?COW which issues an overlap. For example, while loading a error if it is not. It leaves the current screen off the disk the machine will be dictionary address on the stack ( HERE ) either executing or compiling. Here the as a branching reference for AGAIN , and loading state has overlapped with either then the 1 as the first of a conditional the execution or compilation state. The pair. When AGAIN later executes during machine cannot be in the execution state the compilation of the definition it first and the compilation state at the same checks the stack to see that a BEGIN time, though the states may be inter- preceded it at the same level of nesting leaved. An example of interleaved states by executing ?PAIRS . ?PAIRS expects is the use inside a definition of a pro- to find a matched pair of values, in this gram segment similar to this: case ones (l), as a matched set of condi-

FORTH DIMENSIONS III/1 Page 16 [scIBF# 3Co-J. ZITdRAL state when ?COW executes a Compilation Only, Use in Definition error (#l7) vhich temporarily suepads compilatiaa to occurs. calculate the value within the brackets and then compiler it as a sixteen (16) bit If the machine is not in a state of literal. Remember though, that to com- loading when ?U)ADIW is executed a Use pile, the machine is executing a program, Only When Loading error (122) occurs. and that compiler directives (such as LITERAL above) execute during compilation The testing of machine states as above to perform their task, but the machine is necessary when words such as BEGIN state remains that of campilation. and AGAIN (see example in STRUCTURE ERRORS above) are used. These words may Certain words require that the machine only be compiled because they muet compile be in a specific rtate to execute proper- samething other than themselves which is ly. These words are prograd to contain not known at the time they are executed. one of the following words: PAUHETER ERRORS ?COMP ?EXEC ?LOADING During compiling and aimilar operations which check for their corresponding state there are only a few parameters which are and issue an error message if the machine actually checked. In mst cases, the is not in that state. Below is a descrip- parameters checked are those involved in tion of each of the above words and the the other areas of compiler security or parameters which determine the current those which deal with the size or validity machine state. of the dictionary and stack.

?EXEC or ?W?P The words involved in other compiler security areas are !CSP , ?CSP , The execution state or compilation state ?PAIRS . These words are used to protect is determined by the value of the user against structural programming errors ad variable STATE which has a zero (0) described above in STRUCTURAt ERRORS. An value if the machine is in the execution explanation of each of the uses of these state and a non-zero value the machine is words is as follows: in the compilation state. !CSP ?CSP ?LOADING These words are u8ed together to check Loading is determined when the value of for changes in the stack position. the user variable BLK has a non-zero lCSP stores the current stack position in value. A value of zero for BLK id;- the user variable CSP . ?CSP compares cates that input is coming from the user's the value in CSP to the current stack terminal and that the machine is therefore position and, if they are not the same, not loading. issues a Definition Not Finished error (120). !CSP and ?CSP are currently Thj above words are defined as follows: used in : and ; respectively to ensure that all Structures in the definition have : ?EXEC STATE @ 18 ?ERROR ; been completed before the semi-colon. Any : ?COW STATE @ 01 17 ?ERROR ; structures uncompleted will leave data on : ?MADING BLK @ O= 22 ?ERROR ; the stack and thus allow ?CSP to flag the error. These words can also be used If the machine is not in the execution to check the stack effect of user defini- state when ?EXEC executes an Execution tions. For example, if a definition Only error (#18) occurs. should have no stack effect (leaves the same number of items on the stack 3s it If the machine is not in the compilation removes) the following would test this:

Page 17 FORTH DIMENSIONS III/ 1 Definition Name! error (19) is given. If !CSP cccc ?CSP a dictionary entry with a null name were created, the system would attempt to vhich would execute a definition named interpret this as the end of the current zccc and issue a Definition Not Finished buffer with unpredictable results. Crror (#20) if the number of item on the stack at the beginning and end of the ?STACK definition were different. This word checks that the parameter 'PAIRS stack is within bounds. It compares the current stack position (by executing SP@) This word is used when testing for against the base stack position in user correct structure in compiler directives variable SO to check for a stack under- 'see STRUCTURE ERRORS) to check that the flow. It also checks that there are at -slue of the two numbers on the stack is least 128 bytes of dictionary space left rie same. If the value of the two compi- (to leave tom for PAD and stack work). .stion conditionals on the stack is not If the stack underflows an Empty Stack :ie same, a Conditionals Not Paired error error (#1) is given. If the stack comes t19) occurs. ?PAIRS can be used to test within the 128 bytes of the dictionary a similar situations in user programs, but Full Stack error (#7) is given. ?STACK the error message given will be the same is not executed at runtime unless compiled 'error R19). by the programcer, though it is executed frequently during compiling and text The checks on the dictionary and stack interpretation. :onsist of testing the stack for under- flw, the dictionary and stack for over- flow, and the name of the dictionary entry to be created for uniqueness ( in A-POBTIT This definition moves text from the tnis test is optional and there is a test current input buffer to the head of the to ensure that a definition name is not dictionary. The error test performed I null). Some of the tests are performed checks that there is enough space between during the execution of other functions by the head of the dictionary and the top of the testing word (such as the tests per- the stack for the text about to be formed by WORD and by CREATE ). Only moved. If there is not enough space a the testing performed by these words vill Dictionary Full error (#2) is given. This be described here. prevents the system crashing by L from writing over its own stacks. CREATE 1 DO We NEED IT? 5 This word creates a dictionary header c €or a new word. In the process of Should we have all this security all the I creating this header a dictionary search c time? Or just when we think we need it? is performed to check that the header is Fig-FORTH currently does not give us a i' unique. The message given if a duplicate c choice on the matter. Sure, we can cow is found is Isn't Unique This is e (14). pile on top a new set of compiler direc- not a fatal error but just a warning. tives which don't have the tests, but we 7 A-FORTH allows the disabling of this test n have then already wasted all the memory (and the associated message) and performs for the secure directives, the ?xxK words, f!9 another test for a dictionary entry whose d and the lot. The reverse course I con- - name is a null. The creation of a dic- sider more appropriate. The kernel system tionary entry with a null name is not n should have as little protection as pos- allowed because the null is the name of sible. The system should not suffer the t? the entry interpreted at the end of the t overhead for those who do not desire it. disk or terminal buffers. If an attempt If security is desired, a "Novice Pro- to create a null entry is detected a Null gramer Protection" package could be

..-. 1 FORTH DIHENSIONS ILI/1 Page 18 compiled into a user's area which would NEW PRODUCTS include all the words necessary to protect him or her (and the other users) from him POLYMORPHIC FORTH NOW AVAILABLE or herself. This would allow protection even for the words such as ! (store), FILL and CMOVE when desired. FORTH is now available for the Poly- Morphic Systems SSSD 5" systems (8813 & Something as simple and extremely effec- 8810). The PolyMorphic disk operating tive as the !CSP and ?CSP in : and system has been patched in and the system : respectively may be left in the kernel is interfaced to the PolyMorphic operating system to give warning to even the best of system. PolyMorphic FORTH includes a us when necessary. Definitely, also the modified systems disk, and brief documen- stack checks at compile time and possibly tation on changes to interface to the :he uniqwmess (though it should be PolyMorphic SSSD 5" disk operating system optional) and null definition (currently -- based on 8080 Fig-FORTH. Price is A-FORTI! only) checks should be left in, $50.00. For more information contact: but the structure and state testing is iften incomplete and annoying. Anyone who Ralph E. Kenyon, Jr. as tried to write and secure a good ABSTRACT SYSTEM, EX. general CASE structure, or a BEGIN 145-103 S. Budding Avenue WHILE REPEAT loop which allows mul- Virginia Beach, VA 23452 tiple WKILEs will know what a pain it is to try to secure them in a reasonably complete fashion. For these people FORTH FOR HP83/8P85 compiler security dosn't work. Addition- 3'-ly. new structures transported from my A disk based FORTH is now available for system to another may not remain secure the HP85/HP83 personal computers. The because the same conditional pair numbers implementation is the FIG FORTH 1978 used in my structure on my system may have standard with some machine dependent util- been used in a different structure on the ities. User receives both 16k and 32k other system. Again, the compiler secur- versions with user space being 2k and 18k Ity dosn't work. respectively. Both versions require a disk. Included is an assembler, a FORTH The same method used in high level struc- decompiler and editor. This is not an HP ture testing is also used in one known supported product but available through assembler, which the author considers the user's library. FORTH, in object form totally inappropriate. If one is program- (no source), an assembler, decompiler and ming in FORTH assembler one is doing so editor, in source, are sent on a disk. for speed, which may require not being This product recoarmended for experienced structured at all. users only! Those familiar with FORTH should have no trouble using this system Currently, the matter of compiler security (i.e. there is no manual inluded). is being studied by the group writing the However, sufficient references ate next SO80 fig-FORTH version (which could given. Current cost is $50.00. For more possibly outline a new model). Should we infmmation contact Nany Reddington at have all the protection all the time, or (503) 757-3003. just some of it and a programmer protec- tion package? Or maybe there is a better alternative. Your input is wanted and FORTH PROGRAHMER AVAILABLE needed. Write to the 8080 group at FIG, PO 3ox 1105, San Carlos CA 94070 and tell 3 mos. experience with FORTH (also know '3s what you think. BASIC & COBOL) Active member of P.I.G. Contact: Martin Schaaf, PO Box 1001, Daly City, CA 94017 (415)992-4784

Page 19 FORTB DIMEXWIONS III/1 USERSTACK retrieve it when subsequently needed. Admittedly, this is an easy - lazy! -- way to achieve tranisent data storage. Peter H. Helmers But woe unto those who forgot to pop the University of Rochester return stack of this temporary data.. .! Department of Radiology Medical Center, Box 648 USER STACKS Rochester, NY 14642 The "user" stack concept allows a FORTH program to retain the convenience of an IKTRODUCTION auxiliary stack, but in such a way as to avoid mixing temporary data with execution One of the advantages of FORTH is its time return information. As an added use of a stack oriented architecture. In convenience, this concept allows creation conventional FORTH implementations, one of multiple, named, stacks which can be has available two kinds of stacks: the typed according to the number of (two return stack and the parameter stack. In byte) words per stack element. general, the return stack is used to keep track, at execution time, of the path of A user stack can be thought of as an invocation of nested FORTH words while the array (integer, double precision, or real) parameter stack is used to manipulate data of data which has implicit addressing. 3sed within and/or passed between FORTH Consider, by way of analogy, a conven- vords. tional array such as:

Unfortunately, in the real world, such a loo ODIMMY-ARRAY :lean segmentation between parameter data and execution nesting data tends to break One would store the 53rd integer element down. For example, DO... LOOPS are imple- by explicitly stating the index: mented by using the return stack to keep track of the loop count and associated 52 MY-ARRAY ! ( ZERO ORIGIN.. . data. The motivation for this violation af the sanctity of the return stack with This would take data from the top of the W...M)oP parameters is the desire to parameter stack and store it in MY- separate the DO... LOOP data from any ARRAY. Alternatively, one would access an parameters being used by the programmer integer from this array by: vithin the loop. Failure to do so would allow confusion of loop parameters with 27 MY-ARRAY @ actual user data -- causing a consequent abnormal execution of the DO.. .LOOP The disadvantage of arrays is that they arising from an unwarranted modification require both an explicit index, and an of loop parameters. explicit load (@) or store (I) operator. While an array could be used for temporary In addition to the above saving of storage of parameter stack data, such DO.. .LOOP parameters on the return stack, programing practice is not neccessarily it is not uncommon practice for a program- clear or efficient. mer to want to save some parameter stack data in order to be able to first calcu- So how does a user stack help us? :ate using data beneath it. One previous- Consider the integer user stack defined: ly employed method to do this was to cemporarily push the parameter stack data 100 STACK MY-STACK onto the return stack, and then later MY-STACK would, in this case, have a Editor's llotc: Mr. Helmers uses URTH, a size of 100 integer elements. Data can be dialect of FORTH. put into this user stack from the top of the parameter stack by:

FORTH DIMENSIONS III/1 Page 20 PUSH MY-STACK terms of a more general USTACK defining word. A line such as: while it can be retrieved back to the parameter stack by: 22 4 NSTACK WIDE-STACK

POP MY-STACK will define a 22 element stack with eight bytes (four words) per element. NSTACK Note that addressing is implicit- there has two primary parts. The firat part, are no indices - and that the direction executed when a new stack is defined, of data transfer is set by the PUSH and builds a FORTE word header, stores some POP words. stack definition parameters into the dic- tionary, and finally allocates the actual USER STACK WORDS: dictionary space for the stack, The second part, written in 8080 assembly In practice, three types of user stacks language for speed, defines the execution have proved useful; STACK, DSTACK, and time actions taken by the stack varia- FSTACK. While stack variables created by ble. Both of these defining parts will be these three defining words all use the explored in greater detail below. PUSH and POP words to save and retrieve data, the amount -- or type -- of data The format of the user stack in the pushed or popped differs. As discussed dictionary is shown in Fig. I. It con- earlier, STACK deals with integer (two sists of a normal FORTE header, followed byte) words. DSTACK consists of elements by the following four stack definition of double precision integer words (four parameters: bytes) while FSTACK elements are floating point numbers (six bytes). All three of a) current stack pointer (two bytes) these words are defined in terms of an b) #words per stack element (one byte) arbitrary n-precision NSTACK word which c) maximum stack pointer address (two allows specification of any number of two bytes) byte words per stack element. d) minimum stack pointer address (two bytes) Two other words are also useful with user stacks. There are EMPTY-STACK and ?STACK. Note that both of these cannot (presently) be used within colon #BYTES FIELD COMMENTS definitions. The line:

EMPTY-STACK MY-STACK

will, for example, reset the stack pointer for the user stack: MY-STACK so that it will be empty. Again using the MY-STACK example,

?STACK MY-STACK

will dump out the contents of the stack from the top of the stack through the bottom of the stack. ?STACK is intended purely as an aid in debugging.

IMPLEMENTATION: Figure 1 -- Dictionary Layout As was previously mentioned, STACK, for a Stack Type Variable DSTACK, and FSTACK are all defined in

Page 21 FORTH DIMENSIONS III/1 Note that the stack, consistant with the 8080 architecture, grows down in memory. Following these stack parameters is the actual stack area which is allocated in the dictionary.

The PUSH and POP words are code defini- tions (for speed) which push a 0 or -1 flag value to the top of the parameter stack. Thus, when the stack variable is subsequently executed, this flag is used to differentiate between popping from the user stack (flags01 and pushing to the user stack (flagzl). The assembly code is thus separated into two very similar exe- cution loops which move stack data one word at a time until the proper number of words for the stack element have been moved; these two loops differ only in the direction of the data transfer. In both loops, the A register contains the current word count which is intially set to the number of words per stack element and decremented each the through the loop. The BC register pair contains the current user stack pointer while the HL register pair contains the eddress of the stacks parameter field so that the new user stack pointer value may be saved after all words Llk ox within the stack element have been trans- OK ferred. OK 100 STACK WV-STXK OK 35 STACK YOUR-STACK OK OK 11 22 33 44 55 && 77 88 99 CONCLUDING REMARKS OK Pusw WY-STACK OK PUSH MY-STACK OK Pusn YOUR-STACK These user stacks have been optimized to OK pusw MY-STCICK provide rapid execution speed at the OK wsw WV-STCICK OK Pusti WV-STKK expense of high level transportability and m Pusw YOUR-STACK error checking for a stack pointer out of OK t POP WY-STACK - . -11 oc: bounds. It is felt that the concept, in OK POP VWR-STACK wp YOUR-STACK 2wP . . + . 77 33 110 ac whatever realization, is important since OK POP MY-STMK . it provides a very readable and structured 5s OK OK POP WV-STACK . method to temporarily store and sort data 66OK OK POP MY-STKK . without having to resort to such "unclean" 88m practices as using either explicitly -3 POP WV-STLICK . WOK addressed arrays or the return stack. CM It's the type of FORTH word that, once you OK OK have it, prompts the question: "it's so OK obvious, why didn't someone think of it rl( OK be fore?" OK %TACK W-STI\CK USER STACK EWPTY OK OK 11 PUSH WV-STMK 22 PVSH W-STACK ?STACK W-STMU 3A7A 0016 00OB OK Y lx EWPTV-STACK w-STACK ?STACK W-STACK USER STKK EWPTV OK OK OK OK oy

FORTH DIMENSIONS III/l Page 22 A STACK DIAGRAM UTILITY NEW PRODUCT Barry A. Cole STAND-ALONE FIG-FORTH FOR OSI 3450 Sawtelle Blvd. 1332 Los Angeles, CA 90066 FORTH Tools has announced stand-alone Fig-FORTH for all OSI mini-floppy cOm- INTRODUCTION AND CONCEPT puters that combines Fig-FORTH with stand- alone machine drivers by FORTH Tools. A year and a half ago, when I was still With this system OSI-65D is superfluous- fairly new to FORTH, I spent a lot of time with FORTH booting up directly, yet the drawing pictures of stacks as I made up disk is OS-65D compatible. programs. I crumpled them up and started over each time I changed them. As Since FORTH Tools FORTH dispenses with sections were debugged, I drew up another the OSI operating system, FORTH Tools has copy to document the code. When I found developed disk, display and keyboard an error, I would have to redraw whole drivers for the OSI hardware. series of stacks, just as a cartoonist would have to change a whole series of FORTH Tools FORTH for OSI is strictly frames. It soon became clear that I was compatible with Fig-FORTH. All words in expending time to do rather tedious the Fig model, including disk support, work. I came up with an idea for an work correctly. Portability to other automated tool to update these diagrams. machines is also claimed. I thought up a way to represent the stack data easily and an approach to implement Stand-alone FigFORTH for OSI is avail- the tool. The original implementation was able on one 5-1/4" disk for C1 (Super- done in 8080 polyFORTH by my co-worker board), C2 and C4 machines with 24K. Greg Toussaint. We collaborated in the Product includes a structured 6502 macro- initial debugging and then passed it back assembler and disk utilities designed by and forth over the next four months. FORTH Tools and the FIG portable line After nearly a year in active use, I editor. Complete technical documentation converted it to fig-FORTH and updated and the fig-FORTH glossary are also several messy areas to be more straight- included. The complete price is $49.95. forward. The results of these pursuits For more information contact: are detailed in this paper for more general consumption. FORTH Tools Box 12054 ORIGINAL IMPLEMENTATION Seattle, UA 98102 The original program was going to take push and pop information from the keyboard to generate pictures of what was on the stack. It became immediately clear that the stack could more easily be represented horizontally than down the page. We chose to put the stack to the right so that the size of the stack could be read like a bar graph. I figured that if I represented SEE THE NEE- FOR 31 YA??-- each item on the stack as an address "XS- pointing to a count and printable string, that many of the stack diagram words would be identical to the FORTH word equiva- lent. Thus, DUP, OVER, DROP as well as many other primitives would be coded before I started. Even as it was being

0.S- FIR. ?RE- THO---- IS NOT AN EMP----- OF FOR-- IX-

Page 23 FORTH DIMENSIONS III/l built, the tool grew to get the source tered, it will revert to the prompts since codes directly from disk and then to it is not known what a symbolically appro- generate a printer format spool file also priate name is for the fetched value. onto FORTH screens. Keeping track of values when an IF was encountered and Processing will terminate with an "OK" restoring them on ELSE and THEN was for sucessful completion of the screen or added. This generates a warning message colon for SDOC or PDOC, respectively. If if the two paths leave different numbers stack underflow occures, it will abort. of parameters on the stack. Finally, It is good practice to do a FORTH after an concatenation of strings for algebraic and abort condition to insure that the stack logical expressions was added. vocabulary is properly exited. A user abort is also provided. This is accom- plished by typing an escape key followed USAGE AND OPERATION by a carriage return in response to the "PUSH VALUE?" prompt. 'Ihe main mutims called by a user are: SAMPLE DIALOG screen# maefname todoamrent.1definitial scdsxx: to doamEnt a hle screen The package creates a special stack screen# pRlDoc to print fmn gitlen screen vocabulary as well as the user entry pII)c to prina: last doarmentatian points. The use of the package is best seen by example. Figure 1 is a sample The program clears the display stack dialog. Notice how little intervention is before each colon definition. A search is required and how the ELSE restores the made for the first colon on SDOC or the stack values. Figure 2 is the source that specified name following a colon on DOC. was used in the examples. Figure 3 is the The name of the function is displayed printer output as displayed by PDOC. along with the currently empty stack con- tents. It requires user input to continue since the entry conditions of the routine are unknown. It prompts "DROP?" to see FIGURE 1 how many excess elements should be dropped from the stack, A carriage return suf- fices to leave it alone. It continues 100 SDOC with the prompt "PUSH VALUE?". For each ANALY 2 E I , DROP? symbolic name of a value on the stack, a PUSH VALUE? addr free form name should be typed followed by PUSH VALUE? len a carriage return, The prompt will be PUSH VALUE? ANALY 2 E I addr len repeated until a line consisting of only a SWAP add r carriage return is typed. There are no INCH I len limitations imposed on the input, however, DROP? PUSH VALUE? char it is advised that nulls and tabs should PUSH VALUE? not be included as this will detract from INCH I len add r char the clarity of the final output. The DUP I len add r char char 7P I len addl char char 7P ?fogram will then continue reading words - I len add r char (char-7P) from the source screen and generating IF 1 len addr char 3utput lines to the console and spool DUP I len add r char chai file. OD I len add r char char OD - I len addr char (char -OD) IF I len addr char In a typical sequence, up to about a DUP I len add r char chai dozen lines will be handled without inter- OUCH I DROP? 1 vention. For example, occurences of DUP, PUSH VALUE? DROP, and numeric literals will be pro- cessed automatically. When a @ is encoun-

FORTH DIMENSIONS III/1 Page 24 FIGURE 1 (cont .) FIGURE 3

OUCH I len addr char OVER I len addr chat addr CI I len addr AUALY ZL la len 1+ I len (addr+l) SWAP I1 addr I IKB I1 addr char SWAP (addr+l) len DUP 11 ddr char char 1- I (addr+l) (lcn-1) 71 I1 add I char char 71 ELSE I len addr char - I1 add1 char (cha1-7?) I? I1 but char ( I len addr char DUP I1 add r char char DROP I len addr OD I1 ddr char char OD SWAP I addr len I1 bdd1 char (Char-OD) I? I1 ddI char DROP I add1 DUP I1 add8 char Char 20 I addr 20 OUCU il addl char OUCH I Wtl I1 CI I1 DROP? 1 1* I1 PUSH VALUE? SW I1**l) len OUCH 1 addr 1- I1ddr*ll (lcn-1) ELSE I1in addr char 0 I addr 0 ( I1in add1 char OVER I addr 0 addr DW? I1In ddr C1 I addr SWA? IIIda lcn DROP I4MI 0 I addl 0 20 I4Ids 20 THEN I addr 0 own I4Idr ELSE 0 I4Idr o ( OVSI I4MI 0 addr I 2 %%:2:: CI IIMI DROP I len addr 0 I4mt o 8 I len addr 8 ?new IIIbr 0 ELSE I1m ddr char OUCH I' ( I1in bur char DROP? 1 DY)P I1in .ddr PUSH VALUE? I I1in adds 8 oucn I1in add: OUCH I len addr 1- I1ddr-1)in (ddr-1) len 1- I len (addr-1) SUA? I1 SWAP (addr-1) len l* I(*-I) (lcn+l) I ?sell I(*-11 (l.n+l) 1+ I (addr-1) (lcn+l) I I1-1-1) Ilen+l) THEN I (addr-1) (len+l) OK I (addr-1) (lcn+l) OK

FIGURE 2

OK 100 LIST SCR I 100 0 1 f ANALYZE SWAP IYCU WP 71 - I? WP OD - I? 2 DUP OUCU OVlD CI 1* SWAP 1- I ELSE ( CRI DROP SWAP DROP 20 oucn o WLU CI o TII~ HELP WANTED 4 ELSE ( DELETE) DROP 8 Wcil 1- t*AI 1+ TllCll 1 5 6 PROGRAplpiER OK FORTH Entry Level - Will Train John Saclcis Data Breeze 2625 Butterfield Rd. Suite 112E Oakbrook, IL 60521 (312) 323-1564

Page 25 mTfi DIMENSIONS III/1 CONDITIONALS with an embedded plus sign, rather than adding the top two elements on the The IF...ELSE...THEN cons truc t stack. Also, not all operators are automatically saves and restores the stack defined. On detection of this case, the values. A mismatch in number along the diagramer must shift control to the two paths produces a warning message, operator prompt section. In polyFORTH, this was accomplished by defining a new "STK ERROR, ELSE -m THEN -n" vocabulary and having it be the only one searched. in fig-FORTH, this option is where m is the number of parameters left not directly available since the FORTH sn the stack at the end of the IF clause vocabulary is searched after the current and n is the number left when the THEN is vocabulary. This may be solved by encountered. The DROP/PUSH prompts are carefully breaking links with zero presented for the user to attempt entries, or alternatively by defining a recovery. A known cause of this message special dictionary search routine that is a -DUP preceding the IF, as this is stops at some fence value. I chose the Tot handled. latter.

SPOOLING TO DISK It wasn't obvious until the implementation began that operators would To be useful, a hard copy of the output require concatenation of their identifying without all the intermediate operator strings. It was also decided that conversation is useful. It is also quite parenthesis would be placed around each possible that a machine readable version level of expression nesting so that would be handy to facilitate distribution ambiguity could be eliminated without 3f the documentations. A spool file is rearranging expressions for precedence. generated to satisfy these requirements. This occasionally leads to expression such I! may later be displayed or printed by as ((array+2)+2). This is unavoidable ?DOC. since even the constants within the expression are treated as strings rather The spool file contains the encoded than numbers. Thus, the example cannot be screen from which the diagram was made reduced to (array+4). followed by variable length lines separated by carriage return characters. Error recovery is not nearly as good as Tl?e file is terminated by an ascii null I'd like it to be. Stack underflow in the zharacter. It resides on a set of diagraming session is generally fatal. Zonsecutive screens. The first screen and Due to the amount of bookkeeping already 2aximum number are determined by literals being done, there is no provision for -2 SPIT and PRTDOC. I use 10 screens retracting answers after wrong data has jcarting at 230. These may be copied been put on the diagram stack. This is ?!sewhere and printed by PRTDOC. Failure inconvenient in a first pass through a to copy them will cause the listing to be function, but has not proved to be a l2st the next time a function or screen is problem once a feel for the tool and the i L ag rannned . function being diagramed has been acquired. lUPLEMENTATION PROBLEMS AND SOLUTIONS Provision is left for user defined It is important not to search the functions in the last two screens of the standard vocabularies when diagramming diagram source. This allows commonly used scacks. This is because actions are functions to be handled in an automated irfferent for the same name, depending fashion. This makes it very easy to :?on state. By way of example, for the define composite functions such as, 1- as -3erator + must concatenate the symbolic the sum of its component parts. For out- :ame strings representing these elements side of functions, constant and variable

FORTH DIMENSIONS III/1 Page 26 have been redefined to put their own name :LN Line number being printed. Used on the stack. Before this facility was for page headings. added, I always retyped the variable name :sc Current screen number being manually when it came up. spooled.

The spool function and some of the IFPTR The address of top of IF stack. source reading routines such DOC assume Used to restore values on stack for that screen blocks are contiguous 1,024 IF...ELSE...THEN construct. byte areas. Those functions using BLOCK will have to be rewritten if this is not IFST The area reserved for pointers to the case in your system. I recomaend that previous stack contents. It is used to you instead generate a new system with lk restore the stack on ELSE and THEN buffers as that is faster and more clauses. flexible. SPL A temporary variable used by :NFD WEAKNESSES AND PROPOSED FUTURE EXTENSIONS to retreat the spool file to erase the unknown stack prior to operator specifi- The diagrammer presently does not keep cation of what is added or dropped. track of the contents of the return stack. This requires uses of R) and I go' SPOOL Offset into spooled print file. to the operator for clarification. Try a pencil for now. This could be added in a SUM The sum of differences in two similar fashion as IF..ELSE..THEN by an strings. Used in -TEXT. Value is 0 for a additional stack. text match and nonzero if different.

The area of error recovery is ripe for T1 Pointer to current input word in suggestions. Perhaps some dummy buffer memory (type format). area could be added and tested in PSTAK. This would allow detection prior to CONSTANTS destruction on stack underflow. Backing up by reading backwards would be nice but UIHIT The limit address for dictionary also very difficult to implement. search to keep fram using standard FORTH words from within the STACK diagrammed words. CONCLUSION FUNCTIONS Now that the tool has been built, its real function is more evident. It is --- 'FIND pfa length true (found) still used for documenting words as origi- nally intended, however, its primary usage -- 'FIND false (not found) is debugging and validating code. It has also proved to be very useful as a This is the same as -FIND except that teaching aid to explain what is going on the true condition is set only if the work within the stack. I hope it will be as is found above LLIHIT. This restricts the useful to you as it has been to me. search to stack vocabulary words.

--- ( '(' A STACK DIAGRAM GLOSSARY A string constant used for building VARIABLES expressions when arithmetic or logical operations are encountered in the dia- :BK The base block number for spooled gramed input string. stack diagram.

Page 27 FORTH DIMENSIONS III/1 Defined back to its original state Removes and discards the top of the after being used as a concatenation token, IFST. this marks the beginning of a comment. --- :N"D addr All text following it is ignored until the next 1 . This is called when the wrd being analyzed is not in the special stack Tests two strings for not equal. vocabulary. It checks for valid numbers. If this test is passed, it returns a pointer to that string. Otherwise, it invokes SKBD to get user A string constant used for building help. expressions when arithmetic or logical operations are encountered in the dia- adr :PSH --- gramed input string. Pushes the address of a level of the stl st2 -TEXT cond stack values onto the separate IF stack. This is used for IF..ELSE..THEN stack True if the two strings differ. restoration and checking.

va 1 1- Val-1 adr :RST ell el2 etc

Decrements the top of stack value by Restores the stack from the IFST one. stack. Does not affect the IFST.

vl ~2 2DROP -- adr :sAv --

Drops the top 2 elements off the Saves current stack element list on stack and discards them. the IFST. Does not affect the parameter stack. --- :SP -- This is the stack diagram redefinition of colon. It diagrams the Marks the end of the spool file with word following it instead of compiling. a zero.

It is invoked by colon as the very adr ?NUM cond last definition from within this package. Checks current word to determine stl st2 :c st3 whether it qualifies as a legal hexadecimal number. Concatenates two strings into a single combined string. It is used to --- CONSTANT --- build expressions when operators are en- countered in the screen to be diagramed. A defining word which causes the name of the defined word to be put on the stack --- :HEAD -- when that word is encountered.

Prints the header for a line of --- DEPTH depth output to the console and also the spool file. Computes the depth of the stack in it-. --- :KILL -- scri M)c _--

FORTH DIHENSIONS III/1 Page 28 Searches for a colon followed by the compile time of the stack diagram package. word whose name follows this invocation on the specified screen. It aborts if the definition is not on the specified screen. Otherwise, it comences to gen- A defining word for building strings erate the diagram for the word specified. into the dictionary at compile time of the stack package. On invocation of the new --- ELSE ell el2 etc word, the address of the string displaying its own name is put on the stack. The Clears the stack and then restores it word that follows GWRD is read twice at from IFST. compile time, once for the name of the function, and a second time to be placed --- ESC --- in string format into the dictionary. This is used to build up constant words Aborts the package if an escape key for the diagraming package. was the first key pressed in answer to the "PUSH?" prompt. The vocabulary reverts to cond IF --- FORTH; however, the stack diagram packape is still loaded and ready to go. Drops the condition flag from the top of the stack without evaluating it. It --- G-HERE adr cond then invokes :SAV for ELSE restoration and THEN error checking. Moves a string from PAD into the dic- tionary. It allots the space and leaves adr cnt MTYP the address of the item and a true cond if successful. It leaves only a false cond Types the message to the screen and if no valid string was found. also passes the parameters to STYP for spooling. expr G ( 1) op(expr 1 src dst Zen MVB dst len src+l src Builds an expression from a simpler expression. At execution time of the Intermediate function to set up fur following word, the top of the stack is ma. enclosed in parenthesis and preceded by the operation symbol. It is used for arc dst delim MVDEL adr unary operations. eg. -(name) Move a string frm the source to the expr G(2) op(expr) destination address until the specified delimiter is encountered. This is used to Similar to G(1) except that uuary build data strings within the dictionary. operation is also enclosed within the parenthesis. eg. (name*2)

espr G(3) op(expr) Prints the latest generated diagram from the default spool file blocks. Similar to G(1) except that binary operation is also enclosed within the --- PHDG --- parenthesis. eg. (vall+val2) Prints the top of page heading and inadr GBLD --- sets the lines per page count. Used by PRTDOC . An auxiliary word used to build a named string in the dictionary from the blk# PRTDOC --- word following GBLD. This is used at

Page 29 FORTA DlHENSIONS I11 1 1 Prints the stack diagram from the Similar to TYPE but spools to disk spool file whose starting block is the rather than typing to the screen. Outputs specif ied blk# . an additional two blanks after the message.

I adr T; cond ! Prints all words from the string I Tests the current string for a match r addresses on the stack. The top element :s printed to the right of previous to the FORTE word semicolon. This is used ! elements. The stack is unchanged. to exit DOC.

! adr cnt PWRD -- - THEN -- 1 -- Prints one word via Used by Re-defined in the dtack vocabulary, I MTYP. ?STAK. this cleans up the IFST. If the depth of the stack has changed from before the --- REPEAT --- ELSE, it issues a warning and calls SKBD to allow the user to correct a stack depth Functionally identical to the re- disparrity between the IF and ELSE > defined THEN. clauses. i scr# SCRST scr# --- VARIABLE --

Resets the spool pointer and places A defining word which causes the name the screen number into the beginning of of the defined word to be put on the stack :he output spool to be used in top of page when that word is encountered. 1 ieadets by PDOC.

I02 ILILO SCI * 102 0 ( staer diagram p.oka#a 1 Or 14 b. A. @I* 81032b) Documents me whole screen by exe- I cuting it, using the diagram definitions. r a Callin8 n uenees. scram & aerniu 1 sormen S#K 8 rmc 9 I0 OUC builds atmk dlasru ror one ddinitlon. 11 SOW build8 stack diaurau ror entire 8cre.n. This scans the keyboard for user I2 ?OW prints staok diasru built by WX: or SWC. Lnteraction. It generates the and 2 "DROP?" I5 2 "PUSH VALUE?" prompts. It is invoked d SCI * shenever intervention is required in the O( 3 .. I0 :lagramming process. 20 30 10 so char SPIT --- 60 70VAIIIBLC 1% 80 VLIIABLI Irm 90 VARIIBLC IfST 20 ALLOT Writes character out to disk spool 10 :PSI IWrR I -. 11 --> 5 -.- 7le. I2 :f -- STACK --- 15

This is the name of the vocabulary d :mtaining this package. P adr cnt STYP -- -

- PORTEl DIMENSIONS III/1 Page 30 '1 12 13 --> 1Y 15

SCR 4 IOb atmek aiwyrwm packm#e 5 or la b. ! 7YII DU? 1. C? 85 I + BEGIN 1. DU? C? 16 DIGIT W:LE DROP REPEAT C? 32 * ; 8 :HEAD CR 13 SP:? 10 SP:T DUP 5 COUN? 10 M:N SWAP OVER MT?? I1 6 SWAP - 0 Do 32 SPIT SPLcg LOO?

111 TRIAD I3 IF HERE CI LLLOt I" ELSE 2DROP 20ROP C ??EN ' scn I 111 is : ESC PAD cc 27 rst ABWT tmcn ; 1 --> IF . - O( 8UCk 4la#r.m pack.#& 10 Of 14 8. A. C01. 8 10425) 11 rPSH 2 IFPTR +I IPPTR @ I ; 21 :SAV HERE :PSH SPC DEPTH 1 - DUP , 3 DUP + HERE SUP OUP ALLOT cnove ; I::RST IFPTR c e DUP c DUP 2 ROT .SYAP -DUP IF 2 5 0 DO DUP @ SYAP 2 - LOOP THEN DROP 3 SKBD CR :DROP1 - xer WP cn~? < mcmn ~lwTor aroo.vu8Mw) 61IKILL -2 IPPTW +I ; 1: @8 DUP 9 < 1011 STACK DEFINITIWS LLIHIT I 5 IF DEPTH 1 - MIN 0 W MOP LOOP 7 nene . 6 ELSE DROP TUEW 8 ' BEGIN 3R .' PUSH VALUE? PAD 80 9 --> 8 EXPECf ESC G-ULRE 0. END ; 10 11 10 : :NFD fl @ l#UM ( nmnah wrd mt round) 12 11 :f 71 ? ( number) 12 ELSE SXDD SPWL @ SPL I ( un6.flnea) 13 Tl @ :HEAD DROP SIL ? SPOOL I TUEM ; ;: IY --> 15

i I TH~WDEPTH 1wtn c e I+ ce -DUP 3 IF 128 - 2DUP - 4 IF CR .. STK ERROR. ELSE -* . 5 .* THEN -" . SKBD 6 ese ZDROP THEN T ate MOP THEY :KILL ; 8 i : EWE DEPTH 128 + >n SPI :is n> Iwtn e e I+ CI ; 10 11 : IF WOP :SAV ; FOwTH DtlINITIOHS --> 12 13 14 15

scn # 113 0 ( *tack 41a#rm paCka8. 12 of lil B. A. Cole 810326) I : GILD IN I 32 YM~D ncnt cc I+ ALLOT ; 2 : CURD IN @ (BUILDS CBLD DOES> . CURD ) CYiD ( 5 I G(1) IN e SYAP ( SYAP :C :C ; Q 8 C(2) IN @ rC IC ( SUP :C 9 I C(3) IN C (BUILDS OBLD 10 DOES> SYAP 1 :C 1C 1C ( SYAP 1C 11 i ( 41 WORD : IHHEDIATE --> . PktDoc DUP :&K I BLMKe ( print aiaeram fro. *we mcr) : :sc I PHDC 10280 2 Do 12 ' ~ 1028 /MOD :DK ? BLOCK + V -DUI 13 5 :F ?UP EMIT 10 r 14 .F :Ln ? 1 - DUP :LN I 0. 15 0 :r PUDc ?UEY tncn 3 ELSE LEAVE THEN LWP : .a*** from: Barry A. -1. Lor An#elem. CA 13-390-3851 '1 PDL 130 PR?DoC , OK *. __,

Page 31 PORTR DIMENSIONS IfI/1 FORTH CLASS

TklID Date: June 22 - 26

w # 114 G ( *tack dla#raB paCkA#a 13 Of 84 b. 1. COlO Ul0125) I Where: Humbolt State University 2 STACK DEFIlrTIONS : 32 YOID mane DUP w I. ALLOT ; Arcata, CA 95521 : DUP DUP ; : ROT ROT ; I sur SUP ; I own OIU ; . ' I>DROP . : MOP MO? ' I . MOP i I HEX ME1 . I (wo i b 1 DECIMAL D~CIM~L; 1 zour ziur ; : I mor nor ; : tr I ".I 1; I MO? ; I SIlCL i 11; I\; who : Kim Harris and Henry Laxen 8 I 21 I MOP : : 'i DUO? i : ALLOT MOP ; I SLlNl I i 9 : C. MOP ; : W I . I DUMP I ; I EMIT DlO? i : -DUI DU? i 10 : CUD DROP ; : enisc'i ; I +LOOP DIOP i : /LOOP om01 i I1 : EXPECT I ; : MOVE I DlO? . I LEAVE ' What: Intensive 5-day course on the use 12 i SPACES MO? ; : TYPE I ; I &GIN ; I LOO) i : \ ; i Q i 13 : uow men ; I IePelT inti : I umexr i of FORTH I* I AGAII ; : UNTIL I ; 15 --> Cost: $100 - $140 plus room and board

How: Call Prof. Ron Zammit (707) 826-3275

I>.? MMS-FORTH FOR STRINGY FLOPPIES I1 : ;S OUIT ; : --> OUIT i .. 3; WID i I I I1 i 12 rMTH M~lNITIo*S iS 13 I. .I Kalth Microsystems will make available to all licensed MMS-FORTH users a modified S'L S'L 0 110 version that runs on the TRS-80 with an 2 EXATRON stringy floppy. This modification is said to make MMS-FORTH operate as it would on a disk except for the speed. Users retain the capability to switch back to cassette operation with a single cow mand. Implementation includes the normal readlwrite block commands plus a number of new utility words. The modification is available on ESF wafer for $14.95 includ- ing shipping. For more information coatac t :

Kalman Fejes KALTH MICROSYSTEMS P.O. Box 5457,,Station F Ottawa, Ontario K2C 351 Canada

PORTH DIHENSIONS III/l Page 32 How to form a FIG Chapter: Massachusetts 3rd Wed MMSFORTH Users Group, 7:OO 1. You decide on a time and place for p.m., Cochituate, MA. Call the first meeting in your area. Dick Miller at (617) 653-6136 (Allow about 8 weeks for steps 2 for site. and 3.) Seattle Chuck Pliske or Dwight 2. Send to FIG in San Carlos, CA a Vandenburg at (206) 542-76111. meeting announcement on one side of 8-1/2 x 11 paper (one copy is Potomac Paul van der Eijk at (703) enough). Also send list of ZIP 354-7443 or Joel Shprentz at numbers that you want mailed to (703) 437-9218. (use first three digits if it works for you). Tulsa Art Gorski at (918) 743-0113.

3. FIG will print, address and mail Texas Jeff Lewis at (713) 719-3320 to members with the ZIP'S you want or John Earls at (214) 661- from San Carlos, CA. 2928 or Dwayne Gustaus at (817) 387-6976. John Hastings 4. When you've had your first meeting (512) 835-1918. with 5 or more attendees then FIG will provide you with names in your area. You have to tell us Phoenix Peter Bates at (602) 996-8398. when you have 5 or more. Northern Ca 1i f orn ia 4th Sat FIG Monthly Meeting, 1:OO New York Tam Jung at (212) 746-4062. p.m., at Southland Shopping Ctr., Hayward, CA. Fom Detroit Dean Vieau at (313) 493-5105. Workshop at 10 :00 a.m. England FORTH Interest Croup, c/o 38, Southern California Wors ley Road, Fr irnley , Los Angeles Camberley, Surrey, GU16 5AU, 4th Sat FIG Meeting, 11:OO a.m., Eng1 and Allstate Savings, 8800 So. Sepulveda, L.A. Call Phillip Japan Mr. Okada, Presdient, ASR Wasson, (213) 649-1428. Corp. Int'l, 3-15-8, Nishi- Shimbashi Manato-ku, Tokyo, Orange County Japan. 3rd Sat FIG Meeting, 12:OO noon, Fullerton Savings, 18020 Canada Brockhorst, Fountain Valley, Quebec Gilles Paillard at (418) 871- CA. (714) 896-2016. 1960.

San Diego West Germany Wolf Gervert, Roter Hahn Thur FIG Meeting, 12:OO noon. Call 29, D-2 Hamburg 72, West Guy Kelly at (714) 268-3100, Germany, (040) 644-3985. x 4784 for site. Publishers Note:

Please send notes (and reports) about your meetings.

Page 33 FORTH DIMENSIONS III/1 FORTH OlmEnSIUflS

FORTH INTEREST GROUP Volume Ill P.O. Box 1 105 Number 2 San Carlos, CA 94070 Price $2.50

35 Letters

40 Technotes

45 Data Base Design

53 Increasing Disk Access Speed

54 Music Generation

57 Dictionary Searches

58 Tracing : Definitions

59 FORTH, Inc. News

60 FORTH Vendors

61 Decompiler

66 C hapters/Meetings EDITOR’S COLUMN

The feedback on our new applications editorial policy is all positive. To date, we are receiving a nice Published by Forth Interest Group variety of articles. I want to urge our members not to slack off. In order to keep up a steady flow of quality Volume Ill No. 2 July/August 1981 output. we need quality input-IN QUANTITY If you have an article you have been meaning to Publisher ROY C. Martens write. please get it down and send it in. If you havr an C. J. Street Editor application. programming trick or tool that you have found useful, please share it with our members Editorial Review Board Remember: YOU DON’T HAVE TO BE A WRITER-our staff is set up to help you with whatever you need to Bill Ragsdale make your idea publishable. Dave Boulton Kim Harris Please send all submissions to: John James Editor Dave Kilbridge FORTH DIMENSIONS Henry Laxen P.O. Box 1105 George Maverick San Carlos, CA 94070 Bob Smith John Bumgarner HEX is back this month, and there are photos of the Bob Berkey Rochester Conference courtesy of George W. Shaw. 11. We are always looking for photos (black and white or FORTH DIMENSIONS solicits editorial material, color prints preferred) and cartoon ideas, too. comments and letters. No responsibility is assumed for Starting next edition, FORTH DIMENSIONS will accuracy of material submitted. ALL MATERIAL have a marketing column in a question and answer PUBLISHED BY THE FORTH INTEREST GROUP IN IS format. If you have had ideas, programs, etc.. that you THE PUBLIC DOMAIN. Information in FORTH wondered how to sell, this column will be for you. DIMENSIONS may be reproduced with credit given to Please direct your marketing questions to the above the author and the Forth Interest Grouo. address. Ouestions of general interest will be an- swered in this column by experts chosen for their Subscription to FORTH DIMENSIONS is free with knowledge of marketing and computer hardware and membership in the Forth Interest Group at 515.00 per software. year ($27.00 foreign air). For membership, change of address and/or to submit material, the address is: C. J. Street Editor Forth Interest Group P.O. Box 1105 San Carlos, CA 94070 PUBLISHER’S COLUMN Lots of good news! The reaction to the application orientation of FORTH DIMENSIONS has been very positive. Thanks to our editor, Carl Street. The more HISTORICAL PERSPECTIVE articles you send Carl, the closer we come to being able to go monthly. Our plans are to make FORTH FORTH was created by Mr. Charles H. Moore In DIMENSIONS more general interest and publish high 1969 at the National Radio Astronomy Observatory, level (sic) technical material twice a year, ala. 1980 Charlottesville. VA. It was created out of dissatisfaction FORML Proceedings. with available programming tools. especially for obser- vatory automation. Plans for the 1981 FORML (FORTH Modification Laboratory) Conference are underway. Refer to page Mr Moore and several associates formed FORTH, 63 for more details. The FIG National Convention will Inc in 1973 for the purpose of licensing and support of be on Saturday, November 28th in the San Francisco the FORTH Operating System and Programming Lan- Bay Area. Make your plans. guage. and to supply application programming to meet customers’ unique requirements. Now, some bad news! We have to raise some of our prices. It’s been a couple of years since we’ve done The Forth Interest Group is centered in Northern any price adjusting and cost increases have caught up California. Our membership is over 2,400 worldwide. It with us. The order form on the last page reflects the was formed in 1978 by FORTH programmers to encour- new costs which arenow in effect Sorry, we’ll do our age use of the language by the interchange of ideas best to hold the line. through seminars and publications. Roy Martens

Page 34 FORTH DIMENSIONS III/2 ing and debugging, I found that the program was looping through INTERPRET, and each time the parameter stack had an extra 3ear FIG, value on it. Eventually, I found the bug; it was in the ENCLOSE routine and the Please find enclosed two short articles problem is that only an 8 bit counter is i.:?ich might be suitable for publication in used to hold the offset into the buffer. F3RTH DIMENSIONS. However, the Micropolis sectors are 256 bytes and so are my Forth Disc Buffers. I did not ask for the publication kit, If there are any non-delimiter characters 13 I hope the articles do not violate your in a buffer, then all works OK. However, rjles too much. Second, my native lan- if the buffer holds 256 blanks, then the gaage is not English but Dutch, so forgive loop around ENCLl scans to the end of the 3e if there are any errors and feel free buffer but the 8 Bit offset ends up 13 correct them. pointing at the start of the buffer still an INTERPRET never gets to to see the NULL Please note my new telephone number and at the end of the buffer. Obviously, the rarrect it in your listing of local FIG routine works OK for CPM 128 Byte Sectors, r5apters. but needs modifying for larger capacity sectors. We have not had many meetings lately, :robably because our members are too I have included the source listing for a: t ive ! ENCLOSE as modified by me (sorry, I haven't got my printer going yet). I have Paul van der Eijk used the DE register pair for the offset 5480 Wisconsin Avenue 11128 counter and have kept the definition Chevy Chase, MD 20015 character in the Accumulator which means (301) 656-2772 pushing and popping it when it is neces- sary to check for a HULL. Thank you for your articles, Paul. leaders can find them under the appli- I hope you find this of interest and rations area of this issde.--ed. maybe you will include a change of this sort in future versions. I learned a great deal from this problem, and it was )car FIG, probably to my advantage that it occurred, as my only prior information was the I recently purchased a listing of fig- 'FORTH' BYTE. I really learned the hard .?3RTH for the 8080 from you and I am v+ry way. lnpressed with the Language package. You -+ill find enclosed an order and Bank Draft William D. Miles fx several books which I eagerly await. P. 0. BOX 225 I received my Dual Micropolis Mod I1 Disk Red Cliffs :rives only two weeks ago and my first Victoria, 3496 Groject was to assemble FORTH. The disk Australia -3terface routines were quite easy to link ZJ the Micropolis DOS using ideas €tom the Thank you for your contribution. 3?n interface supplied. However, when I NOTE: You will find Mr. Miles' bug fix in iried to LOAD a short word definition off the TECHNOTES, BUGS 6 FIXES section of I screen the system would lock up and not this issue.--ed. :me back with any error messages or the ' 3K' ; because the system would compile DON'T MISS OUT! GET YOUR PAPER IN Irxds from the keyboard and the Disk 1/0 ?orked well, I was puzzled as to why there EARCY FOR THE FORML CONFERENCE! ias a problem. After four days of search-

FORTH DIMENSIONS III/2 Page 35 Dear FIG, ducing errors are ever present. I'm sure that you catch most of them. Could you print my address in your next FORTH DIMENSIONS issue: I would like to Robert 1. Demrow hear from other Belgian FORTH-ists! P. 0. Box 158 BLUE STA. Andover, MA 01810 Hichel Dessaintes Rue de Zualart 64 Thank you for your thoughts. Glad you n B 5810 Suarlee like our new approach. John James SEARCH & Begium is in a previous issue. Regarding errors, ? we do try to minimize them; but we are k OK, Hichel, start watching your mail only human. --ed. PI box! --ed. 1) 1, Dear FIG, Dear FIG, During September of 1980, material was Congratulations on your last issue ordered which included hard copy of (Vol. 11, No. 6). It's nice to see some figFORTH for the Motorola 6802 (6809 tutorial inputs at a level that beginners preferred) CPU, and FIG membership for a like me can understand. Keep it up! year. Hard copy received was Talbot Microsystems -1.1.1. 6809 FORTH. After a Would you please print the SEARCH considerable amount of study, and a cow routine mentioned in John James' article plete rewrite, that software is now up and on page 165 of Vol. 11, No. 6. It appar- running, apparently as designed. (No ently got replaced by the correction operating bugs have been detected, but it notice at the bottom of the page. would be reasonable to expect bugs to appear far into the future.) Some general I was interested in trying EDGAR 8. comments on the system may be of interest. FEY'S FEDIT in Vol. 11, No. 5? but was stumped by the word REPL which was not A major factor in the acquistion of defined. Is it possible MR. FEY could this software was the indicated ability to provide the definition? (Also, I noted run high level software on a small sys- that SCR#67 errors at line 48 -B/BUD - tem. If the Talbot software is designed which apparently is supposed to be for a microsystem, then I must have a B/BUF.) Screens should be required to be nano-system by definition; a disk would loadable, not edited by publisher or cost far more than all hardware currently author without loading edited version. in use, and appears quite unrealistic for this home hobby system. The alternative In respect to editing, please also note cassette is implemented, but patience that Major Selzer's article in the Vol. would be strained beyond limits if nearly 11, NO. 3 issue on page 83, SCR#200 line 8 8K words were loaded for each use at 300 should apparently be 08 CASE for left baud. Thus, my system clearly demands use cursoi as opposed to OB as printed, since of EPROMs for source code. OB is used for UP cursor. This screen does work when above mentioned change is I have used several methods of code made. reduction.

I realize that submitted copy may need . 1. A short branch to several copies of to be retyped but the dangers of intro- NEXT.

2. Place the user area in the direct pad.

Page 36 FORTH DIMENSIONS f11/2 1 3. Add a byte literal as well as LIT. ful constructs. An acquaintance has installed a cut-dm version on a 5K KIM 4. Some high level routines are with ASCII keyboard and walking "times- shorter in code. square'' display on the KIM LED'S. There is no question that we would be more The end result of this process was code comfortable in the hardware environment retaining nearly all of Mr. Talbot's word you define, but compared to Tiny-Basic, iefinitions, and fitting easily in 6K for example, these minimal FORTH' s are 5ytes (3 2716's). There is very little heaven. jenchmark information available (this vould make a worthwhile FORTH DIMENSIONS I found the same bugs in the May 1980 article), but those found generally ran in 6502-version of fig-FORTH that Grotke and :I2 the time cited for the APPLE. McCarthy have already reported. In addi- tion, I would warn prospective installers A. R. Gunion that the TRACE routine depends on the 182 Minuteman Drive output routines preserving the Y-register, Concord, MA and that the MON routine is not quite correct. Since the 6502-processor incre- The real definitions of nano and micro ments the program counter by two when BRK 9s applied to systems vary with each instruction is executed, BRK should be Lser. Suffice to say that FORTH is by followed by a NOP to ensure that a simple :efinition a disk based system. If you do machine-language monitor will return to xt have a disk then you are compromising the start of the IDX XSAVE instruction. 3n an area vital to obtaining the real mtential of the system. My system now includes a 320x200 dot raster-scan display, and I am interested Regarding benchmarking, it has always in corresponding with others concerning 5een the position of FORTH DIMENSIONS that FORTH-based graphics processors. :he nature of FORTH makes benchmarks more 2f an indication of the speed of a CPU Kent A. Reed :ian any particular system and we gener- 49 Midline Court a!ly .. do not publish them. This has been Gaithersburg, HD 20760 Zrscussed at length in previous edi- :ions.--ed. The point of the "Open Response" was not to condemn anyone's system; rather to 3ear FIG, point out that FORTH is derigned to be used with a disk. Naturally, the nature While 1 cannot disagree with the intent of FORTH means that it will perform (and =f "An Open Response" in FORTH DIMENSIONS, outperform other languages) regardless of .,.ol. 11, No. 6, concerning the hardware the environment. Your "bug" comments are requirements for FORTH, I feel you may appreciated.--ed. !iscourage some with the categorical qtatements you made. It is possible to accomplish a great deal with much less Dear FIG, :han you described. I hand-installed the 5502-verison of fig-FORTH on a homebrew, In bringing up the 6502 Assembly Source KIM-based system that had only 8K of RAM listing on my Rockwell System 65, I and traditional cassette-storage. My encountered a problem involving writing or "terminal" was a memory-mapped 16-line by reading the disk drives. The symptoms 32-character display with ASCII key- involved setting an 01 error everytime the 3oard. This minimal system has given me disk was asked to jump to the next track. louts of pleasure and practical experience vith FORTH, and because of the concise The problem turns out to be hardware 2ature of FORTH has been capable of power- and only exists on a Sys 65 with Pertec

FORTH DIMENSIONS fII/2 Page 37 model FD200 drives. The fix is simple and into "Basic FORTH" vocabulary. Certainly, is detailed in Rockwell Service Bulletin more advanced words are useful and should 'SYSTEM 65-7' which may be obtained by be published and documented, and are, of writing: course, part of the FORTH vocabulary by definition. Any standards, however, Rodger Doerr should be kept very simple. Enough. SYSTEM 65 Customer Service Dept. ROCKWEU INTERNATIONAL. Don Latham Microelectronic Devices Six Mile Road P. 0. BOX 3669 Huaon, MT 59846 Anaheim, CA 92803 OK interested members, drop him a (Or call Rodger at (714) 632-2862.) line.--ed.

I hope that this information can be helpful to other individuals who are Dear FIG, working with FORTH on the SYS 65. This letter is in response to C. A. Jack Haller HcCarthy's letter in FORTH DIMENSIONS, 230 Mechanic St. Vol. I1 No. 6 concerning the errors he Boonton, NJ 07005 listed:

Thank you--1 am sure you have saved Page 0061 more than one frustrated progrmer a few sleepless nights.--ed. Yes, there should be a SEMIS at the end of the UPDATE.

Dear FIG, Page 0064

Enclosed is $12.00 (now $15.00--Pub.) I haven't hooked up disks to FORTH yet, for another year of FORTH DIMENSIONS. I so I didn't notice this one, but I have FORTH up on 2 KIM'S (Dean's version) agree that the displacement in line and a Superbrain; although my "playtime" 3075 ir wrong. is limited, I enjoy tinkering very much. It might amuse you and Mr. Moore to know Page 0067 that one of the systems is going to control a 10' dish radiotelescope which I I dropped one of the STX XSAVE's also use for looking at thunderstorms. without ill effect.

I am slowly getting together parts of a Page 0069 Western Digital-based computer. Their p- code chip is a natural for FORTH--almost The extra SEMIS is superfluous, but all primitives are single instructions. will not have any harmful effect. This is a very long-term project and, no doubt, someone will beat me to it, but it I did find another error in the needs doing. Please pass this on to any- listing. This one, rather than being a one who might be interested. I would be typo, appears to be an error in program glad to correspond with them. logic.

As a long-time but not prolific user of Page 0017, lines 0803-0805. The listing FORTH, I'd like to put in my buck's (in- for routine ZERO shows: flated two bits') worth: KISS-- this acronym is keep it simple, stupid. In other words, let's not get too many words

Page 38 FORTH DIMENSIONS 11f/2 LDA 0,X ence to key in definitions, clear, ORA l,x compact, and (CR/LF), to be able to use STY 1,X them. Quite a kick!

Since Y contains 0 at this point, the Calle Hogard zero flag in the processor status register will always be set by the STY inetruc- Glad to hear things are moving ahead.-- tion. Therefore, the branch which follows ed. will never be taken, resulting in a logi- cal "false" value always being left on top of the stack. I replaced the above code Dear FIG, vith the following: Response to "An Open Response". LDA l,X STY l,x I object strongly to the tone of the ORA 0,x above (unsigned) article in Vol. 11, No. 6. It is the attitude of the 'computer This causes the processor status to be professional' with access to a large, all set properly to indicate whether the top singing, all dancing computer looking down stack entry is a zero or not. I know of his/her nose at the pathetic squirmings of no other errors in the listing. the buff. If thin attitude had prevailed, there would be no cheap Steve Wheeler computers. As it is, a lot of harm is 504 Elmira still done by designers making their small Aurora, CO 80010 computer systems in the image of large computer systems instead of making them Thank you for passing along the like super calculators. above.--ed. Like many others, I first became interested in FORTH via the August '80 :,ear FIG, issue of BYTE. One thing that attracted me was the idea that here was a high level A little note about changes in the language which could be used over the situation in NW Europe. During the second whole range of hardvare. There are ialf of March, there was an exhibition in obvious resemblances between the FORTH and VLlroo (close to Copenhagen) - "Datacraft the HP programmable calculator languages 5 1'' (Computer power-81). and it is reported that FORTH or similar languages are used in hand-held language Up until then, FORTH was very difficult translators and in one of the hand-held 12 get in touch with here in Sweden. To computers. Compare the editorial and, p~ great astonishment, there were at least more specifically, Charles Moore's -. perhaps 6, systems running in different "Characteristics of a FORTH Computer" 3x1s. The most interesting one was a (p.88) in that BYTE issue with your "Open ;cly-FORTH system running on an ABC-80 (a Response". FORTH is a language in which 5v 2-80 lowend machine). There were also the user is allowed unparalleled FORTH'S running realtime setups on freedom. Please do not insult us by 'IT'S. drawing arbitrary limits which will in any case be out of date in a short time. To me, who had up until then been 'dry- swimming ' FORTH, it was quite an experi- I will agree that a quart cannot usu- ally be fitted in a pint pot. Solution: devise a means of listing the glossary in such a way that for any word, the indirectly referenced words underlying it

FORTH DIMENSIONS III/2 Page 39 can be read. The answer to those wishing TECHNOTES, BUGS, FIXES to devise minimum systems would then be c "go away and get on with it!" Remember that necessity is the mother of invention TIPS ON BRINGING UP 8080 Fig-FORTH and the professionals are those who carry t Ted Shapin on in the wake of the amateurs-- like a Elsinore Aenue Einstein--to name but one. 5110 E. t Orange, CA 92669 L N.E.H. Feilden t 47 London Road Halesworth Some of the "gotchae" I ran into in Sufolk IP19 8LR bringing up 8080 Fig-FORTX may be helpful I to others. England C l P.S. Number typing (e.g., Fixed, Make sure your assembler Will handle floating, double, quad precision, etc.) lines such as DW A,B-$ correctly. The Surely, all this business of having Boston Systems Office cross-assemblers use hundreds of different numbers types is the address of the first operand as the silly, cumbersome, and FORTRAN-like. value for "$" in the second operand. This leads to a system that will print out the a Why not forget the whole scheme and do sign-on message but will fail to perform it like BASE. That is to say, have a many other operations correctly. I got 1 constant, say NTYPE which tells all opera- around this by changing such occurrences tors how many bytes to operate on and to two separate lines: DW A and DW B-$. whether fixed or floating. It would, of course, be necessary to code all constants The next problem to solve is how to I and variables in the same way so that when type in the editor screens. It ie nearly referenced, the appropriate conversions impossible to type the editor in twice would be done. If this were done in Correctly. As R. Allyn Saroyan pointed linked lists, then the memory overhead out, you only need to type in a mini- would be very small. The whole thing editor twice. Once, to get it in the would be vastly easier to use than what is dictionary so you can use it, and again, I currently proposed. This suggestion would to get it to a screen so you can put in on help to reduce the number of words to disk. The mini-editor is simply taken remember. from the implementation model editor screens as follows: Sounds like you have some interesting and creative approaches to problem HEX : TEXT HERE C/L 1+ BLANI(S WORD HERE solving. You might be interested to know PAD C/L 1+ CMOVE ; that the author of "Open Response" works on a home size computer. I am sure that : LINE MIP FFF0 AND 17 ?ERROR SCR @ no offense was meant and if the author of (LINJ3) DROP ; "Oper Response" would like to answer in this space or another column, we will be : -WVE LINE C/L CmlVE UPDATE ; glad to print it.--ed. : P 1 TEXT PAD 1+ SWAP -Mom ; HELP WANTED DECIMAL Los Angeles Area FORTH PROGRAMMER WANTED -- Contact Linda Stoffer at Pace Now, proceed tQ u8e it to write itself Personnel, (213) 788-7039. to the disk. You can do this by picking an unused screen, say 85 and typing 85 FORTH, Inc. has the following job LIST. Now use ttPt'to place a line of text openings: on the screen, e.g., 0 P ( Mini-editor

FORTH DmNSIONS III/2 Page 40 1 wall place a comment on line 0 of the NOTE: see Hr. Miles' letter in Letters :urrent screen. section.--ed.

Type the rest of the lines above and Mr. William D. Miles :hen use the word "FLUSH" to write the P. 0. BOX 225 uni-editor to disk. Now, when you need Red Cliffs :3 start the system again, just type 85 Victoria 3496 2AD and your mini-editor will be put into Australia I :.he dictionary.

I Use the mini-editor to type in the Fig- CORRECTIONS TO METAFORTH -WETR editor. The string search screen :an be omitted if you do not have a ver- sion written in highlevel FORTH. John J. Cassady 339 15th Street Oakland, CA 94612 USING ENCLOSE ON 8080 The following corrections to the Fig- Using ENCLOSE with disk block buffers FORTH cross-compiler, METAFORTH, by John 2f 256 bytes each or larger on the 8080 Cassady should be noted: ?rocessor. page 26 screen 66 line 7 should read

111) niii ;mt:i.ust: DB 'EllCLOS' KISR H LXI SRA.5 SRLD 12 ORG + LHLD SPHL DB *E*+B~I Dv PFIND-9 HEm m I'CI Dv $+2 POP D ;(DE)<-(Sl )-DELlflllER CIlR pop !I ;(lIL)<-(SZ)-ADDI. OF TEXT TD SCAN page 38 dumped memory location 798C PUS11 11 ;(S4)<-ADDR. should be 6A nov A.E ;(a)<-DELII( QIR LXI D,-1 ;INITIALIZE CHR OFFSET COUNTER IXX II ;(IIL)<-ADDR-l A few lucky purchasers will have noted ;SKIP OVER LEADINC DELItIITER QlRS :KLl INX 11 that they possess those rare copies of I NX D METAFORTH in which pages 8 and 9 are CUP If ;IF TEXT am - DELIPIain J7 EIIC1.1 ;TIIIN LOOP AGAIN swapped. ;ELSE Nou-DeLxn QIR mum rust1 D ;(SJ)<-(DE)-OFFSET TO IS? NON-DELIPI PUSll rsu ;SAVE W.LIR QIR ON STACX METAFORTH, by the way, is a cross- MOV A.M. ;IF 1st NON-DELIH-NULL ANA A compiler for Fig-FORTH. It can be used to J hZ EllCLZ regenerate a FORTH system including the POP PSY ;TIIEEN DISCARD DELIM CllR INX D ;(SZ)<-OFFSET TO BYTE POLLOVlNC NULL nucleus without resort to an external PUSH D conventional assembler. This is helpful ocx D ;(SI)<-OFFSET TO NULL ! PUSll D when modifying low level words, generating Jnr NEXT " stand-alone" applications, convert ing to .'cCl.Z MP I'SY ;(A)<-DKl.lfl CllR FROII STACK I NX II ;(IIL)<-ADDR NEXT CllR FORTH-79 and the like. A special section I NX D ;(DE)<-OFFSKT TO NUT CllR is devoted to generating headless cnr n +IF NEXT CIIR<>DELIH CIlR JE ENCLl configurations vith the same or different rustt PW ;SAW. nELxn ata or1 STACK processor. t1OV A,M ;AND IF NEXT aIR<>NULL AIlA A .JNZ ENCLZ ;'WEN CONTINUE SCAN METAFORTH is available in hardcopy ;ELSE CllR=NULL POP PSU ;DISCARD DELIH QlR through: MlUNTAIN VIEW PRESS, PO Box PUSll D ;(SZ)<-OFFSET TO NULL PUSII D ;(Sl)<-OF'FSET TO HULL 4656, Mountain View, CA 94040 for JHP NEXT $30.00. There are plans to have it ;ELSE CIIR-DELIN am EtlC1.4 PUSH D ;(SZ)<-OFFSET TO BYTE FOLLWINC TEXT available on disk and compatible with INX D ;(SI)<-OFFSET TO ~IIYTESAFTER END nr WORD several of the popular commercial fig- PUS11 D JIlP YEXT FORTH6 from their respective vendore.

FORTH DMNSIONS II1/2 Page 41 CHANGING 8080 fig-FORTH FOR DISK COPYING This is a clear and reasonable un- ambiguous definition. However, at the Rochester FORTH Standards Conference, Ted Shapin there was a strong conseneus that the byte 5110 E. Elsinore Avenue count n should be an unsigned number. The Orange, CA 92669 restriction in the definition seems to be unnecessary; the only thing to be said in The FigFORTH 8080 implementation uses its favor is that it might save a pro- all bytes of all sectors on the single and gramer from an inadvertent error (and double density diskette. This means 2002 generally FORTH does not try to save sectors on a disk for single sector and progranrmers from their errors). If the 4004 sectors for double. This is not a unsigned FILL were to be the fundamental multiple of eight so the last screen on a definition, then the signed version would disk will be split across two disks. By be trivial to implement. The reverse is simply changing the equates for SPDRVl and more difficult. Thus, the unsigned FILL SPDRV2 to 2000 and 4000, we will have an would lead to better "factoring". Fur- even number of screens per disk. This thermore, a common use for FILL is to allows a screen disk to be copied from preset a large portion of memory. The disk A to disk B by using the Fig-FORTH unsigned version is clearly better suited COPY word. for this task.

NOTE: Ted has the correct method. Any Having said that, what should be other system setup that could split done? Since the current definition is screens is incorrect.--ed. unambiguous, and since 79-Standard ver- sions of FORTX currently exist (with several more in advanced stages of FORTH STANDARDS CORNER development), it seems to me that there should be no change to the 79-Standard in Robert L. Smith this area. The Standard Team has sug- gested one mechanism for evolutionary There is a need for a channel of changes in FORTH via "Experimental communication regarding the etandard- Proposals". An experimental program ization of FORTH. A major topic is the would, however, involve a new name for the clarification of the FORTH-79 Standard. changed function and could not become a What changes are required or desirable for permanently accepted change until two clarification or extensions to the Stan- revisions of the Standard. That may or dard? Is the FORTH Standards Team the may not be acceptable, depending on the appropriate mechanism for obtaining a frequency of the revisions. "seal of approval" for corrections and changes to the Standards? Please send in material, questions, and corrments relevant to FORTH Standards. I Let us first consider a fairly simple will try to cover one or two areas with topic, the unsigned count specified in the each issue. Possible topics for next time definition of FIU in the 79-Standard. are the words WORD and +LOOP. FILL is defined as follows: CORRECTION FILL addr n byte 234 "Systems Guide to fig-FORTH" by Ting is Fill memory beginning at address with a -not available through FIG. Orders for sequence of n copies of byte. If the this book, revised 1st edition @ $25.00, quantity n is less than or equal to should be sent to: zero, take no action. MOUNTAIN VIEW PRESS PO Box 4656 Mountain View, CA 94040

Page 42 FORTH DIMENS IONS I I1 / 2 NEW PRODUCTS Product has five active installations of the disk version (79-STANDARD). There are also 50 installations of the cassette SYM-1 FORTH version.

Saturn Software Limited has implemented Price: Fig-FORTH for the SYM-1 single board com- puter. Their implementation takes advan- SFD-1 SYM FORTH FOR DUAL HDE MINI DISK tage of many of the features and resources SYSTEM $150 U.S., includes shipping, tax, of the SYM-1. etc.

SYM-FORTH 1.0 (disk version) requires Vendor support: 16K of ram, serial terminal, and the dual HDE mini disk system. System has been Direct personal support by phone, upgraded to the 79-STANDARD and includes a correspondence, and newsletter. versatile input line editor, fig-style editor, 6502 assembler, and a cassette Order turn around time: interface. This product is also supported by a quarterly newsletter with an initial Inmediate. circulation of 100. For more information, contact: Extras included: Jack W. Brown Assembler, editor, cassette interface, SATURN SOFTWARE LIMITED plus numerous utilities and demos pre- 8246 116A Street sented through subscription to newsletter. Delta, B.C., V4C 5Y9, CANADA (604) 596-9764 Machine on which product runs:

SYM-1, 6502 singleboard computer. OSI-FORTH 2 .O / PIG-FORTH 1.1 Memory requirements: 16K of ram This ie a full implementation of the Manual : FORTH Interest Group Version 1.1 of FORTH. It runs under OS-65D3.12 (or 3.0, The 74 page manual include8 3.11, on any disk-based Ohio Scientific introductory tutorial material, system system, and has access to all DOS comPands information, and glossaries for the FORTH, and resources. EDITOR, and ASSEMBLER vocabularies. The manual is available separately for $25 Extras include resident text editor, which will be credited towards a later Assembler, and utility screens for purchase. transferring the system to a new disk, initializing library and system disk block Form product is shipped in: storage tracks, copying screens from disk to disk, and reconfiguring the system Product is distributed on two 5-114 memory usage. inch diskettes, and boots with 79-STANDARD upgrade installed. (Cassette version is Machines: also available which can be upgraded to a disk system at any time.) Ohio Scientific C4P MF, C8P DF, C3, C2- 8P DF, C1P MF, and C4P DF. While only one drive is needed, dual drives are supported.

FORTH DIMENSIONS III/2 Page 43 Memory Required: 24K

Manua 1 : For more information, contact:

Currently 95+ pages--with new OSI-FORTH Daniel B. Caton Letters added as they are produced. TECHNICAL PRODUCTS COMPANY Twenty-four pages of discussion of 4151 N.W. 43 St., 5507 particulars for OSI, utility screens, and P. 0. Box 12983 operation of the editor (includes sample Gainesville, FL 32604 edit screen). FIG Installation manual (904) 372-8439 included. Listings of utility and other sample screens. Available separately for $9.95, which is credited toward system purchase. NEW PRODUCT

Media Available: Eight-inch or mini disk. DATRICON FORTH Approximate number shipped: 25 Datricon now offers D-FORTR, a software package designed €or use in conjunction Price: with microprocessor-based, STD Bus COP patible products using a Single Board $79.95 includes shipping. (Florida System concept and offering a variety of residents add 4% sales tax.) 68~x165~~processors. Datricon' s single board controllers use interface standards Delivery: 30 days. such as the STD Bus, RS232, and RS422 for serial cormnunicationa and with or without Support : parallel I/O compatible with the popular isolated AC/DC module racks. OSI-FORTH Letters subrcription avail- able for $4 per year. Contains fixes for For more information, contact: any new minor bugs that may be found, as well as listings of application screens DATRICON CORPORATION donated by urers, or developed by 7911 N.E. 33rd Drive Technical Products. Portland, OR 97211 (503) 284-8277

Warning--this FORTH is different in names and omitted 'vestigal words'.--ed. ELEMENTS OF A FORTH DATA BASE DESIGN enclosed in single quotes to set them apart from the English words in the by Glen B. Haydon text. In FORTH, these words are used without the single quotes. In this day and age, data base design and manipulation is one of the major SCR I 21 activities best accomplished with com- 0 1 Sm21: CWDmAIO WD m0 mTA CILC 1 I 27 mIt 69 miT CR CR cn cn cn puters. In practice, FORTH proves to be 2 .* mls damstration data rystm prwldu a pttern for the' 3 CR .: further dwelcpnt of any typ of data b.~.Ihe bask. an ideal language for developing and using 4 CR . file fomtiq dcflnltlcrrr are on SxnM 22 and 23. Sou' custom data bases. By comparison with s CR :ucllltler ace on 24, 25, and 26. The dmo flle * 6 CR .' deflnltlau are on 27. Lluntary 111. wlprlatlm ' other languages, high or low level, FORTH 7 CR .* utl1ltl.r are on 21. mls 61should qet 'pu sUrtd.' 8 : RCOCCDE Crc CR .. Y' TO KEY 89 - IF is a winner. It meets the requirements of 9 29 22 W I WD UOP ; I0 R(QzDE being interactive and providing documen- 11 rS 12 tation as identified by Fred Brooks in his 13 book, THE MYTHICAL MAN-MONTH, as being 14 15 ideal for the development of new sys- re tems. The amazing speed and ease with Xl which custom data bases can be developed, n- more than justifies the effort required to rd learn FORTH. 3f I have developed a number of small data Le bases of up to 800 records containing 128 iS bytes each to serve my specific needs. I 3r have also initialized, with simple for- ut matted input and output routines, a curtom ar data base for inventory control in a few hours one evening. Having used languages other than FORTH for similar work, it is The first two Screenr provide eight highly unlikely I will ever go back to utility FORTH words for developing a data them. bacle file. The comwnts included in the Screenr within parentheses should, com- This discussion presents a group of bined with the mnemonic nature of the utility FORTH word definitions which words, give you a clue to what is hap- facilitate the development of custom data pening. The first two words are variables bases and a sample application using these used in manipulating the file, 'RECl' and es utilities to define a small file. A 'OPEN'. '2@' is a FORTH word, and alias number of techniques available in FORTH for ID@', which fetches the next two are illustrated. values beginning with the address on the top of the stack and placer them on the Some months ago, at a regular monthly stack. The word, 'LAYOUT', places two I meeting .of the FORTH INTEREST GROUP in parameters of the new definition of a file 4 !iayward, the prime mover of the group I on the stack for subsequent use. 'READ' distributed and discussed several FORTH in the first word that one will have Screens which provided the foundation for occasion to use in routine manipulating beginning the definition of a data base records in the data base. It takes the file. I have modified his Screens number of the desired record from the top slightly and expanded them to provide a of the stack and, after checking to see general framework with which to define that it is a valid record, places its custom accounting data bases. I will value in the variable 'REC#' which is used assume that the reader has some knowledge to identify the record then under con- of the fig-FORTH Model and proceed with sideration. The word 'RECORD' takes the the examination of Screens developed from value for a record number from the stack J it. In the discussion, FORTH words are and returns its address to the stack.

- '2 FORTH DIMENSIONS 111/2 Page 45 field" which will identify a field in the Finally, 'ADDRESS' takes the record number E at the variable 'RECI' and using 'RECORD' new record with a length in bytes given on a leaves the address of that record on the the top of the stack and gives that field a top of the stack. With only these eight a name. In subsequent use, that newly b FORTH words: two variables, one utility defined word (text field name) will cause t word, and four basic words for file refer- not only the address of that text field in the record whose value is currently in the encing, we can proceed to the definition U of three defining words in the next variable 'RECI' to be left on the stack, f Screen. but also the length of that ficld, The b M'ZI. length is convenient when the primitive a :a SOYD~Jr1umcwrnwr-i. b I RIPO

The three words on the next Screen are cL called defining words because they are Y used to define new FORTH words as the ~m*nor*rr I I d. u --- r. names of fields in our record and to de- Idr-d d. 41-- ..I. fine the name for the file we are I d --d. d I dl. a. - defining, each with specific properties. I a. 0 -- These wo-ds utilize the combination of the d FORTH primitives '' Q which are present in the Model. It may 0 take some time to fully appreciate what b these primitive words accomplish and the Once the definition of the fields in a P way they work. Perhaps an examination of record is completed, the value of the what they are doing in this Screen will record length remains on the stack. To f help you understand their function. this we need to add values for the number t of records we wish to include and finally, Two types of record fields are the block number in which the records are distinguished and defined with separate to start, before we can use the defining I words, a numerical or data field and a word 'FILE' to give the file a name. I text field. The first word, "DFIELD', is Later when the new file name is used, the used to add to a record being defined, a address of the necessary file parameters field containing the number of bytes given is placed in the recently defined variable on the top of the stack and gives that 'OPEN' as required for access to any given I field a name. In subsequent uoe, that record with the words defined in the first newly defined word (data field name) will Screen. cause the address of that field in the record whose value is curreotly in the With these two Screens, we have the variable 'RECI' to be left on the stack. file utilities necessary to define a new 't This word is used to identify the location file. However, several characteristics of la in a record where a numerical value is to the particular implementation of FORTH 9 be stored in a binary form. I call it a which is being used are important. Most S "data field", in contrast with a "text systems created under the Model have 128 F field" in which the Length of the field bytes per block although any multiple of d should also be immediately available. 128 can be used. In these sytems then, Tl Thus 'WIELD' is used to define a "text the largest record length can be no longer d - Page 46 FORTH DIMENSIONS 112/2 rn e than 128 bytes, but with a larger block afterwards are indicated in the format n size, larger records can be used. In used in the fig-FORTH GLOSSARY. You will 3 order to take maximum advantage of the note that several of these are mixed Y block size, it should be very nearly equal double and single precision operations e to a multiple of the record length. For which are sufficient for the requirements n example, a record length of 70 bytes would of this program. e not leave enough room in a 128 byte block 9 for a second record and in this case, 58 The date compression routine is really e bytes of space would be wasted. If need simple. When I find the time I will e be, such a designed file would work, but develop an to convert the date r at the expense of memory space. Also, the to a true Julian day and store the least e initial block to be used in the definition significant value. This would make created by the word 'FILE' must be chosen calculation of the time between two given 0 according to the block size for the dates easy. In the meantime, the present W particular implementation. For example, routine allows one to enter the date as e block 400 in an implementation with 128 numerical values separated by slashes, a f bytes per block would be block 50 in an commonly used format, and reduce the value e implementation with 1024 bytes per block. to a single 16 bit integer requiring only Although, I find a block size of 1024 to two bytes for storage. The routine be more efficient and use it routinely, provides an example of using a delimiter the Screens presented here have been other than a space to parse 'WOBD' and the written for and tested on an imple- use of 'NUMBER' to interpret a numerical mentation with 128 bytes per block. value without searching the dictionary. After the parsing of the input, three Before starting with a discussion of an double precision numbers are left on the example of the application of these file stack. The word 'DATEBIT' defines a development utilities, several Screens of simple algorithm which is applied to utilities for use in the input and output reduce these three double precision values of numerical data will prove to be most to 16 bits. The execution of '?DATE' helpful. These include a group of double first prompts with the format to be used, a precision utilities, date compression and then waits for the value to be entered. ie expansion routines, a numerical routines The value is then converted to the 16 bits ro for handling dollar amounts and storing and left on the stack for starage. since EK them as double precision integers. '.I is used to conote "print" in FORTH, Y' '.DATE' is defined to print a properly re formatted date from a 16 bit integer on ng the stack. This routine is useful as an e. example of conversion of a binary value to he a text string for printing. rs I 26 D CR :meo m: ?UIIM AKI le ia .- . I 1 ddi- ~RIQI tor each wale Cbso I 1 : muLL 180 D* . : Ism 10 0. ; : BULL ; en 12 ~:BW:INFVTCIOD~-C(I: :J 4 1 d.1 in r.1. case d extud for rmrl t!! 'CTA' 1 st :a 5 * osau CTA unmu WYIK * ISU crA , KCLU crA , :5 6 1SW-A. he The double precision integer utilities lew are used in date compression and expansion Of as well as in the double precision integer :TH msi I I5 operations for dollar amounts. These are CK 1st simple extensions from the limited double .28 precision words found in the Model and Finally, we have a Screen to define of should require no further explanation. some FORTH words used to input and output zn, The input on the stack before executing dollar amounts and convert them to and ?ler the word and the output left on the stack from double precision 32 bit integers with

2/2 FORTH DIMENSIONS III/2 Page 47 the necessary scaling for the location of exists in the Model. FORTH, 1 the decimal point. In the use of a 1 decimal point forces an input number to a With these five Screens, we can very double precision integer which takes four quickly define a record for a data base bytes. A convenient FORTH primitive word, with custom selected fields and then the 'DPL' for decimal point locator, keeps a associated file characteristics. In the count on the number of digits entered past, I have several times included in a following the decimal point. Utilizing data base values calculated from other this value as an input for a case type values in the base. On occasion, it has word, the numerical value entered can be been necessary to change one of the scaled properly, regardless of how many original values. This has always required I digits are entered to the right of the that the calculated fields be redone, decimal if any. This method of executing too. I now find that it is more con- a case like routine is straight forward. venient to enter only the basic data. All First, the action to be taken in each case calculations can be made while the output is is being formatted and printed with no defined. 'OSCALE' means that there 1 were no digits to the right of the decimal significant loss of time. The slowest which requires that the entered double part of printing the formatted result is precision integer must be multiplied by the delay in the output device. 100. In a similar manner '1SCALE' is used SCR 4 27 meaning that there was only one digit 0 CR ." WDi 27: DMO FILE - RECORD CXNfRATION ' 16 2 WIELD TK; I a t4 ) I entered following the decimal point and 2 30 WIELD NAME I itm nme ) 3 2 WIELD MY ( the date ) the entered double precision integer must 4 4 WIELD DOLUR ( a dollar momt I 1 5 280 ( ncnbcr of records I 4oB ( startirq block ) be multiplied by 10. '2SCALE' does 6 FILE m0 nothing since no scaling is needed. 7 : IW I bnlt tor nme them #tore it in record 1 8 NAME CAOP 30 32 FILL WRY 1 TfX PAD CCUM Finally, if more than 2 digits are entered 9 WCRUr MIN CMYE Uf'Mm ; an error must have been made an an appro- 19 : .W ( prlnt mefleld 1 NAME WPE ; 11 ( the rest lollow In the sane WJ~ I I priate error message is given. Once each 12 : IMY~TE MY I upmn ; : .MY MY e .MTE ; 13 : 1-R 'KA- WLIAR DI UPMTE ; I 14 : .WLIAR WUAR ; of the cases is defined, their code field W .- I addresses, 'CFA', can be stored beginning 15 : .REC CR RECl I! 3 .R 2 5- .NAME .MY 2 SPACES .OOLIAR ; , with the address of a defined variable As an example of the definition of a

'NSCALE' and extending into the alloted new data base, I have chosen one in which 1 space. The word 'SCALE' then finds the each record would be allotted 4 fields for two value of the variable 'DPL' and counts a byte tag, a 30 byte stock name, a I over to the proper code field address two byte date, and a 4 byte stock price. I which is then placed on the stack and the Though little could be done vith this as a I selected word is executed. data base, it does provide an example of I each type of input. Finally, a simple set After this scaling operation, the word of routines is given to clear the records, 1 '?$AMOUNT' to input a dollar amount is input new records, and print out a list of 1 defined which leaves the scaled double the records in the file. precision integer on the stack ready to be I stored. Finally, a routine defined by the As a matter of convention, I give each I word '.AMOUNT' connoting "print dollar field a name with no prefix. Thus, a data I amount" will print the double precision field name will leave an address on the I integer on the top of the stack as a stack and a text field name will leave an dollar value right justified in eight address and count on the stack. By using spaces. the FORTH connotations of'!' for store and 1 '.' for print, I define some utilities for There are certainly other and probably inputting data and text and printing out 4 better ways to accomplish the work done by the respective fields. From these util- 1 these three Screens of utilities, but they ities, I can assemble an input format and work. The way they work provides some an output format as desired. I have not I examples of the beauty of FORTH as it included routines €or error checking which I

Page 48 FORTH DIMENSIONS III/2 would be most desirable especially in a The field 'TAG' is not used at this time hostile environment. and specific routines are not defined. To store a name in the name field, we define Now, to examine the actual example of the word '!NAME'. This routine first :he definition of a file which we will fills the existing field with blanks, :all 'DEMO'. Each record will begin with ASCII 32 (decimal) and then pauses for zero offset from the record address and a input from the keyboard. The input text '0' is entered followed by '2' for a two is truncated to the maximum length of the 5yte length of a data field to be named text field if necesary and then moved to 'TAG'. Many occasions in later that field. In order to output the name aanipulation of records make it desirable in the field, we define the word :o have such a field for adding flags, ' .NAME'. In a similar manner, we define etc. Following this definition, the '!DAY' to store a 16 bit integer value of Length value of 2 is left on the stack so a date which has been compressed into that that for the next field, only its length field, In the earlier utilities, we have need_. be entered. In this case, a text already defined '?DATE' which waits for a :ield of 30 bytes which is given the name date to be input and leaves the compressed 'W' which then leaves the value of 32 value on the stack. All that is necessary :the length of the 'TAG' field plus the is to put the address of the field on the 'NAME' field) on the stack. Then a two stack with 'DAY' and then etore the en- byte data field, 'DAY' is reserved for a coded date there. We then define ' .DAY' 16 bit compressed date and then a four to output the date stored in the 'DAY' byte data field 'DOLLAR', for a double field. We get the 16 bit value stored precision integer value of a dollar there to the top of the stack and use the amount. With this, the 4 fields within previously defined word '.DATE' to output che record of a new file are defined. it in the proper format. Finally, we Next, we will define the file name. define '!DOLLAR' to parse a dollar value According to the utility for generating a input with a decimal point in any location new file, we must first add to the value and scaled to a double precision number of the record length remaining on the which is then stored in the proper stack, a value for the number of records field. In a similar manner' .DOLUR'LS we plan to include in the file and then defined to format the stored double pre- the first block number to be used as cision integer to a right justified eight determined by the FORTH implementation in digit number preceded by a dollar sign. use. Then, we use the word 'FILE' to With these definitions, we have completed create a file with these paramters and a set of FORTH words to input and output give it the name 'DEMO'. The data base data from records in our data base. file ia now defined. For the record num- ber whose value is in the variable 'RECP', Immediately after putting data into a we can place the value of the address of record, it is often desirable to see what the data fields and the address and count is actually present in that record. The of the text fields on the stack by simply values in each byte of a record can be entering the field name. Next, a few displayed using a dump routine. Simply simple utilities will make accessing these place the desired record address on the new fields easier. top of the stack by entering the record number followed by our file utility word Remembering the connotations associated 'READ' and 'ADDRESS' followed by the with the FORTH words I!' and '.' we will length of the record and the word for your define words to input data or text to the dump routine. But the byte values printed appropriate fields of that record whose out in hex or decimal are not really all value is currently in the variable that helpful. It is hard to interpret the 'RECB'. These are simple file primitives numerical value in their byte pattern. A which will then be available for routines convenient word '.REC' is defined to print to format input and outputs as desired. out the current record nunber followed by

FORTH DIMENSIONS III/2 Page 49 the formatted output of the value in each the second copy is placed in the variable field using the above utilities and an 'REC#' and we are ready to fill in the appropriate number of spaces and carriage information for the next record. returns. This is the met rudimentary form of a formatted output. If desired, A series of prompts can be formatted on the output could be presented in reverse the screen in any convenient arrangement video by a slight modification of this as in this example. Following the desired routine. It could also be placed anywhere prompt for each field, the previously on the screen. defined word is used to get the informa- SCR t 28 tion for the field and store it there. e CR :SCREEN za: caw FILE - CLVJI.MTA, INPVP, arrpvr it i clear especially taq in the 0 record in file 1 After entering a record, is always nice 2 : CLEAR.WTA 0 RWTK, 128 0 FILL mTE; to see the data you actually put in. This 3 ( exanple ot fonnattrrq for inpt ) 4 . INPVr 0 RWTK @ 1* UPWm WP TK, ! m. is done with the word ' .REC' followed by 5 CRCR.'WI'ESNAME -> !WE 6 CR .* WIUI WTE -> * IMY ( has d-foIlMt PCCUW ) the FORTH primitive 'UPDATE' to flag the 1 CR :mTcR AKlMT -> !DUR buffer as altered~and 'FLUSH' to save the 8 .AEC FLLSH ; ( Sam this r-rd on disk I 9 [ ilst files 1 thraqh the nmbrr In TX of 0 recoC? ) new record on the disk in the file. This la . curm o RW TK, e DUP a- IF CR CR :MPPY FILE ii mop KSL i+ 1 DO F(KM I RW .REC me ~OIFCR CR ; assures that the image of the record which 12 ;s is displayed is the version saved on the 13 14 disk. 15 Finally, a few examples of formatting An output format can be developed in a input and output routines are shown on the similar manner. In this example I have last Screen. First, it is desirable to included a check to see if there are any clear all data in a file with a vord records in a file because the 'DO'.. . 'CLEAR.DATA' before entering new data. 'LOOP' will always print one loop and This particular definition clears only the peculiar output is generated if the bytes first block, all that is necessary in this in the fields are all set to zero. This application. You should be able to modify output routine presents a simple list of the definition of this word to meet the the record numbers and the formatted requirements of your application and par- content of the fields. ticular implementation of FORTH. In conclusion, I find this approach to I use the 0 record in a file for a file definition is time saving and hope variety of information about the file that you will find it useful. The dis- which I can address directly from the cussion of the FORTH utilitie: used to address of its first byte without using define a new data base file and the the field definitions or I can use spe- example example of handling data provides cific bytes or fields in ways other than I some elaboration of the information in- have defined them. In this example, I ure cluded on the Screens. This vill be a the value in the integer at the field 'TAG' review for one who already has learned the in the 0 record to keep track of the last primitives in the FORTH Model and under- record currently in the file. When this stands how the language works, but perhaps record is cleared with 'CLEAB.DATA', a the discussion of these Screens will help value of 0 is present in the location of those less experienced. There is nothing 'TAG' which means that there are no sacred about the techniques used here. records present. '0 READ' places the Modify the various words to suit your value of 0 in the variable 'RECI' and then particular needs. It is easy enough to 'TAG' places the address on the top of the develop new formats interactively. How- stack and '@I gets that value, the last ever, I would encourage you to utilize and record number used in the file. To add a build on the standards of the fig-FORTH new record, this value is increaented and Model. When the '79 Standards become then duplicated on the stack. The top generally available, it should be rela- co7y is stored back in the field of 'TAG' tively easy to update your Screens without in the 0 record which is updated. Then changing the format of the record file.

Page 50 FORTH DIMENSIONS III/2 3e importance of utilizing an accepted assure that there are no errors in the standard in developing programs for printed Screens. iitimate use in a wide variety of imple- nentations of FORTH cannot be over- BIBLIOGRAPHY onphasized. Brooks, F. P., Jr., TRB MYTHICAL MAN- I wish to thank Bill Ragsdale for his MONTH, Addison-Wesley Publishing Company, excouragement to write this discussion 1975. -ased on his presentation to the FORTH ImREST GROUP at one of their monthly fig-FORTH INSTALLATION MANUAL, GLOSSARY, meetings last year. MODEL, Forth Interest Group, Box 1105, San Carlos, CA 94070. -LyP L ICAT ION NOTE : fig-FORTH FOR 8080 ASSEXBLY SOURCE These FORTH routines have beendeveloped LISTING, Forth Interest Group, Box 1109, :3 a FORTH OPERATING SYSTEM for the San Carlos, CA 94070. ZATHKIT H89. This system is available from the MOUNTAIN VIEW PRESS, Box 4656, Yountain View, CA 94040. The compiled -WSTH program image can be saved on disk z2d will be up and running in less than fzur seconds from a cold boot. The system =as 1024 byte blocks which also increases :he speed of operation.

However, after develoment, the Screens iere loaded on a FORTH implementation :?rived from the fig-FORTH FOR 8080 45SEMBLY SOURCE LISTING which is available irm the FORTH INTEREST GROUP, Box 1105, Carlos CA 94070,in printed form and ;:ready on disk also from the MOUTAIN VIEW 33s. This version has 128 byte block zz5 operates in conjunction with CP/M. TO f71s has been added the fig-EDITOR from ---.-e fig-FORTH INSTALLATION MANUAL and a 5:ngle extension, DUMP, used to illustrate :he appearance of the records as stored in z 5lock.

The printed session illustrated was nade using the CP/M control P to echo the -::put on the printer. The session starts mroQ c:h cIuI.mm Q CP/M loaded and its usual prompt. MRll ?e CP/M file, FORTH6O.COM, is the object nzule of the fig-FORTH Model. The warning messages are not on Screens 4 and f and the warning flag is turned off. Tien, the Screens for the fig-EDITOR and a gmd dump routine are loaded. Finally, rye Screens discussed are loaded. The irle 'DEMO' is called and the application -5 some of the file utilities is illus- :rated. This presentation will hopefully

32TH DIMENSIONS III/2 Page 51 HELP WANTED

FORTH PROGRAMMERS Experienced with dni/micro computers and peripherals to produce new polyFORTH systems and scien- tificlinduetrial applications. Degree in science or engineering and knowledge of FORTH essential.

PRODUCT SUPPORT PROGlUIMMER Responsible for maintaining existing list of soft- ware products, including the polyFORTH Operating System and Programming Lan- guage, file management options, math options and utilities and their documen- tation. Also provide technical support to custmers. OK SKATUW PROJECT WAGER Supervise applications and special systems programing projects: writing proposals, setting technical specifications, customer liai- son, hands-on programing, and supervision of senior programmers. Extenoive FORm programmiq experience, some scientific or enginl!ering back- ground and management skills required. Bachelors degree or equivalent.

f &-TREE TELECONFERENCE Contact: Min Moore FORTH, Inc. 2309 Pacific Coast Hwy. (415) 538-3580 Hermosa Beach, CA 92054 (213) 372-8493 If you are an active FORTH programer, or just have an interest in FORTH, you will want to save this phone number. With your terminal or computer and a modem, the number will get you on-line to a dynamic data-base on FORTH. Want to ask a question? Want to know WRITERS WANTED where and when the next important FORTH IntereTt Group seminar, meeting, workshop, ANY FORTH SUBJECT or other event is going to be? The fig- SEND TO: Tree has a calendar section where you can find out about these events and let others know about yours. Want to find out about FORTH INTEREST GROUP FORTH-related software, products and P.O. Box 1 105 services? San Carlos, CA 94070 Dial-up the fig-Tree for on-line information. Use any 300 or 110 baud modem, and type several carriage returns; then the system is self-instructing.

Page 52 FORTH DIMENSIONS III/T INCREASING fig-FORTH CP/M uses a translation table to tell it DISK ACCESS SPEED which sector to use. Someone figured out that while storing the data from one by Michael Burton sector, about five more sectors go by before CP/H is able to read another Anyone who has used CP/M and has then sector. So instead of storing a file in -sed 8080 fig-FORTH will have noticed that sectore 1,2,3 ... it uses its translation :?,'!Iis much faster than fig-FORTH when table and stores the file in sectors 1, 7, yeading or writing data on floppy disk- 13, etc. This means that 1024 bytes of -3:tes. The reason for this apparent speed information can be read or written in two :Ifferenee lies in the manner in which or three revolutions of the diskette I?,'Y stores its files as opposed to how instead of eight. irg-FORTH stores its screens. (Editor's -3te: Speed is also reflected in hardware What can be done about the manner in :?tails such as interleaved formatting and which fig-FORTH reads/writes screens? A :rrect memory access. It is not neces- CP/M-etyle translation table could be 4arily a FORTH characteristic.) I shall added to fig-FORTH, but that would make 2::empt to explain the difference. the diskettes, and the FORTH program, incompatible with the rest of the FORTH A single-sided 8" diskette formatted in world. Instead, the diskettes can be r-e normal manner contains 77 tracks, with formatted to look like a CP/H translation aa:h track containing 26 sectors with 128 table, which is extremely easy and still ::tes of data in each sector. In order allows compatibility. A diskette would f:r the disk controller to be able to find look like this: a particular sector in a given track, -eader data is stored on the diskette just Sector --.---or to each 128 byte data block - a sort sf preamble. Among other information in Oldfmmt: 12345 67 8 9101112U I-:$ preamble is the sector number. A Newformat: 11410236192151124 720 3 !>mat program writes this information on rich track in a consecutive manner; in Old farmat: 14 15 16 17 18 19 20 21 22 23 24 25 26 :f?er words, immediately following the Newfonmt: 161225 821 4171326 922 518 -2iex hole pulse is sector 1,2,3, ... 26.

A program that reads a sector must Most format programs use an incre- f-rst select the proper track and proper menting register to supply the proper sector, then must read that sector's data sector number when formatting. To imple- 2:i store it someplace for use. It is mnt the translation scheme, a table must farrly easy to select the proper track and be added to the program and must be sector and read the data; the problem accessed in place of the sector register :me8 in trying to read two consecutive when formatting the diskette . sectors. There is not enough time between r-e time when the first sector's data is With this new format, fig-FORTR still :cad and the time when the next sector is reads 'consecutive' sectors (1, 2, 3, iiailable, to store the data from the etc.), but they are available sooner. 5-rst sector and request the data from the Using the new style format, fig-FORTIl second sector. This means that reading should be able to read or write a screen ::nsecutive sectors 5 and 6, for example, in two or three disk revolutions instead requires a minimum of two revolutions of of eight. rie diskette. Two simple teats were run to determine CP/M accesses files faster than fig- haw this affects fig-FORTH performance: TI'RTH accesses screens because the files are not stored in consecutive sectors.

T>RTH DIMENSIONS 111/2 Page 53 MUSIC GENERATION IN FORTH by Michael Burton

II)Iu)uscm!m 1: 28 1: 17 12.5% The General Instruments programnable mY)saaau. 224 :53 63.z sound generator (PSG), the AY3-8910, can be used to produce very acceptable three If you can't reformat your dirkettes, voice music when properly programmed. you may choose to copy diskettes rh- FORTH's background as a device control lating interleaveing by this program. The language makes it a good choice to use multiple screen copy definition ured for with the PSG for music production. the second test is listed in rcreen 167. The programmable sound generator is SCX # 167 capable of producing sound on three separate analog channels. The amplitude and/or envelope of each of these channels is also separately controllable. Although the PSG is used by several manufacturers on their music boards, the board that was used for the development of the attached music constructs is the S-100 Sound Effects Board produced by Digital Research Computers of Garland, Texas. This particular board contains two AY3-8910 chips, allowing up to six voices to be generated simultaneously.

Now, for an explanation of the music screens. Screen 51 consists of defini- tions of 110 port values and variable declarations. The variable ALVl is the melody voice amplitude (voice one) and the variable ALV2-6 is the harmony voices emplitude (voices two through six). These amplitudes may be varied from 0 (off) through 15. It is a good idea to keep the hannony amplitude about two steps lower than the melody amplitude, in order to make the melody stand out. The variable DVAL controls the length of the notes, DVAL being the length of a whole note. The variable IVAL controls the length of the slight no-tone period between notes. Together, DVAL and IVAI, control the song's tempo. Experimentation is necessary with there two variables to produce the proper tempo for a particular song.

Screen 52 contains all the definitions necessary to access the S-100 Sound Effects Board in order to play music. The only PSG registers currently being used in muric generation are the tone period, enable and amplitude registers. Note the use of the 8080 fig-FORTH peculiar word

FORTEl DIMENSIONS III/2 P!. P! simply sends a data byte to a slight delay (IVAL) ir introduced so that particular If0 port. the notes will be dirtinct from one another. Screen 58 also contains defini- Screen 53 marks the start of the actual tions for dotted noter, from a dotted definitions used in producing a song. The sixty-fourth (fd) to a dotted whole note definitions vl through v6 are used to (vd). select voices 1 (melody voice) through 6. These definitions do not turn the There is room for improvement in these appropriate voice on, they merely select music definitions. Control of the notes' it so that a tone period (note) may be Pet envelope could be introduced to simulate for that voice. Voices are actually other musical instruments, and played only when a note duration is restrictions imposed by the non-interrupt selected. The definitions vldis through nature of the note duration generation v6dis are used to disable a particular could be eliminated. These exercises will voice the next time a note duration is be left to other aspiring composer/ executed. They do not turn a voice off if programmers. it is currently being played, they just usmi U MY^ 1 turn it off the next time it is supposed ?IYore icflnitlonr I ~RUILD\ c. nup I+ re WAP TO-,PEL i to be played. I:# n c. ML\> c* Lf an? n M Lf bLb n cl LE L1R n cll en 14c n nl 5 nc Cfr n dll FR rnr n 01 LR 12r n II Ir I?r n Ill 6 I9 or7 n 11 19 r'l* n 111 111 at1 n a1 1L 061 n all Screens 54 and 55 define the musical 7 17 ocq n bl r7 177 n c? 17 nu n c12 IF. 017 n dl ? IF. u47 n dl2 15 ILD n IS I90 n I2 05 I47 n I12 3otes. The lowest note that may be played 9 I4 1FC n q2 L4 an4 n ql2 I4 LlC n a? I4 111 n a0 IL I1 Pt4 n h? 03 CIC n cl I1 8116 n cI1 I3 LSJ n 61 -9 b of octave 0, and the highest note II bl 074 n dl1 I2 IF6 n el #2 ICI n fI LA4 n 113 I1 r? MIL n 93 I2 0% n 911 a1 (I30 n a3 I2 Y11 n a0 that may be played is b of octave 8. I3 DI vfA II bl DI enc n c4 01 mc3 ?I el4 nI #M n d4 I4 @I Y92 n dl4 I1 (I71 n *4 Dl U6L n I4 ul 051 n 114 I5 111 Ilk n 94 II 12U n 914 I1 UIC n a4 YI VIC n a14 -->

Screen 56 contains the definitions SCM I 55 VOF'F. I f ruslc - iaprimental Conmcrucca 052hII-*Po I RINIT, VON and RINIT initializes 1 all 2 f not. d*flnltlc I the registers on each PSG. RINIT in 3 II IkD n b4 #I ILl n el5 u# (IU5 n d5 4 II K9 n d15 LI In3 n I5 a0 LA9 n 115 :he only place vhere the amplitude of the 5 eo 19r n q5 II 189 n a5 I0 La6 n a0 ;.sites 6 01 I7P n b5 IL I71 n cl6 On I6A n d6 is initialized, and should be used 7 I1 C64 n dIF. #a I59 n fh LP D54 n Ilk a an 151 n q6 II 147 n a6 MI 143 n a16 2efore playing any music. The definitions 9 ell L3I n bc IC n3L n cI7 be C15 n d7 in am a12 n 617 In I20 n 17 #I LZr n I17 ;'3N and VOFF are used to turn all selected I1 ma #I0 n 07 In I24 n a7 La a22 n a17 I? a@ n71 n b7 La L1c n clR ne I11 n 48 ;.3ices on and off. They are used inside I1 LD I19 n dll Om DI6 n I0 Ib el5 n (18 I4 LP #I1 n RR a1 112 n a1 LI a11 n a10 :he note duration definitions and are not 15 #I 1.10 n ha want to be used in a song definition. ICY I 56 I I nuslc - Laperim~ntalConstructs 1 Screen 57 contains definitions for rest 2 f Clear all rwic board reqs and set ampllcud~s I I : KlNlt UtF WULCI at+' UIA#LE2 3 I DU I CMYIILL I hrations, from a sixty-fourth rest (fr) 4 7 I W L I SLT LOOP Ib 0 Do ALV2-6 D I ShT WOY f3 (wr). 5 eL lld W I I SET LOOP 2 +LOOP I CMIIIILL I 2 VOlCL I a whole rest It also contains 6 ALVI @ MP i 7 :efinitions for slur note durations, from 1 f voicer *nable/dlsabl~ d*finitionb I a 9 I vo* ClASKI C LIIAMLLI LWK2 C LUULLI ; sixty-fourth slur (fs) to a whole slur I* : votk IFr CIIAbLLl IY1 LUlLD2 I 11 --> us). A slur note is one that does not go 12 ___-:< after its duration is finished, 11 I4 allowing a smooth transition between noter 15 &en desired. Screen 57 also contains ok :cfinitions for dotted slur durations, >&I. I 51 irom a sixty-fourth dotted slur (fds) to a Y ( nusic - bZplllrmtal Construer1 0524UI-*h 1 1 &3le dotted slur (wds). 2 ( wsc J*ratlon d*flnitions I 3 : r CD OVAL P SlAk I I W LOOP i 4 64 I fr 32 r tr 16 r ar LO r *r 5 c4 r qr I2 r hr 01 r wr Screen 58 is the last of the music 6 1 I Slur duration definltlons I rsnstructs screens, and contains defini- 0 : sl CL OVAL @ WAP I I Vn* Do LOOP I 9 r.4 .I fs 37 SI ts 16 a1 ss 18 II as :lone for note durations, from a sixty- la e4 .I qs I2 .I h. I1 a1 y. I1 isarth note (f) to a whole note (w). Note I? I Docred slur buratlon b*flnitlons I 11 I ids WJAL c 64 DUP z + I VIWI w Lone ; xat after the note is turned off, a 14 i tda IS 1s I I sds ss ts I I *ba as s8 : IS I qda OI *s : : hds hs 9s I : u6S WI ha I -->

-FORTH DIMENSIONS III/2 Page 55 KN I 58 0 I nusic Lnprlmtbl Conitruela siz4ii-mn I 1 1 2 I not. duratlon dellnlllona I 7 t X1 vl qh v2 -6 "1 ch "1 7% "5 c4 wh cl r3dla v4dlb 1 vl a6 vl a5 vl cc 11 45 vl a5 v. c5 h vl a6 ~2 I(. 1 I d cLUlLDC C. WLSD CC UVAL L PAr I I VW h) LW* .. a vl c6 v4 a5 q vldra v4dis vl 16 vl a vl cI, w2 4 VOW ;VAL # I UU LOOW I I5 a5 vl 15 v4 c5 4s aIL vl lh W V4 .I5 q wldls 5 64dt 32dI 166. ICO* 5 n vl wl 6 M4dq IZdh Ildr b v4dll vl qh vl 95 a vl a16 vl a0 vl a6 v2 16 vl CL 1 7 v4 a5 y rldll v4dla vl qC vl q5 Vl 16 vl 15 # I Dottad mot. duration datlnlrlona I 8 vl qL "2 eh v3 cL v4 q5 q vld1i v4dls vl e* vl -5 9 : do VOtP lVAL I W LOOP I 9 vl c6 r2 q5 vl 05 v4 55 .b y vldlr Vldll vldls Y4dlb V5dI. V6 ql a 10 I fd Ids do 1 t td 16s 40 I : sd Wbdu I 1I s s , 11 i JC2 v2 95 vl a5 v4 vl a85 c6 a v441S 5 I1 ad oda do I I q4 qda do i I M Ma do : v6dll C4 1s I2:rddldol 12 vl a15 vb ql c4 vl ch a 415 a c6.e a15 I I1 ML'lRAL UlUIT 13 I XI c6 vl dl5 "4 d04 a v2dls vldls vl a0 q5 as v4dLs 14 Cli .. WSIC Constructs Loaded . I4 s vl dl5 "2 a14 vl q4 w4 all as dll q8 q3 eS 401 i I5 is 15 -- D

scn I 5s SCI I 71 nr I I sow - J.SUS cmrist Superstar I

1u I1 12 I3 11 I5

0. SCM I 71 0 I Sonq - Jamus Cbrlst SuwrsLar 051281-lPs ) 1 2 I Xb V2 a5 V1 d0 V4 13 V1 C6 SS V4dll s V4 54 14 3 a a vl a15 c6 dIL vl 40vl -5 w4 c4 a vl cfi e 4 a15 v2 15 vl d5 w4 ql a v1 c4 d86 v2 a15 vl a5 v4 c4 ? : MI11 *4 C5 ml 15 V2 a\ 1) f5 V4 C5 V5 f> a8 C4 0 5 vl c6 v2 95 "1 *5 01 v4 ql q vldlb v2dls vldls I 1 vl q5 "5 dl4 "6 d0 as "1 c6 vl 10 v5 d4 V.l 43 0 V2 a5 6 I JC7 c4 el vl 95 s 1 a15 vl 15 v3 d5 I a5 v1 c6 v2 q5 4 vl v4 b4 YL. ql q v2 q5 v1 a5 v4 a14 v5 c4 u6dlr q . f5 7 la h vldls v2dl5 uldis v4 I4 a1 v! q5 s s a15 vl 95 5 v2 15 v3 v4 14 v> "6 q. v2 a5 v4 c5 .I c5 c4 tl vl 15 8 v3 dl5 a vl c6 vl a5 1 11 ql v4 c4 q vldrs vldlr vldls 6 rl c6 vl a5 v1 15 v2 f6 qd I 9 I4 as vl a5 s 1 v? I5 a vldia vl ch fh vl c6 v3 a5 7 : nw Y~~ISY~OIS vwlr v6dls vl c5 rl c5 *a vl t5 v2 15 a II a. v4 cb 9s 11 q I 8 "1 a5 v2 a5 "3 c5 "4 I1 v5 13 a. Y4 c4 a v4 a4 as 11 -D 9 "I q5 v2 95 "1 a14 "4 c4 1 VI t5 vz 15 VI a4 V( 14 17 10 v5 13 q VI95 r2 q5 vl dl5 14 a4 v5 54 VL f3 -8 Vl 15 11 11 v2 I5 .vl d5 v2 d5 vl 411 v4 all v5 a11 vldll eb 14 12 vl f5 v2 15 vl d5 as "4 q4 v5 all *I v4 a4 aa d4 9 I 15 13 --> 14 i5

scn I 65 1 I X8 vldls 12611 vldla v4 c4 ms vl qb 1 1 tb v2 C6 vl a5 1 0 ' Sow - 11.6 R1v.r Valley ~~17m-amI 3 v2dls rldls vl 616 a CL vl q5 vl a5 la ql v4 91 a1 4 vldli vldls vldls c4 as vl q5 a a a0 v2 15 vl d5 a -5 1 I 11111 "ldll V461. V5dll VLdI. Vl c5 v2 c5 a. Vl 15 v2 f5 a 5 vl C6 vl q5 as 0. V4 93 as C4. VldlD vldll vldll I VI a5 vz a5 VI cs ~4 r3 ~5 ri .S ~4 c4 VI as vz a* 6 14 as vl a5 a a v2 15 i vZd1i v1 ch a I6 vl c6 vl a5 a1 4 VI 15 v* cs "4 64 VI C( VI er. vz COT VI 15 14 cs 7 v4 c4 qa 11 *a c4 I 5 v5 a4 vWl1 -1 v5 c4 a1 vl a15 v7 40vl a5 v4 c5 8 I JCI vldlr v2dli vldla v4 14 ml vl 16 1 Ilh s I6 vl C6 6 u5 q4 *s Vl a5 V? a5 Vl f5 vs I4 a vl 05 v7 05 vl 05 9 vl a5 a ~2611vldla vl dl4 a 1L v2 cb v3 a5 Dl v4 dl4 7 v1 c5 v5 94 Y' c4 qs v2dlD v4 a4 as v1 bl VI I4 v5 45 1I qs c4 *s 13 vldls vldll vldll Cb as vl I16 I S IS c ss VI "I a14 v4 a4 vs C) q I I1 v? c6 vl a5 a vldls vldll vl dl6 a CK v2 05 v3 a5 11 9 : Ucl4 vldli v4d1s v5dls vhdls vl c5 v2 c5 as vl 15 v2 15 a 12 v4 a11 91 q5 P i 1C ri a5 vl a5 vl CT v4 tI w5 fl as v4 c4 *a m4 as vl 95 I3 -) 11 vz 95 VI a14 ~4 CI VI 15 vz Is VI a4 V( 14 .S ~6 c4 14 :2 v1 q5 vl 95 vl a5 v4 a14 v5 c4 -1 vl a5 v2 45 '11 dl5 15 13 v4 c5 ~5 II . 14 15 -->

SCN I 66 I I SOW Mad Ilvar Vallay 05llIl-RW I a' I X1I vl 95 v2 a5 vl C5 vb q4 v5 C4 Vh Cl q *Id11 v3dlr v4dlr 1 - 3 VIm5 c5 vl q4 vl a1 h vl a5 rl 15 wl c5 vb a4 v5 14 2 a Yk5 vl CC v2 e6 V3 15 v4 05 US .I3 v6 a12 as V1 415 4 v6 13 y rldls vldll v4dll vl I5 c5 vl a4 es h I5 vl a15 3 v2 a0vl I5 v4 d5 *a v6dii v5 14 am q4 as aI4 q 5 vl d5 a14 v5 a13 v6 a12 q vZd1s rld1a u4dls vl 95 a15 4 vl A5 v2 65 vl q#4 v4 14 v5 ill a1 vl CIS v2 el5 6 a5 v2 15 "1 c5 "4 a4 v5 14 v6 I3 q v2dll v3drs v4dls vl q5 5 v5 bl 0 vl c5 v2 c5 vl a4 v4 t4 v5 c4 qa vl 15 7 15. q5 v2 a5 rl c5 "4 q4 v5 v5 e4 v6 el q vldli v3dIs 6 vl f5 vl c5 v4 a4 v5 el as a vl a5 v2 a5 vl f5 I ~461svl a5 a e5 v2 q4 "1 a4 01 ma v6dls v5 ql qs a v5dls : 7 "4 04 v5 d4 VC 03 q vl 95 r2 q5 vl a5 v4 a14 v5 c4 9' -D 8 vfidis es vl 15 vl 15 v3 a4 v4 c4 v5 13 ql vl a14 1I 9 v4 d4 ss a1 v3 a4 v4 c4 q 8 11 IP : IIW v1 c* vl cs v3 15 v4 dI5 v5 a0 v6 a12 a. vl a15 I2 11 Vl a0I4 45 el Ved1. V5 14 a4 be4 Vl d5 11 I7 vl d5 vl ql4 v4 14 VS all as bl vl c#%v2 CIS ; 14 13 -> I3 14 15

KN # 67 I I I Sow N.d Ylvar Valley I514#14- - I 2 I XI1 v1 0s v2 .5 vl c5 v4 c4 q VlJ1. "MI. Wl .5 a c5 v2 04 1 3 v3 -4 v4 c1 as qs ql a1 c4 a 11 vl a5 v2 15 v3 c5 q vldll 2 : w7 Vl c5 Vl c5 Vl a4 v4 14 v5 c4 q Cl Vl 15 v2 15 4 VWIS VI 15 c5 vz a4 VI rr v4 11 qs 0s a? a41 VI a15 I vl c5 v4 a5 as a vl a5 v2 a5 ul I5 v4 M VS d4 5 v? I5 vl d5 q vldll vldls vl q5 a15 a a5 wl f5 vl c5 vI 13 4 v6 ql q v5dli v6dla vl 95 v2 q5 vl a5 v4 Dl4 OD 6 q V2dll VhllD Vl 95 V4 q1 41 Vl 1s 05 V2 V3 C5 V4 C4 5 VI f5 vz 15 VI c5 V( a4 v5 cr v6 13 *a a8 u2 a5 7 q vldls vldll vl *5 e5 v2 q4 vl 04 a* as v4 q3 qr . i 6 VI f5 V( c5 as 15 va c6 VI a5 0s v2 16 ul c* v4 15 # I .UrA ALVI 0 1 - ALVI 1 ALVl-6 C 1 - ALVI-6 I vl ALVI P UP I v5 a4 qd I 9 v2 ALV2-6 C MI vl ALV2-6 L MP ~4 ALV7-h C UP I 8 t RIVCR ICOI~WAL I 256 ivcl~I III I XplD M ALVI I 6 ALVl-6 I I 9 11111 RR2 I03 NU4 11115 IR2 RIl HI4 10 R17 n13 114 RnS RRl.RlNlt I 12 JC1 JC2 JCA JCI JCZ JCA 5,; J0JCh JC7 I1 Cn :mad nlwr valley 14.d 1J JCI JC9 JCII JCU JC2 JCA JCI JCI JCA Jbb JCS JC6 JCl JCU JC9 12 IS I4 Jtll JCtA JCll JCYA JCll JCFA JCPA JC11 JClMD RlU11 I 11 15 CI JeoW Chrlmt Superstar loadad IS 14 . - I5 011 OR

Page 56 FORTH DIMENSIONS III/2 bPTIMIZING DICTIONARY SEARCHES An application program 70 screens long Paul van der Eijk took 210 seconds to compile; the new 5480 Wisconsin Avenue, 11128 dictionary structure reduced the com- Chevy Chase, MD 20015 pilation time to 98 seconds. (301) 656-2772 To implement the new dictionary struc- Recently, I finished the implementation ture, the following words have to be of fig-FORTH on my Radio Shack model XI. rewritten: I must admit that I did not follow the FIG rnodel precisely; some high level defini- CREATE VOCABULARY LFA NFA PFA . tions were recoded in assembler to (FIND) has to be rewritten as well, but is increase their speed. For example, sign not given here because it is machine extraction in the divide and multiply dependent. vords gives an execution time improvement of a factor two. These improvements are fl ( WA precerdm NQA I of 2: I IIEX predictable and probably implemented many 2 : CREATF. -CIIU IY MOP NCA ID. 4 HCSSACC SPACE TllEN 3 ( chrck unlqw In WRRLNT and CONTEXT ) cimes already. 4 IIERE d uIm~e mn 11 t awe nubrr of chars atored ) I HERE OAO TDGCLYI IIERP. R + WP 080 mCGU 6 ( dieand drllalter blta One deviation from the FIG model I want 7 DUP 2+ R I* -0fOVE ( mvc entry dam to Insert LtA ) I UTEST IIERE I MERE I+ CUUEWT @ I to share with you is the structure of the 9 I> 3 t ALLOT IIERE 2+ , ; dictionary. 10 I1 : WA 3 - -1 TRAVERSE ; 12 : UA WA 2 - ; 13 : ?fA 1 TRAVERSE 3 + ; In the FIG model, the Link Field 14 Address is stored after the last character 15 - 3f the name. When (FIND) searches the for 0 ( LfA precurdm NCA 2 of 2: Rtil van der Eljk aprll-12-1981 1 Aictionary an entry, the lengths of 1 : VOCAUIURY COwTcrr I ; son fails, and this happens a lot, the L 5 :haracters stored are scanned for a high b ( Ihe follwln~charye In -PINO aped. up dlctionmry srarcltes ) 3it in the last character. When the scan 7 ( IDcame the CUREHT mnd aOWTEXT voeabulrrlea are the saw. ) I ( the chansr lm not necraaary lor thr nmu dlctlonary structure ) stops at the last character, we know the 9 LO : -flND EL MOM llERE COWEXT @ @ (FIND) DUP 0- address of the LFA, because it follows the I1 IF DIOP UTEST CONTEXT e @ 0-1 - last character. It will be obvious that 12 I? IIERC SUAP (PIIIO) 13 ELSE mop o :he time spent on searching for the LFA 1b TUEN TllEtl ; vill be linear with the average numbers of 15 DECIMAL :s Zharacters stored for an entry. One way to get around scanning is adding an additional byte in every dictionary entry, indicating the actual number of characters stored. Another approach was taken by Xobert Smith, see FORTH DIMENSIONS, Vol. 1, No. 5. POTOMAC FORTH INTEREST GROUP MEETING The structure I implemented puts the :FA in front of the Name Field Address. Program was presented by Paul van .Then (FIND) stores the address of the NFA der Eijk on IQS - An Interactive Query in a machine register, a search for the System. He described this system which ;FA is not necessary because it precedes lets the user create, edit, search and :he NFA directly. In addition, the char- list a file without writing a program. acters of the entry can be stored in The next meeting is Tuesday, Aug. normal order, which makes changing ID. 4, 1981 at Lee Center, Lee Hiahway at unnecessary. Lexington St., Arlington, Virginia from The new dictionary structure can 7:OO - 9:OOpm. improve compilation speed substantially.

FORTH DIMENSIONS I11/2 Page 57 TRACING COLON-DEFINITIONS Improvements:

Paul van der Eijk 1. If we save in (TRACE) the value of the 5480 Wisconsin Avenue, 51128 variable OUT and direct output to the Chevy Chase, MD 20015 line-printer, words doing formatted (301) 656-2772 terminal output can be debugged effectively . This short article describes a few simple words to trace colon definitions. 2. A variable TRACE is introduced to When I am completely lost trying to find a control the insertion of the word bug in a FORTH program, I use colon (TRACE) in the new definition for the tracing to get a print-out of all words colon. executed together with a few parameters on the data-stack. Such a print-out ia often If the value of TRACE equals zero, enough to spot the bug; in addition, it (TRACE) is not inserted, if the value is gives some insight how many times certain non-zero (TRACE) will be inrerted. words are executed which can help to improve the execution time of a program. This enables tracing code to be inserted in a selective way by changing How it works: the value of TRACE preceding a colon def ini tion. A technique to trace colon definitions is to insert a tracing word i.e.: directly after the colon. 0 TRACE I : TEST1 T11 T12 ; ( TEST1 will i.e., : TEST T1 T2 ; TEST can be traced by not be traced 1 having a definition compiled as if it were: 1 RUCE I : TEST2 T21 T22 ; ( TEST 2 can be traced : TEST (TRACE) T1 T2; U ( trhr eulon wrdw: Paul van dar L1)k aprll-IJ-I981 ) 1 fORTll DLCINlTlMlS When (TRACE) executes, the address of 1 0 VAIlARU TfUC (control8 tram output ) 3 : (TRACE) ( 81- trace output. to be 1nwarr.d 0. firm wrd ) the word following it is on the return 4 WUGC ( trace ourput If non-zero ) stack. Subtracting two from this address I It CI R 2 - WA DUP ID. ( back to RA WA for ) 6 d 31 MD 32 YAP - SPACES ( add 8p.cea to nme ) will give the parameter field address, 1 -2 4 DO sr( I + e 8 .I -2 +LOW ( .tech ) 8 II(CN; from which we can reach the name field 9:: ( rdef1o.d to Jlucrt ftacm wrd after colon ) address using the word NFA. In order to 10 !Lac ICS? cuILI(T P mEx7 1 UUIL 11 (IRA=) CIA W? e RCRL 2 - I , 1 ; lMt@3IATL enableldisable the trace ouput, the varia- 12 13 ( exmpla: trace lollwin( we of I and CI ) ble TFLAG is used; a non-zero value will lb: I f i enable the output and a zero value will 1s I CI CI i ;s suppress the trace output.

Tl,e insertion of the (TRACE) word can be automated if we redefine the definition of the colon. NEW YORK CHAPTER The colon is redefined to insert the runtime procedure for the colon followed First meeting of the New York Chapter by the address of (TRACE). was held on June 23, 1981. There were five FIG members and one mu-FIG person Note that the address of the colon in attendance. The second meeting is runtime procedure is obtained by taking it scheduled for August 25, 1981 and sub- from the code field address of the word sequent meetings wery other month. (TRACE).

Page 58 FORTli DIMENSIONS III/2 FORTH, inc. NEWS Industries' rotating longitudinal- stretch forming machine. This 80- f oot-long , three-story-high giant weighs over a ;e ' re Growing million pounds and pulls 750 tons. It is used to form, stretch, bend and stretch FORTH, Inc. expects to double its staff wrap aluminum, steel and titanium sheet ;.:thin the next year to accotnnodate metal or extrusion parts (typically panels .:.creased product demand and applications used in C5A-sized aircraft). :rogramming. (See job openings listed +:sewhere in this publication.) An LSI-11 detects the yield point of the metal and maintains a pre-set stress The latest addition to our staff is as the operator directs the initial opera- :rogrammer Charles Curley. Curley is a tion; it then takes over full control and izrmer freelance writer and programmer who manufactures identical product ion parts. ?:,ts and publishes the Ohio Scientific This computer program, written in polp -3ers' Newsletter. FORTH, coordinates the motion of nine simultaneously moving servo-controlled FIG FORTH my own axes with a resolution of .008". The -."I put up in Ohio :r:entific C2-8P DF and liked it,'' he system also displays on a CRT the position ~xnnents, "but I wanted to learn FORTH of all axes and a graph of the stress s;stematically, and I figured this was the curve showing the yield point of the :rst place to do that. At FORTH, I get metal. Mike La Manna, Jim Dewey and Gary --1-=-d to do what I like to do.'' Friedlander were involved in the project.

::ner News Starting FORTH Preprints Available

President Elizabeth D. Rather was a A few unsigned preprints of Startin wmber of a panel on programming languages -FORTH are available now for $30 plus 6% -c + -I-- small computers at the NCC Conven- state tax). The Prentice-Hall edition -..-xi. She was featured in both Computer- will be available in book stores September i-r?d and Computer Business News. 8. To order a preprint, send a check to Winnie Shows at FORTH, Inc., 2309 Pacific Programmer Mike LaManna has relocated Coast Hwy., Hermosa Beach, CA 90254 or r: Long Island, New York, and is working you may call her at (213) 372-8493 with a I: I: the 68000 polyFORTH. It should be VISA or MASTERCHARGE number. .-.;ailablemidsummer.

FORTE, Inc. Seminars, Workshops, Classes ?::yFORTH Palo Alto Users Groups Starting Iacatim Semimr Dr. C. H. Ting has volunteered to Chair --e Palo Alto Thread of the FORTH Usera Chicago August 4 Augu st 5 ::~up for the first three months. Anyone Boston August 6 August 7 --.:crested in joining the Users Group may Boulder, CO September 1 September 4 I ::ntact Dr. Ting at Lockheed Missiles and Los Angeles October 15 October 16 1 ;?ace Corp., (408) 742-1101 or A1 Krever San Diego October 22 October 23 i: FORTH, Inc. (213) 372-8493. An introductory class in polyFORTH programming will be offered August 10-14 ?c:ent Applications at FORTH, Inc. Call Kris Cramer for details (213) 372-8493. FORTH, Inc. has produced a computer :=nerical control program for L 6 F "I ;2X?H DIMENSIONS III/2 Page 59 FORTH VENDORS

081 Applicatiom ?ackqee Consumer Caputera InnoSgm 8907 Ldeaa Blvd. 2150 Shattuck Avenue The following vendor. have verrionr LaMena, CA 92041 Berkeley, CA 94704 of FORTH available or are (714) 698-8088 (415) 843-8114 conaultanta: Software Federation Decirion Reaourcer Corp. WEA UICEO 44 Univeraity Dr. 28203 Ridgefern Ct. Professional Managmat Servicer Arlin6ton Heighta, IL 60001 Rancho Palo Verde, CA 90274 724 Arartradero Rd. #lo9 (312) 259-1355 (213) 317-3533 PA10 Alto, CA 94306 (415) 858-2218 Technical Product8 CO. ?insre, Board. d Ikcbima P. 0. Box 12983 Da tr icon Sierra Computer Co. Cainrville, FL 32604 7911 NE 33rd Dr. 617 Hark NE (904) 372-8439 Portland, OR 97211 Albuquerque, "t4 87123 (503) 284-8277 Tom Zi-r APPU 292 Palcato Dr. Porvard Technology IUS (Cap'n Software) nilpitar, CA 95035 2595 Martin Avenue 281 Arlington Avenue Santa Clara, CA 95050 Berkeley, CA 94704 WOO b 6809 (408) 293-8993 (415) 525-9452 Kenyon Microryatemr 3350 Walnut Blvd. Rockuell International George Lyona Hourton, TX 77042 Microclectroaicr Devicea 280 Henderaon St. (713) 978-6933 P.O. Box 3669 Jerrey City, NJ 07302 Anaheim, CA 92803 (201) 451-2905 mr-11 (714) 632-2862 Laboratory Software Syatem8, Xnc. Micronotion 3634 klandeville Canyon Pd. Zeodex Corp. 12077 Wilrhire Blvd. #506 Los Angeler, CA 90049 6398 Dougherty Rd. Los Angelea, CA 90025 (213) 072-6995 Dublin, CA 94566 (213) 921-4340 John S. Jwr Variety of low Praducta moss coIIpILEus P. 0. Box 348 Interactive Computer Syatemr, I NAutilur Syatew Berkeley, CA 94701 6403 Di Mrco Rd. P.O. Box 1098 fmp, PL 33614 SAnta Cruz, CA 95061 ns-80 (408) 475-7461 Hiller Microcomputer Servicer Mountain Viev Preaa 61 Lake Shore Rd. P. 0. Box 4656 polylDRTd Hatick, MA 01760 Mountain View, CA 94040 FORTH, Inc. (617) 653-6136 (415) 961-4103 2309 Pacific Coaat Hwy. Hermosa Beach, CA 90254 The Software Farm Superroft AlrOCiAtcr (213) 372-8433 P. 0. Box 2304 P.O. Box 1628 Perton, VA 22090 Ch.npaigo, IL 61820 LYNX (217) 359-2112 3301 Ocean Park 1301 Siriur Syatew Santa Monica, CA 90405 7528 Oak Ridge by. cmsnlturt. (213) 450-2466 Knoxville, TN 37921 Creative Solutiona, Inc. (615) 693-6583 4801 Randolph Rd. M h B Deaign Pockville, 1Q) 20852 820 Sweetbay Drive IOM Sunnyvale, CA 9U86 Eric C. Rehnlrc Dave Boulton 540 S. bnch Viev Circle #61 581 Oakridge Dr. Ilicropoli, AMheim Hill89 CA 92067 Radvood City, CA 94062 Shaw Lab., Ltd. (415) 368-3257 P. 0. Box 3471 ~/~/~~ Rayvard, CA 94540 Laboratory Microryrtau Elmer Y. Fitter). (415) 276-6050 4147 Beethoven St. 110 Hc Cregor Avenue Lor Angelea, CA 90066 Mt. Arlington, NJ 07856 north Star (213) 390-9292 (213) 663-1580 The Software Work., Inc. P. 0. Box 4386 Mitebell E. Thin Engineering Co. Go Polrn Mountain View, CA 94040 9575 Genesre Ave. #E-2 501 Lakemead Way (408) 736-4938 Saa Diego, CA 92121 Pedvood City, CA 94062 (714) 455-9008 (415) 366-6124 C.aowlraat Inner Accear Henry Luen P. 0. Box 888 1259 Cornell Belmont, CA 94002 Berkeley, CA 9b706 (415) 591-8295 (415) 525-8582 Page 60 FORTH DIMENSIONS 1II/2 DECOMPILER FOR SYN-FORTH

SYN-1 Urer's Group PO Box 315 Chico, CA 95927 The following decompiler works very ell except that because INTERPRET ir not remembered by ;S nor (;CODE-) nor QUIT, :his FORTH decompiles loop I

ENGLISH FORTH APPLICATION

Golden River company har been using FORTH I IJ -> for the RCA 1802 for the last three years, to fill a need for a lwcost development 8nd prototyping tool with potential for being u8ed at remote sites where power is not easily available. The most interesting concept in the equipment ir it uses 32K of dynamic RAM as rtorage apace for up to 30 screens of rource FORTE code. The equipment is designed with law power in mind and is normally ured like an electric car--it is urually kept connected to an AC source, 8Ithough it has nine-days battery life and can be ured remotely. The product ir currently being shipped in Europe and will be introduced in the U.S. mrket through Golden River Corporation, 7315 Reddfield Court, Falls Church, VA 22043 For -re information, contact: Golden River Company, Ltd. Churchill Road Bicester, Oxfordshire OX6 7XT England Phone: Bicester (08692) 44551 Telex: 83147 VUOB G 'GRIVER'

GET READY! FORML's COMING!

I 1 WRTH DIMENSIONS II1/2 Page 61 NEW PRODUCT active installations as of writing-- ANNOUNCEMENT FORMAT no unreleased products) 17. Product price

In the interests of comparison uniform- 18. What price includes (shipping, tax, ity and completeness of data in new etc.) product announcements, FORTH DIMENSIONS requests that all future new product 19. Vendor warranties, post sale announcements use the following format: support, etc.

1. Vendor Name (company) 20. Order turn-around time

2. Vendor mailing address

3. Vendor street address if PO Box. MEETINGS/EVENTS Used as mailing address. For ANNOUNCEMENT FORMAT reference file.

4. Vendor area code and telephone In order to have uniformity and insure number complete information in all meeting and rpecial event announcements, FORTH 5. Person to contact DIMENSIONS requests that you use the following format: 6. Product name 1. WHO is holding the event (organi- 7. Brief description of product zation, club, etc.) uses/ features 2. WHAT is being held (describe 8. List of extras included (editor, activity, speakers' names, etc.) assembler, data base, g8111e8, ete.) 3. WHEN is it being held (days, times, 9. List of machines product runs on etc.; please indicate if it is a repetitive event--monthly meeting 10. Memory requirements etc. 1

11. Number of pages in manual 4. WHERE is it being held (be as com- plete as possible--room number, 12. Tell what manual covers etc.)

13. Indicate whether or not manual is 5. WHY is it being held (purpose, available for separate purchase objectives, etc.)

14. If manual is available, indicate 6. REHARKS and SPECIAL NOTES (is there separate purchase price and whether a fee, are meals/refreshements being or not manual price is credited provided, dress, tools, special towards later purchase requirements, pre-requisites, etc.

15. Form product is shipped in (must be 7. PERSON TO CONTACT diskette or ROM-no RAM only or tape a y sterns 8. PHONE NUMBER/ADDRESS (include area codes, timer to call and give work 16. Approximate number of product and home numbers in case we need shipments to date (product must have c 1ar i fi ca tion)

Page 62 FORTH DIMENSIONS III/2 FORTH STANDARDS CONFERENCE ROCHESTER, NY - SPRING 1981 1981 FORML CONFERENCE Asilomar, California November 25-27, 1981 ATTENDEE REGISTRATION FORM

Conf erence The 1981 FOBML (FORTH Modification Laboratory) is an advanced seminar Purpose : for the presentation of FORTH language papers and discussions. It -is -not intended for beginning or casual FORTH programmers. Attendee The FOWL Conference is limited to 60 FORTH programnets (approx. 30 0 Select ion family and other non-participants accommodations are also available). Priority: The priority for selection of attendees is:

1st -Paper presentors who send in their 100-word abstract by the deadline of September 1, 1981.*

2nd -Poster presentors who send in their 100-word abstract by the deadline of September 1, 1981.* 3rd - FORTH programnets who wish to attend only. Depending upon the response of paper and poster sessions there may or may not be room for non-presentore.*

*The FORMI, Conference Referees will make the final decisions on paperfposter presentors which will in effect determine attendance and priority positions. Registration Form, Complete and return to: ADDRESS FORML CITY STATE ZIP COUNTRY PO Box 51351 Palo Alto, CA PRONE (Day) (Evening) 94303 I have been programing in FORTH for: (years) (months) Types of CPU's and/or computers: I have authored the following papers and/or articles about FORTH:

I expect to: -present a paper, -present a poster session -chair a section, -non-presentor My tapic will be: Accomnodationr Roome at Asilomar include meals (including a huge Thanksgiving) and the De s ired : price of the Proceedings is included in participant costs. -Myself -Double $iio.oo -Single SlSOeOO -Wife/Husband/Friend ($85.00 for room and meals) I will arrive the afternoon or night before, please reserve a room for: #- on Tuesday, November 24 @ -$35.00 double Or -$47 .OO single FOR MOW INFOBMATION CALL: ROY MARTENS (415) 962-8653 Page 64 FORTR DIMENSIONS III/2 LATE NEWS BURKLUND & ASSOCIATES 3903 Carolyn Ave Fairfax, VA 22031 (703) 273-5663

Mr. Roy C. Martens June 29, 1981 Forth Interest Group P.O. Box 1105 San Carlos, CA 94070

Sirs : Tsk, Tsk, Tsk! You really did it this time1 Tsk, Tsk, Tsk. The product review of Timin Eng. version of FORTH is totally beside the point...what you did, was crucify one of the finest versions of FORTH currrently available on the market, namely the Laboratory Microsystems, 2-80 FORTH. I bought Laboratory Microsystems 2-80 Forth about 3 months ago, and was ecstatic with what I had bought for a paltry $50. When I read your product review, I tried the same definitions on my 4 MHZ system and found that all times were approximately 2-5% less than your comparative data for Thins 8080 version...there- fore with the differing CPU clock rates of 4MHz for my and 6Hhz for Timins systems on which the Laboratory Microsystems 2-80 versions were compared (how convenient is was tried on Mr. Timins systems) the 2-80 version should reflect benchmark times approaching 30% better than those cited in the comparison test. I would have thought that FORTH DIMENSIONS would have ~taff expertise of a bit higher quality than that reflected in the product review article.

As for the tiptoeing disclaimers via the Editors Comment... hey, it just won't wash1 I think that FOFtTH DIMENSIONS owes a larae apology to LABORATORY MICROSYSTEMS, and at least a full page of space to try to counter the damage you have done to 2-80 FORTH; or will you allow the old adage that "the truth never catches up to the lie", prevail? FORTH DIMENSIONS...Shamel Shame! Shame!

Sinirely, /7

hblisher's Comment: The following letter was received in feference to a Product Re- 7iea by C. H. Ting in FORTH DINENSIONS, 11111, page 11-12, which compared some bench marks between CP/M FORTH fran Thin Engineering and Z-80 FORTH from Laboratory Micro-

I systems. We are printing this letter in its entirety for several reasons: to correct aq unintentional damage to Laboratory Microsystems; to ask our members whether they &sire cornparisions between FORTH and other languages and between FORTH products; if we are to do cornparisions then it will have to be by volunteers since we do not have a staff, it then becomes a problem of who and how, Any volunteers? DIXENSIONS III/2 Page 65 How to form a FIG Chapter: New England Boston 1. You decide on a time and place for 1st Wed FIG Meeting, 7:OO p.m., Mitre the first meeting in your area. Corp., Cafeteria, Bedford, MA. (Allow at least 8 weeks for steps 2 Call Bob Demrow, (617) 389-6400, and 3.) ~198

2. Send FIG a meeting announcement on Boston one side of 8-1/2 x 11 paper (one 3rd Wed MMSFORTH Users Group, 7:OO p.m., copy is enough). Also send list of Cochituate, MA. Call Dick ZIP numbers that you want mailed to Miller, (617) 653-6136 for site. (use first three digits. if it works for you). Southwee t Phoenix Peter Bates at (602) 996-8398. 3. FIG Will print, address and mail to members with the ZIP'S you want from Tulsa San Carlos, CA. 3rd Tues FIG Meeting, 7:30 p.m., The Computer Store, 4343 So. Peoria, 4. When you've had your first meeting Tulsa, OK. Call Bob Gilea, with 5 or more attendees then FIG (918) 599-9304 or Art Gorski, will provide you with names in your (918) 743-0113. area. You have to tell us when you have 5 or more. Texas Jeff Lewis, (713) 719-3320 or John Earls, (214) 661-2928 or Northern California Dwayne Gustaus, (817) 387- 4th Sat FIG Monthly Meeting, 1:00 p.m., 6976. John Hastings (512) 835- at Southland Shopping Ctr. , 1918. Hayward, CA. FORML Workshop at 1O:OO a.m. Hid Atlantic Potomac Paul van der Eijk, (703) 354- Southern California 7443 or Joel Shprentz, (703) Los Angeles 437-9218 4th Sat FIG Meeting, 11:OO a.m., All- state Savings, 8800 So. New York Tom Jung, (212) 746-4062. Sepulveda, L.A. Call Phillip W~SSOU,(213) 649-1428. Hidwes t Detroit Dean Vieau, (3139 493-5105. Orange County 3rd Sat FIG Meeting, 12:OO noon, Fuller- Foreign ton Savings, 18020 Brockhorst, England FORTH Interest Group, c/o 38, Fountain Valley, CA. (714) 896- Worsley Road, Frimley, Camber- 2016. ley, Surrey, GU16 5AU, England San Diego Japan FORTH Interest Group, Baba-bldg. Thur FIG Meeting, 12:OO noon. Call 8F, 3-23-8, Nishi-Shimbashi, Guy Kelly, (714) 268-3100, Minato-ku, Toyko, 105 Japan. x 4784 for site. Canada Nor thweet Quebec Gillee Paillard, (418) 871-1960 Seattle Chuck Pliske or Dwight- Vanden- or 643-2561. burg, (206 1 542-8370. West Germany Oregon 2nd Sat FIG Meeting, 1:00 pm, Computers & Wolf Gervert, Roter Hahn 29, D-2 Things, 3460 SW 185th %", Aloha, Hamburg 72, West Germany, (040) Eric Smith, (503) 642-1234. 644-3985.

Page 66 FORTH DIMENSIONS III/2 FORTH llImEnSlOflS

CORTH lWtCRCSt QROUP Volume 111 P.O. Box 1105 Number 3 Sen Carlos, CA 94070 Price $2.50 1'1 68 Letters

73 FORTH Standards Corner

74. FORTH-79 Standard-A Tool Box?

78 FORTH Engine

80 FORTH, Inc. Line Editor

Recursion and the Ackermann Function 91 FORTH, Inc. News

P 3 Marketing Column

96 Classes

g7 Chapters/Meetings

98 FORTH Vendors EDITOR’S COLUMN This month introduces the long-promised MARKETING COLUMN. Considerlng that one of the bmt ways to proliferate FORTH I8 to 8011 it in the form Published by Forth Intemt Group of appikntkns, 1 believe thir column will contribute to the Hnanciai welfare of our members and help make Volume 111 No. 3 8.ptember/October 1881 the FORTH language a force in the software world. Quaations related to all phases of marketing from pro- Publl8hM duct research and development to pricing. advertisinu Editor and distribution channels are welcome

Editorial Revlow Board Our next edition will be devoted to the conference at the University of Rochester and will be coordinated Bill Ragsdaie by Mr. Larry Forsely of that institution. One of my main Dave Bouiton gods as editor has been to “de-Caiifornne” FORTH Kim Harris DIMENSIONS and make It reflect more accurately the John Jam- opinions and techniques employed throughout the Dave Kilbridge FORTH world. This next edition is a bold experiment in Henry Laxen thk regard and I have every confidence in Mr Forsely George Maverick hdping to make it a successful one. Bob Smith John Bumgarner The brue following ROCHESTER will be devoted to Bob Berkey musk, graphics and games. Currently, this type of ap- pllcstion is In very short supply and I am appealing to FORTH DIMENSIONS rolicits editorial matorhi, our members to submit them as .soon as possible. comments and letters. No responelbility is auumed Pleare remember, YOU DON’T HAVE TO BE A for accuracy of material 8ubmltted. ALL MATERIM WFlilER-our staff will help provide whatever is neces- PUBLISHED BY THE FORTH INTEREST GROUP IS IN sary to make your article or game pubiishable-but the THE PUBLIC DOMAIN. Information in FORTH raw Ideas and code haw to come from you. Also, we DIMENSIONS may be reproduced with credit givon to are not necessarily looking for lengthy, complex and the author and the Forth Interest Group. dogant applications-simple, instructive. short codes often are best and the most useful. Subscrlption to FORTH DIMENSIONS I8 free wlth membership in the Forth IntcHe8t Group at $15.00 per Pleese contribute whatever you can--’ultimateiy the year ($27.00 foreign air). For membrrhip, chango d quality and utility of FORTH DIMENSIONS comes from address and/or to submit materlal. the addmir: our members!

Forth intereat Group C. J. Street P.O. Box 1lo5 Editor San Carlos. CA 94070 PUBLISHER’S COLUMN Nov. 2-4: Mini/Micro Show. Anahelm, GA HISTORICAL PERSPECTIVE Nov. 25-27: FORML Conference, Pacific Grove, CA Nov. 28: FIG National Convention, Santa Clara. CA Mar. 19-21 :Computer Faire. Sen Francisco, CA FORTH was created by Mr. Charlw H. Moon In 1989 at the National Radb A8tronomy Obwmtory, FORTH vendors-these shows can be helpful to Charlottesvilie, VA. It was created out of diucrtlrhctiocl you In 8everal ways. First. if you will send FIG approxi- wit.1 available programming tools. eauechlly for obwf- mately 500 flyers. 8% x 11, about your products, we’ll vatory automation. dirplay them at ail four places. Second, you should ex- hibit at the FIG Convention on November 28 at the Mar- Mr. Moore and beverai associates formed FORTH. rbtt Hotel, Santa Clara, CA. An 8’ table is only Inc. in 1973 for the purpo8e of licenring and 8upOort of $SO.W-aend a check to FIG, today. Third, FIG has a the FORTH Operating System and Pmgmmmlng Un- prime location at Computer Faire, March 19-21, 1882 guage, and to supply application programming to mot In San Francisco. We have booths 1343C and 1442C; customers’ unique requirement8. ho8e face the central booth area and form an island wlth eight other booths. Six of these booths are cur- The Forth Interest Group ir centersd In Northom rently available. Lets get all FORTH vendors together. California. Our membership I8 over 2,400 worldwid.. It All you have to do is call Computer Faire (415) was formed in 1978 by FORTH programmer8 to oncour- 851-7075 and tell them you want to be in the same age use of the language by the interchange d id.r, Island as the FORTH Interest Group. through beminam and pubilcatlons. Roy Martens

Page 67 FORM DIMENSIONS III/3 LET'TE ,RS Dear Fig:

isturbed to see that you have recently Let me introduce myself: Pm Jim Gerow, en a review comparing our 2-80 FORTH avid MMS FORTH user, a FORTH programmer to TIMINS FORTH and stating that the (installer) for larger machines, and a member of RTH is significantly slower than the the local MMS FORTH user group. rersion. Please be informed that the ark was run on an early version of 2-80 I've been referred tQ you by Dick Miller of lvhich has not been distributed for the MMS as a correspondent. Please let me know -LP months. The current version that we how I can be of service and how our MMS =-iv has been benchmarked by some of FORTH User Group can support you.

Jim Gerow 1630 Worcester Rd., 1630C Framingham, MA 01701 Thank you--we would appreciate any arti- cles, ideas, bug . fixes, or usable programs or tools you can send in. Looking forward to Jnsatisfied customers. I think it reflects hearing from you-ed. mrly on your publication that you would sxh a review without checking the facts Dear Fig: a2 of the interested parties. If you people =ally concerned with promoting the San Oiego has a FORTH InteFeet Group that 7 language, please be a little more care- meets informally each Thursday and somewhat .tC1 attacking the reputation and products formally the 4th Tuesday of each month. TW FORTH language vendors. Because of the different machines, MPU's, and operating systems, (i.e., Disk or Cassette, LABORATORY MICROSYSTEMS etc.) we have a problem of software exchange 4147 Beethoven St. (transportability). We are considering the Los Angeles, CA 90066 development of a communications package involving RS-232 modems and software. re fail to see how publishing a comparison N of products that were on the market less We are interested in finding out what FIG 3 year ago can be construed as an attack has, if anything, in standardizing any of the '7er that product or the reputation of its communications such as protocol or hardware specification.

inference has been made that Laboratory Currently, most of the software exchange ystems Z-80 FORTH is an inferior involves hardcopy. If you have any information i, or that it has dissatified custorners. In relative to communications between FORTH operating machines or protocol standards used, we would appreciate your help. K. G. bsch 2, but we know of no facts that were inac- Rancho Bernard0 :eiy reported. If we are to provide the 12615 Higa Place TH world with useful product reviews, San Oiego, CA 92128 xacy is important, and if Laboratory xeystems knows of any inaccurate fact8 or O.K. members--how about giving Ken a 2-d care Lo provide us with an updated hand? Or better yet, send the info to FORTH .ow, ample space will be provided.--ed. OIMENSIONS and we will publish it for all of our members' use.--ed. Dear Fig: The hard- and soft-bound editions by Prentice-Hall will be on the shelves Sept. 8. Would you please forward me a writer's kit? h thinking about writing something for Let us know what you think of the book. We Nov./Dec. GRAPMC/MUSIC. I have imple- are anxious to hear your comments. mented a set of graphic words for Columbia Data Products' MX-964 (2-80 Micro-"2, 512x256 Winnie Shows bit mapped, $10-8080-figFORTH), and am Public Relations working on some musical words for a dual GI's FORTH, Inc. sound chip board. If I can get my hands on 2309 Pacific Coast Highway Oigitalk (National Semi) early enough, maybe Hermosa Beach, CA 90254 some work also can be done on that before the date I send out my articles. Thanks, Winnie. Please note the review in this issue.--ed. Since you share the very same address as the 8080 Renovation Project, would you please for- Dear Fig: ward the following page to them for me? Many thanks. Happy FORTH! I live in a country town in Australia and the number of local computer hobbyists can be Tim Huang counted on one hand. I have so far converted 9529 N.E. Gertt Circle one friend to FORTH and we have found all the Portland, OR 97211 back issues of FORTH DIMENSIONS very helpful with programming examples. I have had Thanks, Tim-we'll be in touch. The my system for about 5 years; it is an SlOO Z-80 graphics issue is approaching rapidly (deadline is system with recently added dual Micropolis Mod Oct. 15, 1981)-word to the wise-ed. II disks. I have rewritten the 8080 FIG FORTH CP/M interface to work with Micropolis DOS Dear Fig: and am currently reworking some of the 8080 CODE definitions to use 2-80 instructions This is a note authorizing you to uae the where they will improve the code. I am cartoon-style illustrations in the book Starting interested in corresponding with other FIG FORTH by Leo Brodie of FORTH, Inc. The users, particularly those with systems similar to credit line should read Leo Brodie, FORTH, mine. Inc., Starting FORTH, a forthcoming Rentice- Mall publication. Reprinting oy permisaim of I wish to make a comment about the naming Prentice-Hall, Inc., Englewood Cliffr, N.J. of words related to 32-bit integer operations. After October 1, 1981 you can leave the The present mixture of prefixed "D" and "2" "forthcomingtt out since the book will be in make these words more frustrating to learn and print. Thank you for your interest. use. That would not be the case with consistent prefix character. I think that the prefix Jim F. Fegen, Jr. character should be t'Dtt for double. I am sure Editor, The Computing Science8 that most of us find the prefix letter "C" easy PRENTICE-HALL to use for 8 bit operations and I am glad the Ehglewood Cliffs, NJ 07632 ASCII did not allow 1/2@ to be used. When floating point comes around (for example, in a 6 Thank you hntice-liall. Watch for byte format), it seems most likely that F! will cartoons from this important work.-ed. be used, not 3!. So let's be consistent and leave digits for numbers and use a prefix letter Dear Fig: mnemonic to indicate stack operations, etc. that are not the usual one word (16 bits). Here is your complimentary copy of Starting FORTH. We at FORM, Inc. hope you enjoy it Could someone please explain what the HEX as much as Mark Garetz of INFOWORLD, who value A081 is for, in the definition of said it was the best beginner's book he'd wen. VOCABULARY? I can't work it out.

Page 69 FORTH DIMENSIONS ID/3

-TTH DIMENSIONS III/3 Page 70 Dear Fig: In either case, you should be aware that good FORTH code is well thought out and very I very much enjoyed my first paso through short. Most definitions, in either high level or your article "Compiler Security" in FORTH assembler, should be very short; not more than DIMENSIONS m/l. I plan to re-mad the article a few lines. In very few instances is high level when Ihave more time. code ever longer. Those definitions that are long should be so well scrutinized as to the In terms of the multi-user environment, reasons for their length that the type of errors haven't you almost answered your own question that the current compiler security would trap of security always versus security on demand should not exist. Assembler code should only be with your parenthetical "and the other users" used when speed is a critical factor. And then, remark? This was near the end, in the structured code may not be the easiest or discussion of the possible use of a ttNovice fastest to program without error, or the fastest Programmer Protection" package. In a single- to execute. The programmer may still program user environment, more liberties can be taken, structured if he desires. He may even load a but I know Fm a novice user, having only been package to ensure this. And if the code involved with computers since 1958 or so, and definition is long then the statement for high having only "FORTHed" non-intensively for level would apply also. The code should be well about 3 years. My single-user system would scrutinized as to reason. always include the protection package (well.. .almost always). I would not, however, Note that using SP and ?CSP is a simple and object to making security optional in the single- effective way to catch many of the errors made user case (but Iam not a prospect for a FORTH in either case. They can even be used outside implementation without it). of the definitions of : and ;or CODE and END- CODE, and never otherwise interfere. I am not I don't agree with your characterization of saying there should be compiler security at Assembler security as inappropriate. It is the all. If I had this viewpoint I would not have ability to have unstructured code that causes bothered to write the article. Even I feel much many of the problems with assembly code. Ifit more comfortable with an application that I is so easy as to be tempting, we will all err. have programmed after it has been successfully FORTH makes the cost-to-fix versus time- loaded into a secure system. But I do object to error-found curve perhaps less steep, but early having to program around the compiler security error detection is still cheaper, and software is (which wastes time and introduces errors) when sti9 the largest part of the system cost (and I wish to load a perfectly correct program getting larger). I cannot argue against being which the security does not like. With an able to defeat Assembler security fairly easily, optional package, I can check my application as however, since there may be situations in which desimd, but do not have to fight the compiler the risk is worth it. security to get the job done. Or, I can have the security package resident. I make the choice. John W. Baxter Sr. Principal Programmer Analyst George W. Shaw NCR CORPORATION SHAW LABS LTO. Coronado, CA PO Box 303 San Lorenzo, CA 94580 MR. SHAW REPUES:

I hope that after three years of FORTH programming that you have developed good FORTH style. This should be the case unless YOU have let your previous 20 years of experience interfere with your learning of FORTH's simplistic concepts.

Page 71 FORTH DIMENSIONS IIV3 Here is a very short contribution, a compiler ?xtension, which has been helpful to me. Iwant 13 share it with all RGgers; perhaps it can Ihave no way of knowing whether this solu- :ecome a fig-FORTH standard. tion to the multiple WHILE problem is generally known, though Iam sum that many people must Often in creating a definition, we want to be using it. The note has been kept as short as :est or output an ASCII character, using words possible, and could easily be expanded. ..

The new word is ASCII, and it is followed by with one ENDWMLE for each WHILE in the 3 literal character. The definition of ASCII is loop. :.Tple: The definition is :ASCII BL WORD HERE 1+ CB [COMPILE] LITERAL; IMMEDIATE :ENDWHILE 2 - EOMP 2 ?PAIRS HERE 4 + OVER - SWAP ! ; IMMEDIATE. : :s made immediate so that it executes during :-npile-time. WORD takes the next input- It causes WHILE to compile a branch to the ;:ream text, delimited by a blank, and places it word following AGAIN or UNTIL, and is directly :: HERE. Then the first character is placed on analogous to ENDIF (THEN). It can be easily :-e stack for use by LITERAL, which has been understood by comparing the definitions of 'xed to be compiled into our definition. What WHILE and IF, and ENDWHILE and THM. ::dd be easier? A similar ENDWHILE can be defined for use Formerly, we had to write 65 EMIT to out- in the ASSEMBLER vocabulary. x! the letter "A" (assuming decimal radix). 'aw we can write ASCII A EMIT , clearly the The ENDWHILE construction is awkward retter for everybody's understanding. The (poor English) but simple, and is worth using -mice of the word ASCII is open to change, but until something better is decided on. :-e idea is a valuable addition to our efficient -se of the language. Julian Hayden 2001 Roosevelt Avenue That's my contribution. I hope others can Vancouver, WA 98660 2 it to improve their work. Thank you for zxviding a medium for ideas.

Raymond Weisling Jln. Citropuran No. 23 Solo, Jawa Tengah Indonesia

3RTH DIMENSIONS IIIl3 Page 72 tion. The action to be taken on an error condition depends on the implementa- Robert L. Smith tion. A number of schemes have been proposed, but there are none that are The word WORD has caused implementera of completely satisfactory. Many people, the 79-Standard a certain degree of difficulty. including this author, feel that any The definition of WORD as it appears in the count should be allowed. FORTH-79 Standard is as follows: 4. The definition uses the phrase "actual WORD char -- addr 181 delimiter encountered (char or null)". I do not believe that the Standards Team Receive characters from the input stream meant to required implementations to until the non-zero &limiting character is use a null as a universal delimiter, encountered or until the input stream is although many undoubtedly will. The exhausted, ignoring leading delimiters. The sequence in which the above-mentioned characters are stored as a packed string phrase appears probably means that if with the character count in the firat the end of the input stream is en- position. The actual delimiter encountered countered before the specified termi- (char or null) is stored at the end of the text nating character is seen, then a null but not included in the count. If the input should be appended at the end of the stream was exhausted as word is called, then packed string instead of the specified a zero length will result. The address of the terminating character. beginning of this packed string is left on the stack. 3. Note that in addition to being a termi- nating delimiter, char also specifies Theme are a number of problems with the initial characters to be skipped. That definition as it stands. Later I will suggest a property makes WORD very difficult to slightly modified definition which should clarify use in conjunction with strings which the apparent intent of the Standards Team, al- may have a zero length. An example of though some of the problems will remain for the a zero length string is the null comment present. ( 1. If one attempts to use WORD in a straightforward manner to enclose the 1. The phrase "non-zero delimiting charac- command terminated by the right ter" presumably means that char must parenthesis, he will find that it and all not be the null character. An emor succeeding text will be skipped! Since condition should be specified if char is under the Standard, the use of WORD is found to be zero. about the only way that one has access to the contents of the text input buffer, 2. The character count is to be stored in this limitation appears to this writer to the first character position of a packed be unreasonable. string. That could mean that the character count could not exceed 127. I believe that the following definition of Since a string holds a sequence of 8 bit WORD meets the essential intent of the bytes, the Clarification Committee of Standards Team, and clarifies the problems the Rochester Standards Conference stated in (1-4). in order to not add to the felt that the term "character position" confusion, I have put a new serial number on the was a typographical error that should definition. have been "byte position", thus allowing a string count up to 255 characters. WORD char -- addr 501 3. Since the source string could be as long as a block (1024 bytes), the character Receive characters from the input stream count could exceed 255. This cam according to the delimiter char and place should be specified as an error condi- the characters in a string beginning at

h9e FORTH DIMENSIONS III/3 addr+l. The character count is placed in the ME FORTH-79 STWARD-A TOOL BOX? byte position at addr. An error condition results if char is an ASCII null or if the George W. Shaw, II

~ count exceeds 255. Initial occurrences of I char in the input stream are ignored. If char As e vendor of a version of the FORTH ' appears in the input stream as a terminating language, and a self-proclaimed priest of the character, it is appended to the string but FORTH religion (I carry a soap box in my back not included in the count. If the input pocket and will mount upon it at a moments stream is exhausted before char is en- notice), I am very interested in the best countered as a terminating character, the standardization of the FORTH language possi- terminating character null is appended ble. There are many items in the '79 standard :nstead of char. A zero length will result if which need work. Many cannot, and maybe !b input stream is exhausted when WORD is should not, be changed this time around, but called. will have to wait for subsequent standardization efforts. To this end, I am conducting interviews The problem of the character count limits- to compile as complete a list of problem areas . 3c1 could be considered in the future. One and solutions as possible. Iwould like to thank Tole approach would be to use a full word for all of the people who have spent time giving me *-e character count. Another would be to elim- the input, comments and ideas which are the ?ate the character count and always append a inspiration for this article. - ~llat the end. The user could then do his own T-enning. The problem of null length strings Much discussion centers on the defining: -3uld be "defined" away by making null length "What is a '79 standard program?' Many of the :.r ngs illegal. I think that that is a poor questions are similar to 'Can I xxx, and will it --:dion. The real problem is that WORD is be standard?", or "My system has a zzz which -mrly factored. As usual in FORTH, the less a does more than the standard says. Is it stan- does, the more useful it becomes. The dard?". These are the wrong questions. :vcess of scanning for initial delimiters should Granted, many of these questions could be -9 separated from the process of scanning for answered by more explanatory text within the irminating delimiters. standard. But, in general, the real question is "What does a standard mean?", or better "What is the FORTH-79 Standard?"

The '79 standard very clearly defines itself. 28002 Software Development System under But, unfortunately, it seems that many people 3 P/M @ or Cromemco COOS. Includes cross skip reading the first page of the standard and :ompiler and a number of utilities. Available branch right into the glossary. If one is to read 3rl 54" or 8" disks. Price: $4,000.00 the first page, one notices a section of great importance: Inner Access Corp. 517K Marine View 1. PURPOSE Belmoqt, CA 94002 The purpose of this FORTH (41s)591-8295 standard is to allow transportability of standard FORTH programs in source wStartingFORW form among standard FORTH systems. Available NOW! A standard program shall execute equivalently on all standard FORTH $16.00 Paperback systems. $20.00 Hardcover This section very clearly states t!w standards Mountain View Press purpose is 'I... to allow transportability of PO Box 4656 standard FORTH programs in source form..." Mt. View, CA 94040 Further, that the program "...shall execute (415) 961-4103 equivalently...I' The section previous to the above clarifies the extent:

=ORTH DIMENSIONS IIID Page 74 0. FORWARD vocabulary mechanism. The standard seerns The computer language FORTH extremely limiting and impossible to deal was created by Mr. Charles Moore, as with. But, the solution is simple. Do as you an extensible, multi-level environment have always done in FORTH. If a structure is containing the elements of an operating inadequate for an application, define a struc- system, a machine monitor, and facili- ture which is adequate. The standard itself, by ties for program development and content, forces development in those areas testing. which have not yet been fully developed. It forces new ideas, better solutions, and, States clearly of FORTH as "...containing hopefully, a better standard next time around elements of ..." the various environments. by its own proper usage. Thus, the standardized FORTH should be a language which contains only the elements As for the two most asked questions necessary to allow the transportation and mentioned earlier, read the standard carefully. equivalent execution of programs between Does it specifically or implicitly prohibit FORTH systems. This is even further limited xxxing? If not, try to transport it to other by the definition of transportability. systems. If you are still unsure, send the question to FIG, we'll work out a clarification transportability and recommend it to the standards team. What This term indicates that eauivalent if your system does more than zzz says? Can it execution results when a program' is exe- be ma& to do only what ztt says by possibly cuted on other than the system on which it not exercising options? If so, it is probably was created. See 'equivalent execution'. standard. Still not clear? Send in the questions. We need them to make a better Which implies that a 79 standard system (in this FOR TH-79 Standard document. case, a system which contains only the standard words) does not necessarily allow program There are areas of the tool box which may creation (development). This is not to say that be cluttered by pacameter testing or unnece- one could not define within the standard the mary words. Some areas may require better additional tools necessary to develop pro- factoring. Much work has yet to do done. grams. Only that the set of standard words may These areas need to be exposed. Write FIG not be sufficient for development. (The about them. All input is greatly appreciated. I additional words necessary for development is have found that each person sees different valid definitely an area to be looked at for the next problems. Many are seen by all, but most standard.) people usually see at least one that has not been seen before; an application or solution which Considering the above definitions, Ipropose had not been considered. this answer to the title question of this article: The FORTH-79 Standard is to be a When considering the FORTH-79 Standard, basic tool box upon which other devices can be treat it as a basic tool box. Additional tools are built. From the definitions within the standard applications from the point of view of the stan- one should be able to build almost any other dard. Extend it as necessary. Can you add needed tool or application. We do not know yet what you need by defining it only in terms of if this is the case. It is extremely unlikely that standard words? If not, what is the minimum the initial effort would have encompassed all necessary to allow you to do that. More design possibilities. The 79 standard is a first definitions or more explanations? Experience is effort--a place to start from; a base from which all that will tell. Send in your results. we may begin to determine the minimum addi- tions necessary to allow all tools or applications George W. Shaw, II to be built transportably. Shaw Laboratories, Ltd. P. 0. Box 303 Yet, even with this understanding, it may be San Lorenzo, CA 94580 feIt that the standard is incomplete. In a few cases this may definitely be true. A good example of this is in the text dealing with the

Page 73 FORTH DIMENSIONS III/3 Book Review: There are even a few surprise questions to lighten the air. title: Starting FORTH Author: Leo Brodie Moving from the general to the specific, the FORTH, Inc. value of this work becomes even more apparent Copyright: 1981 in the following chapter by chapter review. Publisher: Prentice-Hall, Inc. Price: $19.95 (hardbound) The Introduction is not just one introduction, $15.95 (softback) but two: one for beginners (to computers) and Availability: Mid September, 1981 one for professionals. The beginnner's section Review by: George W. Shaw I1 explains conceptually what computers and Shaw Laboratories, Ltd. computer languages are, using an analogy (as will often be found) to simplify. the In most books the useful information begins professional's section answers the usual .7 chapter one, or later. Startinq FORTH is an skeptical questions of "What is" and "Where is" 5xception.- Useful information starts in the Forth with an impressive list of facts about the - xward section of the book. language and applications in which it has been used. The book is designed to be interactive. After only two pages of chapter one, you are Chapter one, "Fundamental Forth", presents t,ving at the terminal. It is seldom that a the basic concepts of dictionary extensibility sentence will leave you thinking, "Now, what and problem definition immediately, so that ioes that mean?" Analogies are used throug- after only two pages, you are typing at a -out. Any "buzz" words, or differences between terminal executing commands and defining systems, or phrases which might cause con- words. The text steps the reader through the 'Jsion are footnoted to explain in more detail. complete development of a program and then -?is presents extremely basic or nonessential illustrates its execution with the previously .leas outside of the main text, allowing the mentioned cast. The operation of the stack is 33ok to be simple enough for the beginner, but then illustrated, and the format of glossary -3t to become tiresome to the more knowledge- entries explained. ible. For example, in the sections of the book zealing with math, separate sections or foot- Chapter two, "How to Get Results", presents -3tes are presented to explain what integers are the basic four arithmitic operations, calculator x what an absolute value is (for beginners). Or and definition style, with conversions between :? give additional information about a faster infix and postfix notations. Practice problems zlgorithm than was used in an example in the and stack pictures are provided to ensure com- -.lain text (for experts). Where appropriate, prehension. The next half of the chapter covers xizzes or exercises are interspersed within the the basic single and double precision stack 3apters to help with understanding the operations with excellent stack pictures and ?aterial presented. quizzes to help along the way.

The book is written for the current "close- Chapter three, the "Editor (and Staff)", :3-79-STANDARD1' version of polyFORTH with again looks at the dictionary, but in terms of w,ations or footnotes to indicate and explain redefinition and FORGEThg of words. Forth's :he differences from the standard. Throughout use of the disk is also described, along with :5e book, tables and lists are used to summarize USTing, LOADing, and the word "c' for and clarify the information presented. The comments. xcasional tables of new words (in glossary '3rm) are of great help. They prevent having to Chapter four, "Decisions, Decisions, . . .", !ig through the text for the words to perform illustrates the IF ELSE THEN structure of :5e practice problems. At the end of each Forth; the various conditional tests, their uses 5apter is a complete glossary of the new and alternatives; and flags and how to manipu- dords. Also, at the end of each chapter are late them. xoblems, with the answers in the appedicies.

'ORTH DIMENSIONS 1x113 Page 76 Chapter five, "The philosophy of Fixed polyFORTH, but the theory is sufficiently Point", expands upon the basic four arithmetic general to apply to the operation and structure operations with some of the composite (I+, 2+, of most Forth systems. etc.) and some miscellaneous operations. The operators for the return stack are introduced Chapter ten, "I/O and You", discusses string with examples of their use in ordering and text manipulation as they relate to disk and parameters for formula calculations. A dis- terminal I/O. Block buffer and terminal buffer cussion of benefits of floating or fixed point access is discussed with notes for multi-user math is followed with instruction about scaling systems. String operators and string to number in fixed point to eliminate the need for floating conversion are also covered. point. Discussed also are the use of 32 bit intermediate operators and the use of rational Chapter eleven, @'Extending the Compiler: approximations in fixed point. Defining Words and Compiling Words", weans the reader from the friendly cast of characters Chapter six, "Throw It For a Loop", dis- as it shows the code behind the faces. All of cusses the operation of the various types of the aspects of Forth compiler are discvssed loops in Forth. A new cast of characters including: time periods, the various compilers illustrate the ''how" of DO LOOPS, nesting inside Forth, DOES > words and immediate loops, using IF ELSE THEN inside loopp, etc. words. D-charts are introduced. BEGIN UNTIL and BEGIN WHILE REPEAT are also introduced. Chapter twelve, : "Three Examples", presents three programming problems and their Chapter seven, "A Number of Kinds of soolutlona as an example of good Forth style. Numbers", is divided into two sections: for Text manipulation is presented with a random beginners and for everyone. The beginners paper generator; Data manipulation with a file section gives an excellent tutorial introducing syetem; and fixed point number manipulation the novice to computer numbers. This section with a math problem which would seem to need describes in detail both signed and unsigned floating point. single and double length numbers. Also covered are arithmetic shifts, bit-wise operations, Following chapter twelve are four appen- wmSer bases and ASCII character representa- dices which contain the answers to the tion. The section for everyone explains Forth's problems, the features of polyFORTH not handling of signed and unsigned single and discussed in the text, the differences from the double length numbers for input, formatted 19 Standard and a summary index of the Forth output and mathematical operations. The words presented in Starting Forth. effect of BASE on I/O, some usage hints, and mixed operations are discussed. On the whole, Startinq Forth is very well organized and presented. On occasion a few Chapter eight, "Variables, Constants, and topics seemed to appear out of nowhere, as the Arrayst1, discusses the uses and operation of section on Factoring Osfinitions in the chapter these structures. Both single and double length abwt variables, constants, and arrays. But, structures are introduced. Example problems these digredone only serve as short breaks are used to show various designs for byte and from the subject at hand and do not detract single !ength arrays. Factoring definitions is from the organization of the material. The text also discussed. in very complete and easily understood. I rate the book very highly for both the novice and Chapter nine, "Under the Hood", presents a intermediate Forth programmer. very clear, detailed, explanation of the various types of execution and structures within a Forth system. Of the many things examined are: text interpretation, ticking (9, compiling, vectored execution, dictionary structure, colon definition execution, vocabularies, the Forth memory map and its pieces. Much of the detail applies to

Page 77 FORTH DIMENSIONS III/3 THE FORTH ENGINE features are not mirrored in hardware. Thus, the semantic gap for ALGOL running on a David Winkel Burroughs 86500 would be small, for PL/1 running on CDC machines quite large. What can computer architects do to make their lives interesting? If we reduce the semantic gap to zero, we have a direct execution machine where hard- It has been clear for some time that building ware mirrors all the constructs (both data and nonventional Von Neumann computers is useful control) of the language. Good discussions and 3ut dull. This in spite of large vendors' bibliographies are given in references 1 and 2. advertising literture which breathlessly announces new architectural advanc s for their Now we have the maximum in speed and the .atest machines. Meyers' book' has an minimum of generality. The computer now runs entertaining discussion of the history of these only one language. What that language should "Qew" advances. For example, virtual storage be is a central question. The !SYMBOL com- goes back to the Atlas system (U. Manchester, puter was an early, truly heroic, system built by :959). Fairchild to directly execute the Symbol lang~age.~This is a PL/1-like language with a How can we improve performance? It great deal of power. System performance was appears that there are two practical ways: spectacular and yet the entire exercise cannot a. Engineering - faster components, be considered successful. A large part was due pipelines, caches, etc., applied to to language complexity which translated into conventional architectures. hardware complexity. It was difficult to fix b. Architectural - building fundamentally bugs and impossible to add features inadver- different computers. tently left out.

The engineering approach has been remark- What we need is a well-tested, simple ably successful as shown by Seymour Cray's language before we build a corresponding direct Droducts. These machines do an excellent job execution machine. FORTH is the obvious Nith Fortran, but conceal gaps that program- choice. Ters have adjusted to and, in fact, accept as tkologica' necessities. For example, the array The goal of this research is to build the is a fundamental concept of Fortran, yet is only world's fastest FORTH engine. This is a no- .?directly supported in hardware. Subscripts compromise effort to force the hardware to going out of range is a common run time error mirror the language. We did not start by saying sut the hardware happily goes on with the it must be built with bit slices, or PLA's, or ... wong data pointed to by a bad subscript. In fact, an early paper design was done with bit slices and discarded because it was too slow. The architectural approach would reverse ?he procedure. Build hardware to support a The measure of speed is clock cycles per .anguage. We can do this at several levels, the instruction. Clock rate, in turn, is a function of owest being language-directed design where technology, not architecture. The machine I vrdware features are added to support specific currently runs at 333 ns but could be easily !anguage features. An example would be speeded up by using ECL or Schottky logic and Surroughs' concept of data descriptors to faster memories. provide run time checking of subscript ranges. Another example would be a P-code machine. The design cycle for a FORTH primitive "-code is language-directed since it was proceeds as follows: proposed as an ideal machine for compiled Pascal. It would be less suited for FORTRAN a. Pick a primitive such as DO or LOOP. for example. The general idea in language- directed design is to mirror important high- level language concepts in hardware. Semantic Gap is defined as the degree to which language

FORTH DIMENSIONS III/3 Page 78 b. Postdate hardware data paths, stackr, Results for randomly chosen inatructions are registers, etc., that implement DO and given below. All comparisons are based on a 1 mating primitives such as LOOP end MHz 6809 running fig-FORTH. The FORTH I +LOOP. engine rum at 3 MHz. DUP 99Xfaster SWAP 132 X faster c. Make sure this hardware supports @ 101 X faster U* 96 X faster hidden logical concepts-in this case, I, ! 114 X faster ROT 624 X faster J, K-and violates no other FORTH AND 126 X faster DO...LOOP 110 X faster concepts. (null body)

d. Count clock cycles. As a rule of thumb the speedup is a factor of 100. Why the 6809 (or any other computer) is so e. Repeat b-d until you can think of no slow i8 an interesting question and will be more speedup possibilities. treated in a more formal paper. f. Make an engineering choice for imple- We have received a number of inquiries mentation. DO takes 2 clock cycles about machine availability. Does anyone really without overlap, 1 with. LOOP and need a machine this fast? It is obviously a large +LOOP take 1 clock cycle. For the (ZOO+ IC) machine in the minicomputer class first machine, we use a 2-cycle DO and and will cost more than a 280. I would reserve the 1-cycle version for later appreciate hearing from readers about this as enchancements. As a byproduct of this well 88 memory and 1/0 requirements. implementation we can support loop nesting to a depth of 1024. David Winkel 2625 Solar Drive f5 This process is repeated far each FORTH Salt Lake City, UT 84117 primitive. Finally, this collection of indi- vidually optimized hardware must be forged into a coherent whole that makes engineering sense. he result4 is not too surprising. -re REFERENCES are data and return stacks plus separate stacks for loop control. Of course, the loop stacks are lAdvences in Computer Architecture, Glenford invisible to the programmer. An arithmetic J. Meyers, Wiley, 1978. unit operates from the data stack, etc. What is surprising is the mass of data paths required to zSouthcon Conference, Atlanta, Georgia, 1981, support parallel operations such as 2SWAP in session 20/2, Phillip crews. one clock cycle. The results are impressive. For the fig-FORM primitives all but 4 can be 3SYMBOL - A Major Departure from Classic executed in one or two clock cycles with the Software Dominated Von Neumann Computing exception of multiply and divide which take 1 Systems. Roc. 1971 Spring Joint Computer clock cycle per bit. The machine currently hem Conf., AFIPS, 1971, pp. 375-587. 16k X 16 main memory with lk X 16 stacks both extendable by 4 X. 1/0 is done with a slave 4Southcon Conference, Atlanta, Georgia, 1981, 6809 'rith programmed access to the data stack Session 20/4, David Winkel and DMA access to main memory. Control is microprogrammed with a 2910 driving a lk X 60 Art of Diqital Design, D. Winkel & F. bit write ble control store. This follows Logic Rosoer, Prentice Hall, 1981. Engine ' philosophy so the user has very pleasant access to the micromemory for tailoring high-speed special purpolle instructions.

Page 79 FORTH DIMENSIONS II1/3 a THE FORW INC UNE EDmm A high level vemion of the word MATCH, used by the line editor for marches, 18 Included S H. Daniel for those who do not already have a version System Development Corporation written in . If you intend to 500 Macara Avenue use this version of MATCH, screeno 216 and 217 Sunnyvale, CA 94086 should be loaded prior to loading the rest of the line editor. Credit for this version of MATCH The upcoming publication of Starting goes to Peter Midnight of Hayward. -3RTH, which is destined to become the ltbible" :' FORTH neophytes everywhere, provides an THE EDITOR COMMANDS qortunity to upgrade the existing fig-FORTH -- editor at a very small cost in time and The word 'text' following a command indi- ?Yort. cates that any text typed after the command will be copied to the text buffer used by that There are at least two good reasons why this command. The buffer contents will then be qrade should be done. The first is standard- used when the command executes. If no text is zation. A user of any version of fig-FORTH typed by the user, the contents of that buffer -.!: be able to step up to a polyFORTH system (left over from the previous command or com- md use the line editor. Conversely, FORTH, mands) will be used without modification in the 1-c. customers who try fig-FORTH will not have execution of the command. :: !earn to use a different editor. X extract ( - ) The second reason for adopting the r::vFORTH editor is its increased flexibility Copies the current line into the INSERT buffer, t-c ease of use. The current fig line editor uses and removes it from the screen. All following ~:ythe PAD for storage of user inputs for lines are moved up, and line 15 is left blank. searches, deletions, and replacements. The x:yFORTH editor employs both a FIND buffer T Type (n- 1 5-d an INSERT buffer, in addition to the PAD. --IS allows both of the extra buffers to be Type line n from the current screen. Set the :aded, and the contents reused several times, cursor to the start of the line. -.'.Clout extra typing by the user. This makes sc-nmands like D (Delete) and R (Replace) L List ( -- 1 ?: Jeciall y useful. Like the FORTH word UST, except that the 3y taking a few hints from Starting FORTH, current screen number is obtained from the s-d combining them with the existing editor, I variable SCR, rather than being typed in by the -3s able to write a line editor which is user. --ictionally identical to the polyFORTH editor, :I-: which is in the public domain and can be N Next (-1 -54 by anyone. Increments the current screen number by one. 7 -' STEM REQUIREMENTS This command is used just before the L com- mand, to allow the user to list the next This editor should run on any fig-FORTH sequential screen. i . stem, including FORTH-79 Standard systems ' the changes mentioned in the section 8 Back (-1 -3RTH-79 Standard are made). The compiled -e editor requires approximately 2K bytes of Decrements the current screen number by one. -cnory, plus room in the system for the PAD This command is also used before the L com- 2-d the FIND and INSERT buffers. It operates mand, to allow listing of the previous sequential -.thin the confines of the default data and screen. P:J~stacks.

-3RTH DIMENSIONS m/3 Page 80 P Put (-1 position, TILL searches for a match with the P text contents of the FIND buffer. If a match is found, TILL deletes all the text on the line from Any following text will be copied into the the current cursor position up to any including INSERT buffer. The INSERT buffer will be the end of the matched text. copied into the current line, replacing its previous contents. If the text consists of one or S Search ( last screen#+1 -- ) more blanks, the current line will be erased. S text

WIPE Wipe ( -- 1 Any following text is copied into the FIND buffer. Starting at the top of the current Erases the current screen. Equivalent to the screen and continuing until the bottom of the original CLEAR command, except that the user screen immediately before the screen number need not enter the screen number. on the top of the stack, S searches for a match to the contents of the FIND buffer. Whenever a cow copy ( from -2, to-1 - match is found, the line containing the match will be typed out, along with the line number Copy one screen to another. and screen number in which the match occurred. Because of the way FORTH handles F Find (-1 loops, the number on the top of the stack must F text be one higher than the highest screen to be searched. Any following text is copied to the INSERT buffer. The contents of the INSERT buffer are I Insert ( -- 1 compared to the contents of the current line. If I text a match is found, the line is displayed with the cursor positioned immediately after the end of Any following text will be copied into the the string searched for. The F command, with INSERT buffer. The I command copies the no following text, is exactly the same aa the contents of the INSERT buffer into the current previous editor command N. If no match is line, rtarting at the current cursor position. found, the requested string is echoed to the Any text to the right of the cursor will be terminal and the error message “NONF‘ is phed to the right and will be pushed off the output. line and lost if the total length of the line exceeds 64 characters. E Erase (-1 U Under (-) Erases backwards from the CUNOF, according to u text the number of characters in the FIND buffer. This command should only be used immediately Any following text will be copied into the after the F command. INSERT buffer. Spread the scmen at the line immediately below the current line, leaving a D Delete ( - blank llne. All following lines are pushed o text down. Any text on line 15 will be lost. The contents of the INSERT buffer will be copied Any following text ia copied into the into the blank line, and that line will be made buffer. The D command is a combination of the the current line. F and E commands. The string in the FIND buffer is matched against the contents of the R Replace ( - ) current line, and if a match is found, the found R text string is deleted from the line. Any following text is copied into the INSERT TILL Till (-1 buffer. The R command operates as a TILL text combination of the E (Erase) and I (Insert) commands. Starting at the current cursor Any following text is copied into the FIND pcmitim, and working backwards towards the buffer. Starting from the current curwr start of the line, text corresponding to the

Page 81 FORTH DIMENSIONS IW3 .ength of the contents of the FIND buffer is length byte of 1 will be stored, but Aeted, and the contents of the INSERT buffer PAD+1 will contain a null to indicate are inserted into the line. Since the contents of the absence of text. :w FIND buffer determine how much text will :e erased, the R command should only be used (LINE) (Line#, Screen# -- Buffer Address,64) ?mediately following the F (Find) command. Using the line and screen numbers, M Move (Block#, Line# -- computes the starting memory address of the line in the disk Zopies the current line into the INSERT buffer, buffer. May not be necessary in rwn copies the INSERT buffer to the block, FORTH-79 Standard systems, depend- r3ecified by Block#, UNDER the line specified ing upon implementation. Should I:. LINE#. The original block number is already be present in earlier :Qstored, and the next line in the block becomes implementations. :?e current line. This allows sequential lines to 2 moved with a minimum of keystrokes. One LINE (Line# -- Buffer Address) A?fortunate side-effect of this command is that 13 move something to line 0 of another screen, Ensures that the line number is within - ZIU must first move it UNDER line 0, using the the legal range of the current screen, xmmand xxx 0 M, make screen xxx current, then uses (LINE) to set the starting 37d then extract the old line 0, moving address of the line in the disk buffer. 3verything else up. WHERE (Offset, Block# -1 t ( -- 1 Used when a compile time error Jsed as a terminator for all commands allowing occurs during loading. Converts the text input, such as P, F, R, etc. Allows more block number to a screen number, :?an one command to be entered pn a single make8 that scmen current, and prints ..w,e.g., the line in which the load error occurred. Underneath the line in 3 T P This is line 3? L (cr) error, the cursor is printed to show the approximate location of the Although useful, this feature does preclude the error. Enables the EDITOR vocabu- JS~of the " " as a character in any text to lary as it exists. Strictly speaking, x! put on a screen. this is not part of the polyFORTH editor, but it is a highly useful tool. 3L0SSARY #LOCATE(-Cursor offset, line#) The following glossary addresses all the -3RTH words in the line editor except the Uses the current cursor position to xtual editing commands, which are discussed compute the line number which con- zSove. tains the cursor and the offset from the beginning of the line to the cur- 'EXT (delimiter - ) rent cursor position. Any following text in the input #LEAD (--Line address, offset to cursor) stream, up to but not including the delimiter, is moved to the PAD. The Computes the beginning addreas of length of the input string is stored at the current line in the disk buffer, PAD, with the actual string starting and the offset from the start of the at PAD+1. In FORTH-79 Standard line to the current cursor position. systems, if no text follows in the input stream, a length byte of 0 will be stored. In non-Standard systems, a

'ORTH DIMENSIONS III/3 Page 82 #LAG ( 0- cursor addre-, count after current line, pushing all lines below cursor) the current line down, and leaving the current line blank. Any text on line Computes the addrem of the cursor in 15 is pushed off the screen and is the disk buffer and the count of lost. characters remaining on the line after the cursor. DISPLAY -CURSOR ( -- -MOM: (from address, to line# - Displays the current line with the cursor in place. Moves a line within the dlsk buffer to the line specified, completely re- placing the previous contenb of that line. Replaces the current line with the contents of the INSERT buffer. Used ?MOVE (destination buffer address - ) as the primitive operation for the P command. Ifany text has been entered into the PAD by TEXT, moves that text to the (TOP) ( -- specified buffer. bed to load the FIND and INSERT buffer8 fm Resets the stored cursor position to searches, etc. If no text waa in the the top of the screen. PAD, no action is taken. lLINE ( -- Flag) >LINE# (- current line number ) Scans the current line for an exact Uws the stored cumor location to match with the contents of the FIND compute the current line number. buffer. If a match is found, the stored cursor position is updated. FIND-BW (-1

Establishes the FIND buffer a fixed 1 distance above the current addrum of Starting at the current cursor posi- the PAD. tion, searches the rest of the current acreen for an exact match to the INSERT-BUF ( - ) contents of the FIND buffer. If no match is found, the contents of the Establi8hes the INSERT buffer a fixed FIND buffer are typed and the error distance above the FIND buffer. message "NONE" is output. (DELETE) (Count - 1 Non-destructively copies the contents Starting at the current cursor posi- of the current line to the INSERT tion, text is deleted backwards buffer. (towards the beginning of the line), according to the count. The remain- (KILL) (Line# - ing text MI the line is moved to the left and the end of the line is filled Replaces ths specified line with a with blanks. blank line.

(SPREAD) (-1

Spreads screen, starting at Copies any following text to the the the FIND buffer and searches the page 83 FORTH DIMENSIONS In/3 n current screen for a match. Usd 214 5,6,7 The FORTH word R as the primitive operatian for the rhould be changed to R@. F and 0 commands. 212 3 The 0 preceding the word VARIABLE should be de- leted, since variables are Uses the length of the contentm of initialized to 0 auto- the FIND buffer to set the count matically under the for (DELETE). Uaed aa the FORTH-79 Standard. primitive for the E and R commands. 202 12 The word 1+ may be de- feted, since the FORTH- ZWNTER A variable uaed by the S command 79 Standard specifies that to count the number of lim a length byte of 0 will be output to the screen end printer. stored when WORD finds no text in the input WMP (-1 stream. Increments the number of lines output and sends a page eject ERROR MESSAGES when 56 lines have been output. Used by the S command to handle Only two error memagem am output by the line pagination on the coneole and &Stan printer. FoRll+79 STAISARD "E Micatea that no match was found on the current screen The following changes should be made to the comwpondinq to the contents of .3ed screens shown in order to bring the line the FIND buffer. editor into conformance with the FORTH-79 Standard: NOT ON CURRENT EDITING SCREEN keen Line(sx=hanQe Indicatm that the line number paad to the word LINE was 299 9,lO The FORTH word R outride the legal range of 0-15 should be changed to R@. decimal.

8 9 I LINE

13 14 --> 15

TH DIMENSIONS m/3 Page 84

sm*2eG e < YIPE. cow. ~LIW 1 2 3 I YIP€ < c1.r th cvrvnc > 4 ie e DO I ~ooe J - 5

018715 Sru ) A 21 3 4 S 6 7 $1 9 19 11 12 i 13 14 -> 1s

IONS m p.gb86 eiem

2 I < find QCCCT- oc fOllaUina text > 3 fEm 4 FIED-BVW-PUXS 5 1 6 ?:F < find ud diuln, f'ollauitu text >

SCR 0 211 e < D. TILL 818715 SCO > 1 2 3:D < find. d.lot0, md divlrv follouin. tat, 4 CF> E I 5 6

4 S 6:- 7 1- 8 S8> IF 9 CRCRBF 10 11 -> 12 13 14

? WIN 8 1LINE IF DISPLAV-CURSOR 9 m=Rme< ie MIL 11 LOW R> SCR ! i 12 13 -> 14 15 SCR 0 215 0CR.M 818715 YU > 1 2:R c rwlrr fard trxt uith inset Wffor > 5 I I 4 s:n < 6 SCRIM < 7 RIIM < 8 %IN3 o*LD> < 9 SYFYSCR! < 10 1+ WL I R. ! 11 < 12 R> C/L + Re I 13 R> SCR ! I i 14 15 FORTW DEFINITIWS DECIWC

SCR 40 216 e< 810715 Yo >

3 4c3wIp 5 ROT M ROT R> 6 7:- aJERockR 0 9:

SCR a 217 e< 1 2: S 4 S 6 7 8 9 10 11 12 If 14 15

qRTH01 MENSIONS IIU3 Pep 88 RECURSION AND THE ACKERMANN becomes: "CTION (FIG-FOR TH) Joel V. Peterszn 0 VARIABLE CALLCNT : ACKERMANN ( I J - F ) Recursion involves the calling of a program 1CALLCNT +! by itself. An example of where recursion might O= IF be used is in the parenthesis handler of an SWAP DROP 1+ algebraic string parser. Every time the parser ELSE encounters a left parenthesis, it calls itself; DUP every time the parser encounters a right O=IF parenthesis, it completes a call of itself. DROP 1- 1MYSELF Recursion is somewhat difficult to explain and ROT ROT DROP 1- SWAP MYSELF very difficult to use properly. However, the THEN implementation of recursion in any language THEN ; can be tested with a program called the Ackermann Function. This is a recursive (MC-forth) function of two variables which is almost impossible to explain. The followintj is an VARIABLE CALLCNT implementation of the function in PASCAL. : ACKERMANN ( IJ - F ) VAR K,J: INTEGER; CALLCNT;INTEGER; 1CALLCNT +! OVER THEN FUNCTION F(K,J: INTEGER): INTEGER; DUP BEGIN THEN CALLCNT :=CALLCNT+l; POUP 1- MYSELF IF K=O THEN -ROT DROP 1- SWAP MYSELF F :=J+l ELSE ELSE DROP 1- 1MYSELF IF J=O THEN EUOIF F := F(K-1,l) ELSE ELSE SWAPDROP 1+ F :=F(K-l,F(K, J-1)); ENDIF ; END(+ACKERMANN FUNCTION*); For comparison, tb Ackermann Function Recursive programming as illustrated in the was tested on the Nicolet 1280 20-bit PASCAL example is not possible in FORTH. A processor in both (compiled) PASCAL and program can not invoke itself simply by ming MC-forth. The K=3, 305 function took 8 its own name while defining that word. seconds in (compiled) PASCAL and 12 However, recursion is not difficult at all to seconds in MC-forth. (As an aside, the achieve: addition of a simple hardware mod to the 1280 processor to speed up NEXT in MC- (FIG-FOR TH) forth reduced this to 9 seconds! Who says : MYSELF LATEST PFA CFA , ; inline coding is 80 much faster than indirect IMMEDIATE threaded code!)

(MC- f or t h) When attempting to try the Ackermann : MYSELF LAST @IQ 2 + , ; IMMEDIATE Function, one must allocate lots of room for both the parameter stack and the return MYSELF simply places the address of the stack. Every time the function is called, code field of the word being defined into its there must be two elements on the own definition. Thus, whenever the program parameter stack, thus the parameter stack needs to invoke itself, the word MYSELF should will fill up approximately twice as fast as be used instead. The Ackermann Function now the return stack. The K=3, 3=6 function requires over 1000 elements on the RMEW parameter stack and over 500 elemenb on the return stack at its deepest point. When A Brief Review of the Manuals the K=4, J=1 function was tried, the pro- for the PET/CBM fuIIFORTH+ V1.3/4 gram finally crashed after five houn with the return stack containing over 5000 by Jim Berkey elements!! Complete system is available from IDPC The results of the simpler Ackermann Co., Box 11594, Philadelphia, PA 11916 for $65 Functions are given below. F is the value (plus shipping?). Includes about 70 pages of returned by the function. CALLCNT is the documentation and a 5p diskette (not re- count of how many times the program called viewed). itself. MAXDEPTH is the maximum depth attained by the return stack. IDPCb fulIFORTH+ is noted to have taken a person-year to be developed by an experienced Y J -F CALLCNT MAXDEPTH programming staff. I give them a triple E for b8l 1 effort, but the product is, at best, rough. 012 1 102 2 fuLlFORTH+ is described as "a complete 113 4 3 implementation of the FORTH language, as 124 6 defined by the FORTH Interest Group." If this 203 5 is true of the disk, then there are glaring 215 14 technical errors in the glossary, whose defi- 227 27 8 nitions deviate substantially from the FIG 239 44 10 manual. One example from +LOOP : "If the 2 128 259 33669 counter and limit values are equal, either 305 15 before or after adding the increment, the DO 3 1 13 106 loop is exited . ..'I If you take this literally, the 3 2 29 541 counter (read "index") is compared to the limit 3 3 61 2432 63 twice-once before and once after the incre- 3 4 125 10307 127 ment-and exit can never occur on greater- 3 5 253 42438 255 than, as it does in the FIG model. 3 6 509 172233 511 3 0 13 107 16 On the plus side, the package includes 6502 0 1 ?? ?? ?? assembler, screen editor (not PET'S), printer support, and floating point routines. These are 'JC-forth is the implementation of FORTH on nice to have, but from the samples of use '-e MCOLET INSTRUMENT CORPORATION shown, I suspect the presence of endless small - 30/1280 series computers. This computer is a inconveniences. To be fair, endless small :"-bit minicomputer with a 19-bit address inconveniences are a built-in feature of CBM rtace.) disk systems which fuIlFORTH+ has not Joel V. Peterson mrrec ted. Nicolet Instrument Corp. 5225 Verona Road I can't recommend fuIIFORTH+ for any but Madison, Wisc. 53711 the desperate, because of two central pmb- (608) 271-3333 lems: (1) the manual reveals a mangled view of the FIG model, and (2) fuIIFORTH+ was I-_- - A great article, but watch out. Most probably not implemented originally for the -- ;=ORTH implementations have insufficient PET/CBM. 3:xk space to execute this function. Rograms muld be reviewed for compatibility.)

'3'ITH DIMENSIONS IIID Page 90 FORTH, INC. NEWS program management. He has degrees in physics, finance, and corporate and contract BETTER SUPPORT PROMISED THROUGH law. FORTH, INC. AND TECHNOLOGY INDUSTRIES MERGER Robert E. Smith, Jr. is FORTH, Inc.'s new vice president of sales and marketing. Smith FORTH, Inc. and Technology Industries, Inc. has over ten years of experience marketing of Santa Clara, CA., have announced a application software for minicomputers. He has merger. This means that FORTH, Inc. will already tripled the size of the marketing become a wholly owned subsidiary of department and plans to triple it again within Technology, and the present shareholders of eighteen months. FORTH will become shareholders of Techno logy. Other important additions to the staff include two people in the accounting depart- Technology Industries is a new company ment and three sales and marketing representa- founded in February 1981 by John Peers. Peers tives. The products department has been is best known as founder and former chairman reorganized with Leo Brodie, author of Starting of Logical Machines Corp. of Sunnyvale, CA. FORTH, acting as manager. The publications This very successful company manufactures and department has grown by two, and three general sells business computers that feature a support staff members have come on board. "programmer less" language called Adam, designed by Peers. RECENT APPLICATIONS

"The principle change that everyone will FORTH, Inc. recently signed a contract with notice," said FORTH, 1nc.b president, Elizabeth International Business Services, Inc. in Rather, "is that we'll be doing a lot more of Washington, D.C., to supply hardware and soft- what we do best-selling and supporting high ware to the United States Forest Service. quality professional FORTH systems and applications-and doing it even better. We're FORTH, Inc. will provide the hardware and expanding wr staff and investing heavily in update and enhance the software for a high- equipment training." resolution map analyzer system. The system will work with digitized data from existing FORTH, Inc. will operate with its individual contour maps in raster format. identity, retaining the same name and operating structure. Technology Industries will be the The raster-scanned maps will be displayed "parent" of several other new companies as on a high resolution (1024 x 1024) image well. Each will specialize in hardware designed system. A pDP-11/44 is then used to follow a around and featuring FORTH. wMembership in given contour line and convert it to a string of this group will provide us with the opportunity vectom. Operator assistance is required in to do some things Pve wanted to do for ye-," selecting a contour line, labeling, handling said Chuck Moore. "Fm extremely excited breaks in data, and making corrections from the about these plans." original map. Operator input is via a track ball interface and alphanumeric CRT. EXPAF lSION CONTINUES Dick Liston of USFS has used FORTH for FORTH, Inc.% growth in recent months has several years developing a prototype version of included two significant additions to the system using miniFORTH on a PDP 11/05. management.

Joseph ''Skipn Reymann, formerly with GOULD NAVCOM of El Monte, California, has joined FORTH, Inc. as vice president of opera- tions. Reymann has extensive experience in both the technical and business aspects of

Page 91 FoR7Hort(mnusItn\rsIlTPJ Remember your media should be purchased on the baais of cost per pros- pect, not cost per 1,000. Q. Pve written several programs that all my friends think are excellent; what is the best MESSAGE-you may be saying the right way to market them?-M.L., New Mexico thing to the right people, but in the wrong way. Part of your test marketing should A There is no universally "best" way to market be to give your advertising and sales copy anything, and that includes computer to a rank amateur and see if what they programs. Generally speaking, however, think you are saying is the same thing you planning is your best ally. Since you have think you am saying. already received some feedback (and I assume you are certain that it is valid and The above list is by no means all-inclusive, not just your friends being politely sup- but these are the areas you should start portive), it makes sense that persons that looking into first. closely match the profile of your friends in terms of need, occupation, income, etc. Q. Is there any way of selling my programs would be your best prospects. Simply put, other than by buying ads, etc.?-B.C., marketing under these circumstances will Walnut Creek, CA consist of finding a way to communicate effectively and cost effectively with this A. Yes. One of the most common ways is to target group. have your software merchandised through any number of firms that specialize in this Q. herun a number of ads for software I have field. Basically the way they operate is to developed and while I have sold some, I just contract with your for ownership of your don't seem to make any real money for the software and pay you a royalty on sales-- time I am putting in-what am I doing much like an author receives from a book wrong?-R.B., Sandusky, Ohio publisher. Naturally, the royalty is nowhere near the amount you would receive if you 9 Your problem points up many areas that do sold your software directly to the consumer not occur to the amateur entrepreneur. In yourself; but considering that you have no the interests of brevity, I will touch on a risk and your time is free to develop few of the more significant as being instruc- additional products which in turn can be tive to our readers. sold, the reduced percentage is still often the best way to go. The point is that it isn't RODUCT--in this area you may be pro- how large a percentage you receive that is moting a product that serves no real need important-but how much money you make. or is competing with an already estab- lished vendor. Questions of general interest regarding the marketing of software will be answered in each PRICE--your price may be too high, edition in this column. Because of time causing your potential customers to seek limitations, it will not be possible to provide other sources or do without; or, more private answers either by phone or mail. In the commonly, your price may be too low, interests of personal privacy, questioners will causing you to perform excessive labor in be identified by initials only. Questions should selling and servicing your accounts for the be addressed to: amount you are charging. MARKETING COLUMN MEDIA--you may be advertising or selling Editor, FORTH DIMENSIONS to the wrong audience. If you have failed PO Box 1105 to research your market and are running San Carlos, CA 94070 ads based on who's cheapest as opposed to who's reading (prospect profile), you are unlikely to achieve any realistic sales.

Page 92 t€LP WANTED EMJCATIONAL STAFF ASSISTANT

FORTH PROGRAMMERS Experienced in dealing with public, sales and marketing, and some programming. Duties will Openings at All Levels include assisting education department manager At FORTH, Inc. with overflow administrative tasks, active participation in FORTH, Inc. user group. Programmers experienced with mini/micro computers and peripherals to produce new polyFORTH systems and scientific/industrlal applications. Degree in science or engineering and knowledge of FORTH essential. Experienced in public speaking or educational instruction, programming on various processors PRODUCTSUPPORTPROGRAMMER --high-level languages and assembler. Micro- processor and FORTH programming background DUTIES: Responsible for maintaining existing valuable. list of software products, including polyFORTH Operating System and Programming Language, CONTACT: file management options, math options and utilities and their documentation; and providing Pat Jones technical support to customers. FORTH, Inc. 2309 Pecific Coast Highway Requirements include: Hermosa Beach, CA 90254 (213) 372-8493 Good familiar ity with FORTH--pref web1y throu# one complete target-compiled application. Assembler level familiarity preferred with the 8080, PDP/LSI-ll, 8086, coNSuLTANTWAM€D M6800, CDP1802, NOVA, IBM Serim I, TI990. Communication skills are ewential. We are designing a heat pump controller sptem, which is based on the National Semi- conductor "COPS" Microcontroller. It is a 4 bit PROJECT MANAGER calculator chip, with 2K of ROM and 128 nibbles of RAM. ' Project manager to supervise applications and special systems programming projects: writing We need a consultant who can: proposals, setting technical specifications, customer liaison, hands-on programming, and 1. Advise whether or not Forth can be put supervision of senior programmers. on the COPS

2. Estimate the program size, once compiled

Exper:enced in course writing and development, 3. Write software which would allow me to technical education in computer software, hard- write and debug code on a TRS-80, ware, and related subjects, including FORTH Model I, and then cross compile it to programming. Responsibilities include mar- the COPS. keting seminar support and instructing in-house poly FORTH courses. For information call:

THE COLEMAN COMPANY, INC. Scott Farley Design Project Manager (316) 832-6545

Page 93 FORTH DIMENSIONS IIIl3 H89/Zenith Z89 users with the HDOS operating system. It is a version of 8080 FORTH by Timin Engineering, Release 3 FIG-Forth Version 1.1 customized for HDOS and the H/Z89. Disk I/O takes Release 3 of FORTH by Timin Engineering is place via a standard HDOS disk file. In z complete software development system, It is addition, the FIG-Forth source listings are provided and may be modified and --teractive (conversational) in nature. The re- - 3RTH system incorporates a command proces- assembled on a single-disk HDOS sytem. scr, compiler, editor and assembler, all memory msident. The principal benefits are a reduction - Extras: None. - software development time and a reduction - memory size for large applications. The - Target machines: Heath HE9 and Zenith :::mipal application area has been machine and 289. Heath H8 users may also use the ~xcesscontrol. The language is suitable for all system if they modify the console 1/0 zdications- except scientific mathematics. routines. 'is product is based on the well-known FIG -35TH but with numerous enhancements, - Memory requirements: 32K of RAM - zluding: - Number of documentation pages: 140 - visual (screen) editor - array handling (implemented in machine - Documentation description: code) - very fast disk 1/0 Documentation consists of release notes, - configurable for different memory size a copy of the FIGForth Installation - creates turn-key applications Guide, and a copy of the official 8080 - CP/M system calls and file handling FIG-Forth version 1.1 source listing. The manuals provide the information Selease 3 of Timin FORTH will run on Z- necessary to install and modify the Forth K '8080/8085 hardware systems with CP/M or system. 3MS. Minimum memory size is 28K. The :-.=for Release 3 of Timin FORTH is $235 (if - Emex does not offer the manuals xyer than 8" standard disk, add $15). To order separately. They may be purchased =..ease 3 of Timin FORTH, write Timin separately through the Forth Interest 5- gineering Company, 9575 Genesee Avenue, Group. i:te E-2, San Diego, CA 92121, or call (714) -!5-9008. - We will reduce the price to $25.00 for persona already owning copies of both FIG HOOS FORTH docurnents. - Vendor: Essex Computer Science - Form of Product: 5" HDOS diskette, including source, object, and release note - Address: 1827 St. Anthony Ave., St. Paul, files. MN 55104 - Shipments to date: about 4 - Telephone: (612) 645-3345 - Rice: $45.00, or $25.00 for those who - Contact: Rick Smith already own the FIG documentation. - Product Name: Essex HDOS FIGForth - Includes: U. S. postage, local tax. - Description: - Warranties and support: 30 day free replacement, of defective media. We are Essex HOOS FIG-Forth is an inexpensive interested in fixing bugs that crop up but version of FIG-Forth for Heath do not guarantee that bugs will get fixed.

'3RTH DIMENSIONS III/3 Page 94 - Order turnaround time: 3-4 weeb. The software is on 2 disks. One contains the complete source and object. The other contains Order from: Editor, Screens, &or Messages and other bits of FORTH code of my creation done while I hexComputer Science started using FORTH. Richard E. Smith 1827 St. Anthony Avenue I will supply my AIM-FORTH "Hacker's St. Paul, MN 55104 System" to anyone for $25.00. THIS IS NOT (612) 645-3345. FOR BEGINNERS! THIS IS NOT A COM- MaiCIAL PRODUCT! I am interested in con- tacting other FORTH hackers in my area and AN 1802 FIG FORTH would like to possibly make some noise with them or start a phone line software interchange Version 1-RCA COOS of techniques using MODEMS. I welcome any Load under RCA COOS letters or input on this idea. Disc with source and object files for RCA CDP18S008 Eric Johancwon COP18S007 55 A Richardson St. COP18SO05 with COOS upgrade Billerice, MA 01821 A minimum of 8K from addresa 0 is Fequimd (617) 667-0137 (home) (617) 899-2719 x 224 (work) Version 2--RCA unit-track Load under RCA unit-track Oisc with source and object files far RCA CDP18SOO8 FORTH MAILING LIST FOR APPLE CDPl8S007 CDP18SOO5 with UART card Allows users to maintain 1,000 entries per A minimum of 8K from addre- 0 is required floppy. Functions include adding, deleting, and modifying entries. The mount option allows Version 3-object and FORTH screena mounting any number of mailing list floppys. Load under RCA unit-track Labels can be generated in 1,2,3, or 4 across then LOAD FORTH screens format8 with ueer optional selection criteria.

Version 3 Is suggested unless tho user wanb This application package includes: 16 sector to manipulate the 1802 source code. This boot disk for the Apple; Source code for system version will be continually updated with and a bonus of one mailing list floppy with name program materiel. addresses and phone numbers of over 100 FORTH users. The discs are $50 each (Calif. re8 add 6 percent sales tax) Rice is $45.00 from: Order from: CMOSOFT, P. 0. Box 44037, Sylmar, CA 91342 Elmer W. Fittery INTERNATIONAL COMPUTERS 110 McGregor Avenue Mt. Arlington, NJ 07856 (201) 663-1580 (call after 6:00 pm) AIM-FORTH 'HACKER'S SYSTEM" I finally got my figFORTH 65 running on my AIM-65 at work and I would like to offer it to other hackers like myself. This FORTH FIG CoMasG - NW. 28 system runs on AIM -65 with the DAIN DISK SYSTEM and uses an external terminal.

Page 95 FORTH DIMENSIONS III/3 and October 5-9 at FORTH, Inc. An advanced course will run October 12-16. Contact Kris FORTHCLASSES Cramer for details. FORTH, Inc., 2309 Pacific Coast Highway, Hermosa Beach, CA 90254, NEW CLASS (213) 372-8493. BY KIM HARRIS h HENRY LAXEN

FORTH, PRINCIPLES AND PRACTICES MORE FORTHCLASSES This clam is intended to teach the student -2w to write programs in FORTH. It is a "how Intensive 5-day FORTH workshops are being I;" class and not a "why" workshop. The class offered at INNER ACCESS CORPORATION. *ill meet on each Monday in October from 6:30 These workshops provide en introduction to the '3 9:30 at Berkeley Computer, 1569 Solano FORTH programming language sufficient to 'denue, Berkeley. The phone number there is design and debug programs to solve real '26-5600. The topics to be covered are: problems. These workshops also serve to enhance one's mderstanding of the FORTH TheLanguage tools necessary for complex applications. Input output StrucfUre string Hendling wabhop Date8 Time CaBt Vocabularies Septa 21-25 9-4:30 $295 Defining wards Oct. 19-23 NOV.16-20 This is an ambitious schedule, and depending 3" the level of the students, more or less will be To obtain more information on these work- rzvered. Experience with other computer lan- shop, call Inner Access (415) 591-8295 in pages would be helpful, though it is not Belmont (home of Marine World) in the San Tquired. There will be homework exercises, Francisco Bay Area. zYj machines will be available for students' se. For more information, contact Henry dxen at (415) 525-8582.

SEMINARS, WORKSHOPS, CLASSES ANDMORECLASSES FROM FORTH, INC. Free Beginner's Clam for Apple users. In San Diego, two-session course on 9/26/81 and acetian *miner Walcbhop at p.m. at Computer Merchant, 5107 -:s -:s Angeles October 15 October 10/30/81 1 16 El Cajon Blvd. K. V. Amatneek, Instructor. 31 Diego October 22 October 23

Introductory classes in polyFORTH zxqramming will be offered September 14-18

'ORTH DIMENSIONS III/3 Page 96 How to form a FIG Chapter: southwest Wnix Peter Bate8 at (602) 996-8398. 1. You decide on a time and place for the first meeting in your area. (Allow at least Td8a 8 weeks for steps 2 and 3.) 3rd Tues FIG Meeting, 7:30 p.m., The Computer Store, 4343 So. Peoria, 2. Send FIG a meeting announcement on om Tul~e, OK. Bob Giles, (918) 599- side of 8-1/2 x 11 paper (one copy is 9304 or Art Gorski, (918) 743-0113. enough). Also send list of ZIP numbers that you want mailed to (use first three Texas Jeff Lewis, (713) 719-3320 or John digits if it works for you). Earb, (214) 661-2928 or Dwayne Gustaua, (817) 387-6976. John 3. FIG will print, address and mail to Hestings (512) 835-1918. members with the ZIP'S you want from San Carlos, CA. Mid Atlantic htomac Joel Shprentz, (703) 437-9218. 4. When you've had your first meeting with 5 or more attendees then FIG will provide New Jersey George Lyons (201) 451-2905. you with names in your area. You have to tell us when you have 5 or more. New York Tom hg, (212) 746-4062. Northern California Mldwmt 4th Sat FIG Manthly Meeting, 1:OO p.m, at Dean Vieau, (313) 493-5105. Southland hpping Ctr., Hayward, CA. FORML Workshop at 1O:OO am. maLame Collina (03) 292600. Southern California Los Angeles -land FORTH bltemst Group, C/O 38, 4th Sat FIG Meeting, ll:00 a.m., Allstate Wor8ley Road, Frimley, Camberley, Savings, 8800 So. Sepulveda, L.A. Surrey, GUl6 5AU, England Philip Wasson, (213) 649-1428. Japan FORTH Interest Group, Beba-bldg. Orange County 8F, 3-23-8, Nishi-Shimbashi, Minato- 3rd Sat FIG Meeting, 12:OO noon, Fullerton ku, Toyko, 105 Japan. Savings, 18020 Bmckhorst, Fountain Valley, CA. (714) 896-2016. Canada Quebec Gillw Paillard, (418) 871-1960 or San Diego 643-2561. Thur FIG Meeting, 12:OO noon. Guy Kelly, (714) 268-3100, x 4784 for We& Germany site. Wolf Gervsrt, Roter Hahn 29, 0-2 Northwest Hamburg 72, West Germany,(040) Seattle Chuck Pliske or Dwight Vandenburg, 644-3985. (206) 542-8376. New Enqland Boston 1st Wed FIG Meeting, 7:W p.m., Mitre Corp., Cafeteria, Bedford, MA. Bob Demrow, (617) 389-6400, x198.

Boston 3rd Wed MMSFORTH Users Group, ROO p.m, Cochituate, MA. Dick Miller, (617) 653-6136 for site. Paw 97 FORTH DIMENSIONS IW3 FORTH INTIRIST OROU? Volume 111 P.O. Box 1 105 Number 4 w San Carlor, CA 84070 Price 52.50

101 FORTH and the University

11.FORTH in Laser Fusion

Proceedings of the 1981 Rochester 2FORTH Standards Conference Implementing FORTH-Based .-, .-, Microcomputers Data Structures in a SdTelecommunications Front End Mapped 113 Techniques

fle A High Level Interrupt Handler in FORTH Optimized Data Structures for 11,Hardware Control

121 The String Stack

125 Complex Analysis in FORTH A FORTH-Based, Micro-sized 126.Micro Assembler mmrcamw

d tho A mecial thanks this month aoes to Larrv Foralev I _..- -7.- ~ Mr. Univenlty of Rochester. The f&]ority of thia kue comes from hia efforta and those of his asociates. While acting as guest edi- Published by Forth Interest Group tor for this i88ue of FORTH DIMENSIONS, Mr. Forsley was also compiling end editing the proceedings from this year's FORTH Volume In No. 4 Nowmber/Detcomber 1981 conference at the University of Rochester. Even with this "double duty," Mr. Forsley hor done en excellent job. Publisher Roy C. Mutens Editor C. J. Street The quality of material we hove received from the University of Rochester is excellent end greatly encourages me in my plans Editorial Review Board to "de-Califomize" FORTH DIMENSIONS through the use of re- giocul gwst editon. While Mr. Fonley and the University of Bill Ragsdale Rocheater may be e tough act to follow, I will welcome contacLs Dave Boulton from anyone else (penon and/or organization) who would like to Kim Harris try guest editing en iuw. For your peace of mind, let me asaure John James you that production (typesetting, proofing, printing, etc.) will be Dave KiISridge handled for you. If you think you have whet it takes, give me a Henry Laxen call or drop me a line. George 'vlaverick Bob Smith Yw may find that wme of this irrue's aectiau have been re- John Sumgarner duced is size and/or eliminated. his is a temporary concession becaurs of the volume of material we have to publish in this irrue. htel costa prohibit expending the size of FORTH DIMENSIONS to publish a11 we receive, so when we have a quan- FORTH DIMENSIONS solicits editorial material, comments tity of quality material we publish those items that would %em to and letters. No responsibility is arumed for accuracy of material hove the greatest reader interest. submitted. ALL MATERIAL PUBLISHED BY THE FORTH INTEREST CRDUP IS IN THE PUBLIC DOMAIN. Information in I hope to meet many of you at the FIG National Convention in FORTH DIMENSIONS may be reproduced with credit given to tha Santa CIare, California on November 28th. Meanwhile, author and the Forth Interest Group. GO-FORTH adget additional members.

Subscription to FORTH DIMENSIONS is free with mmbarrhip C. J. Street in the Forth Interest Group at $15.00 per you ($27.00 foreign Editor air). For membership, change of addresa and/or to srrbmit material, the address is:

Forth Interest Group P.O. Box 1105 San Carlos, CA 94070 We are heeding into aome bury times for FIG. By the time you pet thir copy of FORTH DIMENSIONS we'll have completed the Mini-Micro Aow in buthem California and be deep into the details of the FORML Conference and FIG National Convention. Remember that the Convention is Lturday, November 28th at the Muriott Hotel in S.nta Clara, California. Expect to see many of you there.

We've rent out packeta to FORTH vendors about exhibiting at the FIG National Convention. If you are interested in exhibiting FORTH waa created by Mr. Charlea H. Moon In 1969 et thr and haven't received a packet, call the FIG line and request ooe: National Radio Aatnwmy Obwrvatory, Chulottesville, VA It (415) 962-8655. Only $50 for a table! was created out of dissatisfaction with available proprunmlng tools, especially fa obwrvatory lutomatim. This inue ia the much awaited Univenity of Rochester effort. Ita packed with useful material. You ought to order the Mr. Moore adseverel aseociatss formed FORTH, tnC. in 1973 Proceedings of the 1981 Rocheater FORTH Standards Conference. fathe purpae of licensing end support of the FORTH Operating It her 378 papof excellent papers System and Programming Lngwge, and to wpply opplication programming to meet wstomcrs' unique requirements. "Starting FORW by Leo Bmdie is available from FIG ------md replecea "Uainq FORTH" u the book to have The Forth Interest Group is centered In Northem Cdifomla. about the FORTH I~guag8. Our membership is over 2,400 worldwide. It waa famed in 1978 by FORTH programmers to encourage we of the language by the Now, a little lecture. We have conducted en unscientific interchange of ideas through aemiovr and publlcatiam. wvey and fwnd that in many locations there are people who are uring FORTH md aren't members of the FORTH Interest Group. ORDER YOUR COPY1 Yw M a member ahould work on them to join. All you have to do Proceedings of the 3981 Rochester FORTH Standards is make a copy of the Order Form------and Conference hove your aaociatsr fill in their name and adarea. If we each $25.00 US, $35.00 Foreign. Send check or MO to get w more person to join well have over 5,OOO members. Let's FIG in US funds on US bank. do it.

'Starting FORTH' Roy C. Mutens Hard Cover - $20.00 US, $25.00 Foreign Soft Cover - $16.00 US, $20.00 Foreign

100 FORTH DIMENSIONS mr 4 FORTH AND THE USVERSITY Keck and me, demonstrates a high level unstructured environment find both their interrupt handler used in plasma physics productivity and creativity increased. Lawrence P. Forsley experiments. The third paper in this But, some direction must be applied to Laboratory for Laser Eneigetics section is by Joe Sawicki, and suggests share code anrong uabrr. I wggest that University of Rochester powerful structures for easily and this direction should be one of form, and efficiently interfacing hardware. not of content.

Welcome to the wonderful world of The last mction illustrates the dlffi- It Is appropriate to define documenta- -9W, or, University of Rochester culty with defining the difference between tion ntandards which imply a form. But is -39TH. URTH was developed wveral systems and applications. The first piper is inappropriate to state that something .cars ago and has been used for meny is by Michael McCourt and Hichad Marisa, can be done only % (with the implied zxl!ications, some of which are and describes a transportable String right) way. However, people who learn %-merited here. Beginning with the Stack. The second paper is by Alfred something by doing it the wronq way FORTH Internatinel Standards Clark and covers a FORlKbased complex understand much better than people who Znference, held on Catalina, we have arithematic calculator. The IisL paper is are JoJ the right way. ':..swed the FORTH standardization by Greg Cholmondeley and documents a "'ort. As a result, the majority of our microprocessing tool similar to one I thiqk an example of this can be foun 8.items are close to being FORTH-79 supplied by Signetica in a conversation 1 had with Kim Harris. I I:rndard, although not FIG model. Very Kim took exception to an emr er paper by 'er papers in this issue will refer to These papers have many things In Peter Helmers on Userstacks! I was told -% TH. common. Dn. example is the difficulty in thnt the approach was wrong. Period. But discriminating between user8 and imple- on further diacueaion, I found that I agreed The 1901 Rochester FORTH Standards mentors. Bob Keck, a user, worked with with Kim. The fault was that Peter had Imference was held at the University. me to develop a tool for high level inter- found only a partial wlution to data --.e major reason for this, aside from the rupt handling. Likewise, Al Clark, also a typing, and in a multitasking system his x .ptful weather at that time of year, is user, has augmented a floating point technique might be very cumbenome. "e FORTH activity at the University. package with words appropriate to the That's fine. Peter I-bImem does not wb --.s work shows up in several divisions and complex plane. The String Stack is clearly multitasking systems, as his systems are 2ezartments including the University a system tool. Complex arithmetic is ISM all single uwr, interrupt/event driven. z-vuting Center; Optics; Physics and thus, it is worth remembering that eac of so, end a microprogramming system is us has different, and valid, viewpoints. A rtronomy; Chemical Engineering; clearly an application. Or is it? In the P -'?zhanical Engineering; Department of context of its user, the microprogramming i:.ology, Division of Diagnostic Ultra- words are a system. We seem to be for- As a major promoter of FORTH at the i:-Td; Department of Cytopathology; ever chasing our tail when determining a Univemity of Rochester, I have tried to rz:rical Engineering and the Laboratory FORTH context. But 1 think that this is define an environment conducive to this :- Laser Energetics. Indeed, we are the power of FORTH. type of interplay. This has resulted in a -03ted to the original work by Dick learning environment with many student ze-7,, who in 1976 was an assistant profes- Another facet is the use of defining opportunities; and with Leo Brodie's book, r-3f Physics and Astronomy, for deriving words used throughout the papers. An Starting Forth, and Don Colburn's study -e first URTH system; and to Ken extension of defini words, Paul guide, Goinq Forth, we can begin teaching --.-( wick, who in 1977 was with the Bartholdi's TO concept? is used in both with FORTH. Not teaching FORTH, but -r bersity Computing Center, for bringing Joe Sawicki's and Greg Cholmonde y's teaching with it. Four of the authors in z :?e IBM 360/65 TSO version based on code. Mike McCourt's "IN" concept' is this issue are students and three other 1 zg's work. At this time, Ken, Dick and I used by Peter Helmer's to implement the authors teach courses or neminars. If or-c the only FORTH users at the TO concept. However, a student, Carole FORTH is ever to catch on like Pascal, or -? Wersity. I believe the name URTH was Winkler, thought that TO complicated FORTRAN, then it must begin wtih -I ud by Ken, although Dick was partial things unnecewarily, so she doesn't use it. university teaching as those two languages I PARTH, for Mike Williams' did. In five years my present students will - -':itasking Intel 8080 FORTH system. This last comment illustrates one of be in industry, as my first student con- --'xtunately, Ken and Dick are no longer the virtues of universitier freedom of tacts already are. A univeristy environ- - :- the University; and Mike's commit- dissent. Unfortunately, 1 have found that ment coupled with its students' enthusiasm -t-ts prevented his authoring a paper. most groups, and many people, using and their eventual employment will Trever, their work is reflected in the FORTH are intolerant of different views. further FORTH more than any seminar -3:erial presented here. During my involvement with FORTH I series or interest group. But it will take have watched many grodps rise to time. -his issue starts with three overview ascendency, tout the true way, and then :xcrs. The first paper is mine and covers be replaced by another group. This has -c development of FORTH at the Labora- been especially true of the FORTH 1. FORTH DIMENSIONS Vol. I No. 4 and :-. for Laser Energetics, which remains Standards effort where Kitt Peak, Vol. I No. 5. .-c iargest university FORTH user. The FORTH, loc., the European FORTH User's p.:md paper, by Peter Helmen, reflects Groups and FIG have all played this role. 2. FORTH DIMENSIONS VoL I1 No. 4 T :ye uses of FORTH in medical research But another view is possible, which is rc clinical applications. The third, by more in keeping with FORTH8 nature. 3. Personal conversation on May 10, 1981 D--Lefor, covers one of the more visible prior to the Rochester Conference. r .ersity FORTH systems: The IBM 3032 Many of us see FORTH as being' a 2 -0mmunications front-end. system of controlled, or directed, 4. FORTH DIMENSIONS Vol. 11, No. 2 anarchy. Since every man, or woman, can -* next three papers demonstrate a be for himself it is highly idiosyncratic 5. Since thet paper, Peter has published i-.cty of ways by which FORTH can be and anarchistic in form. Anyone who has another one, entitled "Alternative ze: to interact with hardware. The first tried a team approach to FORTH Parameter Stacks," which can be found L.CP-, by Rosemary Leary and Carole programming is familiar with the tendency in the Proceedings of the 1981 wler, deals with three methods of using towards a Tower of Babel. On the other- Rochester FORTH Standards Con- -axed memory. A second paper, by Bob hand, people comfortable with thie ference.

Page 101 Ip TH DIMENSIONS Ill14 FORTH W LASER FusioN upon standard computers, interfaces and cases, the scientists were very knowledge- software. Originally, in 1971, we chose able about FORTH, whereas in other Lawrence P. F orsley the Hewlett Packard 2100 series com- cases, they only knew a few words. 1 was Laboratory for Laser Energetics puter, and the RTE (Real Time Executive) especially impressed by Dr. Mark Alcott, University of Rochester Operating System with Fortran, Assembler who was, st the time, with Cal Tech and and Algol. We used the HP backplane for was observing on NRAO's 36 foot radio Abdrrt our instrument interface. This system ran telescope. He was pleased with his ability for over five years and 15,000 shots, but to change the graphics routines and other Inertial confinement fusion research building a completely automated laser "systems" software while continuing to using lasers has resulted in the laboratory with 24 instead of 4 beams required a collect data. Similarly, I found many creation of extraordinary conditions of different approach. technicians programming and writing test temperature and pressure, duplicating program& This appeared to make good those found in the cores of white dwarf The Hewlett Packard computer brk- use of their time, especially when they stars. The machines which create these plane was limited in the number and vari- would be familiar with a device, like a conditions and the diagnostics that mmi- ety of devices which could be procured Varian computer disk controller, and did tor them have become increasingly auto- and attached to it. We overcame this not have to explain ita function to a pro- mated. The demands of this research heve difficulty by adopting CAMAC (5). grammer. It also appeared that many of forced us to adopt new techniques, like CAMAC provided us with a large capacity, the computer group's staff enjoyed FORTH, for enhancing interactions computer-independent backplane. It was FORTH, although there were problems between engineers, physicists and their also a widely used standard in the nuclear witk standardization and change. I found cxper iments. physics community with instrumentation out several years later, talking with Jeff and interfaces appropriate to our needs Moler, who was then in operations at Kitt Introrhctian available from several sources. Peak and is now with the Livermore Tandem Mirror Experiment, how difficult Lasers have been used to simulate The problems of computer and wft- it wos to maintain programs in this envi- plasma conditions of high density (ap- ware standardization ware more diffi- ronment. proaching solid) and temperature (over 60 cult. Some of our applications were real- million degrees) for several years. The time, and appeared to require a fast FORTH seemed to have many desirable goal of these experiments has been either interrupt response. In other cases, we charocteristics, and it provided the same for weapons effect simulation, practiced were interested in direct imqe digitize- programming environment on many at the national laboratories, or for the tion and needed a large address space. machines. It allowed both very low level possible commercial generation of Other requirements suggested the need for access to hardware and high level struc- power. This latter program has been a powerful multiprogramming operating tures to shield users from that hardware. exclusively pursued by the Laboratory for system. Unfortunately, no one computer There was an assembler, a compiler, and Laser Energetics (LLE) for almost a type and operating system supported aU of interpreter. What we did not know decade. As can be expected, these exper- our applications; and yet, with limited then was the care required in documenting iments have resulted in the development manpower, it was difficult to support a it, md the tendency to create personal- of new diagnostics, and these diagnostics, variety of hardware and software. ized applicetione Md words. But, we in turn, have resulted in new fields of needed a version of FORTH at the Univer- physics. Besides the Laser Fusion Feasi- Computer I~g~aps, including sity. bility Project, there are research FORTRAN, are different from one vendor programs in: sub-picoaecond hem, nano- to another, and especially when operating Dick Berg, M assistant profels r in second X-Ray sources, X-Ray lasers, system calls were taken into account. The physics and astronomy at the time,' de- laboratory astrophysics, and materials problem of software consisteney and sup- compiled a Kitt Peak Varian nucleus circa damage testing. port was not limited to dissimilar com- 1974. He recoded it for the National puters. Ehrman (4:16,17) hag shown that aa Semiconductor PACE microprocessor. These research programs, and the main many as 12 different Ionquages may be Ken Hordwick, t with the Univerity supporting lasers, are highly automated. encountered by a programmer when edi- Computing Centeyused this as a model About me half of the computer systems tors, linkers, and loadert M included in for the IBM 360/65 under TSO and Mike on the 24 beam 13 terrawatt infrared addition to the programming language. Williams developed a multitasking version Omega laser and all of the computers on Therefore, a unifying software spprooch on the INTEL 8080. This was the birth of the single beam Class Ocvelopment Laser was needed among various operating sys- URTH. (GDL) are implemented in FORTH. This tem functions and languages on the same paper will explore the development of and different computers. We did not know We also procurred a version for the FORTH-like languages at LLE. of the unix System from Bell Laboratories Zilq Development System from FORTH, (11:1905-1929) and the 'C' programming Inc. at about the same time to demon- The laboratory is also part of the language of Richie and Stevens (12:1991- strate an automated X-Ray spectrometer. College of Engineering of the University 2019) in 1976. However, I had talked with Although I had a system for the Hewlett of Rochester. Thus, them is an important people at Kitt Peak in 1976 and travelled Prkard 2100 from Kitt Peak and a "disk- interplay between the staffs, and students, there in the spring of 1977 to see FORTH led version from Don Berrian at Prince- of LLE and the University. Most of our being used. ton, 1 decided that we should develop our FORTH systems have been partially, or own version bawd upon the URTH model. totally, implemented by students from FORM Ken Hudwick and I did this in late 1977. chemistry, electrical engineering, physics Since then, other members of the Univer- and computer science. Four of the other FORTH was originally developed M a sity community and the Laboratory for papers in this journal issue have a student smell, real time operating system for tele- Lawr Energetics have worked on various author who is also a member of LLE. rope control and image processing by versions of FORTH for Data General, Moore (8:497-511), (9) and Rather (101223- Modcornp, PDP 212 and IBM 3032 compu- Shndardizatim 240) at the Kitt Peak and NRAO facilities tam. Through the efforts of Mike which are funded by the National Scimce &Court, originally with the Department LLE was one of the firrt Laser Fusion Foundation. I found the groups at th~w of Cytopathology and then with LLE, we to automate itr laser facilities uaing FORT* scientists, com- developed a FORTH-79 system. All of ~s;bS~~~s?esWheneverpasible, wa relied puter engineers and bchniciw fn wme thew were multitasking systems (2514-

Page 102 FORTH DIMENSIONS 11!/4 ::8). 3. March 1978- A laser amplifier organize related devices into rubaystems. testbed was demonstrated. This hierarchy consists of both spatial and T-tbda temporal relationships among components 4. April 1978- Single her amplifier (11, (3). The menipulation of these rcla- The first FORTH applicatims at LLE testbed was operational at laser tionships requires the development of a we hardware testbeds. Them are two hardware rubcontractor's site, data-base-like language. My initial work :.)tinct phases in dealing with hardware. with a duplicate at LLE. with Fortran and RTE, end discuuions -*first OCCU~during its initial checkout with Ray Helmke a d Eric Knobil at the =d reoccurs when it fails, or you suspect By April, it was clear that the Wilson Synchrotron! led me to develop : of failing. At this stage, one is con- Omega Power Conditioning com- such a language for process control called mned with device and interface imple- puter would not be available until Maps, because it "maps" relationahips "entation, and it is important to be able August, 1978. Since the Depart- 6:109,110. 3 interactively set md test data and ad- mmt of Energy four-beam mile- iress lines. stone was originally scheduled for A Map contained two types of struc- early September, 1978, this left tures, or Tags. A tag was either a collec- A testbed must be capable of exer- insufficient time for laser prepar- tion of data, or a set of pointers to other :mng hardware at a rate of about 1 kilo- atim. Tags. The Map contained an inverted list Yrtz. Devices which operate In a fartar of pointers to each tag, so that all tags :me domain will usually be buffered, as 5. April 1978- An LLE engineer, John were unique end accesaible. Two special- rn example, with transient digitizers. Boles, and a consultant with the ired programs, SETUP and BUILD, were 'Jmt other devices, such as relays, software subcontractor developing developed to manipulate and create the :mate in a 10 Hz or slower time the power conditioning software, initial Maps from text files. About a dozen =main. At a 1 kHz rate, tufficient sam- began coverting the single ampli- subroutines were developed to allow tags :.es can be taken from A/D's and D/Ats to fier testbed to run 4 laser beams to be accessed. Data could then either be :xkly check their accuracy and range, synchronized with the laser oscil- placed into one or more Tags, or retrieved ndthereby checkout many parts of a sys- Iator. from them. In the interest of speed, this :em quickly. system was recoded in assembly language 6. June 1978- A Bix beam laser sys- and later microcoded on a Hewlett Several language features are required tem was operational. Packard 2lMX-E computer. This com- '3r tests like these. A means must be pro- puter currently runs the Omega 24 beam ..*d to individually and collectively set 7. August 1978- Preliminary delivery power conditioning, and was mentioned in ,:dress and data lines. There must also be of full 24 beam system which wan the Testbed Section of this paper. 2 way of repetitively issuing data/ address Fortran-based. zatterns. Often, a hardware problem is Alternatively, by using the text inter- -termittent, and a test and branch capa- 8. October 1978- Department of preter and FORTH8 capability to define :.!ity is necessary to allow loopiung until a Energy Milestone passed. arbitrary data structures, several data- 'ahre occurs. base-like systems have been developed. In There were substantial differences be- its simplest form, everything in FORTH is Thus, the specificatim for a testbed tween the 24 beam Fortran based system an executable data structure. Thus, mguage grows quite large, with a major and the 6 beam FORTH versim. These FORTH allows one to define spatial and 'ale occupied by the command processor, included the lack of an error detecting temporal relationships in a simpler, and X text interpreter. Regardless of command processor, a graphic display end more coocire fashion than Maps. In ad- ether the testbed language is imple- error archiving on disk. However, whereas dition, it is internally consistent, whereas -ented in Fortran, Basic, Pascal or most the FORTH version used 16K words of Maps had Fortran, assembler, microcode ::mr programming banguages, a wbstan- memory and a floppy disk, the Fortran and operating system interface facets. :.a1 Effort will be spent on the text inter- based system required 196K words of z-ter. On of the virtues of FORTH is memory and a 15 megabyte hard disk. Roductim syoteima :-.at it comes with a generalized text -terpreter, suitable for testbeds and This application also made us aware of Once FORTH had proven viable for ::%r applications. FORTHS compactness and the speed with small systems, we decided to implement which applications could be developed. It productim systems in it. These systems Our FORTH testbed applications in- is my feeling that this, and several other included automated diagnostics as well as :.Jded: power conditioning testbed for applications, were brought up in me half the laser control systems. The prototype 3cking out laser amplifiers; alignment the time it would have taken in Fortran, Omega 24 beam calorimetry system was restbed for debugging and calibration of including FORTH training time. Once an example of an early production *Jtomated compments; ' and, general good documentation is available, FORTH system. It used simple, vector like struc- 3 AMAC module testing. Other testbeds will prove even better. tures to contain the addresses, relation- 'ave been used to develop image pro- ships and values associated with various :*ssing hardware and software, and one- Also, I have found FORTH systems to calorimeters, analog to digitel convertors :;wnsimal rsticon arrays. be more maintainable than comparable and calibrators. It was capable of diaplay- Fortran systems, because FORTH uses 10 ing beam energies and calculatinq expo- The laser amplifier testbed was times fewer source lines. Some care is nential fits to the data. xveloped almg the following schedule: needed when writing FORTH. Another advantage can be gained by the ease of The Omega 24 beam Alignment System 1. October 1977-Ken Hardwick and I using data base technology when building is more complex. It has run on an LSI 1112 began writing a FORTH system process control systems in FORTH. with 5 CAMAC crates and 3 color dis- for the HP 2114. plays, controlling over 1000 devices. Sp.tid md Temptma1 Rslatidi Initially, the operators used the FORTH 2. January 1978- The FORTH system text interpreter for ell commands and was completed and CAMAC soft- The first phase of dealing with hard- queries. One advantage was their ability ware started. ware is over when the hardware works. to write new "macros" to setup compli- The relationships among devices then cated alignment procedures more become important. One can hierarchically quickly. However, there was a risk anso-

-~RTHDIMENSIONS in14 Page 103 ciated with letting operations' personnel mentation at LLE. It has allowed the PROCEEDeKTffM directly program the system. Thenfore, computer sytems grwp to adopt the phi- 1981 ROOESTER FORTH STWARDS t5e new Alignment System has a more losophy of providing tools to scientists and cx3wmfNc€ complete command processor impla- engineers, equipping them to do a job rnented in FORTH, but which does more themselves. Sometimes, it was questioned Many have been waiting for this con- error detection than the simple text inter- whether this was the best use of their ference proceedings to come wt, from preter. This system also uses the defining time: and, for some people, It wam't. But. what was a very interesting, and different words capability and has a large disk resi- for the majority of people in GDL, and a conference. It was the first conference to dent data base for describing components. fair number on the Omega systems end addrer the FORTH Standard since the With the advent of the command proces- other laboratories at LLE, FORTH has Catalina meeting of October 1979. Al- sor, the system was switched ov been a success. though it was suggested that the LSI 11/23 with mapped memory? t:G Rochester conference was only a regional addition allowed approximately 20 tasks to ~l~~trmeeting, attendees came from six coun- handle various functions, communicating tries and thirteen states. Also notable, we via a queue-based massage protocol. I would like to thank an dmat endlesa succevfully divided papera into serial oral list of people for their help over the past remiom one morning and had parallel The laser beam quality is also impor- five years. Moat important among them poster scrrions that afternoon. This way, tant to us. We use streak cameras inter- though, are Ken Hardwick, Dick Berg, almost everyone of the seventy partici- Chip Nimick and Mike McCourt. faced to Princeton Applied Research Ah, pants presented something, and no one Optical Multichannel Analyzers for this without the help of many students during misred anything (we think). purpose. The PAR OMA includes a this period, many of these sytems would FORTH-based LSI 11 for acquisition and never have been built. In addition, we added travel sponsor- reduction. As with the early Alignment ship this year. The Standard Oil Company and Calorimetry systems, ib iv;;; This work was partially rupported by (Ohio), Friends Amis, Inc., Miller Micro- grammed directly in FORTH. the following sponsora Exxm Research computer Services, Md Software Ventures those systems though, this was originally and Engineering Comp~y,General Elec- contributed over $5,000. This travel fund not a turnkey system provided by software tric Company, New York State Energy covered partial travel expenses for atten- engineers, but rather was incrementally Research and Developmmt Authority, dees from w far away as Hawaii, Chile, developed by physicists and students. Northeast Utilities, The Standard Oil Germany and the Netherlands, and a3 Company (Ohio), the Univenity of close as California and Kentucky. We also use FORTH excludvely on the Rochester, Empire State Electric Energy Glass Development Laser (CDL) with simi- Reaearch Corporation, md the U. S. The original call for papers was in lar computer systems. A FORTH based HP Department of Energy inertial furion pro- three major am.= the Standard, floating 2100 is used for power conditicning and gram under contract number DE-AC08- point end fifes management. These ereas interlocks for the main bay and three sur- 80DP40124. are well represented in the proceedings. rounding laboratories. A DEC LSI 11/2 In addition, there are sections on philoro- collects laser and target calorimetry data, Lawrence P. Fonley is group leader of phy, Vocabulary, Multi-tasking and Data reduces it, and also maintains a data base the Computer Systems Group rt the Acquisition, Data Structures and the on disk. A second LS1 11 is used in a PAR Lm4oratory for Laser Energetics, Univer- Future of FORTH. The organization we OMA for processing streak camem data. sity of Rochester, Rochester, N.Y. adopted combined poster sessions, oral This is especially dgnificant since GDL is reuion and lomc material not presented engaged in converting the infrared light to Footnot.. at the conference. There is an entire sec- ultraviolet, and the fint harmonic a IR, tion devoted to working groups on areas second harmonic green and the third har- The four-beam system, Delta, had like Standards clarification, FORTH tech- monic, UV are observed with the same computer control ond monitoring in niqucl, Floating Point and Filer Manage- streak camera. This required a very flexi- 1972. (&lOl). mmt. There uu 378 pages covering the ble system to allow reduction in a quasi- state of FORTH. The Proceedings are two dimensional mode. Another Hewlett He is now with the Deferue Mapping available for $25. See the FIG Order Packard 2100 has two video digitizen and Agency in Washington, D.C. Fotm. a color graphics unit. It is used for determining absolute beam intensity md Ken is now with Network System Inc., for those who are interested, there modulation for materials damage teeing. in Minna.polis, MN. will be mother Rorhester FORTH Confer- This system is being converted to a DEC ence the third week of May, in 1982. The Ls1 11/23 with an RLOl disk attached. A Come11 Univerity in ths aummer of tentative subject area will be Process third LSI 11 has been used by a graduate 1977. This facility is now known as the Control end Data Acquisition. We expect student to observe target plasma produced Cornell Electrm Storage Rlng. that then will be subareas dealing with X-rays? Finally, M LSI 11/23 is used microprogramming, FORTH machiner, with the nanorecond X-Ray facility for The meed memory tschniqum are personal computing, and the Standard. the real time acquisition and reductim of discussed by Laary and Winkler In the For information, please contact the con- 20 X-ray diffractim pattern. Recently, "Mapped Memory Techniques In ference chairman: Chis system has had an array processor FORTH' poper in this irrus. interfaced to it to allow real-time fast Lawrence P. f orrley fwrier transforms of sample diffraction PAR purchased thir system from Laboratory for Laser E mrgetics rings. All of these systems ue FORTH FORTH, Inc. 250 East River Road based, with the automated imaging ding- Rochester. NY 14623 nostics serving as prototypes for Omega This is mentioned In Bob Keck'a and my dieqnostics. paper, "A High Level Interrupt H.ndler in FORTH", which can be found in this Carluim Iaue.

Although FORTH was relatively m- known, it has made a positive impact on the development of system and irrtru-

Page 104 FORTH DIMENSIONS 1U/4 bPLEMEN1WC FORTH BASED accomplished by a mixture of standard by first threahholdinq, than detecting MCROCOMRJTERS AT THE commercial and/or wire-wrapped peri- vemel edges via a wftware algorithm. By UdVERSITY OF ROCI-ESTER pheral interface cards. Let's consider using FOQTH/Z-80 OMembly Ianguage, the MEDlCAL CENTER some of these iystems in greater detail, diameter determination executes in IGM looking at apecial hardware and how this is than one second. Peter H. Helmen reflected in the systems' software. This data acquisition system also con- htmhctim UlPUMd Diffrrtim Appuatum (UON tains a dual mode graphic8 diaplay capable of 128x128~4grey scale images or 256x "The micros are coming!" Everyone The UDA microcomputer is part of an 240 dot graphics Digitized video images -as heard this so that it is not unexpected experimental system to explom the scat- use the former mode while acquired pres- :?at physicians and researchers at the tering (diffraction) of medical ultraround sure and force data use the dot graphics. Jrliversity of Rochester Medical Center signals through tissue samples. The In addition, the TV signal dynamic range ask the question: "How can they be put to scattering is a function of both frequency can be studied by a dot graphic plot of TV .re?" Over the past four years I've been of the ultraround dgnal (2 to 8 Mhz) and signal amplitude versus time. artempting to answer this question by the angular podtion of a receive trans- assembling a series of microcomputers for ducer relative to the ultrasound transmit- AIM included in this system, to aid in 30th research and clinical applications. ter. The UDA system thus must control data reduction, is an Advanced Micro -?ese systems are all similar in their use three primary functions: analog carrier Devices AM9511 high speed floating point 2' an 5-100 bur hardware architecture and signal generation, tissue sample position- processor IC. This circuit's weed, com- j WRTH software environment. Yet they ing, and received signal analog process- bined with the memory mapped graphics :.'fer significantly when it comes to ing: At present, only sample positioning display, allows real-time analysir and uecific hardware interfaces, application (us~rq stepper motors) ir not directly display of acquired data, thus giving r;!tware, and types of system users. handled by the UDA microcomputer. continuous feedback on the progrew of the experiment. In this article, I am going to focus on Carrier signal generation is controlled :2th there similarities, these differ- by means of a Hewlett-Packard 816SA Overall, this system replaced a manual r~esin microcomputer systems. I am programmable signal generator interfaced strip chart ad photographic recording ;31ng to start out by discussing their to the microcomputer by means of an setup that required several days for data timmon hardware foundation, and then IEEE-488 (GP-IB or HP-18) instrumenta- collection and analysis. Now data can be exdore peripheral devices unique to each tion bus. An opto-iaolated parallel TTL automatically acquired and processed :.stem's design. Because the ultimate output port is used to control a program- within a couple of hours. xrs of a system have a significant mable attenuator on the output of the "oact on application software, I am going 8165A. With a range of 0 to 130 db, the Pulmonry Micmconputsr :3 try to characterize the types of users I attenuator can be used to automatically -3ve dealt with, and their specific soft- adjust gains for maximum signal dynamic The pulmonary clinic uses a micro- -are capabilities and needs. From here I range. computer identical to that just damxibed -.I1 discuss some common software pack- except without the TV video data acquisi- i;es that were written to transcend both The most critical aspect of the UDA tion interface. Used in a clinical setting, . rriable hardware, and v~iriabk user, hardware is the generation of gating this pulmonary microcomputer is inte- -equirements. By discussing all. of this in signals used by the malog processing grated with a mass spectrometer and a :ems of how FORTH has aided system circuitry. This is accomplished by using breathing chamber to allow analysis of zcvelopment, 1 hope to fully support my high speed analog mixers driven by digital pulmonary tissue volume and capillary rzitention that FORTH is an ideal envi- timing circuitry with a resolution of 100 blood flow. The basic procedure requires 'zqment to meld many different types of nsec., and an accuracy of 0.01%. keeping track of the patient's breathing .sers to just as diverse hardware configu- (by monitoring volume within the flexible '3LIOnS. Study of Vein Mechnirn breathing chamber) while analyzing the decreasing concentration of two soluble -are1 Hardware Chqmizatirn The basis of this system is an experi- gees: dimethyl ether (DME) and acetylene ment to measure axial force, diameter and (C21-$), referenced to the concentration Sa let's start out by considering the transmural presrure in a blood vein (in of an insoluble gar helium (He). rzmmon architectural arrangement of vitro) while controlling axial strain and "ese microcomputers. They are all Z-80 pressure. The system consists of a verti- The hardware floating point unit facili- :3sed machines with typical memory sizes cal chamber for the vein rpecimen, a pre- tates rapid (30 seconda) analysis of the :' from 32U to 48U bytes of static read/ fusion and pressure clamping apparatus, acquired data, including several curve fit- -r:te memory and 1K to 2K of EPROM force and pressure transducers, and a ting operations, and analysir of signals for -e-nory used to contain machine specific microprocessor for data acquisition. relative maximdminima. The graphics -dementations of commonly needed I/O interface allows immediate viewing of the ?Jtines such as console and disk drivers. The microprocessor contain8 a sixteen acquired data to ascertain proper signal cr:h microcomputer uses one or two eight channel, twelve bit multiplexed analog to levels, and to compare raw data to the -3single density floppy disk drives. The digital (A/D) converter to digitize the curve fit data. Z-mary system console is comprised of a force and pressure signals under high level .S line by 64 character memory mapped program control. XRay scmilq system . ?eo display along with detached ASCII aevboard. Each machine also has an RS- In conjunction with this AID is a com- This experimental rcanner uaes a :!Z serial port faprinter hookup. mercial video (TV) digitizer capable of slotted wheel and two horizontal slots programmed resolution Up to 240 lines of (mounted at 90' to the radial orientation These computers are all organized 256 picture elements. The input to this of the wheel) to achieve a mechanically i-wnd the 5-100 (IEEE-696) bus with from digitizer is from a TV camera aimed at raster scanned X-ray source. The wheel :en to fifteen card slots available. With the blood vessel under study. A special and horizontal Slob are controlled by 1-e basic setup described above using from code definition was written to analyze a means of three reparate rtepper motors '2Jr to six of these slots, the customiza- programmable area of the TV image for an pulsed under control of the :. n to specific system configurations is indication of vesael diameter. This works microcomputer. X-ray exposure is also

3RTH DIMENSIONS Ill/& Page 10s controlled by the computer as a function and interactively, control peripheral ~tmEVIrw of meawred patient X-ray attenuation. devices. A research scientist may not ( view plots of gascr m 1 understand how a word like RAMP Or CzB2 mad The microcomputer contain8 a SAMPLE works,but can readily learn what 5 counterltimer chip which is used to they do. ( ... graphica disolrv ) control the stepper motors, a seven channel multiplexed eight bit A/D con- For example, the FORTH software By learning a limited, yet full, vocabulary verter (Uaed to measure patient X-ray written for the UDA sy8tm allows of perhaps twenty to fifty well chosen attenuation and X-ray power), and an explicit uaer control of the hardware for worda, these non-technical usen can elght bit D/A converter to control the setup purposes aa well as automatic con- effectively use a FORTH based micro- axposure time of each X-ray pulse. trol during experimental data acquisition computer with little training or under- Several digital l/O lines are used to start runs Setup can be done through words standing of programming. And without the X-ray rotor, turn on the X-ray genera- auch as fail, they learn to use colon definition8 to tor, and control stepper motor direction. OK 25 DB group theae beric words to their own Other lines are used to sense mechanical - lpecific uaage patterns. limit switches. ( RRl'r a natural herct ) PRQ 2500 XHZ' TAU commm sottwrra Prlrrp. The software used in this machine is (via the CFIB primarily concerned with controlling As we have just seen, I group FORTH exposure time for each X-ray pulse in -OK 2.5 US= CUUIIW-OR software in three coarse categories cor- synchrony with the motor movement. The A data acquisition experiment can be rat reaponding to types of users: basic system ramps the motors up to apeed from up using words auch aa: FORTH system software, peripheral sup- an initial stopped condition. In addition, it 100 2000 swEPr-?RltQublcy port extentions, and custom applications. gradually increases speed to compensate ( define control of BPBldU ) The basic syttem software does not vary the for linear speed as horizontal slots are OX FIX~-AlTEWATION at a11 while custom application software is moved radially towards the center of the - unique to each end-uaer system. Peripher- ( define control of atten 1 wheels. 'he software also controls expo- al aupport software is in a hazy area. DON'T-CSIO*-ATFWUA"IOUS sure time by sampling the attenuation of OK From the point of view of documentation 1500 32 mvA-comtoL X-rays through the patient once each and support, any given type of peripheral ( let the minicomputer take motor step, and using table look-up tech- should uniform between systems; over control of the micro.) appear niques to set the next pulse's exposure but at the hardware level, each type of time. In addition, total x-ray power is In addition, the remarcher can build peripheral varies in myriad details. By sampled and accumulated to keep track of upon basic words to create custom appli- creating common roftware packages with total patient dosage and X-ray tube uaage. cation programs ar needed. Thur the X- thir in mind I have been able to avoid ray scanner system can be earily program- constantly recreating software because of How umrs' Nshd. IrqMCt Thwe Spbm med by: hardware variations. -OX MO'IOR VHEEtMO'IOII In my development of these systems, 1 ( define a 'WTQR' data th) Common software packages can do have encountered three types of users: OK : ROTATE-m more thn Just enae support for similar system developen, researchen, and phyri- - rystema. It can effectively hide hardware cians (and their clinical technicians). This -ORDO details from the user, thus making dis- grouping of usen also roughly correaponda 2!! Wk'EUXQR RMP umilar AID converters. for example. to levels of FORTH software utilization. ( ramp rteppinp motors) appear identicd from the software point The system developer--myself and pre- -ox LIH IF IlCBG57 of view. And a well designed set of driver sumably yourself-is expected to know all ( exit loop if motor limlted) software alw imparts increased capebili- the in's and out's of system operation. If OK SYNCERONI21 ties to a system than just those of the something is miuing, it's generally eary to rsynchronize to =tor pulse) 'raw' hardware. Let's look at a few add it; this is a primary reason why many exampler of software peripheral drivers to UUP of us like FORTH. However we don't reinforce theae point& actually apply a system, we only aet up -m; the roftware foundation for the syatem. A physician or clinical technician ir Many of them microcomputers are As uaers, we don't cwot! much more of Wl end-uwr than the uwd for data acquisition purposes involv- rerearcher. Ar auch, they are leu ing different type8 of A/D converters and A true end user, whether researcher or concerned with words that @llow them real time clocks. From a hardware point physician, cannot be sold on FORTH flexibility in control of peripheral of view, wme of these A/D's have eight because missing capabilities can be easily hardware; instead they want worda that bit vemus twelve bit resolutions. Some they don't have the knowledge filled in; to control herdware in specific wayr towardr have raven or eight analog multiplexer Nor they really want to learn to do so. do some lpecified clinical objective& Thus chmlr while othen have rixteen. Some do They have to be sold other so. on they need to implicit1 use both basic of the real time clocks have fixed 60 Hz virtues of FORTH. FORTH ,words and perip~erddriver words, rewlutiom, othen are programmeble. but want to only explicitly know wordr In my experience, researchers have From a conceptual point of view, these that achieve specific aims. But even here been very receptive to FORTH. In general FORTH can be appreciated. It data acquisition rystems all operate they have aophisticated technical back- allows a flexible, conceptual system with a non- identically: they can randomly rample grounds but little practical computer confining syntax. With the pulmonary multiple analog signals at some specified knowledge. This is a prime benefit: they microcomputer, the phyticirn might rate. The driver software Implements may have used FORTRAN on a large typically have the following didogr these concepts using two words SAMPLE machine for number crunching, but other- and DELAY. SAMPLE taker an integer wise they have few preconceived notiona -OR mLwoNm CAW~ATIONS multiplexer channel number as an input about computer organization. They ore ( .equlre data, and ulc it 1 argument, and returns an integer ampli- less impresaed with structured program- OR ORIN= naS RGSDLTS tude value. It works identically no matter ming techniqwr or file systema than they what hardware is controlled by it; the results are by the fact that they CM physically, Tpint multiplexer addressing and A/D digital

Page 106 FORTH DIMENSIONS in14 wtput format are hidden from the user. problem is that the hsrdwue has to be lary that a user can have a flexible, effec- f!milarly, the real time clock works in a forced to conform to the manufacturar's tive, and friendly syrtem. FORTH IS -anner transparent to hardware language standard. unique among languages in that it encour- Icecifics. DELAY requires only an input ages the programming of solutions: argument to specify the number of real At the Medical Center, a hardware ..ne clock "ticks" to delay. floating point package waa easily added as Peter Helmerr is a rsnior laboratory engi- an extention to the basic FORTH system; neer In the diagnostic ultrasound reaearch But the conceptiial basis of the data the language adopted the hardware! laboratory within the Department of icquisition package transcends jusl the Radiology at the University of Rochester z'3 hardware; there must be some place Anrhrmim Q pprt.nt? Medical Center. :> put the data. This may be on the para- "eter stack, in data arrays, or in disk At this juncture it is valid to ask if 2ascd virtual arrays. When this capability FORTH justified itself in it8 ura at the Eolmorr' Wide continued s added, the data acquisition specific University of Rochester Medical Center. QI next two pqor 'ardware creates a synergy with the fund- 1s it an anachronism of the past, or a phi]- a-nental system hardware such as read/ owphy portending the future? cite memory or floppy disk. Admittedly, FORTH is wmewhat Another example of a peripheral driver limited without such thinga qs a file Zackage that I developed is a memory- system or procedural name rcoplnp of -apped vioeo graphics package. The variables. Perhaps there should also be I .sical hardware interfaces ranged from less explicit knowledge of addresses, and BUG FIXES 13x256 resolution up to 512x460 resolu- more system security. Perhaps. But if m, : YI, with as many different methods of then these things will be evolved as Corncum roFEDn ~ddressingspecific dots on the display. FORTH matures. Sorry you had trouble with FEDIT. The Conceptually, we want, first of all, to It is what FORTH eepouws, thwgh, llsting was retyped crt FIG and several 30 able to plot physical X,Y points inde- that justifies its use. It allows hardware typw cmeped in. They are: :endent of hardware specifics. A word components to dictate the software %xhas PLOT, using X and Y integer para- design, thus allowing rapid incorporation 1. SCR 64 Line 10: compile should be -etem on the stack top, can give us this of technological advances. Other lang- COMPILE raoability very readily. uages force conformance of hardware to language standards-a slow, expensive 2. SCR 65 Line 23: 1+ /MOO ahwld be 1+ But to really us0 graphics effectively, process. 16 /MOO : IS nice to be able to specify different ireas on the video screen to plot different FORTH allows isolation of uwrs from 3. SCR 67 Line 46: B/BUD ahwld be :3ta, as well as scaling functions to adopt hardware dependencies, and adds capabili- B/W qical coordinates to this specified ties to the basic hardware. The result is a 4. XR67 Line49: : €should be: .E I-aDhiCS area. The GRAPH data type user environment that supersedes specific 2dilt with a defining word) allows these machine configurations with concept 5. SCR 67 Line 50: + ALIN should be ? fferent graphics areas and scaling func- oriented, yet free syntax, computer opera- +&IN I ms to be associated, and invoked, by a tion. The FORTH system developer might :-mmon name. Further capabilities were need to know w,but the system user i3ed to allow easy creation of vectors, need only know E. Conventional You are perfectly right that aource ;-ids, tick marks, axes, and boxes. All of systems, to the contrery, generally require text should be loadable. I talked to some of people at FIG about this and they I wdden, a very proletarian graphics peri- everyone concerned to ask: "why?" the :-era1 is transformed into a powerful wen acutely aware of the problem but they simply not s0t to directly ~221. And because these new functions are FORTH encourages an exploratory are up reproduce listings in FD at the present i.' built on the PLOT word, they are development technique. A user can -?adily tansferred between systems with choose between interactively trying con- time. They do the best job they can with :fferent hardware interfaces. cepts, writing full programs, editing pro- the resources available to them, and they grams. compiling programs, and/or debug- work darn hard at it. I can't fault them. A final software driver to consider is ging programs. He or she can do this in a :-at of the hardware floating point unit. single, consistent FORTH environment, REPL is a pseudonym for the fig- FORW line editor definition, R I ued : IS interesting to consider this from both utilizing any of these phases of develop- . the pseudonym because FEOIT was the 8 FORTH, and a conventional language ment as required. The result is efficient :2int of view. In a language such as use of all system resources. first program I wrote in FORTH and I =ASCAL, the system generally has built in wasn't really familiar enough with sftware based operators for floating The embodiment of the FORTH philor- Vocabularies to comfortably us0 a word that WM already ured in the FORTH :gint. Because the system is not inherent- ophy is thet programming is not what it is . extensible, the addition of a hardware often taught to be: the application of top- vocabulary. '.Jating point peripheral requires either a down programming techniques to e ingle Let me kmw how it works for yw. If -anufecturer rewrite of the PASCAL problem. Instead, it involves a series of '.3ating point routines, or elre a user interrelated problems all related to yw would like a machine produced listing, -terface through PASCAL functions or system use. This might mean a set of I cwld run one for you from my current :rocedures. The former requires manu- words that allow a researcher to control a version. Let me know. Good luck. 'acturer acceptance and support of a new TV digitizer, or it may mean a seriea of -ardware peripheral; unless a very popular words to calculate end graphicelly display Edgar H. Fey Ievice, such support will be reluctant at the results of a mathematical analysis. 16 Calendar Court zest. The latter requires a very awkward While the wries of capabilities needed will La Grange, L 60525 anguage syntax to invoke hardware float- always vary between different systems, it -q point capabilities. Either way, the is only by providing a rich enough vocabu-

-3RTH DIMENSIONS 1II/4 Page 107 L b >I 9 TV DATA DISPLAY ASCII 4 * ACOUISITION INTERFACE KEVOOARD .

* J STATIC CPU FLOPPY DISC RAM +-+I 40K ZIOA - 8TORAQE

SAYPLINQ MULTIPLEXED ARITHMETIC AD PROCEIIlNO CLOCK . CONVERTEA UNIT

f "'9

I lb FORTH DIMt"S 4 Microcomputer a)

Scanning beam

I i Film cassitte :-ray detector DATA STRUCTlRS IBM environment was at the University for plexor channel. Since the protocol fur NA many years to come). The front end had channel interfacing is non trivial, there TELEOOMMCMICATIONS FRONT W to provide access for the ever growing are a limited number of vendors of mini- number of ASCII terminals being computers who were able to provide this John A. Lefor purchased for both computing and non- interface capability. Another irnportant University of Rochester computing environments. Importantly, the consideration in the design of a telecom- front end had to provide for access to the munications front end is the realization Aatnrt 1BM host from more terminals than could that if a failure should occur in the fronr be dedicated to the host at any one time. end, there is a perception that the host URTH, the University of Rochester The only front end which could posribly computer failed. Because the-? :s great dialect of FORTH, was used to implement meet these goals and be reasonably Cost need to Occesa the host computer, it is a telecommunications front end for an effective had to be one of local design. undesirable to have hardware failures IBM 3032. This package provides acceas to meeting local requirements. affecting the Front end. To this end, the the IBM 3032 from as many as 160 ASCII Fwbm Rwicbd mini-computer chosen as the frorit end had terminal at speeds up to 9.6Kb. Each of to have both a history of :eliaDle service these terminals contend for 128 simulta- The front end designed at the Uni- and a maintenance trani capable of news connections at the IBM computer. versity of Rochester Computing Center repairing any difficulty with a minimum of does provide some unique features to the fuml. The reasons for choosing URTH as the users of our IBM 3032 computer. To be development language and a review of the sure, the features are not unique within In evaluating the available mini- major advantages and disadvantages of the context of computing, but are not computers against these criteria, the pro- using Urth for this project is discussed. generally available in an IBM mainframe cessor which was finally chosen was a Also, some conclusions as to the applica- environment. Digital Equipment Corporation PDP bility of URTH, and the data structures 11/36. The interface to the channel is via used in this application is reviewed. The One of the major advantages provided a DX-118, and the ASCII terminals are UK of conventional data structures for by the locally designed front end is the supported by DZ-11's (actuaily many of providing information paths between the ability to switch between systems from the terminals are supported by a Digital various components of the system is the same terminal. In a traditional (non- Communications Associates 205, which examined and the possible advantage of SNA) IBM mainframe, it is not always emulates 32 lines of DZ-11 on a singie less cmventional data structures more convenient to have a terminal rwitched quad height board). firmly based in URTH constructs is ex- between different software teleproceuing plored. applications. Typically, a terminal either In retrospect, we can see that though is connected to one application or an- the PDP 11/34 does work in the required A plan for development of similar sys- other. With the locally designed front environment there are some deficiencies. tems is presented which integrates some end, it is potsible to choore the appli- The most notable is in the maintainability of these concerns and promises a better cation ot which the terminal is attached. of the DX-118 (the channel interface structured system. In effect, the front end is a port contender which connects the PDP 11/34 processor for various applications on the mainframe. to the IBM processor). There are so few htmduction DX-11B's In production throughout the The aecond major feature arising from United States that the DEC customer In 1977, the University of Rochester a local front end is the ability to support engineers are relatively unfamiliar with Computing Center first got involved with an XON/XOFF protocol. Since the IBM the details of its operation. When subtle the FORTH language. The initial devel- mainframe communicates with its termin- problems have occurred, the repair of the opment In FORTH was the implementation als in a half duplex mode, XON/XOFF problems has taken considerable time and of various flavors of the FORTH system support is not traditionally available. The talent. To be sure that the subtle difficul- known collectively as URTH. Most of the local front end is based on full duplex ties were discovered and corrected is a URTH systems developed have provided communication to the terminal so tribute to the engineers dedication to the multitasking capability on a variety of XON/XOFF can be supported in a fully problem, but a more popular interface micro-, mini-, and mainframe computers. effective fashion. Thoae terminals which wwld probably have been repaired in a During the development of the various have buffera which can overflow can turn shorter time. URTH iystems, a number of people within off the input at will, a feature not avail- the Computing Center showed interest in able without special support in the IBM softvpe Drim using an URTH based system for develop- world. ment of real projects rather than viewing In determining the nature of the soft- URTH as just another academic curimity. The front end is today ming at the ware to run for this application, it was University of Rochester Computing Cen- necessary to evaluate the probable struc- Concurrent with the development of ter. It is supporting 160 ASCII terminals ture of the end goal and to consider all the the URTH system, was the growth of tala- contending for 128 host computer ports. concern8 of a project of this sort. After communications in computing at the Uni- Each terminal CM aelect connection weed the major considerations are evaluated, versity. A need for additional tele- between 110 and 9600 Baud M well as a the best software choice can be made communications lines into the computer few other tailored features. The fact that baaed on the concerns and knowledge of was fast becoming a necessity md the the implementation continues to run fre- what is available. financial support for such a purchase was quently appears to be a miracle but repre- on the verge of becoming a reality. rents some faith that the concept is at A telecommunications front end is a least ementially wund. realtime device which must be able to In this environment, the design and handle a relatively large number of poten- implementation of a locally deiigned tele- l-kdwmm Dsum tial 1/0 devices. ki particular. many ter- communications front end was begiming minals are expected to be connected to to emerge. The front and had to exist in In order to implement the telecom- the front end. Also, there were consid- an academic computing center where the municationa front end to M IBM erations for attachment of synchronous need for teleprocessing was growing. The computer, ths pmccgor chosen for the liner for wort of Hasp Bieync, Remote front end had to communicate with an IBM implementation had to provide the capa- 3170'8, and local area network communi- host (it was generally believed that the bility to interface to an IBM byte multi- cations. All these considered together, it

Page 110 FORTH DIMENSIONS ]Ill6 *a( important to choose a mftware sidered in the aoftware choice. *eel- level languages is their UM of memory, .nplementation which provides support for fically, the PDP 11/34 hod 64K bytes of and sophisticated operating system ser- reltime device handling. memory. We had to have some degree of vices. These two concerns may make a confidence that the entlra system could be larger faster CPU needed for effective The wide variety of I/O devices which packaged in 64K bytes. If that was not execution of the application. Another Yere contemplated for the front end also possible, the development time cwld be drawbeck of both the asletnbler and high -mired that the software provide tools to slowed down waiting for shlpment of addi- level solution is the lack of inherent inter- Telp the designers of the system gain tional memory. The weed of the 11/30 active develoment and debugging tools. ,nderstanding of a wide variety of hard- processor led us to believe we would have They typically can be designed into the ware devices. There were going to be sufficient CW to do the job, but not a lot system, but they generally are not present asynchronous and synchronous devices as to apare. in the basic environment. *ell as a channel interface which had no *ell defined characteristic8 (the best The final and perhaps major conridar- EvJlwtlm of UPTH xmmentation of how the OX-116 worked ation which affected the choice of was found in the diagnostic programs sup- software was the perceived development URTH appears to meet many of the 2:ied for hardware maintenance). In time. The project was inltiated at a time goair in the software choice. Though addition, there was alway8 the porsibility when there was an extra I8M processor at there are limitations, the advantages seem

:f needing to support a new and different the University. It would be possible to to outweigh the disadvantages eapecially ::ass of 1/0 device. Though the manuals design and debug the entire front end on a when design time is so important a consid- mcumented how the hardware worked, processor which was not in use. That was a eration. 31y software which would allow inter- real opportunity not to be parsed up. iition with the unfamiliar hardware would However, the procemor could not remain When looking at LJRTH, a clear advan- 3e beneficial in the debugging of the over- idle for too long a time. Any software tap fforded by URTH is implementation 3.: syrtem. package which could help to shorten the time.l Mort of the other advantages pro- development time and thereby allow de- vided by URTH can be directly tied to the Another area of debugging which was bugging of the front end on the unused speed of implementation. URTH provides Imsidered in the software choice was the processor would be of great benefit to the easy access to any set of unusual devices, mftware protocols. The connection to the implementation. because the device handlers are ach tai- rTannel of an IBM computer by asyn- lored to the system and the hardware. :?ronous ASCII devices invokes a non- Albmatiw Software Stnhgiea Once a program is debugged in URTH, :-;vial set of software protocols. A simple there is good reas7 to believe it will trample of the kinds of problems is in the Examining the issues in making the continue to work. Another major :-anmission of any single ASCII character software choice, there appear to be three advantage offered in the URTH environ- 13 the channel. In the IBM environment, alternative software strategies. The uw of ment is the enormous flexibility in design :x software running in the processor assembler language, the UM of a high level of both murce coder and data structures. ?vects that any ASCII characters trans- language such as C or Fortran, or the use The ability to code both high level URTH -i!ted from a telecommunications front of URTH. and medine level code and to achieve a r-d are sent not as simple ASCII uniform interface provided many oppor- riaracters (as generated by the terminal), Assembler language provides a number tunities to geed up inefficient code. The I,! rather demands t at each ASCn char- of solutions to the problems wtlined It ability to design new data atrucutres to x:er be bit reversed? Though this is not tends to be compact in memory uaage, it work in a large scale environment offers i difficult feat to accomplish, it points certainly has the potential to make most much flexibility in design. SJ~the nature of some of the software efficient use of the limited CPU, and it is :-XocoI issues which must be dealt with quite capable of handling the foreign The URTH environment is not without - a telecommunications front end. devices needed for a front end. However, fault. The fact that URTH is an inter- S,ffice it to say the software used to the assembler has a few drawbacks. preter does mean the code is not as :*sign the front end would benefit the Probably the major difficulty with assem- efficient in CPU geed as possible. Of zesigner if it helped to identify, and bly language is the extended development course, the eaae of generating assembly -?solve, software protocol issues. time. Debugging is slow and tedious and code helps alleviate this problem. How- design of code and data structures to aid ever, a major drawback of the URTH In the development of any realtime debugging is totally a responsibility of the environment stems from its flexibility in r'tware project, it is recognized that the programmer. Thus. development of a data structure design. :-roughput of the system is important. major application in assembly Ienguage is 'ye telecommunications front end is no concerned both with the solution of the The very fact that it is possible to exception. Since there are to be a large problem but also much effort is gent on design any needed data structures coupled -t-nber of 110 devices providing input to good design and coding techniques. with the implementation of the traditional :-e software application asynchronous to Another difficulty with the asaembler is data structures of arrays, constants, and :v operation of the software, it is imper- maintainability. Each programmer has an variables created some difficulties in the 3:ive that the application software be able individual design style. The documenta- design of system which had so much pres- :3 keep pace with the demand. On the tion rests largely in design of the code. If sure for development in a short time. r:?er hand, the inability of the front end the original &signer is no longer available There was not a lot of time pent on :: keep pace with the demand is not criti- for maintenance of the project, there is a development of the best data structure for :3:. If a character destined to a terminal long learninq curve to train a new indi the problems encountered. Rather, tradi- s lost, a human being will not die but a vidual. tional data structures were used to meet :rogremmer may get upset. Keeping individual demands. In particular, many .wse priorities in mind the project had to High level languages solve many of the arrays were implemented for storing of 10 implemented in an environment which difficulties with amembly language. Ifthe information relating to specific 1/0 -as not wasteful of processor time, but language is well conceived for a realtime devices, and queues (obtained from a free- :-.ere was no need to be alarmed if there problem, it will support the difficult pool) were used to buffer data between -as the potential to loose data. hardware iawes and will provide a frame- devices. The uae of such data structures work for data structure design which pro- had two major impacb on the project. The hardware decision made specific vides readability and maintainability of Firat, the queues were sufficiently diffi- 'eatures of the procewr had to be con- the software. A major difficulty with high cult to handle as to have impact on the

-3RTH DIMENSIONS IN14 Page 111 weed of the overall system.' The use of does solve one of the major difficulties any uwful stand-alone dump with indexing the arrays to hold information for later encountered in the front end design. Given to help the programmer walk through the processing yielded much difficulty in this set of considerations, it mms like a dictionary. When total application col- debugging individual words and tended to good idea to define a "Mmed object lapse occurs, URTH is not very informa- leave side effects which had impact stack" for each 1/0 entity defined in the tive as to the nature of the problem. A on ' words already debugged. telecommunication environment. When a memory dump (with a good index for the particular I/O device medr mme form of dictionary) would help to debug some Thus, the use of URTH has many vir- service, the named stack is invoked and a11 rather sticky timing problems. tues but it is crucial to recognize the data relating to the I/O device is availa- particular issues which may lead to ble. The rtack can contain pointer8 to Overall, URTH is a good choice for difficulty in debugging. Udng data ring buffers as well as current status of development of realtime applications, but structures such as arrays and variables to the device. Using thia strategy provides care in the design of data structures communicate information between teaks an environment that naturally fits within 8hwfd help to make the overall mainte- in the front end tended to leave open the basic strucutm of URTH proqram- nmce of the application a simpler chore. many portential pitfalls in the debugging ming, makes effective we of cwtructr and design of a system as complex and within the URTH ryrtem, and promotes Foornotr highly integrated as a front end. gwd URTH progmmming practices which minimize the side effect problem& Over- 1. Thin is not simple an example of a per- Altarnative Dgiq Stratogias a11 speed of the spplication is not vem IBM, but instead is another fact significantly impacted and many old of IBM computing history. The stan- In examining the resulting front end functions can take advantage of the data dard device IBM used to connect ASCII for difficiencies, it becomes clear that structure. terminals to the host (a 270x) was not there are some strategies for alternative designed using today's UARTS, rather design which could limit the difficulties The stack will contain rufficient it collected the bit serial data in 8 encountered in any similar realtime volumes of information about each I/O register. The data was collected in a project, and wwld make URTH a vehicle device that it may be advisable to create register in wch a way as to cause the for well designed, well integrated, and a "framing" of the stack. This would allow characters to be captured in bit effective systems design. access to individual parts of the rtwk as reverse order. Rather than correcting if it were the current top of stack, thus the problem in the front end, they The issues of code design are well con- allowing accesa to more data in a conve- transmitted the bit reversed ASCII to sidered in URTH. The ability to switch nient notation. the host, and translated the bit between machine level code and high level reversed ASCII to EBCDIC for pro- URTH provides a classic tradeoff between SUmf-Y censing. The roftware stayed, so the speed of execution and memory utili- nwd for bit reversed ASCII exists zation. The fact that the interface The telecommunicationr front end today. between both environments is standard designed and implemented at the Univer- allows all design in high level URTH, and sity of Rochester Computing Center Is a 2. This advantage was certainly realized conversion to machine code when and useful model of many realtime applica- in the actual project. The basic system where appropriate. In this area, URTH tions. In the design are fwnd a number of was operational within four months provides suffficent tools and a good set of flaws which are primuily related to the from beginning of the project. options. particular presures premt at the time of the design. The choice of URTH as the 5. This is dependent upon good URTH In the data design area, URTH provides roftware vehicle appear8 to have been an progmmming practices. But, in our so many options that the best data struc- excellent one however, the choice of data project there became clear a self ture choice is very much at the control of structures to uw within the URTH anvi- evident truth. We attempted to debug the programmer. In the case of the front ronment was not a8 well conceived. ro many "words" which were already end design, the traditional data structures correct, we began to believe that it is were not sufficient to effect the job but URTH provided a software very difficult to &bug a working pro- there was insufficient time to design an environment which clearly affited time pram optimal data structure. In retrospect, it is effective development of a complex possible to peruse the alternatives and system. It provided a compmheruive 4. Converting mwt of the queues to indi- choose a structure which provided the interactive debuggi~environment with vidually aaaignad ring buffers npeeded flexibility needed, and also limits the side the ability to addre88 specific Ipeed ~poverall proceasing by 20% or more. effects from preventing effective debug- inefficiences in a uniform manner. The ging of words. major drawbacks to the URTH environ- 5. See Peter Helmen, "Userstack", ment relulted from the choice of data FORTH DIMENSIONS, Vol. 111, No. 1 One of the major advantages URTH structures for intartaak communication and Peter Helmera, "Alternative provides over alternative aoftwarc within the qplication. Parameter Stacks", Proceedings of the approaches is the stack. Proper design of 1981 Rochertor FORTH Standards URTH worck with parameter passing via URTH -8 provib tooh to d.velop Conference. the stack helps to insure that a debugged the optimal data rtructuwa for any par- word will tend to continue to work, and ticular .ppllcation. In tho case of real- will have no dde effects Given this time applicatiw, the choice of data Observation, it would be natural to use the structures ir particularly critical. from -I would like to thank Richard Marisa, Ken stack to pa= parameten in the telecom- my experience, 1 believe that a data struc- Hudwick, Mike Armstrong, and Mike municationa environment. Unfortunately, ture dmilar to the -named object stack Willimmr for their assistance. the stack is not useful in communication wwld benefit many redtima application# between tasks, and the stack is difficult to in URTH both function provided and in the LA. Lafa was senlor systems programmer address and use when too much infama- limiting of rids effecb m prevelmt in at the University Computing Center at the tion is parsed In the front end, there are global data rtrucutres ruch a8 may% Univerrity of Rochester and is now Data so many unrelated parameters which need Communications Manager. to be parsed between tasks that the stack A mond feature which wwld be valu- is not uaefuf. But, the concept of a stack able in m URTH envlronmant would be

112 FORTH DIMENSIONS II1/4 MAppfDKMoRY MANACEMENT icd addre~er. OM wt of ngirterr I8 Flpora 2 lhowr the logical address TECCMQUES H FORTH wed when the procraor ir In "kernel" apace. mode, the other when it lr in *uwr" Rosemary C. Leary mode. Th mode ir dotermined by two Page 7 4 K Carole A. Winkler bit8 procemor status word. 'TI} of the Laboratory for LamEnergetics block buffers University of Rochester Each set of regirten contain8 eight 32- Page 6 .------bit Active Page Raqirterc (APR'r). Each return stack Wrt APR 18 acturlly two regirtersr the Page Addreu Register (PAR) which contain8 a Page 5 Three techniques for using memory brae address, and the Page Descriptor -anagcment hardware in a FORTH rystem Regirter (POR) which containr the page 'we been implemented at the Laboratory length and the accau control key. Page 4 '3r Laser Energetics at the Univerrity of qxherrter. One method UM~mapped The &bit logical addreu apace I8 -wmory for data storage by creating e divided into eight "pager" ihown In PIge 3 * 28K 'data window" in the logical address Table 1. When the memory mnagemmt uace. A second method increases the unit is enabled, my acceu to memory will available space for programs by mapping be mapped through the APR for that Page 2 :asks in a multi-tasking system. The third eddrau. -5es mapped memory for data itorage by Pare Lolical Address Ranan :wnq advantage of special instructions Page 1 z-4 a second set of memory management (octal) 0 -eqisters. 0 - 17776 dlctlonary 1 20000 - 37776 Page 0 - __-..------tion 2 40000 - 57776 nucleus 3 60000 - 77776 The problem of insufficient memory 4 100000 - 117776 Figure 2. Loglcal address space for '2: programs or data is commonly encoun- 5 *120000 - 137776 slngle task without napped mmory. ::red on computers with a 16 bit word 6 140000 - 157776 Additional information on the PDP-11 i.ze. Many manrlfacturers now offer hard- 7 160000 - 177776 memory mmegement it can be found in -are to alleviate this probiem. At the the procemor handbookr . -7lversity of Rochester's Laboratory for Table 1. Loliral Address Sracr. -aser Energetics we have devised solu- D.taWlnda*d~~t : 3% to three different aspects of the The physical memory eddrers that will :-?blew using FORTH on PDP-11/23 and actually be accened is a combination of One way to utilize the memory men- =Y-11/34computers. the logical addreu and the PAR for that egement hardware and additional memory page. Figure 1 rhows how the logical ir to uw it for data rtorage. Two of our Two applications at the Laboratory had address is deriv d. Bits 15-13 of the applicetim at LLE require large data I Teed for large image processing arrays logical address give the page (or APR) arrays (up to lOOK words) for image pro-

2~ to lOOK words). We solved this by number. The PAR for that page gives the cesaing. We wlved this problem by .s.ng a double precision array index which bass addrean in 64 byte blocks. Thin value creating a "data window" in our logical - 33s physica! memory into a logical mem- is added to the block number field of the address apace. Figure 3 rhows the logical I-.. "data window" within the FORTH sys- logical address (bits 124) to find bits 17-6 addreu layout of a system with a data 1CT. of the physical addreas. Bits 5-0 of the window. physical address are the same m bit8 5-0 On a different, very large FORTH ap- of the logical addrew. I .cation, we needed both more program iwce and more data space. We increased Logical IP amount of program space by imple- Page Block No. DIB -tnting a multi-tasking system in which Address :+:tain portions of memory contain the -,-:!em and common code, while other ::::ions are task specific and are period- :o:ly switched in and out of active u&. It 0 Active Page Page Addrtss Field To increase the available data space Reg is ter -0 are using special instructions and a I second set of memory management regis- :crs on the PDP-11/23 and PDP-11/34 ~r-nputers. I1 0 Additional material these systems on Physical Block DIB Physical :a be found in "FORTH in Laser Fusion," No. Address Larry Forsley, in this issue of FORTH I :. (Dlsplacemnt 3:WENSIONS. In blocks) *ware Figure 1. Construction of a Physical Address The memory management hardware on :Y PDP-11/23 and POP-11/34 computers (derived from figure 7-9 of [l] and :mists of two ets of registers that map reprinted with pennlssion from DEC.) .: bit logical addresses into 18 bit phyr-

'XTH DIMENSIONS IIl/4 Page 113 Figure 3. 110 space for tham in tha muter taak's dic- Page 7 tionuy. Figure 4 shows the logical Page 7 If0 address mace in M wmapped.. multi- tasking system. return stack Page 6 data window Page 6 .___--_------paramter stack block buffers 14k t 4 Page Page 5 ___------5 dictionary ____------return stack - paraneter stack return stack block buffers Page 4 Page 4 .----._ ------return stack

Page 3 1 Page 3 ,24K 1 Page 2 Page 2

Page 1 1 Page 1 di c t iona ry d ic t Iona ry Page 0 . _____ ------. Page 0 __-_------nucleus nucleus t i- Logical Address Space With Data Window. Figure 5. Logical Address Space for d1 C t 1OMry Happed Multi-tasking System. The black buffers, return stack, and Page 0 parameter stack are moved dom to the nucleus top of the next 4K word page of logical Implementing thir technique required memory, leaving B 4K word gap in the log- Figure 4. Logical address space for the following chonges ical addrean space. In a 128K word sys- unmapped system with tw tasks. tem, lOOK words of physical memory are return stack - Modify the scheduler PAUSE so then accessed through this window. parmeter stack that it lab the page 5 and 6 t 4 memory management registers, as The X and Y coordinates of the image dictionary well M swapping in the uwal state array are converted to a double precision ?V buffer veetar information. index. This is donc by multiplying the Y state vector - Move the block buffers and master coordinate by the number of pixels per tad stacks to the top of page 4. line and adding the X coordinate. Thir Task state vectors .ro linked to each - ch.nga the routine BLDTASK to index is divided by the number of paps other in a circular fahim, ona pointing to uignthe new tank's return stack, per image. The quotient indicates which the next ndthe last back to the first. A puameter rtack, and dictionary to page the pixel is in, and the remainder will "round robin" scheduler starts running a pages 5 4 6, inrtead of givlng be the addregl offset of the pixel into the new task when the cumt tad exacuter a them space in the master task's Page. PAUSE. PAW store8 the current dictionary. machine state into tha state voctor of the - Chngc BLDTASK to aslign physi- The relocation constant for the needed existing tdc and wta the now mrhim cal memory to the task. It must page is set in the PAR so that it cnbe Itate according to the new tad's Mats caiculats the appropriate settings accessed through the data window. The vector. far APR 5 and APR 6 and save logical address of the pixel is obtained by them in ths tank's state vector so adding the address offaet to the starting Additional intonrution on mu1 ' that they EM be loaded into the addma of the data window. tarlcing y" be found in works by Forale$: memory management registers by M~COWC,nd ~euyand ~c~~muw4. PAUK. Multi-rrd-MrrPnrcnt Figure 2 shows the logical add~rpm of a FORTH application with a dngle tea UrSpmcmtafhtm Our venion of FORTH implements nd not udng mema), mmg.mhnt. multi-tasking in the following mmr. The two pprorhm discussed prt- Each task has a "state vector" which To odd propnm p.ce Lo our multi- vWy both ran in procensor "kernel" contains "uaer" variables that can differ tnking ryotem, we reserved a "tnk win- moda. To increoae our memory rerident from tank to task. Thir includes dow" in th. logical mddmas pm. The dd. otw.ge k, the multi-taaking appli- muter teak occupies the low five pepof cation described previoualy, we une the - Dictionary and atack pointers addrcnr ve. Code in thir mais wrble "user" mode memory management regis- - Program counter and interpreter by tUkh ters. pointer - Status flags and state indicator8 Mqpd tuks occupy p.gst 5 and 6 of The paoceror status word has two - Terminal 1/0 routines end buffer the logical .ddrerr spoca Oefinition .nd mod. fields current mode and previous pointers data within a rm~psdtdc M mdblc mode. The instruction MPD moves a - Vocabulary pointers mly to itwlf. Each tank must have a word from the "previous" mode address - Numberbaw wpmate vocmbuhry. If deflnitionr in a weto the "current" mode processor mapped tuk aa entarad into the FORTH tL& (the return stack in our FORTH The state vector for the master UC is vocabulary, the dictionuy Ilr*r will ha lmplemenhtion). The instruction MTW included in the nuclaur grw whrn ths next tdc bomeJ active. moves a WOEd from the "current" mode This urully nultr in 8 sy-m -8h. prucetaor stack to the 3mvious'' mode Each task also has its own tarminl Figure 5 ahowstha logical uldrwsp.ce In -pra. buffer, dictionary, parameter stack, and a mqpad multi-Wing rydem. return stack. New tasks are created with Using there inatruetione it is pwsible a routine called BLDTASK which allocates to retrieve and store data quickly and

FORTH DIMENSIONS Ill/ b a'. ciently, and the data stored there ia iixssiblc to all kernel mode programs, ~.~88~t888888t888tS8888BLOCh # 445 StttS8lt88tS888888888*8 --et?er they are mapped tasks or not. 1a:a tables that would otherwise need to ( MEMORY MANAGEMENT - ue, u! ) := ?isk resident because of their size can COtlE____ U@-~ ( CADRSI---CDATAl RETRIEVE FROM USER HOIlE MEMORY ) -f* be memory resident to speed resoonse 7777760 @# 300000 # HOW, ( SET PROCESSOR STATUS UORD: 1 -e. ( CURRENTPhERNEL, F'REW=USER ) 8 P)+ FPD, ( FROM ADRS ON STACh TO RP ) The source listing of the user mode 7777760 @# 0 t NOV, ( PSU BACK TO NORHAL ) -) )+ MOW, ( RP TO STACh 1 :1:3 storage code is included at the end of s RP - s article. NEXT, ( RETURN ) CODE Ul ( CDATAICADRSI- --El STORE IN USER MODE MEHORY ) ~ncluaion RP -) 2 s I) MOW, ( DATA FROH STACL TO RP ) 7777760 et 3ooooo t MOW, ( SET PROCESSOR STATUS UORD: ) ( CURRENT=KERNEL, PREWsUSER ) The first technique, the data window, TPD, ( FRON RP TO ADRS ON STACh ) -5: Seen used for two image processing s e)+ %:;:!cations. One is used to view infrared 7777760 Bt 0 6 HOVt ( PSU PACK TO NORMAL ) Jt ( RETURN UITH CLEAN STACK ) t-i ultraviolet laser beams in materials POP -:-age testing experiments. The system --, --_---a< circular averaging and calculates an 8**lS8lt88tS88888kSL8t BLOCK t 446 88888S88888tl88888t888~ zslute intensily withir, the 10 minute _.. .. cycle. ( tIEHORY MANAGEMENT - K:U ) CUIIE h.U ( Ch ADRSICU AIIRSICCOUNTI---CI COF'IES 'COUNT' ) -5e other image processing application ( UORDS FROH KERNEL SPACE TO USER SPfiCE ) ::je-beS X-ray diffraction patterns pro- W S jt HOUt ( UtCOUNT ) :.:*$ by a nanosecond X-ray source. A F'O s )+ MOW, ( RO=USER SPACE ADDRESS ) *riiique of radial averaging is also used HOU, ( RlXKERNEL SPACE ADDRESS ) -._ K1 s )i - e to enhance the diffraction pattern 7777760 es 3ooooo t PIOW, ( SET PROCESSOR STATUS uo~ci: ) -~ : study changes induced by sample stim- ( CURRENT=KERNEL, FREW=USER ) 2: 37. HEGIN, hP -) R1 )+ MOW, ( FROH KERNEL SPACE TO RP ) -ye second and third techniques are RO )+ TPD, ( FROM RP TO USER SPACE I -1.5: on the Omega Alignment System, U SOH, ( LiEC U, HRANCH IF NOT ZERO ) -- :b no+ has 17 tasks installed and uses 7777760 C# 0 # MOW, ( PSU BACk TO NORMAL ) EI-: 100,000 bytes of memory for pro- NEXT, ( RETURN ) --:- - sDace. The user mode data storage --. -5:yod is used by the data base software I-I 'or the intertask message queues. tt($Ltttt*SlXttl888i88 BLOC& # 447 8888~88888888~l88888tt8

;.though this paper describes tech- ( HEHORY HANkGEHENT UI.K ) . - :-es used with DEC PDP-11 series com- CODE U:h ( CU ADRSICh ADRSlCCOUNTl---Cl COPIES 'COUNT' ) .. :ers, the techniques are similar to those ( UORnS FROH USER SF'ACE TO KERNEL SPACE 1 .:?: with any limited address system with w s )t MOW, ( Y=COUNT ) : ; :al/physical mapping hardware. Thus, R6 s )+ HOU, ( ROzKERNEL SPACE ADDRESS ) -4. are applicable to minicomputers like R1 s It HOUi ( Rl-USER SPACE ADDRESS ) -s ?ewlett-Packard 1000 series and the 7777760 Ct 300000 # MOW, ( SET PROCESSOR STATUS UORD: ) -.:l newer 16 bit microcomputers like ( CURRENT=KERNELv FREVtUSER ) -- '.4otorola 68000 and Zilog 8000. The BEGIN, trviques are especially appropriate in a Rl )+ FPDt ( FROM USER SPACE TO RF ) -Iz.TY-79 context where the FORTH RO )+ RP )t MOW, ( FROM RP TO KERNEL SPACE ) -+:line is defined as having a 64K byte li SOB, ( DEC UP LOOP IF NOT ZERO ) ~:-essspace, carved out of an arbitrarily 7777760 61 0 t now, ( CURRENT=KERNEL, PREWIKERNEL ) =-?physical address space. NEXT, ( RETURN ) is brnwledgamsntr

4. Roclemary Leary and '* -ye following people played a major R.C. Leary is a conrultant employed by '. the Engineering Division of the Laboratory McClimans, Omeqa Alignment System 7 5 :n the development of the software =j:r,Sed in this article: Donald P. for Laser Energetics. C.A. Winkler is an Software Maintenance Manual, Univer- undergraduate in the Department of sity of Rochester, Laboratory for '*-II.imans, Lawrence P. Forsley, Reade ? '..mick, Robert D. Frankel, Joseph A. Mathematics, University of Rochester. Laser Energetics, 250 East River Road, Rochester, NY 14623,1981. D, and Robert L. Keck. RdWOnCW -71s work was partially supported by -c '3Uowing sponsors: Exxon Research 1. Microcomputers md Memories, Digital FORTH CLASSES TI Engineering Company, General Elec- Equipment Corporation, Maynard, MA -I Company, New York State Energy 01754,1981. -arch and Development Authority, 2. Lawrence P. Forrley, "FORTH Multi- November 16-20 *:-:?east Utilities, The Standard Oil tasking in WITH," Proceedings of the December 7-11 I :->any (Ohio), the University of 4th West Coast Computer Faire, 1979. January 11-15 :rester, Empire State Electric Energy 3. Michael A. McCourt, POP-11 FORTH- %arch Corporatim, and the U.S. 79 Implementation Guide, University Ca!l: Inner Access zc-artment of Enerov inertial fusion of Rochester. Laboratory for Laser (415) 591-8295 :yf:-am under contractnumber DE-ACO8- Energetics, 250 East River Road, 633A0124. Rochester, NY 14623,1981.

-Y-Y DIMENSIONS In/& Page 115 A HCH LEVEL MERRWT use an interrupt driven acquisition system vector allocation. The SV register points HANXER N FORTH which will avoid needless looping. This to the state vector and the state variables requires the writing of interrupt service contained in the state vector are addres- R. L. Keck and L. P. Forsley routines in machine code, which is at best sed relative to the value of the SV Laboratory for Laser Energetics cumbersome. It would be nice to be able register. Unversity of Rochester to write high level FORTH interrupt ser- vice routines which could be readily It should be noted that it is not Abrtrrt changed. This can, in fact, be done and necessary to have a multi-tasking system our method for doing this is discussed in order to implement high level interrupt A system for writing interrupt service below. routines. This is because the values of the routines in high level FORTH is des- state variables referenced by the interrupt cribed. An evample of the utility of high Inrplemenbtim routine are in general identical to those level interrupt service in a dynamic data for the master task. On a non multi- acquisition situation is provided. Our system consists of UR FORTH-79 tasking system we would simply reserve a running on a Digital Equipment Corpora- parameter stack area for the interrupt htroductim tion LSI-11 microcomputer under DEC's routinea and set S to point to it. It is RT-11 operating system. While a com- necessary, however, that FORTH be coded X-ray data from laser-plasma inter- plete description of the implementation of reentrantly for this scheme to work. action experiments on the GOL laser this system may be found in the imple- system at LLE has in the past been mentation guide', we will briefly cover The SV.SET.MACR0 is used to gener- acquired from photographs of oscilloscope FORTHs usage of processor registers for ate code which will set the SV and 5 traces. Because of the large number of reference in the following discussion. registers. Note that it also changes the detectors currently being employed, this return stack location. This would not be method has become impractical and we Four of the processor's general purpose necessary, except for the fact that the have chosen to use 12 channel integrating registers are dedicated FORTH registers. FORTH stack checking routines require AID converters for data acqu sition. These R6, the system 5tock pointer, serves as that the return stack be located in mem- A/D converters are CAMAC I compatible FORTHs return stack pointer (RP). R5 is ory immediately above the parameter modules and because of the extensive used as the stack pointer (S). R4 is used stack. The value of the interrupted task's CAMAC vocabulary available in the UR as the FORTH interpreter pointer (IC); it return stack pointer is stored in a free FORTH-79 system, as well as the contains the address of the compilation vector location [52T(SV) 1. suitability of FORTH for use in a dynamic address (also referred to as the code field programming environment, FORTH is used address or CFA) of the next word to be SETUP.INT sets the interrupt vector, for the acquisition software. executed. Finally, R1 is the state vector in this case specifically for CAMAC (the pointer (SV!; more will be said about the vector for the device in slot N for the The A/O modules integrate the signal SV later. CAMAC crate is located at 400+N*4). at each of their 12 inputs for the duration The processor is run at priority 7 during of a gate signal, which is derived from the The procedure for executing a FORTH interrupt service to prevent further laser oscillator. The oscillator is fired word from code is essentially quite simple interrupts from occurring. once every 10 seconds to keep it in stable and is accomplished by the word operation, however, our data signal occurs XEQ.MACR0 (a tisting is included in the To make it simple to create interrupt only when the full system of laser ampli- appendix). It accepts an address, into service routines, the macros previously fiers is fired as well, an event which which will later be placed the compilation discussed am combined to produce a occurs when a fire sequence is carried wt address of the interrupt rervice word, on defining word called by the laser system controller on com- the stack and generates code which will mand from the operator. We require a place the compilation address of the CREATLCAMAC. 1NT.WORD . means of clearing the AID modules just in service word on the stack [MOV BWADDRI advaqce of the oscillator pulse at which ,-(S) 1, loads the IC with the address of the This word when executed, accepta a task the full system will fire. This is accom- compilation address of the return from area and CAMAC slot number on the stack plished by feeding a ready-to-fire signal, interrupt code [MOV &HERE+8~1C1 (note and creates a word which contains the provided by the laser system controller 4 that

Page 116 FORTH DIMENSIONS in14 APPEND1 X WORD LISTINOS :cvice). They ahare the rame t8ak area ,.ice only one interrupt service routine BLOCK 1 888l8888t88888888888888888888888888888888888888888888 Ian be active at a time. ( Yiah level FORTH interrurt hrndler rlk Irf 25-.mu-81 ) In block 6, the high level wrvice -:Jtines an defined. RDYJNT io used to : REQ.RESTORE+HhCRO ( <>-<>t restore resisters 0-3 8) : ear the A/D module, enable A/D LAM'S ASSEHBLER 0 5 DO I RP )+ HOUt -1 +LOOP FORTH I TZLR XENLAM) and then clear and dis- C3DE RTI ( restore re#isterst return from interrupt 8) a3.e further LAM'r from the contact senre RP SZT 8U I) NOUt AEO,RESTORE.HACRO RTIt FORTH : ( xeo 8ssemb1w 8) -xi; module, on occurrence of a LAM XEO.HACR0 <8ddr of word, time>-<> '-27 the contact renie module. FIRE[ ASSEH8LER 8 -) BUAP R# HOU, ( Push handler word 8ddr on stack) r:;iccts the A/D data, dirabler further IC HERE 8 + # HOVt ( preset the IC ) 1 3 LAM'S (XCOLLECT XDISLAM) and ' EXECUTE P JHPI ( Jurr to execute 1 az::vates another teak which will print the COHPILE HTI ( pointer to next instruction ) -rrdlts (ZTASK DISPATCH) on occurrence FORTH 8 3' a LAM from the A/D module. There : REG.SAUE.HACR0 ( 0-0, 8.V. T'elliSterS 0 - 5 8) - jh level routines are inrtalled M the MSEHBLER 6 0 DO RP -) I HOVt LOOP FORTH I -:errupt service routines for the rppro- :-.ate CAMAC devices with the aequen- --> :es RDY.WORD SOYJNT and BLOCK 2 88888888888888888888888888888888888888888888888888888 -'SE.WORD FIRE[. Changing an interrupt !?-rice routined with thia system reauires ( more interrurt stuff 25-maw-81 rlk ) I-.V defiqing a new high level handler : SETUP.INT ( (slot#>-<> set c.18~ vector 8) -:-d and installing it as the handler word, SWAP 4 a 4000 + DUP ROT sum I ?.;., FIRE.WORD FIREZ[ will make the 2+ 3400 SUAP ! I -:rd FIRE2[ the new interrupt service .:-:ine for the A/D module. : SU.SET.HACR0 ( -0 set SU for interrupt routines 8) ASSEMBLER SV SUAP 4 HOW* S 141 SU I) MOW, 521 SV I) RP HOVt :Jncllmim RP 16~su I) now, FORTH I

We have shown that it is possible to : CREATE.CAHAC.INT.UORD ( -<>r create int. 8) -- :e high level interrupt service routines ( defin. word. 8) - -3FITH. This makes it possible for pro- .\'BUILDS0 t HERE SETUPIINT HERE 2- REG.SAUE.HACR0 z-amrners unfamiliar with interrupt pro- SWAP SU.SETeWACR0 XER.MACRU :-inming to easily write interrupt service DOES> CCOHPILEI INSTALL SUAP ! i -:L:ines. In addition, the facility with -- ?-I this system permits changes to be --> - 3& to the interrupt handlers makes this RLOCK 3 8~~~~8888888888l888888~88*88888888888~8~~8~8~88888888 I- .ha1 way to handle data acquisition in i -apidly changing experimental environ- ( Interrupt task area initialization rlk 16SEPB1) -?-It. 20 30 0 47 PLDTASK lTASK CPe8te f8.k 8?@8 8) *nowledgament lTASK TCLEAR ( initialize t8.k area 8) ITASK DUP ! SU DUP ! ( delink task. fron t8rk list 8) The authors would like to thank 1TASK DISPATCH ( n8rk t8.k 8s 8CtiVR 8) 'I' r'lael McCourt for assistance with =:ails on the internal operation of -- UR ( cre8te 8 re8du to fire hmdler word for CAMAC slot 6 8) . -9TH-79. 1TASK 6 CRE~TE.CAnAC.INT.UORD RDYeUORD ( Cre8te 8 time uord for the A/D module )I) -. Yeck is a graduate student in Mech- 1TASK XAD CREATE.CAHAC.INT.UORD FIRE-UORD a- :a1 Engineering at the University ?f ' :Chester. L.P. Forsley is Group Leader I' Zornputer Systems at the Laboratory . -_- Laser Energetics, Universitv of - r3ester. ;s BLOCK 4 t*tatf*taa*t*t*tt**aa888888*8aa8a8~8888*8888*8*88888*

. Vodular instrument and digital ( XP~Yinterrupt service 13-a~r-81 rlk 1 interface system (CAMAC, IEEE STD. 40 120 0 47 BLDTASK 2TASK ( task area for Post fire uord 8) 5amns) : HcCwrt, Michael, "Univerrity of : Rt!Y.INT ( rdu fire int handler 8) Soehester PDP-11 FORTH-79 Imple- XCLR XENLAH 6 N 0 A 2 F DROP 24 F 1 mentation Guide," Release Number 1.0, May 1981, unpublished. t FIRE! ( fire time h8ndler 8) XCOLLECT XDISLAM 2TASK DISPATCH I

RDY tUORD RDY NT ( m8kW RDYeINT the readv to fire 8) ( interrupt service routine *)

FIRE.UORD FIRE ( make FIRE! the fire tire interrupt handler 8) --..

Page 117 =XTH DIMENSIONS IU/& OPTIMIZED DATA STRUcfLREs FoRHARDwARZ:ma

Joseph D. Sawicki Laboratory for Lmer Energetic8 Univerrity of Rocheater Ab&mct

Data rtructmr have been developed to more edly control hardware. A di8k driver ir uwd u M example for exploring alternative FORTH data rtructurer ond way8 of optimizing them. These examptar ahow that FORTH data rtructum M well wited to minimizing programming time and increaring dtware efficiency. hbdJCti0Il

While workifg at the Laboratory for Laser Energetic8 thir ummr one of my project8 w.8 to write a general purporc backup routine for e MC-like RX02 mob floppy diak drive. In doing thir certain commmly uwd FORTH twfr benmuwful. Thir pwer will rervc to ihrtrate thew tools, and the modification8 mcerrcrry due to the future of the project. o.t.stn#ctANa

The TO concept war developed by Dr. Paul Eutholdi and we8 derribed in FORTH DIMENSIONS Vol. 1 No. 4 and VOL I No. 5 concept2 in variables. Thir cwld be implemented in hioh level a8 followr

0 VUIABLE %TO :TOI%TO!; : VAL -<> , ACCEPTS INITIAL VALUE )

&ES> ( <#>-<>;<>-<#>, SrORES OR GIVES "VAL" ) %TO @ XF ! 0 %TO ! ELSE @ THEN ; It would be uaed like a variable. Entering 0 VAL+lAME+would define a variable with an initid value of zuo. To change the value to a rix one would aay 6 TOeNAMD, rsyiWNAME+wwld now put e six on the atrk. Thir technique make8 the codn more readable by eliminetlng the uw of a and [ 4th vui.blar (nd ' with cmrtantr) to access and modify them. The backup driver ir no exception to thir and in frt offera the opportunity to carry the campt one rtsp furthy. In the DEC POP-11 architecture, VO ir memory mapped w that, for intame, the Dbk Control Statum Rqirter ir at location 1771700 end the Data Buffer Ragirter ir at location 1771720. One way to communicate with them .dhrrer ir to define two conetntt: 1771700 CONSTANT CSS 1771720 CWTANT 13BR but then the u8e of @ nd [ become8 neceosuy. A way around thir problem i8 to define a dmta structure umUu to VAL excspt that it contain8 an address in it8 parameter field inrtead of a value. It would .Im be uwful to fetch the adha a8 well a8 to send data to and from the addrow. An ~ry,though by no mean8 optimal, implementation of uch a 8tructum ir given beIow.

: TO ( SETS FLAG SO THAT A MUM MILL BE STORED IN A REG.) 1 ZTO ' i : FRO# ( FLAG so TWT n MUM YILL BE GO:HN FROM A REQ) -1 LTO ' i

( TEST BED FOR BEGINING OF RX02 DRIVER JltS 15JUNbl J : REGISTER +BUI DS t shD,-\*, BUILDS A DATA TYPE CALLED A REGISTER ) DOES) ( GIVES REGISTER ADDt CONTEdTS OR SENDS Db7fi 10 THE RE6ISTER DEPENDIN6 0)r THF STATUS OF P %TO P I QET hDDRESS OF REG AND #rO DUP -1 = IF SMAP P SYAP (GET CONTENf) THEN 1 = IF i ( STOREVALUE IN RET; i THEN 0 PO Once thew two rtructumr are implemented It become8 very easy to talk to the diJc drive. For example, if a VAL had bea defined called IN-TRACK# which contained the trek to be read, dingIt to the DBR would simply cmrirt of uying N-TRACKI TO

B.rp 118 FORTH DIMNSIM m/b In the RX02 mode there are eight disk commands. They are ell similar in that they need to have a drive and denrity bit set and they are sent to the CSR. The first problem is solved by a VAL called DRIVE/DENSITY and the four words drown below:

: SINGLE-DENSITY I *.COB. -El THE DCIVE BIT TL1 1 DRIVE/UENSITI 16 815 TO DRIVE/DENSITY T

After setting the drive and density as desired, the V4L DRIVElDENSITY can then be ORed with the command to produce the draired results. There are two approaches that can be taken at this point. For example, take :he command to format a disk in a single or doubk density; call it (SET-DEN). A word could be defined, alonq with seven others like it, as shown:

:(SET-DEN) 110 DRIVE/DENSITY OR TO CSR ;

The second approach would be to again use a defining word:

: bISh-COBBAN[~ BUILBS .CON - TAhES THE CON FOR A DISh of'. '

110 DISh-COBNANU (SET-DEN! ( USED TO FORNAT IlIShS SING OR D DEN) Optimiratim

As usual we have a classic FOR fH space-time tradeoff. The second approach executes somewhat slower (see figure 1) because the constant needs to be fetched, but whereas the first approach takes 18 bytes per command or a total of 144 bytes, the second approach takes only 10 bytes per command plus 24 bytes for the defining word for a total of 104 bytes. Because of the space savings the philoso- phy that very similar things should be grouped together could override the execution speed losses and the second approach was used.

All of this would have been fine except that when doing the track to track backup a sector interleaving technique must be used to keep backup times down to a reasonable level. Since these VAL'S and REG% have high level IF statements in them and they are used each time 8 sector is read or written, they require an overly large interleave step size. The solution to this problem is to use ;CODE instead of DOES? Though this makes the word less transportable it isn't seen as a problem since this is a PDP-11 specific disk backup. The VAL word now can be defined as follows:

: YAL \BUILDS ( #;- , v TALES THE INIlIAL VALUE OFF Tlct STACh 1 I iCODE ( -4.- , OR ':- 4'9 GETS VALUE OR STORES VALUE ) ZTO F TSTr ( SEE IF %TO fOSITIVE I GT IF, YPARAB W 1, S )+ HOVr ( STORE VALUE ) %TO F 0 4 BOV, ( ZEKO OUT ZTO FLAG t ELSE I s -) YPARAN Y I) nov. I FETCH VALUE OF VAL ) THENr NEXTr --

where W is the PDP-11 register containing the CFA (code field address) of the word executing, WPARAM is a constant equal to the offset from the CFA to the PFA, and I) indicates indexed addressing. Not only is the coded VAL faster than the hi@ level version, but it IS also faster than a VAR at fetching and the same speed at storing (see figure 2). It was also necessary to code REG as shown below:

: REG <.BUILDS ( BUILDS A IIATA TYPE CALLED A REGISTER )

IT0 F TSTr ( CHECA IF IT0 IS POS NEG OK ZEKO ) GT IFr uFARnn Y el) s )t nov, ( STORE VALUE IH REG ! ELSE, LT IF, 5 -) WARAN Y el) now, ( GET VALUE ) ELSEr S -) YPARAH Y Ii NOVt I PUT T.0.S. 1 THEN, THENr %TO F 3 4 NOW, NEXT, -- , oh I rql

To illustrate the use of these concepts the FORMAT-DISK word will be shown. But first to insure that the program doesn't try to do things before the dlsk controller is ready, two more words am needed that wait for the done and transfer request bit to be asserted in the CSR.

: TR.YAIT ( YAITS FOR THE IIATA IRANSFER BIT TO BE SET ) BEGIN 2000 FROPI CSR AND END : DONE.YAIT ( WITS FOK THE DON{ BIT TO BE ASSERTEb ) BEGIN 400 FROB CSR AND ENU P

rORTH DIMENSIONS ID14 Page 119 The dink command an almwn bofom war called (KT-DErJ). After ~ivlngthlr commend tha dlk controllor walta for a “key” byte {lllo,the letter Iin ASCII) to be sent to the DBR, thorefom the entin cwmnmd ir coded ao ohown!

To format the dirk in the elve om double denrity one would mtar lDRlVE WUBLEdMSlTY FORMAfaISK$ to format the disk in drive zero single denaity one wwid enter ODRIVE SHGLE-DENSITY FfflMATaIM- Mno

To &ow tho effocta of the different approache8 timinq t08t.8 WON IVI. Th. fht rontruta tha diffOrWC0 ktwnen tho two tyvOf dirk commendr In all tort# tha action wan placed iddo Idouble loop likcu : TEST 10 0 00 30000 0 W LOOP LOOP ;

This routine took 23 rcondr which war then dtrocted from the other Mlk8 to glvo tho tima to do tha op6ration lOap00 timer Thir was then divided by 300,000 to give the time per operation. Thew M tho dtaon a MCLS11112r

To Send Dirk Corvad

Colon definition .23 met. hfining word .28 msoc.

Then a hi* level VAL war compued to a coded VAL and a VARI

fetching (nec) rtoriq (mooel hish level VAL .237 .39 coded VAL .067 .ll

VAR .083 .09S

-This psper not only ahowed tho urfulneu of certain technlquer In FORTH hut dm Illwtr~termme prrral proportier of the Imguage. The firat of the- is the ease of implementation of new data rtructum Thmuph tha unof BUILDS ... DOES or BUILDS ... ;CODE one can fint build the dructum to uit the me& of tha qpllcatlm and Lhwr lmbod in tho exacutable coda neceauy cprrtionr for the 8trUCtUm. Alm a rtructure can earily be glvm vuiabb execution ma in MuCY of VAL ond REG Another importrnt banefit of FORTH u the ear of optimization of the word by the UI of aammbly coda. Chmglq tho VAL md REG ymrdt to tCoDE taok low thon --a half hour. I would like to thank Mike MCCOurt, Bob Keck. LBW?OIEOFdoy md Peter Pubn far Uutr h.Lp In pttinp the hardware running ad for comments on the mftwue. This work war partially upportad by the following par#rm Exxm R.r.rch ond Enpinrrhq Campmy, Canard Electric COWMY, New Ywk Stab Energy Research and Development Authority, N0rthS.d Utilitiw, Th. Standard Oil Comprny (Ohio), the Univedty of Rocheater, Empire Stata Electric Energy Rowarch Corparation, and tho US. mtmmt of ern^ inrtial fdon program under contract number DtZ-ACOB-80DP40124.

J. Sowicki i8 n undsrgrrduate With the Electrical Enginoerlng D.putnunt of tho Cdl.gl of khginwriq at tha Univadty of Rocherter. Ha ir a DJ in hi8 gsre time.

1. DEC end POP-11 am trrd.muk8 2 The TO c~lcat by P~ulButholdi FORTH 0IMENSK)NS VOL 1 Na 4 nd VOL I Na 5- ibix indiciter octd BLOCh 91 M STRWG STACK t::ltaSttla:iatatt Stt:S:ll8t:tl::l4lt i STRING STACh--FIXED LENGTh STRING COMPARISON LAR 19-SEP-79 ) Michael McCourt : SS i ( NOTE: PAR&^ ORDER NOW ..ADR;z.LEN,, MAM ll-JU#-B(, I ( [ADD At ABD Bt LENIP---[ADDA~ ADDBt a OR t OR - 3 ) Laboratory for Laser Energetics ( COMPARES CHARS. IN STRINGS A L P PAkIWISEi RETURN5 0 IF University of Rochester ( STRINGS ACE =t t IF A'B, - IF A\P ) : swo o SWAP o DO DROP OVER ce OVER ce - ROT it Richard A. Marisa ROT 1t ROT DUP J= NOT IF LEAVE THEN LOOP i Production Automation Project ( [ADD At ADD 81 LEN]---[= OR t OR -38 SAME AS SVFDO ) University of Rochester ( EXCEPT ADDRESSES NOT RETURNED ) : SVF S'FDO ROT ROT ZDROP i Abstract ( [ADD At LEN]---[= OR t OR - 11 OMPARF STRING A TO ) ( A STRING OF BLANKS--RETURNS 0 I! TWO AWE EOUAL J : sv o SWAP o DO DROP DUP ce BL - SWAP it SYAF DUP 0, Applications which require a text data IF LEAVE THEN Loor SWAP DROP i -- type are supported by a group of functions which operate with string variables and a tattaataat~aaaaata BLOCK 97 t8ttSlt::S::tlt:::t string stack. The string stack is analogous to the parameter stack, however, the data type with which it operates is the string, containing length and character data.

String Defining Words Two defining words are available for the creation of string data entities. The first is: STRING-VAR which creates a varying length character strinq with maximum length cmaxlen>. InvokingeNAMbplaces ( STRING STACh WORDS LAR 19-SEP-79 ) SVAR SSO 0 SVAR SSM 0 SVAR SS! on the parameter stack. The first byte , SSTOP SST @ i : SSTOFlSSMX SSTssn I Ii atebeginning addressais the current string : SSCIRG sso e i . e ( [FROM, TO, LEN I---[']CHEChS FOR STACk BOUNDARIE length; the string text begins at the next : SOVCHECk OVEh SSORG U, byte. IF SSMAX SSTOf 1 141 TABORT THEN i ( CADDI---Cl INSURES THAT ADDRESS POINTS TO STRING : SSVER DUP DUP ce t SSMAX u.= The second string defining word is: IF SSMAX SSTOP 1 131 TABORT THEN i ( ADD OF TOP STRINGl---tAP OF NEXT STRING DOWN3 ) ()STRING 4AJW : SSDOWN DUP ce it t , ( CADBI---[l PUSHES STRING AT AbIlR. TO TOS ) which creates an array of variable length : SSPUSH DUP C@ It SSTOP OVER - DUP SSTOPI SWAP RMOVE strings. Invoking

ei>eNAME> placer caddress of the i-th 8triRg> Uul.0, STRING STACk UORK LAW 19-s~p-79 ) 'DROP ( [I---[IPEMOVES TOP STRING FROM STACK tj on the parameter stack. Note that sB:O,P SSVER SSBOWN SSTOF t (number of elements) x (maxlen) bytes will ( LI---Cl_. .. RETURN~ LEN OF TOS STRING I! be allocated to hold the string array. SEOPSSVER ce i 'Lot ( [I---[I.. RETURN ADDR OF TOS STRING L) SJTOV 1t i String Stack tulmipuletim DUY ( [I---[ICOPY TOS STRING t) !STOP SSVER SSPUSH i WAF ( [I---[IEXCHANG TOF STRINGS 8) A string stack, separate from the para- SITOP DUF SSDOUN DUF SSPUSH SSD6UN SStOP SWAP SSTOPl meter stack, is maintained in memory for !WAF SSPUSH SSPUSH 9 ROT ( [I---[I ROTATE TOP THREE STRINGS ABC->BCA the purpose of manipulating string data. SSTOP DUP SSDOWN DUP SSDOWN DUP SSPUSH.SSDOWN SSTOY SYAP t Several words which manipulate the string SSTOPl SWAP SSPUSH SWAP SSfUSH SSPUSH --j stack are defined in the string stack library which can be compiled by execut- ing >STRINGS (which loads in the string stack package). Currently 200 (decimal) ( STRING STACK WORDS HAM 13-JUN-80 I bytes are allocated for the string stack. : 'OVER ( CI---Cl PUSH 2ND STRING DOWN ONTO TOS 8) !STOP SSDOWN SSVER SSPUSH i The quote word ('I) is available for : 2DUP ! []---[ICOPY TOP 2 STRINGS 8) placing a string the string stack. TO 'OVER 'OVER I on : :?DROP ! [I---[]DROP TOP 2 STRINGS t) stack a string, type: DROP 'DROP t " " : '20VER . ( [I---[]PUSH 3RD AN11 4TH TO TOS 8) $STOP SSDOWN SSDOWN DUP SSDOWN SSVER SSPUSH SSPUSH i : 2SWAP ( [I---Ll EXCHANGE 1ST I 2ND WITH 3RD AND 4TH '' is followed by exactly me space, then !UP SSDOWN SSDOWN SSDOWN SSTOPI SSPUSH SSPUSH 55PUSH SSPUSH 8 'LEN,---Cl PUSH STRING AT AODR TO SS t) * DROP SSPUSH i A string print word .SS is used to print the top element of the string stack,

!?CORTH DIMENSIONS UI/4 Page removing the top element in the proceu. 888888888888848888 BLOCK 101 88888888&1l841&84~4 For example, ( STRING STACK YORDS CONT'D MAR 13-JUN-80 ) " STACK STRING " OK THIS : " ( CADRICLENI---Cl STORE TOS AT ADDR, 1 DROP TOS 8) ~~:o;~;~R~;~;~A~OVER ce RIM ~DUPSYAP c1 1t OK ( CSTRINGI---[I STORES STRING IN PAD THEN MOVES IT FROM ) ( THERE TO THE TOSS -- YORIS DURING EXECUTION TINE ) .SS : x' 420 YORD o *e : $' R> DUP 0 '@ Dub CB UUP MOD STACK THIS STRING OK IF 1t ELSE 2t THEM t .R P ( CSTRINGl---Cl STORES STRING AT TOP OF DICT. STACk 1 Notice that the functions .SS and. are ( DURING COMYlLATIOM ) : c* COMPILE $0 420 YORD ce !UP 2 MOD similar. Several other functions operate IF 1t ELSE 2t THEN ALLOT 9 on the string rtack in a manner analogous : STATE @ IF C' ELSE X' THEM i IMP * to worth which operate on the parameter -- stack. These am:

"DUP copies top of stack BA BAA "SWAP reverses top two strings on tho stack BA AB "DROP removes top of stack BA B "OVER copes 2nd string onto top BA BIB "ROT moves 3rd string to top CBA BAC "ZDUP copies top 2 strings BA BABA "ZDROP ruoves top 2 strings CBA C " reverses 16 2 with 3 6 4 DCBA BADC "ZOVER copies 3 6 4 to top DCBA DCBADC "+ string addition (eatanation) BA BA

888888888888888888 BLOCK 102 8888888888888888888 sbk)-- ( STRING STACK YORDS CONT'D M11M 18-MAR-81 ) : .S ( Cl---Cl TYPE OUT STRING AT TOSS 8) Just as the pumnuter stack relational iS!OP SSVER R Y COUNT TYPE i operators -move their arguments from : ( <>-0,'8U? STRIMG IM DICTIONARYr MAKE EVEN LEN8TH 1 the parameter stack, the following string 410 YORD COUNT DUP HERE SYAP it -2 AND ALLOT SIMP cnovE , stack relational operators remove their ( SOME FIXED LENGTH STRING DEFINITIONS ) arguments fmm the string stack. The ( CADDRvMAX LENI---Cl PUSH STRING AT ADDR TO TOSS ) logical result of the string relation is : '(F DUP SSTOP OVER - 1- SSTOPl SSTOP C' SSTOP 1t SYAP CMOVE i pleced on the parameter stack. The avell- ( CLIDDRvMAX LENl---Cl COPY CHARS ONLY FROM TOSS TO ADDR ) able nlationals are: : 'IF ZDUP BLANk 'LEN NIM SSTOY It ROT ROT CMOVE 'DROP I 'k " "<> ">=

"< "> 888818888888888888 BLOCK 103 888888888888t888&88 string VrWstaq. d R.triml ! STRING STACK YORDS CONT'D LAR 19-SEP-79 ) ') The string store word, 'f, places tho ' *hAP(SS&-QdDt& #&IEp'R~~~~Po::s~~~KRbFFT lo top of the string stack in the string vui- SSTOP C! SSTOP DUP 1t ROT It RMOUE SSTOP It SSTOP! I able described by the parameter stack, ( [LEN, BEGINNING CHAR #I---tl REPLACE TOSS YITH ) ( SUBSTRING OF LENGTH CLENI. STARTOMG YITH SPECIFIED ) popping the string stack. Tho string ( CHAR OF ORIGINAL STRING ) retrieve word, "I,places the string : 'SUBSTR 1- SSTOP SSUER 'DROP t DUP ROT ROT C! SSPUSH I referred to by the parameter stack onto ( CADD OF ZND STRt1, 1ST CHAR OF 1ST STR, LEN OF 2ND1 0 I ) ( ---t FFSET R 0 I SEARCHES ZND STk. FOR IS1 HAR OF ) the string steck. ( 1ST q1R.L. I? FOUND, COMPARES ZND STR. FROM THAF POIHT f ( TO 137 STR 1 : 'INDEXDO DO OVER I t CI,OUER = OK 30 STRING-VAR MYSTRING t SSTOP t EN S?F IF!%RhP I 1t RO# RO\ LEAVE !;EN THEN LOOP 1 OK

" string taxt " MYSTRING "1 OK

HYS~ING 'I@~ST~~ING 'I@ "+ .ss string tat string tat OK

Page 122 FORTH DIMENSIONS m/4 -.:ding the Mme of the string vrrirble -' . STRING in the preceding example : ired

on the para- -e:er stack. String store and itring '.":eve check the maximum and current *-;!h of the string variable when moving ! . -q data.

I io ahen it is required to move field8 of :!! length which do not contain an t-zedded current length in the fint byte, : '? 0. 1 ( Cl---CT/Fl LOGICAL LESS THAN TESTS TOP 2 STRINGS ) 1.3 length string store and retrieved : '<'?O> i -:-:3 may be used. The syntax i8;

"!F
"@F STRING STACK YORDS CONT'D HAM ie-nAR-81 ) e *'> ! EI---CT/Fl TESTS TOP 2 STRINGS FOR 8) st-uq Functim '? nr : i Il---tT/Fl TESTS TOP 2 STRINGS FOR <= 8) *:> NOT i -EN returns on the parameter iteck, : '>= ( [l---CT/Fl TESTS TOP Z STRINGS FOR >= 1) -c .ength of the string on top of the *< NOT i . -3 stack. The string remains on the : 'SPACE ( d'N>-c'>r PU H A STRING OF N PA S ON S 1) DW o 00 ssiop i- BL ~VCHEC~OUFR ci SsiESI Loof . . '3 stack. The address of the first byte SSTOP 1- DUP ROT SYAP C! SSTOPI 9 . :?e string (one byte after the length t : IS found by executing "Lot. : 'INIT ( <#CHARS TO ALLOCATE FOR SS>-<>.t INIT SS-INTO DICT ) 1 ?# HERE SSO 1 ALLOT HERE 2- DUP ! SST I v .r-gth> :.:s!ring of length , beginning - :- the specified character of the ttttltttt8lttltttt BLOCh lob 8t88ltttttltt8lttlt ._; qal string. For example, ( STRING VARIABLE AND STRING ARRAY MAH 13-JUN-80 ) ( CHAX LENI---[I ALLOTS SPACE IN DICT FOR MAX LEN AND 3K ( MAX #-OF CHARS. ) : STRING-SPACE DUP 9 0 9 2/ DP+! i " 3 .SS abcde" 2 "substr ( CNAX LEN1 STRING --- BUILDS A STRING VARIABLE ) cd OK ( WEN

-%-mg stack Em ( STRING ARRAY ROUTINE HAM 13-JUN-80 ) : OSTRING ( C# OF ELERENTSr NAX LEN3 ---<;MANE> (BUILDS sunp DUP I ( BUILD HEADER, STORE # OF STRINGS ) -do errors are reported by the string o DO DUP STRING-SPACE ( ALLOT PIC SPACE, STORE NAX LEN ) izg package: string stack underflow and LOOP DROP - +-!low. As stated previously 200 bytes DOES:. 2t DUP P ROT ROT 3 PICK ( ADDR OF 1ST ELENENT ) :-t initially allocated for the string DUP 2 MOD IF 3 t ELSE 4 + THEN ( l+ TO NAX LEN IF ODD ) :I<. If repeated overflows are gener- ( Zt IF EVEN, 2t FOR HAXLEH ) ROT 2t t SYAP i ( STRING ADDR t ELENENT OFFSET ) f +I more space can be allocated for the 8 ( RETURNS COUNT AND ADDR 1 . -3 stack by changing the parameter :%ed to "INIT in the string stack r-ery. String stack initialization is the *?: 'unction performed when the rtring --> ):I( library is loaded. tS88tt88888888St8t BLOCK 108 ttlSttttttttltltSS8 irrmmy ( STRING EXECUTION ROUTINE LPFvHAH 18-MAR-81 1 This was the fint major mftware : 'EXEC ( -Oc EXECUTE YORD IF FOUND ) HERE 'LEN *! :i:dage transported throughout the FIND TDUP IF EXECUTE .- Versity LJRTH community. Originally, ELSE 0 TABORT THEN i ( UNDEFINED YORD ERROR ) -ad a few code routines which were - Szhine specific to reduce execution : 'FORGET ( (YORD NAME ON TOSS>-<>, FORGET YORD IF FOUND ) -e. However, these were removed on HERE 'LEN '1 L :be systems but the Intel 8080. The FIND 'DUP IF YPARAM + SFORGET :?:*age has run, without change (except ELSE 0 TABORT THEN i ( UNDEFINED YORD ERROR 1 IC the above mentioned machine-rpecific :?=' on Hewlett Packard 2100, DEC is 32-11, IBM 360 and the INTEL 8080.

-- ISTH DIMENSIONS III/4 Page 123 NEW pRowcT5 The first application was for a screen- Released on two 5.25" diskettes with oriented data entry system, Later appli- source in Z80 aswmbler 120080-ZS ($80). cations included an ISAM data bare, a menu-driven interface for flow cytometry FORTH mtiatlm Mofhla DLkat. Released on one 8'' diskette with and a word procesaing system. The pack- mrce in ZBO assembler #$008O-Z8 ($80). age consists aImost entirely of its original code written in 1977 by Mike Williams, of the University Computing Center. The major change has been the addition of comments.

Acknowledgsmentr

We would like to thank the following people for their asaistence: Mike Williams, of the University Computing Center, who developed the original String Stack Package for URTH on the IBM 360 and the Intel 8080; and two undergradu- ates who worked for Lawrence Forsley, Lynn Raymond and Dan Blumenthal, for documenting this package.

This work was partially supported by the following sponsors: Exxon Research and Engineering Company, General Elec- The FORTH scmena, written by Scott Released on two 5.25" diskettes tric Company, New York State Energy 120100-89 ($l,OOO). Research and Development Authority, Pickett, may be used with Timin FORTH or other fig-FORTH. The price for the Northeast Utilities, The Standard oil Releared on one 8" diskette 120100-88 Company (Ohio), the University of diskette of FORTH application modules is ($l,OW). Rochester, Empire State Electric Energy $75 (if other than 8'' standard disk, add Research Corporation, and the U.S. $15). To order the FORTH modules, write Complete Ziloq (AM) 28002 Department of Energy inertial fusion Timin Engineering Company, 9575 Cenesee Ave., Suite E-2, Son Diego, CA develoment system that CUI be run under program under contract number OE-ACOB- CP/M or CROMEMCO CDOS. Syrtem 80DP40124. 92121, or call (714) 455-9008. includes a METAFORTH Cross-Compiler which produces a 28002 fig-FORTH R. Marisa is the manager of the computing compiler/interpreter for the Zilog 28000 facility of the Production Automation MRACCESS FORTH SOFTWARE AND DOCUMENTATION Development Module. Pockege includes a Project in the College of Engineering at Z8002 awembler, a Tektrooix download the University of Rochester. M. McCourt program and a number of utilities. was a senior laboratory engineer with the Fig-FORTH compiler/interprater for Laboratory for Laser Energetics at the POP-11 for RT-11, RSXllM or stand- Released two 5.25" dlJtettes University of Rochester and is now an elm with source code in native as- on 129102-85 ($4,000). applications engineer for Harvey sembler. Included in this package are an Electronics. aaaemblsr and editor written in FORTH end installation documentation. Released on one 8" diskette 129102-88 (W,OOo). This is available on a ooc 8" single HELP WnNTm density diskette only. #Moll-01 ($80) Ziloa 28002 Develoment Module fig- -M.ngar, Referm ~~~~lfor p~p-11 fig- FORTH-ROM set. Contains fig-FORTh -crmprtsr- FORTH above. 120011-99 ($20) with ZBOOZ aaembler and editor in 4 (2716) Primary responalbility for designing, PROMS. 138002-M1 ($850). debugging and implementing major wft- ware projects on the Pulmonary Computer Fig-FORTH cornpiledinterprater for System. Programming experience with CP/M or CROMEMCO COOS system For aden and further information, POP-11 Assembly Ianguagn and FORTH comes complete with source CO& written contact: desirable. Some hardware experience will in native assembler. Included in this be useful. package are an armbler and editor INNER ACCESS CORPORATION written in FORTH and installation Software Division Salary range to t35,WO. Superior documentation. Box 888 benefits package, three weeks vacation Belmont, CA 94002 first year. All di8kettes are ungle density, witP (415) 591-8295 5.25" diakettes in 128 byte, 18 Contec t: rcctor/track format and 8" diskettes in 128 byte, 26 rectar/track (IBM) format. John Gilbert, Employment Officer Cedars-Sinai Medical Center Releared two 5.25" diskettes with Sym-FORTH Newletter now available, 8723 Aldsn Drive on wurca in 8080 egcmbler 120080-85 ($80). contact: Saturn Software Ltd., PO Box P.O. Box 48750 397, New Westminister, British Columbia, Los Angeles, CA 9ooo8 Released on OM 8" diskette with V3L4Y7, CANADA. (21J) 855-5529 mrce in 8080 aawmbler 120080-88 ($80).

- Paiga 124 FORTH DIMENSIONS 11114 COkpcEX ANALYSIS PI( FORTH to define all of the Important rtack mani- define. For example, Z+ ir defined by pulations such as ZDROP, ZDUP, ZOVER, :z+ mP+mPwrIum; Alfred Clark, Jr. ZROT, and ZSWAP, which perform exactly Department of like their integer and florttng point where FROT is a floating point ROT, and Mechanical Engineering counterpart#, The basic load and rtore F+ is a floating point add. University of Rochester operators, Z@ and Z[, can be defined in terma of 3 and [. Higher functions can be defined, pro- 3uring my years as an engineering vided the underlying real floating point educator and a researcher in theoretical There are many single number opera- has the standard real functions SIN, COS, fluid mechanics, 1 have often wished for tions which are ureful. There include the ATN, and EXP. The complex exponential, the perfect calculator--a compact real part REZ, the imaginary part IMZ, for example, is then defined by machine which would perform intricate the complex conjugate CONJ, the modulus :zD[p ps139wpmJPApTmcTsPwrF. and useful mathematical tasks in response /Z/,the quare of the modulus /Z/2, the to a few keystrokes. The pocket scientific reciprocal 1/Z, and the phare ARM ApTPFfurmsINP calculators, amazing as they are, never (radians). Most of there are quite rimple seemed to have quite the power and flexi- to define. IMZ, for example, ir juit Other uaeful functions wch a8 ZSIN, bility (and certainly not the graphics : IMZ FSWAP FDROP ; where FSWAP and ZCOS, ZTAN, ZSINH, ZCOSH, and ZTANH ability! that I hoped for. I always sup- FDROP are floating point rtack oper- are defined similarly. posed that my hopes were unreasonable ations. As another example, consider l/Z until I discovered FORTH two years ago. Of the multi-valued functions, the definedby : 1/z ZDJP /z/2 Pwr Having been a FORTRAN programmer for mmi F/ most useful are the square root ZSQR, the 20 years, I found the transition to FORTH ?lWrrrOrF/mU: logarithm ZLOG, and the power Z*+. As somewhat difficult and even painful at For ARGZ it is very important to establish an example of the definitions, consider the times. Originally, I took up FORTH out of a precise range and to implement it care- principal value of the square root: curiosity, but gradually I realized that the fully. The conventional range, which I x- RlkR2.F/FSAPmRMWEP: quest for the perfect calculator was over- have used, is -PI < ARGZ <= PI. Any care- -it is FORTH plus a microcomputer. lessness in the definition of ARCZ will The baaic words described above can lend to disasters later when multi-valued be the building blocks for substantial Perhaps 1 should say a little more functions are introduced. Many engineer- applications. One such application, which about what a perfect calculator is sup- ing applications require the phar in is particularly ueeful pedagogically, is posed to do. Among other features, it degrees, and it is convenient to build in a conformal mapping. I have defined a word should have (1) staidard trigonometric and function DARGZ which supplier this. MAP such that the uequence exponential functions, (2) other common -> Cfryrticn, special functions (e.g., Bessel functions), Conversion words between rectangular :5) graphics and automated plotting of and polar forms are also very ureful. To will take any previously defined curve in functions, (4) numerical integration, (5) a go from retangular to polar, with the the Z-plane and any previously defined root-finder, (6) special purpose applica- phase !in radians) on top of the stack and complex function, and produce a graph tions, such as a direction field plotter for the modulus just below, we have showing the curve and its image under the first order differential equations, and (7) transformation. This tool allows students :mAR ?mP/z/mc113TAIIGz: complex arithmetic, including complex (and the instructorD to improve their transcendental functions. Further, all A similar word, DPOLAR, leaves the argu- understanding of the geometry of complex procedures should be executable with a ment in degrees. For cormrsion from functions. few keystrokes. polar to rectangular, we have RECT (angle in radians) Notar m 1rnplemsnt.tirn The last item in the list-complex--is :m~~035PRz7pFTursIblP ' in some ways the most stringent test of The code described above runs on the any would-be perfect calculator. It's and a word DRECT for the angle in author's 48K Apple 11. The underlying certainly not available on any pocket degrees. A very useful application of integer FORTH is the excellent version calculator. Although it can be imple- these is a rotation operator ROTZ, defined written by William Graves and distributed mented in BASIC, it is cumbersome and so that the sequence Z F ROTZ rotates by SOFTAPE. The real floating point requires a large package of subroutines. Z by F radians and leaves the result on the arithmetic and functions have been The versions of FORTRAN available for stack. The definition is implemented by interfacing the SOFTAPE FORTH with the Applesoft ROM rou- small machines generally omit the com- mFlDTRxARFlWpF+m;. plex arithmetic and complex functions :m tines. The same data stack is used for which are available on large machines. There are several different useful integers (2 bytes), reds (6 bytes), and With FORTH, however, the extension to formats for complex output. ("y system complex numbers :12 bytes). The code for complex from real floating point is simple has 8 different formats, which is handy the complex routines was written entirely to implement, easy to use, and powerful. but a little extreme.) The word 2. prints in FORTH, and, in compiled form, occu- Since complex arithmetic is not yet very the number as an ordered pair -- 3.5 7.2, pies about 2K. The conformal mapping common in FORTH on small machines, I for example. The conventional mathema- code compiles to about 1% additional. thought it would be worthwhile to sketch tical notations is obtained by Z1. -- (3.5) + briefly my implementation. (7.211. Words to print in polar form are

also useful.-~~ ~ For examole.~rI ZP. is defined The most fundamental question in so that the sequence 3.5 7.2 ZP. gives ORDER NOW! , introducing complex analysis is how to Proceedings of the 1981 Rochester represent complex numbers. Here it turns 'Ix) 8.u)5b2303 AiG 1.11832144 (RAD) ' FORTH Standards Conference , out that the Dure mathematician's defini- All of these WtDut words are defined in $25.00 US, $35.00 Foreign. Send tion of a complex number as an ordered terms of the basic floating point print check or MO to FIG in US funds pair of real numbers is exactly what we word F. . For example, 2. is defined by on US bank. need. Thus the complex number 3.5 + 7.2i "Starting FORTH" : Z. FZXW F. 2 SPXS F. ; IS regarded as an ordered pair, and is Hard - $20.00 US, $25.00 Foreign pushed on the stack by typing S.5 7.2 . The binary complex operations are Z+, Soft - $16 .OO US, $20.00 mreign With this convention established, it is easy Z-, Zf, and Z/. These are quite easy to ORDER NOW!

FORTH DIMENSIONS IIV& Page 125 A FORTH BASED defined. A simple example of ouch a FOWT MCROSTZED definitim wwld be as follows FIELD GG WIDTH 16 DEFAULT 65535 MCROASSEIUSLER FORtlAT .END INSTRUCTION WIDTH e FIELD HH WIMH 8 DEFAULT 255 Gregory E. Cholmondeley Define an &bit instruction. END.INSTRUCTION Laboratory for Laser Energetics University of Rochester FIELD A WIDTH 4 DEFAULT 3 Figure (1) : Sample Instructon Definitioo Define field A as the 4 most signifi- Abstract cant bit poritim in the imtruction, having a default value of 3. instruct ion The FORTH programming language can I be used to implement a very small and FIELD B WIDTH 2 I umful micro assembler. Functions ranging Define field B as the next 2 bit pmi- 1 from automatic field alignment to user tions, having a default value of 0. M-->BB-+HH fields AA, BB and HH definable macros can be written and I altered easily, permitting a flexible and FIELD C WIDTH 2 DEFAULT 1 I easy to use microcoding technique. This Define field C as the 2 hatdgnifi- *---->*field BB has 2 alternate paper also serves to illustrate several of cant bits, having a default value of 1. I I formats the many programming features fwnd in I I FORTH. ENDJNSTRUCTION I I Close the instruction definition. CC-->DD GG format 1 contains fields CC Introductim 1 ad DDformat 2 contains field The resulting instruction word wwld I SG Computer central processors often appear in the following form: contain an iternal data form called I field DD has 1 alternate "microcode." This code defines the :7 4:3 2:l 0: I format instruction set of the processor. The J A 1 BI CL I creation of this internal code is called EE-->FF fields EE and FF "mic rocoding." From this point m the field names A, 8, and C will be unique and may not be uaed Microcoding by hand is at best a tedi- to define other fields. Figure (2) : Structure of Figure (1) ous and wasteful undertaking where a sig- nificiant portion of a programmer's time is While the preceding example is rather spent aligning fields, formatting output trivial en instruction definition may The programming phese of the micro and correcting typographical errors. become quite complex. It is, for imtanca, awernbler is where the actual microcoding Understanding (let alone debugging) a possible to define multiple format8 for wtm place. An imtruction is created by microcode program is difficult due to the every field, with each of thew mtaining typing the name of a field followed by a lack of readability from a human point of multiple sub-fields. This is uaeful when it number or axprenim reprewntinq the view. Through the use of comments, auto- is deemed that fields should have different vmlue that that field ahould take. This is matic field positioning, labels and other meanings depending upon the context of continued for as many fields as needed in such tools, a good micro assembler should the rest of the imtruction word (vertical the instruction word. When the instruc- minimize the above problems making vams horizontal programming). %- tim ir complete a "$" (dollar rign) is typed microcoding a much more agreeable form fields are treated in the wme manner 88 and the computer readies itself for of programming. fields 80 that they too may haw multiple another word. At this point any undefined formats and nub-fields. This feature ir field8 an set to their default values, the There already are micro assemblers implemented aa a tree structure allowing inotruction and other related information written which handle these along with an unlimited nesting of fields, formats and is stored in memory, and the location other problems associated with micro- sub-fields. Figures (1) and (2) chwld counter is incremented. Figures (3) and coding, but most of them share one rather clarify this concept. (4) demonstrate a rimple microcoded pro- serious drawback: they are large pro- gnm which merely oets one field at a grams. The micro aaaembler preaente This part of the micro uaumbler hu time equal to a zem. here is bawd heavily upm the Signticsf error checking capabilitim which prevent micro assembler but requires only a few unintentimal overwriting of fields. For "blocks" of FORTH code. Thus it is pa- example, if field EE of figure (1) is filled, sible to have a micro aaaembler m a mall then fields BB, DD and CS (and of cwrae PROGRAH lEXAWLE WIDTH 32 home computer[ Such en assembler could could not be ured. Automatic field' EE) 512 be used as a deign tool as well as an defaulting uaes the wme mechartiam 80 ORG inexpensive and effective teaching aid. It that if field EE is the only field filled wwld allow even wide instructim words (udng the format from previous MOS the BB $ to be built in a simple to urn, high level example) then fields AA, CC, FF and HH 0 form. will be defaulted. cc 0 $ DD 0 $ urgc INSTRUCTION WIDTH 32 EL 0 $ FIELD M WIDTH 8 DEFAULT 255 no$ There are two main phases associated FIELD BB VIDTH 16 DEFAULT 65535 =O$ with this micro aaaembler: instruction FORMAT mO$ definition and actual programming. A FIELD CC WIDTH 4 DEFAULT 15 END. PROGRAn third phase will be implemented shortly to FIELD DD WIDTH 12 DEFAULT 4095 allow the user to explicitly md easily FORJIAT define output formats. The first of thaw FIEWEE WIDTH 10 DEFAULT 1023 phases to be explored is the instruction FIELD FF WIW 2 DEEAULT 3 definitim phase. This ia the time when FORtlAT. END the various instruction word formmb are FORUT. END

Page 126 FORTH OlMENSIONS lnl4 Another way to increase readability in ::30000011111111 1111111111111111 M urod 6 dofaultod BB HH the micro aowmbler is through the ure of .::1111100000000 1111111111111111 BB urod M 6 HH dofAu1t.d ..1111:100001111 1111111111111111 CC urod M, DD 6 HH dofaulted labelo. Thir famture ia only partially implemented at thin time but will work a8 .:illllllllloooo 0000000011111111 DD urod M, CC 6 HH dofAu1t.d .::1111111110000 0000001111111111 EE ured M, CC, FF 6 HH dofau1t.d follow#. Labela muU have unique names ..:1111111111111 1111110011111111 FF used U, CC, EE 6 HH defaulted and muat be Lclared via LABEL atate- ..11111100000000 0000000011111111 GG urod M 6 HH dofaulted mentr before they ara uwd. When a label .~illlllllllllll1111111100000000 HH urod M 6 88 dofaultad Ir found Immediately preceding a new inatruction word (or in other words; immediately following a "S") the current Figure (4) : Sample Output value of the location counter ( LC ) is While automatic field alignment ia in An example of thia microp in uw wwld be atord 08 the value of the label. Multiple :self a vast improvement over hmnd found in tho prognmmlng phew uid might labelr may be uwd to repnrent the name :3ding, then are a few other toola avall- look Ilke: llm of cob. When a label ir uwd inride a31e to the programmer which make an inrtruction definition after ita value 7icrocoding even eaaier. A ''(2' Cnoter a hu been mt, it will be treated M any :imment allowing anything up to md other variable. If the label ha8 not been Yluding a lt.)ll to be ignored. Typing ORC wt to a value (Lo., forward referencing) a aid a number or an expnrrion will aet the zero will be returned and a11 information .xatim counter ( LC ) to that value. necewrry to remlve the reference will be -vping SET atomd in memory for the aecond pars. NOTE2 LC In the preceding example in During the wcond par, the micro amem- TO bler will rhift the correct vaiueb) of the a variable, the "('I and 9" am requiwd .4 declare and initialize a variable, while for it8 proper execution. They do not Imbol(8) into the proper place(@)and then :.>ing add the rewlting number to the reat of the EQU Lnote a commmt in tha MICRO vocabuluy context. fhia a180 true word. Thin allow labels to be referenced WITH ia when building micrapr In the MICRO more than once in a single instruction. It -111 store a new value Into a previourly vocabulary commenta are delimited by also allow addition and rubtrsction of 2eclared variable. Thew variable8 return y." Md"?. other rum-label expramionr to labels be., :wir value when they are typed (aimilar to AA ( lLABEL + 2 ) or AA ( ILABEL - 1 3 constant in FORTH) and can be ursd in Being aimple colon definitions, micropr but not AA (1024 - lLABEL ) ). When this rxpressions at any time and in any phacu can do internal teating, looping and every- ir implemented another extended precision :' the micro assembler. thing elm offered in FORTH. Micropa can function ( E+ ) will be needed to perform expect parametera on the at& as well a8 the extended precirion addition. One of the most verratile toolr avail- numberr or exprerrionr from the input nle in this micro assembler ir the buffer via a function called =TI. for '.':CROP function. Microps are user- example: rfrnable functions designed to eliminate I :arge part of the repetitious program- HICROP ?GT (. ?GI -- tests if exprl is > exprZ .) -:ng associated with microcoding. For GET# > example there may be times when several IF M 0 BB 0 CC 0 ' .ids will always take on conrtent or ELSE HH ( Lc ) -elative values. Rather than cluttering THEN :--? program by having to a& all of these END. HICROP '.eids every time, a microp can be written The last major feature of the micro :J do this automatically. A program writ- assembler concerns output formatting. using well named microps can in turn This could be used like: :?n This has not been developed at all but will 33 quite a bit easier to read and under- consirt of a baaic inrtruction set for ::and than me which merely cuts the programmen to uae to define npecific '>elds. M 19 $ output formats (i.e., hex, insertion of ?GI 1024 $ special delimiting characters, etc.). The The definition of a microp requires a programmer will define a function (similar --tque name and a set of commands which to a microp or colon definition) for each -111 be executed whenever its name is type of output format. The executabfe :elled. Any FORTH programmer will soon Finally, micraps have macro capabilities cod0 field address of the current format- -talize that a microp definition ir nothing in that they can be mated md may even ting function is rtored along with the ::her than a colon definition, thus allow- create several lines of code in one call (as other instruction word information on the -q the full power of FORTH to be easily may be needed in a tort md branch, or first pas% On the second paas the format- jccessed directly from the micro amem- jump subrtitute routine). ting function will be executed to produce ::er[ An example of a simple microp that the derird result. It will be possible to sets a few fields to zero would be: change the current format function HICROP EX3 between instruction worh by using a Lc 100 > command of the form: IF EX1 J YICROP EX1 (. set fields CC, FF, Lc ?GT 1000 5 SET.FORPUT cc 0 and HH to 0 .) ELSE M 0 J FF 0 allowing multiple output formats within a CCOHHO$ single program. By installing different HHO TIEN END.!IICROP formats in currently existing ones, it will END. HICROP be pouible to view the code in punched cud format as well as a format suitable for blowing PROMS!

Page 127 FORTH OIMENSIONS III/4 w-np 1-b- 888888888888888888 BLOCR 160 88888888I8IlL&4L&O

The firrt problem that Iaddreooed war ( alsebraic notation 6EC 15-JUL-dI I how to align the field, in m instruction word definitim. For wordr that are or : GET: ( Cc,--l t 32 32 WORD NUHDER NOT t tet next inrut charlnum I fewer bitr wide the wlutim ir simple, IF R> R> SYAP >Ir >k THEM 8 ( if char then treat as '4' t merely do logical ohifting and ORing. Since 32 bit. is a rather rtrinpent limit on : (, CCOHPILEI ( I IMHEDIATE ( define (. as coaaent delialter t Cbword width, Ihave kept the rambaoic rtrategy but have defined a mt of func- tiw which can do logical operations upon extended precision words. The precirion (in terms of 16-bit words) is stored in a variable called PRECISION and ir wt at the PROGRAM WIDTH rtatement. Thee are the extended precirion functions which 888888888888888888 &LOCI 161 88888888888888t8ttt Ineeded: ( value and flirflor tvry 6EC 10-JUM-81 ) 0 VAR %TO ( flas ) TO 1 %TO ! i 1. EXT.PREC - This ir a defining . word that creater an extendsd : VAL ( returns Value Of Variable c not address 3 ) precirion variable which uaer the *.WILDS v DOES, %TO @ IF ! 0 %TO 1 ( store value J Bartholdi "TO concept" to atore ELSE p t rush value ) and fetch extended precirion THEN i numbem. EXT.PREC expectr the : FLIPFLOP ( returns 011 and stores 110 ) desired precirion of the new cDUxLDs 0 1 ( Cw--(.>l initia1i:e F.F I variable on the rtack. DOES> XTO e IF 1 0 %TO I I C--\>I set F.F. ELSE DUP e DUP NOT ROT I ( c~--<1~0,~1ti1, F.F. t 2. LFILL - E.FILL expectr a number THEN 8 and the precision of that number -- in terms of 16-bit wordr m the 88888l8888I888l888 BLOCR 162 88888888888888ll888 otack. It urer thir to fill in tho mcmt significant places with zeror ( variable definitions 6EC 19-JUN-81 ! until the number has a precision o0 unlunL C;FiE.LD.CURADDR ( current address J ( current field ) equal to the current value of ( current format ) PRECISION. Notice that the O0 VkL INSTR ( current instruction uord ) value of PRECISION must be 0 VAL F,LENOTH ( field lenrth I I field rosition ) larger equal to the length of 0 VAL F.POS or 0 vnL LC ( location counter 1 tho given number. 0 VAL IMSTRYIDTM ( instruction uidth ) 6 VAL L.FIELD ( last tielo i 3. €.DROP Thir function an 0 VAL LeFORM ( last format I - drops 0 VLL L.1MSTR t last instruction ) extended precision number from o unL MEH ( current aeaoru addr for rrint routines I the top of the stack. 0 VAL NEW.YORD ( flas set at start of neu instr. uord I 0 VAL OFFSET ( offset of shift {used in ESL) 1 --. 4. EK - The ESL function perfarmr a logical ohift to the left m an 888888888888888888 BLOCK I63 8888888888888Llll88 extended precirion number. It ( variIable definitions - 2 BEC 19-JUN-81 1 expecto the extended preciaim o unL OVFLb ( overflou flar ) number and the number of ahiftr 0 VAL PAPkEEFSIOM ( addr of temp storage in extended orerations b 0 V(IL ( rrecision of vord in 16 bit units ) on the stack and return the 0 VAL 1ESl.FLAG 4 flat used in error rheckins and defaultins 1 dMbd number. 0 VAL TSHIFT ( interbedlate number Of shifts 0 VAL XDEF ( default rhase (0. use/l. set/?. initialize) ) 0 VAL LFLA6 ( value to store in flarc toll> > 5. EOR - Thir taker two extended 6 VAL XPRINTeFORHAT ( addr of outrut format code i precioion numben off of tho FLIPFL.OF FLPeFF ( field F.F. for error checkinn S defaUltlnS1 otack, logically OR0 them togeth- 0 XEO BROTHER ( brother of current field/foraat 1 G XEO PARENT ( rarent of C.FIELD ) er d returns the mmjiting 0 XEO SELF t C-FIELD ) number. 0 XEO UNCLE ( uncle of C.FIELD ) --, 6. EXOR - This executer an exclu- rive OR operation between two 888888888888888888 BLOCK 164 888888888888888I888 extended precision numberr. It expecto two extended prociaion ( extended rrecision functions 6EC 12-JUN-81 J numberr and returns the rerult. : EXT.PREC ( \rrmision>-<> builds an extended wecision t ) -it 0 .., O> ruts 0's in hish order.rlaces ) needed to implement forward referencing PREClSION SWAP ZDUP ;, IF DO 0 LOOP ELSE 2PkOF TMEN t of I&dr Thir function haalready been : EDROP ( ilou-order ,,. hiah-order>-O drors cxt.rrecision t ) mentioned and will be called E+. PRECISION o DO DROP Loor i -- >

128 FORTH DIMENSIONS IIIh When a field in assigned a value and is aligned, the following procer occurs. An 8888888888888888~8 BLOCK 165 8888888888~8888l888 extended precision number with a preci- ! cxtrnded wrc. functions - 2 GEC 12-JUN-81 sion equal to PRECISION is on the stack. I ESL clou-ord hish-ord O-shifts:-~lou-ord ... hirh,ord This is the value of the current line of shifts #-shifts to lrft {drops hiJh ov 1 shifts in ri's microcode. After the field-name is typed, o TO OUFLG HERE PRECISION 2 8 t DUF TO PLACE HEM DO 0 I I ? tLOOP ( crertr uorCs~rcc an extended precision number with a 0 PRECISION 1 - 21 DO I TO OFFSET DUP TO TSHIFT SWAP precision equal to the width of the fleld is ( for butr from hiih to lou do accepted. E.FILL is used this number BEGIN TSHIFT 16 )= on IF #-shift )= 16 to make it the same precision ar the OFFSET ? t TO OFFSET instruction word, ESL in ured to rhift It TSHIFT 16 - TO TSHIFT over the proper number of bitr, and EOR 1 TO OUFLG ( set ovrrflou flrr ELSE ( #-shift 16 < shift normrllv > is used to update the micro-instruction. DUF TSHIFT *'-L OFFSET HERE t This is repeated until a "$ is encountered DUP e ROT OR SUAP 1 which will clear the flags, set any default- --> ed fields, store the extended precision instruction word in memory and lerve an 8888888l8888888888 BLOCK 166 888888888888l88t888 extended precision number equal to zero on the stack (for the next micro- rxtrndrd rrrc. functions - 3 6EC 12-JUN-81 ) ! t i ns t ruc on). OFFSET 2 t HERE t DUP P ( hrndlrs #s that arr srlit ROT 16 TSHIFT - ->L OR SUAF 1 ( into ? bvtrr bu shift J The second main problem that I feced THEN OVFLG MOT 0 TO OUFLG END dealt with how to handle multiple for- -'t OOP DROP mats. I implemented a tree rtructun PdHERE PO I P 2 +LOOP i ( frtch # from trmr uorksrrcr ) where the instruction is the root with the ?PRECISION ( Ct of bitsJ--t# of 16-bit uordsl J list of fields as its children. Each field o 17 MIMOD DROP swDROP it i ?as a list of formats or a zero for its zhildren. Every format has a list of field8 EOET ( C..rddr Of v8rirblr:.--'.cxt.?r..1,] J as its children and the cycle continues. DUP PRECISION 1 - 28 t DO I e -2 tLooP t Each node in this tree has pointers to its -- parent, "oldest" child, and next youngest 3rother. Each node also contains a flag 888t8888888888888S BLOCL 167 8888888t8t888t88888 denoting whether it is a valid field or not, cxtcndrd rrec. functions f a value corresponding to its starting pmi- - 4 GEC 15-JUN-81 : €OR ( ,rxt.rre.l rxt.rrr.# -.rxt.rre.#> trk 2 rxt.Fre bs 1 :ion in the instruction word, its field HERE PRECISION t 1 - DUP TO PLACE HERE DO o I 1 2 tioof length and its default value. Thus when a 1 PRECISION DO 'ieid IS accessed a test is executed to I PRECISION t PRECISION I - t FICk PRECISION 1 t PICh OR -1 tLOOf' determine whether it is valid or not. This HERE PLACE DO I I -2 tLOOP ,s accomplished by traversing up the tree PRECISION 21 0 ti0 DROP LOOP and checking the validity flag. If the first PIACE HERE DO I P 2 tLOOP i set flag is found in a field, then the : ECOfi ( C~ext.b,--..NOT ext.# 3 one comrlemrnts ext.Pre.t ) :rogrammer is trying to overwrite another HERE PPECISIGN 28 t 1- DUP TO PLACE HERE ormat in the same field. If no flag is set SUhP DO I 1 -2 tLOOF and this is not a new line of microcode, PLACE HERE DO I e cofi tLooP i :hen this field is not defined in the same : ERWOR.FUNCT .' ERROR CODE: CR i -_. .istruction word as the previous one!s) and 8888888888t8888888l another error condition is found If, how- 888888888888888888 BLOCh 168 ever, the field is determined to be valid, I rxtended prec. functions - 5 GEC I,5,-JUk-81 1 then the flag bit of that fieid will be set ,:,- '0 HERE i ' 2 along with the flag of its parent, and its PLACE DO o tL0OP 3arent, continuing up to the root. When a - t Pxcm "$" is encountered, the tree is traversed in tL0OP :be same manner but from the root down and all flags are reset. At the same time any unused brothers of the lowest level 'ields used will be assigned their default -- . values. St88888888888~8~88BLOCk 169 888888888888888S888 :r\lSTRUCTION FORMAT FIELD ! offsets in field structurr GEC 3-JUL-El ) . OFF.UAL INSTRUCTION FORMAT t XTO e IF I o XTO 1 ELSE DUP o\> IF e THEN THEN i : ?PARENT 0 OFF.UAL i : ?BROTHER 2 OFFeUAL i 2arent I 0 I 1 field I : ?FLAG 4 OFF.UAL 9 : ?CHILD 6 OFFaVAL 9 format : ?ANCESTOR ?PARENT WAkENT i ircther I 0 I I I : ~1NSTRUCTION.WIDTH 8 0FF.UAL i ( INSTRUCTION i sed Flag I 0/1 I I 0/1 I : ?FIELD.START C.FIELD 8 OFF.UAL i ( FIELD ) :-.:ld \ field I I field I : *FIELD.LENGTH C.FIELD 10 0FF.UAL i ( FIELD ) '.eld Starting Position : TDEFAULT'C.FIELD 12 t i ( FIELD ) : NEW.SON 'leld Length DUP ?CHILD DUF ROT AND .eiault Value IF o sunP BEGIN DUP ?BROTHER ROT DROP DUP NOT END DROP 3r ELSE DROP 0 Zeros THEN TO BROTHER i -- >

FORTH DIMENSIONS I1114 Page 129 With the rtructurw defined, the teak ttttaattttttttttta BLOCK 170 ttaatttataartaaaata of creating a program comes to lipht. An headers of fields I formats GEC 3-JUL-81 ) explanatim has already been given der- ?NAME DUP 0.:. IF CFA6TNAME ELSE UROP THEN i cribing how the words are constructed. : IGNORE 32 WORD DROP I The following diagram should help clarify : HEADER ( creates 1st 4 fields in FIELD and FORMAT ) how a "program" is actually stored in 0 TO UNCLE HERE TO SELF memory in ib first pau form. BROTHER 0.;. IF SELF BROTHER TO *BROTHER LSE SELF PARENT TO ?CHILD TO Choral First Pam Stnrtus for 5 HEN SELF BROTHER I v 0 v 0 9 i rsrrnt/brother/flal/child 1 Mi-pmgrrmr PARENT 0 : F0RNAT.HEADER ( defines FORMAT relatives L executes HEAbER ) ...... III Forth INSTALL LeFIELD IN UNCLE INSTALL CqFIELD IN PARENT Name INSTALL LSFORI IN BROTHER INSTALL CeFORk IN SELF Forth Ill*--I ----- CrFIELD NEWeSON HEADER 0 TO CeFIELD P --, Header...... I- Link ...... I- '--I----- Description ttttattattttttaatt BLOCR 171 tttattatttttatttaaa *--I Instruction Word Width Program I------( instruction and format defs. GEC 3-JUL-61 1 Header...... 101 ...... I- *--I-----Address of Label : INSTRUCTION ( INSTRUCTION

Each program has a unique name which defines a FORTH header. When this name : FIELDeHEADER is typed, the program is listed in a basic INSTALL LOCORN IN UNCLE INSTALL C-FORM IN PARENT binary and hex form along with the format INSTALL L.FIELD IN BROTHER INSTALL C.FIELD IN SELF SELF *:I IF SELF ?PARENT ELSE C.FORM THEN address, LC, and any unresolved Iabelr DUP 18 PARENT NEYeSON HEADER P --. One of the primary objectives of this micro assembler is to make microcoding easier by making it mom readable, and atttttatttattttttt BLOCK 173 tattaiatatttttaatta there are quite a few places where the ! error checkinr for used fields GEC J-JUL-al ) reverse polish notation found in FORTH ER.CYECk ( check to see if field 1s rerbittel J 0 TO FLDeFF CeFIELD does not appear quite as nice as an infix or BEGIN prefix form. Hence, I have written a few DUP ?FLAG TO TEST.FLAG short functions to allow FORTH functimr FLDaFF DROP to accept numbers and expressiw from 'PARENT I so to parent 1 DUP NOT TEST.FLAG OR t if flar found or root reached) the input bufter as well as from the para- END DROP meter stack. TEST.FLAG FLDaFF AND IF 4 ERROR.FUNCT RESTART f field defined tuice ) This method uees the return stack vie a ELSE TESTeFLAG NOT iLF5, ERROR.FUNCT RESTART ( not rrorer instruction ) function GET# which accepts input from the input buffer. If the input is a number THEN-0 TO TEST.FLAG i -- \ GET# places it on the stack and return If the input is not a number than GET# assumes that the programmer typed a left parentheses meaning that there is n expression or a variable in the input : D0,DEFAULT buffer. if this is the case then GET# will 'FIELDeLENGTH ?PRECISION XDEF SEL swap the last two values on the return << 2 ==' DROP 0 DO 0 9 LOOP 0 TO XDEF 0 )> stack and return. When a right parenthe- << 1 ==> DROP E-FILL ?DEFAULT ?FIELD.LENGTH ses is found, the top two valuer of the ?PRECISION OVER i 21 SWAP DO I 1 2 tLOOP 0 TO XDEF 0 22 return stack are again mapped md the <\ 0 ==) DROP ?DEFAULT SWAP 1 - 3 OVER t system is back to normal. Thia is oimpla DO I P -2 tLOOP 'FIELD.LENGTH 'PRECIS #ION and fast, although it has no method of €.FILL ?FIELD.START ESL EOW 0 ' NDSEL i checking whether a set of parentbs is : TO.Dh 1 TO XDEF i : INIT.DEF 2 TO XDEF i properly clored. However, a vuiable : DEFAULT could be used which would be incrementad ~ GET6 10-DEF DO.DEFAULT i -- when a ''(" is encountered and decwment- ed when a ")'I is found. This would catch myerrors involving too many closing pu- tttll$ltlt&ttStttS KOCh 175 ttl~tttt<#lltltlS t?theses. A "1" function cwld be written ( field structure ) 4ich would behave in the same manner as GEC 3-JUL-81 :?e UCI LISP function of the same name. : FIELD I FIELIl 'nrre YIDTH width; ) :! would use the variable mentioned above

niw C.LEYGTMI__.._... <= :3 close all open parentheses for a suc- --. . IF FIE D.HEADER cessful evaluation of the expremion. F,LbNGTH OVEC; - TO F.LENGTH F-POS OVER - DUP 10 FSPOC, GET# and its related algebraic func- ( field start/f:rld lrnfth ) :20ns have rorne interesting features in :Tat there is no hirrarchial ordering of THEN 'rctions (i.e., 2 + 3 5 = 25 while 5 3 + DOES:, TO C.FIELD 0 TO FRvCHECL 1 : = 171, however, expresrions enclmed in NEY~YORDIF NEUeYORO ELSE THEN SET*F?hGS GET# TFIELD.LENGTH TPFECISION E.FILL --> xrentheses will be solved before others ?FIElD*START ESL EOR 1 .c., 2 + (3 5) = 17). The entire code for :-IS is only a few lines long and is aa '?:!ow% FORTH-like, it does result in much cleaner code. I adapted the concept in XTlr om place to build a flip-flop function. 32 WORD NCXBER pets number This function creates a data type which WT' IF R> R> SNAP >R >R soap if not s number alternately returns and ones when- TKES ; zeros ever it is called and makes use of the "TO conceDt" to allow itself to be initialized to ,::ABCLARY ALGEBRAIC ALGEBRAIC DEFINITIONS redefine functions eithe; state. The micro assembler also makes use of multiple vocabularies to allow the same function to have different meanings in different contexts. While this - GET0 + ; : - GET# - ; - GET// * ; : 1 GET# 1 ; re-swap return stack is not absolutely essential for the assem- R> R> SYAP >R >R ; swap return stack bier to run, it again makes the code ); cleaner and easier to use. :::3DEFINITIONS carlurion The reeaon why I have chosen to write A typical usage of this function could this micro assembler in FORTH is simpli- 1e: city. As 1 mentioned earlier, this "pro- gram" is based largely upon a very lengthy micro assembler written by Signetics and yet the FORTH code is only a few pages long. The time spent programming was ." equally short. It took roughly half of my IL time at work from around June 10 through July 15 to complete the micro assembler to this point (although I have occasionally --rrent I 1 Parameter I Return gone back to add or change a feature or --?ction 1 Command I Stack I Stack two). Two of the features. that I did ------_------...... change, labels and forward referencing main I 3 1 3 1 input a 3 through the first pass, brought up another !*) 1 (+I I 3 I main call function (+I quality of FORTH its modular nature. SET11 I GET11 I 3 I main (+I call function GET# These are rather major additions and yet I ( I 3 I (+) main suap return stack ttmy only required one new "block" of main I 4 I 3 4 1 (+) return and input a 4 code, a few minor changes in the old code '+I I {+I I 3 4 I (+) main call (+) again md took only a few hours to implement[ SET11 I 5 1 3 4 5 I (+) main (+I input a 5 a+) I + I 3 9 I (+) main return and add Once the forward referencing is com- nain I I 3 9 I (+I return to main pleted and the output formatting is imple- 1 I 3 9 I (+I main call function ) mented, this code will be a micro assem- I I 3 9 I main (+) swap return stack bler by iteelf as well as a kernel for more I+) I + I 12 I main return and add extended versions. An example of an aain I . I - I return and print extended feature is the compilation of a symbol table at the end of a program. A further extension would involve tying this There are a few general concepts symbol table to other symbol tables to dich are used throughout this micro allow external references. Through the zssernbler, one of which is the "TO Con- UIC of external symbol tables the micro- zept" (see Joe Sawicki's paper entitled code could be maintained in the first pas Zottrnired Data Structures for Hardware format so that the external references Ixtrol). This concept allows the UK of could be resolved reveral times for labels sariables without the programmer having with differing values. This cwld result in :1 deal directly with the address. While a modular microcoding technique. :-IS may be thouqht of as bainq a bit un- Anotbr extension could be a FORTH pro-

=ORTH DIMENSIONSm14 Page 1 aaaaa:aaaaaaaaaa:a BLOCh 176 aaaaataaaa:iaaaaaaa gram which would be used, in much the same manner as the micro assembler, and ( end.instr L find root I brother 6EC 11-JUN-81 ) rimilar to Hardware Description Lang- : END-INSTRUCTION ( checks for any u?defined fields ) uages, to describe a simulator for the BEGIN FORNAT.END C-FIELD ?ANCESTOR NOT END 9 microcode. These two programs would : ROOT o sutw ( finds instruction constitute a powerful yet inexpensive BEGIN ( Ca sclfl--Cselt rarentl ) teaching aid as well as an effective design DUP ?PARENT ROT DROP DUP NOT tool. Programmers and students wwld not END DROP i need to waste their time punching cards or : FIND.BROTHER 0 SUAP ( finds brother uith flar set 1 blowing PROM3 in order to discover the REGIN in PUP 7RROTHER ROT DROP ( La selfl--Cself brother1 i errors their coder A dozen other "nice" OVER 'FLAG OVER NOT OR ( )la¶ Oh not brother ) features can be imagined (i.e., prohibiting END DROY DUF forward referencing to allow interactive ?FLAG NOT IF DROF 0 THEN 4 ( [brother OR 0 1 ) -- microcoding, or the development of intrin- sic microps to define commercial chips, taaaaa:aaaaaaaaaat DLoch 177 tttaaaataaa:aaaaata etc.), but the point is that they could all ( default - 2 6EC 8-JUL-81 i be bared around the small "kernel" micro assembler presented here.

AcJtnowl~msnta CR 7NAM .' DEFAULTED ' [I 0 OVER TO 7FLAb i flar set-reset to 3 ) I would like to thank Lawrence Forrley BOP ?CHILD FIND,bROTHEL DUP ( find sub-format used 1 IF 0 OVER TO 'FLAG t reset forrat flrr to 0 ) for the time and effort he expended help- ( CheCC sub-iiclcl:. 1 ing to direct and complete this project. I -JP 7BROTH5R ( n? format used-fino brother) LD CR 7Nk)tE USED would also like to extend thanks to Dr. Ur NOT . Charles Merriam for his useful comment8 DP 'ANCESTOR DUP *BROTHER OVER NOT OVER OK' END and suggestions. sunP NOT END DROP CR i -- This work was partially wpported by the following sponsors Exxon Research a:aaaat::taaaat:ta BLoch 178 ta:atataaaa:aaraaai 8nd Engineering Company, General Elec- f micro-assemhlcr: forward ref. 6EC 17-JUL-81 ) tric Company, New York State Energy : LABEL- .__ ( LABEL ';~Jw: ) Rerearch and Development Authority, *< BU I L DS 0 v 0 I ( def.fla9 / Val 1 Northeast Utilities, The Standard Oil DOES NEU.YOR[r , Company (Ohio), the University of IF DUP !? fF , Label rrcviouslr defined' CR RESTART THEN Rochester, Empire State Electric Energy 1 OVER ( set flae ) 't LC sunP 1 ( set value ) Research Corporation, the Center for ELSE DUF P Naval Analysis, under grant number CNA IF 1t e SUB M0016-76-C-0001 and ths US. ELSE 7FIELD.START SYAP I t 0 Department of Energy inertial furion THEN THEN i program under contract number DE-ACDO- 8ODP4012Q.

G.E. Cholmondeley is currently mdor- an BLocti 179 graduate student in the department of aaaaaaaaaaaaaaaaaa ~aaaaaaaaaaaaaaaaii Electrical Engineering at the University of ( end of uord I orisin 6EC 11-JUN-81 ) Rochester. His interests lie in computer :s ( ends uord in ~rolrammode ) software and hardware design. C.FIELD ROOT IF DEFAULT' THEN 0, f end of labels ) XPRINT.FORNAT v LC DUP r 1t TO LC 1. Signeticr Micro Asaembler Reference PRECISION 0 DO )UP B. t LOOP CR Manual 0 1 €.FILL 1 TO NEY.YORD i : ORG GET: TO LC i HELP WANTED

FORM bftwra l3gineer

Program, edit and maintain files for ttttttttttaattttaa BLOCK 180 a::aaaaaaaaaaaaaaaa 8080. Ability to troubleshoot the ! rrintinr routine GEC 18-JUN-81 ) rof tw are-hardware interface. U+ZERO DUP 40961 U.= IF OT ELSE DUP 2561 U- IF 11 Cell: ELSE DUP 161 U,= IF 21 ELSE 31 THEN THEN THEN Wendy Palmer DUY-IF QUP 01 UO 01 11 U.R LOOP THEN 1-800-225-4060 47 sunP - U.R Instrumentation Laboratory, Inc. Analytical Instrument Divirian Jonapin Road Wilmington, MA 01887

132 FORTHDIMENSIONS inio tllBttbttttBSttBtl BLOCL 181 tttBBBtlktlBB8tBBBB ?au!miYNmS ' rrintins routines - 2 GEC 16-JUN-81 ) FORTH-Ebed Savvy Lob hr Talk to Computer : (PRINT ( 6ext.Pre.8.rddrz-0 rrint ext.Pre.4 in binrru 1 hex ) DUP ~KE$ISI~N27 8 t SUM ?PUP DO I I 8. 21 tLOOP . . DO I e U.ZERO 21 tLoop i FORTH, hc. Is working with ita parent company, Tschnology Industrim, Inc. of Santa Clua, Cdlfomia, to develop a new wftwue package for the Apple Il, using a ZBO P~COM~.With it, the Apple will offa the kind of crawl and efficient man- computer interface that until now, exirted I Printins routines - 3 GEL 16-JUN-81 ) : l+PASS*PRIWT only in movie8 like 2001 and Star Wara. DUF T0,kEH 0 1 AND IF ERROR - PR GRAM LEN TH 0 ' CR ELS~io BASE ! c! BEGIN n@n e IF BFGIN Tha project callr for Savvy-the trade I LABEL ' ' HEM DUP Y CFA TNAHE CR 2t TO MEH name for Excdibur Technology Corpaa- SHIFTEII~ ' MEN DUP CR CR 2t DUP 10 MEH R NOT cun.' I . tiarb Adaptive Pattern Recopnition Pro- THEY~R;t TO HEM cnsor-ta be wed u e uniqw lnguage a' FORHATi kEk DUP C CR 2t TO MEk interpreter. Savvy permite a user to com- ' It * MEH DUP e . CR zt 70 HEM municate with a computer in the user% AEk 8YRINi CR HEk PRECISION ?a t 10 hEH Mtiw language normal prarsology--no LR Cli-CR HEk @ 1 = END CR 101 bASE 1 and THEN r -- 1 spacial language and formm are needed. *ific.lly, savvy: ItltttttlttttlllBl BLOC& 183 BBBBtBtttllBBBtBttt o Recognirm written wordr strung ! Profraa statement GEC 16-JUN-81 J together In idiomatic phrares. : PROGRAH (Future venion will understand BVILDS !GNORE GET8 DUP v ?PRECISION TO PRECISION 0 P spoken words nd respond to 1 TO NEU,YORII Spanish command m well M 0 1 €.FILL DOES DUP @ 'PRECISION TO PRECISION 4 t 1.PASS.PRINT 4 --;. English Other Imqueger will follow.) ~llllltttllltBtttt BLOCK 184 ~tBBl~lStBBBtBlBBBt o Trw\rlatm there imprecise ! end rroaram 1 Hicrop combmdr GEC 17-JUN-81 ) patterm into procine computer . E!4b.PROGRNI. CIlROF 1 I f comm.nb. ; NICROP CCOHPILEI : i Savvy% unique interactive approach to : END.HICROP CCOHPILEI i I IMMEDIATE dealing with computera in an important development fa the 80s. The powerful : SET i defines 3 variable data ture ) combination of FORTH and Savvy will be HJlLBS i IGMORE GET# SET .vrr.name? !O iexrrerrion> ) oignificant in realizing the ryrtem't, full DOES e v ( tvar,nrme,. returns value ) potential mnd demonstrating the power of : EOU ( i EOU 'var.nrmep. UI!H FORTH. A special development team h.8 1" SUAP 1 t IGNORE GET8 beon formed for thin project, including Art IICRO DEFINITIONS IS G?~v~M,Chuck More, Dean Sendenon, md mother programmer who ha8 not been idantif ied.

NO ROOM FOR THE ORDER FORM THIS TIME! ORDER - Proceedings 1981 Rochester FORTH Standards Conference. Send check or MO to FIG in US funds on US bank, $25.00 US, $35.00 Foreign.

h TRAVEL THERE 8 RESORT X

YpF..*%F ...... ,...... :...:...... *..'. ....,.,...... ,...., - -3- 4.lr;

FORTH DIMENSIONS III/ 4 Page 133 FORTH UlmEflSlOllS

FORTH INTlRlST QROUP Volume Ill P.O. Box 1 lo5 Number 5 San Cador, CA 04070 Price: $2.54

IflSlUE

FurrctkMl Programming 8nd Forth 137 H8Wt?y GIBSS Forth and Artificial Lingulstks 138 Raymond Weisling 140 Technotes A Forth A8semMer for The 6!302 143 William F. Ragsdale A Technical Tutdd: Table Lookup Exampies 151 Henry Laxen The Game of Reverse 152 M. Burton The 31 Gsme 154 Tony Lewis Simulated Tektronks 4010 Graphics with Forth 156 Timothy Huang A Video Version of Master Mind 158 David Butler Transfer of Forth Screens by Modem 162 Guy T. Grotke EDrroRr COLulrH

FORTH UlNEflSlOra 1981 is behind us and as I look back, I am pleased to we how much has been accomplished for FORTH, FIG and FORTH DIMENSIONS.

Publirrhsd by Forth Interest Crag I really eppreciete all the help and support I have received from our readen. I have not dons everything right and some of Volume III No. 5 J.nuuy/Flrwy 1982 the beat help hm been your disagreement. Intelligent, construc- tive criticism is a8 welcome as earned praise. Rlblisher Roy C. MULm Editor c. J. stmet 1982 will be a year of continued growth. You CM look forward to continuing responsiveness. It is my plan to contact Editorial Review Board every FIG chapter by telephone at least quarterly to get feedback and encourage reader contributiau. Bill Ragrdale Dave Boulton FORTH DIMENSIONS will also be awarding AUTHOR’S Kim Harris CERTIFICATES for outstanding articles that contribute to the John James growth and understanding of the language. While we are not yet Dave Kilbridge In a pooition to give you carh for your contributions, we at least Henry Laxan will give you credit. George Maverick Bob Smith Starting in this imw will be a policy of putting in tutorial John hmgamer uticler designed to help our entry level readers. This, however, will not be done at the experwe of our more seasoned FIGGERS FORTH DIMENSIONS solicits editorial materlai, cowwnmb who will find an expanded bane of challenging articler and and letters. No responsibility is uumed for .cwrcrcy of matwid p9licatim. submitted. ALL MATERIAL PUBLISHED BY THE FORTH INTEREST GROUP IS IN THE PUBLIC DOMAIN. Information In In closing, I want to say that the writer’s kits have finally FORTH DIMENSIONS may be mpmduced with credit given to tho coma off the presses and I will be glad to send one to anyone who author and the Forth Interest Crwp. wants to contribute. Please send in applications and utilities, philomphy, questions and problems -- in the final analysis, Subscription to FORTH DIMENSIONS is frao with mMb.rrhip FORTH DIMENSIONS is what you make it. in the Forth Interest Grorp at $15.00 per year ($27.00 foreign air). For membership, change of addms and/or to ubmk material, the address ir: C. J. Street Forth Intereu Grwp P.O. Box 1105 Sen Carlos. CA 94070 RmLElim5cu-w

1981 has been a great year for FORTH, the FORTH Interest Cmup and for me, personally. FORTH has spread around the world and is being used on thousands of computer and microprocessor-based products. It is being taught extensively in ochools, companies and by FORTH programmen. FIG has just FORTH WM created by Mr. Charles H. Moors in 1969 at the completed its most successful national convention with almost National Radio Astronomy Observatory, Ch.rlotteavllie, VA. It 500 attendees, over 20 exhibitors and multiple sessions. (Thanks w8m created out of dissatisfaction with available progmmmltq to Bob Reiling, Conference Chairman and Gary Feterbach, tools, especially for obwrvatory automation. Program Chairman.) The FORML conference was well attended md the Proceedings are now available--see order form. Mr. Moore and several arrociates formed FORTH, Inc. in 1973 fo the purpose of licensing and apport of the FORTH Opnrtiq My deepest thanks to the FORTH community for “THE System and Programming Language, and to wpply appllclltim FIGGY”, Man of Year Award. It was a fantastic thrill and a programming to meet customers’ unique requiremanta. rurprire. 1 stand in good company.

The Forth Interest Grorp is centered in Northem Cmlifdm. Our membership is over 2,400 worldwide. It w8m formed in 1978 Roy C. Martens by FORTH programmen to encourage use of the by the interchange of ideas through seminars md publicatiar.

pese 1% FORTH DIMENSIONS IIIl5 tioru of volunteers aervlnq without Him- N"ALpROQRAMlr0JcAH) functlm udng a set of functional bumment. The FORTH DIMENSIONS FORTH forms that combine them- editorlal staff aupporb FIG afforts to tunction, to form new ones. keep FORTH intact and rasiat tho temp- Harvey Clam tation to obtain mere popularity and in Lhe Univanlty of Swth Florida - The moat fundamental functional process, fail in their misalon to pnwlde College of Engineering form is called compwition. If the and wort the finest roftwm concapb Department of Computer Science comporition operator is denoted by and tools available today. Thir ha8 not Tampa, FL 33620 0, then in Backus' notation "fog" Is been an easy task (and all too oftan, a the function where g is fint applied thankless one) but It is hoped that If The dlstinpuirhd computer rcimtist, and then f. others will least try to understand, the John Backua, in his 1977 Turing Award efforb and contribution of thew volun- lecture (1) describes the shortcomings of - The functions incorporate no data teers will continue to benefit us aIl.--ed. conventional programming languages and and do not name their conventiw wggests a new Wproach to programming nor substitution rulm. in a atyla dercribad as functional pro- 3ear Fig: gramming (FP). We will wmmarize the - A function is hierarchicalj i.e., built faulb that Backus finda in conventional from simpler functions. Congratulations to all the people who Imguages, brlafly dercribe the functional produce FORTH DIMENSIONS on Its qual- programming style, and lastly show that Backus point8 out that, TP (Functional ity and improvement. Pleare rend ma a FORTH mmts the apirit of this style of Programming) systems are 10 minimal that writer's kit 80 I cm make soma of my 8P- programming. some readen may find it difficult to view plications presentable for publication. them as programming languages." We Conventional Langue9es have a set of predefined functions in a Bob Royce library (dictionary) and may define new Box 57 Michiana An mderiying problem of conventional functions in terms of there predefined New Buffalo, MI 49117 pmqramming languages is that they tend functions. to be high level descriptim of the Von Your kit is on the way! Anyone elm? Nwmam computer. The assignment Functional forms are mstrucb do- statement is ths principal construct of noting functions which take functions as --ed. there languages. A program becomes a parameters. For example, the mtruct aeries of these asrrignment statements, "if-elm-then", and the construct "do each of which requires the modification of while" are functional forms. As indicated 3ear Fig: a single cell. We may think of the Von above, compodtion is aim a functional Neumam computer aa a set of storage form. Glen Haydon's nice article in FORTH cells, e sparate pmewor, and a channel YMENSIONS llI/2, page 47 talks about an connecting the two. If assignment state- FORTH of course has predefined con- algorithm he would like to have to ments imitate the store operation, then strucb which serve as the functional getermine the Julian day. With the branch statements imitate jump and test forms of FP systems. In ftxt, FORTH 3ackground that FORTH has in astronomy, while variables imitate storage celir The provides fecilitiea for adding func- :'TI sure there must be several, but this is high level languages provide sophisticated tional forma. An example would be a :7e nicest I know. It comes from the U. S. cmtructs to directly model the under- "case" construct to provide a more flex- Uaval Observatory via an article in the lying Von Neumam design. Conventional ible and clear decirim structure than that 4strophysical Journal Supplement Series, languages in the "word at a time" flow of a set of nestad "if-elm-then"'s. The b'01. 41 No. 3 NOv. 1979 pp 391-2. deecribed above require large data trans- capability of language to add new func- fen through this small channel connecting tional forms is not inherent in FP 3 ( JULIAN DATE main storage end the CPU. Backus calls systems. Reckus Qfines a language with : : JD >R SWAP this the Vm Neumann bottleneck. It is this capability a8 a formal functional pro- Z DUP 9 + 12 / R + 7 + 4 I MINUS not merely a physical bottleneck but, gramming (FFP) Isnguage. 3 OVER 9 - 7 / R + 100 / 1+ 3 *4 I- more importantly, it is a bottleneck to our i SWAP2759+/+ : thinking about computer languages. i + S-> D 1.721029 D+ Backus refen to it as an "intellectual An Example of Functional Proqramminq: 6 367 R> M* D+ ; bottleneck." He characterizes conven- The Factorial Function tional languages as both fat and weak sin- increams in the size and complexity An example of a program written in Cxample: 3 20 1982 JD D. of these languages have provided only the style of functional programming is aa 2445049 OK small increems in power. The typical pro- follows: gramming language requires a large fixed - If you are only concerned with dates set of constructs, is inflexible, and is not def 2:eqO-r I; o [id, !! wbll, where Jetween 3/1/1900 and 2/28/2000, then you extensible. The problem has been eased the notation 0, -, end [ 1 denote func- :an omit line 3 entirely. by approaches such as top-down design and tional forms. As we have awn, o denotes structured programming, but them have composition. The notation [f ,f I denotes On another subject, there is another not provided a solution to the underlying construction where [fl,f2] &Tied to an correction I noticed in the dump of the difficulty. Backus suggests that we need a argument x yields the aequence . The notation p * f;g applied to an xation OC32,80 1A should be 07 08. describer a new style which he calls func- argument x indicates that the value p(x) is tional programming. to be examined and if p(x) is true the ex- Peter 8. Dunckel pression yields f(x) elm it yielda dx). 52 Seventh Avenue Functional Pmmminq San Francisco, CA 94118 Other definitions uaeeo in the above This new atyle of programming has the are: ?eally slick! But the algorithm would be following characteristics: eq0 applied to x yields a value trw if x Tard to explain to most people.--ed. is 0, and yieida false otherwim. - A function (program) is constructed - from a mt of previously &fined 1 is the literal value 1 and yields the valw 1, regardler of the argument. larly among tho6e interested in innovative FILE ,CATALOG ,OUTWT . Since the approaches to computer architectures. It action of theae words is not known from is the multiplication operator, and is this authorb contention that FORTH is the word itself, but only from either prr- applied to a sequence yields x*y. a functional programming language which viws agreement of syntax, and since syn- closely resemble8 the approach wggested t.x sensitivity is not a common part of id is the identity operator. id applied by John Backus in his definitive paper. It FORTH (i.e., where a syntactical form to x yield8 x. will be interesting to aee if, 08 a rewlt of does not alter the way in which a word is this paper, lanquager which have attri- compiled), some degree of confusion can sub1 applied to m argument x yields x- butes similar to FORTH begin to appar in result. 1. academic circles. Furthermore, use of a word in only one Following the logic of the above func- - form rules out its use in another form, ex- tion we see that 2 applied to an argument The author has recently implemmted cept where it can reside in a different vo- n yields 1 if n is zero. If n is not zero we such an operator in FORTH. cabulary. Thus words like KEY , LOOP , generate nqn-1): BLANK , and TYPE (all FORTH verbs) ** Thc way that literals are handled can cannot function as nouns despite our Clearly then for @ this is a definition be viewed aa merely a question of im- temptation to use them that way for their of the factorial function. In FORTH (if plementation and efficiency. inherent (English language-based) clarity. the language were recunive) we would The same is true of some of the FORTH write: nouns like BLOCK , BUFFER , STATE , LIMIT , and BASE . .-. I1 References o= IF I+ Thus it is not possible to know the ELSE wp 1 - 2 1. J. Backus, “Can Programming be nature of the word from its name alone. THEN ; Liberated from the Van Mumann Would prefixes for verbs unnecessarily Style?” CACM, VoL 21, No. 8, August clutter the language? Would some preflx The syntaxes of the two examples are 1978, p. 613. or suffix to differentiate constants from different. The composition rule is applied variables be useful? Or should we leave it right to left in the fint example md left alone. The TO and FROM words help clar- right FORTH. The for dropping to in rules FORTHAN~AR~C~ALLDNCXIISTICS ify things but are not without problems, arguments are different. Construction is whereas : and @ are perfectly uniform in not used in FORTH.. That the rulm of Raymond Weisling function. Could a FORTH-like languaq~ syntax are different rhwld not be wr- Surakarta, hwa Tengah be built that allows the word-type to be- prising. The operations were defined by Repubilk Indonesia come part of the header, with the com- different people at different times. What piler choosing which form of the same- is most important is that on clom exami- There has not been much raid about named word to use based on its syntactical nation it is qparent that the atyle is en- the linguistic nature of computer position, like nouns (variables, constants, sentially the same. We have “words” langruger, principally because m few of arrays) being objects of TO and FROM ’ which denote ftmctiorm which are eval- them permit the dewlopmant of syntax Or does this push us back into the horrible uated following very similar rules. Str~Cture8that spparh humm language, me= of artificial syntax forms such as and hence foster lingulstic observation. algebraic notation (something we are per- FMiTH and its other thma&d-co& rela- haps proud to have departed from)? FORTH as a Lanqu.qe with Charac- tivm allow for such structure8 to be teristics of Furtional prwrSmmirq developed, principally haum of the I offer no solution per se. I only wish lopger body of word8 that .rim from its to point out a weakness that we all should Consider the FORTH (outer) inter- extwibillty and hierarchal function of be sensitive to when we assign names to preter. Literally all that the interpreter operatom. our words. Since FORTH is still in evo- recognizsr are functims; or to be precise, lutim, this is yet another aspect to con- words thet denote functions.* The fund- The point I wiah to addmr here is the sider when standards are defined. 1 wish amental combining form is composition syntactical limitatiom of the Irmguage we to disclaim any implication that I am a where in FORTH “tog” would be expressed are building, m artificial language based linguist of any sort other than Armchalr as g f. Functiorm need not incorporate in put on e human I.nquage (English) that Linguist. My sensitivity to this IS a result data, do not M~IWtheir arguments, and i8 widely lmd wherever tschmlopy has of living in a different culture where I am require no rubrtitutlm rule8 faparameter developed. &It them i8 a fundamental learning a human language that permits paaaing. There are no assiqwnent rtate- weaknam in this hglln which Ithink we far greater fluidity of structure due to the mmts and a new function is built from must be warn of, since it rww counter to inharent differences in nouns and verbs, simpler previously defined functions. It is the philosophy of FORTH. This is the syn- shown by a well codified system of pre- this style of programming in FORTH-so tax-dtivity of word fm, eopecially fixes and euffixes (morphemological dif- different then that of cmventimal Ianq- mum and verbs, which in Englirh are ferentiators). Those here who learn uages--that provides a power and flex- commonly 8petlled end ptunounced exactly English struggle with the structural dif- ibility that ha8 sparked the enthusiam of the name. We rely m the structure (word- ferentiation of all the parts of speech m many of us. order, partly) to distinquish Chore often while our morpheme differentiators are unrelated words. used for relatively useless things like verb conjugation, plurality, cases, and tenses Summary A few eramplar are in order. Comider (which are 011 essentially absent in this the possible function .of tha# FORTH part of the world). As technology spreads, This very rhort summary of the article words, both with respect to Lhair current m artificial language for man-machine by John Back- doer not begin to do use (some are nouw while othen are manipulatim (a two way street) should be justice to either the scope or depth of the verb), but also in their opposite hypothet- more universally based, at least with re- paper. ical use: BUFFER , FENCE , KEY , spect to linguistic modeling. As FORTH is LIMIT , LOOP , SPACE ,,TYPE , etc. already in use in many parts of the world, The “new“ type of programming has Othen which a programmer might wish to the channel for feedback is already open. generated considerable interest within the urn in developing opplicatims might computing commulity md most particu- include: OFFSET , SPAN ,INSERT ,

pe1% FORTH DIMENSIONS Inl5 FORTH STMARDS CORNER fIg-FORTH). Fht, wo bfl~Idlgitr Control and Data Acquisition". IEEE Robert L. Smith Journal of Quantum Electronics, VO~ QE-17 No. 9. NSW Ymk, NSW Vom Words on WORD V~~~:IEEE,September, 1981. A digit b MY one of a aet of AXIS In my last column, I discumed WORD. charrctira which-reprerent numeric vaiws 4. -----. Towards More Umble ! neglected to mention an important topic in the range from 0 to bare-1. For buer Syrtems: The LSRAD Raport. relating to the implementations of WORD greater than decimal 10, the set of chu- narae Swtems Reoulremenb. .. for-. which may influence tranqortabllity. actera is 0 ... 9 A 8 C ... whom the m- Appl?cati& Development). Chicago: 'rior to the 79-Standard, the execution of cendlng ASCII wqwnce Is udfor A end Share, Inc, 1979. NORD caused the string from the input above. Tedium to be moved to the dictimary 5. -----. IEEE Standard 585-1975. area, starting at HERE with the character Next., wo add to the original definition of New York: IEEE, 1975. count. Some imDlementerr would be number as followr? rempted to define the 79-Standard WORD 6. -----.1977 Laboratory for Larsr '?om the older WORD in a manner some- Energetic8 Annual Report. what like this: number Rocheater, W: Laboratory for Laser Energeticr, 1978. : WORD WORD HERE : A number ir reoremted in the inwt rtream a8 a word compwed of a mq&e 7. Moore, Charles. "Forth: A New 3ther implementen would probably put of one or more digits with a leading AX11 Way to Program Minicoimputen" :?e string elsewhere. Now suppme that minur (4 if the number is negative end a Journal of Astronomy and Astro- :% user wished to reverse the character trailing ASCII dot (.I if the valw ir to be phydcr Supplement E. New York: r:ring and emplace the modified string in considered double precision. AAAS, September, 1974. :T dictionary. The result from the for- -er implementer's system will not be a8 I recommend that implementera allow 8. Moore, Charles. "Forth, The Part expected, and will not result in "equiva- the above format, and that authom of Ten Yeam. and the Next Two ent execution" on the later implementer's tranrportable programs adhere to the Weeks". Forth Dimenrims. Vol. 16 !rstem. A similar but much less serious same format. In any cars, when the Stan- Sm Carl-, CA: Forth Interest :-oblem occurs with PAD. PAD is dards Team meets again, they should car- Group, 1979. -mventionaliy offset from HERE by a tainly clarify this area. ' red amount (68 bytes in fig-FORTH). 9. Rather. Elizabeth and Charles -?ere are at least three different soh- Under the Spreadinq FIG-TREE Moore. "The FORTH Approach to : ms: Operating Syrtems". ACM 76 Pro- As many of you are aware, there is a ceedings. New York: ACM, (1) Implementations which place the Computer Conference Tree (now nick- October, 1976. string at HERE could be con- named the FIG-TREE) which contaim sidered non-standard, and the items of interest to the FORTH com- 10. Ritchie, D. M. and K. Thompwn. problem goes away. munity. I would like to encourage all "The UNIX Time-sharing System". persons interested in the 73-Standard to The Bell System Technical Journal. (2) A clarification could be added to read and contribute to the branch of the Vol. 2 No. 6 Part 2. New Provi- the Standard indicating either that FIG-TREE called 79-STANDARD. All you dence, NJ: A.T. and T., July-August, the string will always be at HERE, need is a terminal (110 or 500 baud), a 1978. or that it may be at HERE. modem, and a telephone. The number is (415) 538-3580. See back issues of FORTH 11. Ritchie, D. M., et al. "The C Pro- (3) The problem could be forced upon DIMENSIONS for further information, or gramming Language'(. The Bell Sys- users by requiring that the char- just call up and send a few carriage tem Technical Journal. Vol 57 No. 6 acters from WORD be stored in a returns until the system reaponda. Part 2. New Providence, NT A.T. user-defined area prior to their and T., July-August, 1978. movement to the final destination.

-et Me Number the Ways Change: FDII1/4, pg. 118, para 3 to: The TO concept yas developed by In many areas the 79-Standard defines CORRECTMNS Or. Paul Rartholdi as an alternative nits and formats in painful detail. There to constants and variables. 5 an important area in which very little is Add to: FO IU/4, pg. 102 the following: said, namely the format for single and rouble precision numbers in the input REFERENCES ::ream. In the section "interpreter, text" : is clear that "numbers" are allowed in 1. Fomley, Lawrence P. The Beta :w irput text stream end may either be Laser Control Sydem. A talk given zwnpiled or placed on the parameter at the Laboratory for Larer Energet- r:ack. A definition of the format of a ics on March 9, 1977 and on July 16, umber should include at a minimum the 1977 at the Wilson Synchrotron, EDITOR'S NOTE: I stinction between double and single pre- Cornell University. :.ston, the sign of the number, and the set Peter Bmgtson of DATATRONIC AB in :' allowed characters from which the 2. Fomley, Lawrence P. "Forth Multi- Stockholm. Sweden sent us a CODV of the -umber is constructed. In keeping with tasking in URTH'. The Best of the September, 1981 edition of Eiectronics :Te spirit of the rest of the Standard, I Computer Faires Volume E. San And Computing Monthly. Feature article -odd like to propose a few definitions Francisco: 1979. was FORTH, "The Lanouaw of the Eiqht- -7ich should be fairly easy to implement iw" in which FIG is mentioned prominent- ad which appear to be compatible with 3. Boles, J. A., Pewel, D. and L. P. ly. More confirmation we are all riding lost current implementations (including Fomley. "Omega Automated Larer the crest!

?RTH DIMENSIONS Inl5 Page 159 TEcHWm BUGS A)*(D FIXES THAT MYSTOUOU6 fig-FoRTH If your used RAM is large in compar- AMNESIA ison to FORTH, you are likely to find most I have three questions about FORTH: of FORTH still available as a kind of crip- Many fig-FORTH users have probably pled monitor to help you find out what (3. I know of two CP/M FORTH, that have noticed the curious phenomenon I refer to went wrong without re-booting the system their own way of dealing with the BIOS as "amnesia" in their computers, and those (which destroys the damage). Further- and BOOS and as a result cannot read each who understand the method of the fig- more, since you now know the cause of other's screem. What I'm leading to is FORTH dictionary search, no doubt under- this illness, you can exploit it to your ad- this: CP/M Md fig-FORTH are both sup- stand it as well. It is an amusing, often vantage. Simply modify your boot-up posed to be machine independent systems perplexing, but usually useful property RAM-check routine so that it leaves a but cannot read each other's source code peculiar to fig-FORTH dictionaries. pattern in your unused RAM, such that no files. CP/M figgers ought to get together matter how it is viewed, it will appear to on this one. Because names in fig-FORTH may be an address somewhere in the middle of have variable length, the distance between a name-field, somewhere near the top of A. Differences between disk organizations the start of the name and the link to the your basic FORTH and utilities. You will are sector skewing and location. It is easy next name in the dictionary is also vari- now find, to your delight, that when you to add definitions to a FORTH which uses able. Because the width (number of char- "crash", you usually have your most BIOS ao it can read other organizations; it acters saved) is also allowed to be less powerful tools still at your disposal. is not possible the other direction. than the actual number of characters in the name, one cannot rely on the count to Users of FORTH, Inc. Micro-FORTH provide the addreas of the link-field, given are not likely to observe this phenomenon. 2. When selecting a new drive, you need the address of the name-field. This is why Because names are always exactly four to do a COLD start or you'll remain on the the fig-FORTH compiler automatically characters long, the link field does not last drive--this is only true if you are sets the most significant bit of the first have to be scanned for; instead, it is found accessing the same screen number. If you character and the last character in every by simple arithmetic. In order to re-enter leave an empty line between two defini- name. By this device, one can scan a the dictionary, one must land by chance on tions on the screen, a LOAD will stop name forward or backward by looking for the exact beginning of a name-field. loading at the empty line. Are these this bit. Much more likely than this, is that the FORTH conventionr, I haven't heard about search will enter a loop in which it goes yet or are they peculiar to my Timin In a dictionary search, the address in again to an address it has already visited, FORTH? the link-field is followed to the beginning and get caught forever. Remember that of the name-field of the previous word. If the addresses found are by no means ran- A. Both of these are bugti-demand fixes it is not a match to the key yw are look- dom. All you have to do is cover the most from Timin. ing for, we scan forward in memory until common ones. the most significant bit tells us we have found the link-field to the next word. Steve Munson 3. Somehod?), I've been leaving a lot of When a dictionary link is "broken" by clob- 8071 E. 7th Street, Ill& control characten behind when using the bering RAM, an erroneous address is fol- Buena Park, CA 90621 editor. They don't show up on a acreen lirt lowed, and the system is mid to "crash". but they sure ruin any attempt at loading the acreen. I am not wre if thir is a However, in fig-FORTH, the system common problem but I have enclowd a doea not always "die". In many cases, it is short routine to replace control charaters merely "wounded", displaying a strange with spaces for any- else who har this kind of amnesia in which it has no recol- TRANSDENT DEFINITIONS problem. lection of recent definitions, but remem- ben with clarity its "childhood". What These utiliites allow you to have tem- SCREEN 95 happens is this: the broken link sends the porary definition (such as compiler ( HUNT FOR CONTROL CHARACTERS) dictionary search off to a totally random words: CASE, OF ENDOF, ENDCASE, :HUNT ( SCREEN # --) part of memory (if you do not have 64K. it GODO, etc.) in the dictionary during BLOCK may address RAM where there are no compilation and then remove them after 1024 0 DO WP C@ OW 32 < board& Since it is not likely to find a compilation. The word TRANSIENT IF CR ."t" 64 + EMIT match at this address, it scans forward for moves the dictionary pointer to the 2' @ :" Dup u. ELSE DROP the most significant bit that marks the "transient area" which must be above the ENOIF I+ LOOP DROP ; end of the "name". The o& are that it end of the current dictionary. The tem- :FIXSCREEN ( SCREEN # --- ) will eventually find one, mistake the next porary definitions are then compiled into BLOCK two bytes for a link, and follow another this area. Next, the word PERMANENT 1024 0 00 W C@ 32 < IF wild addrew somewhare else. restores the dictionary to its normal OW, 32 SWAP C! EWF location. Now the application program is 1+ LOOP DROP ; Now, depending on how much of your compiled and the temporary definitions ( ACTUALLY WTAND FIXSCREEN memory is filled with dictionary, and de- are removed with the word DISWSE. ARE QUITE SIMILAR, HUNT JUST pending on what is in your unused RAM, DISPOSE will take a few seconds because SHOWS UP ANY GUILTY CHARACTERS the odds are not bad that after bouncing it goes through every link (including vo- AND FIXSCREEN REPLACES THEM) aimlessly arwnd for awhile, the search cabulary links) and patches them to bypass may land in the middle of a valid name. all words above the dictionary pointer. A. Don't know. May be an editor bug or One doea not expect a match to compare the way you are using it. If you add a line with the middle of a name, but the search NOTE: These words are written in with #P followed immediately by a car- then scans for the most significant bit, MicroMotion's FORTH-79 but some riage return in the fig editor, a null is fin& a valid link, and gets back into the non-79-Standard words are used. The introduced into the line which stw com- dictionary. What the "amnesia" has ac- non-Standard words have the fig- piling. (editor fix &odd be supplied) tually forgotten, then, is everything be- FORTH definitions. tween the broken link and the point where the search re-enters the dictionary. Philip Wasson

Page 140 FORTH DIMENSIONS IU/5 MOREWOWXABUJTWORD memory isn't needed. When memory fillr, buffer to rcompliih it. Whlle thli my these "free space" buffen prevent code mund a little llke trying to %ave ywr Robert D. Vlllwock from being compiled into their pace. The cake and eat It ban, a nthar dmple Mlcrosyrtems, Inc. floating buffer concept swmr to obocure factoring of WORD can easily accomplilh this fact more than If the token buffer and it. To Ulurtrate my point, luppaao we In analyzing or proposing changes to the PAD were given fixed, dedicated areas &vim a mom basic WORD called (WORD) any Standard definition, it is very impor- of memory. and define it a8 followor tant to concentrate on the details of the needed function and to avoid any precon- If the token buffer must handle 1024 I (WORD) ( c -- a n 1 BLK 0 ?WP ceived notion of internal implementation byte strings, the situation is even worw. I? BLOCK details, unless, of course, the two are in- We then have to stop compiling whsn the ELSE TI8 0 separable. If this is not done, we can dictionary has over 1K byte8 of apace ?WEN >IN 9 + SWAP ENCLOSE severely and unnecemarily constrain left! Since most of the time the tokens >IN *I OVER - -ROT + SWAP I future implementors from doing their best extracted by WORD am very short (31 possible job, or, worse yet, find them a- characters or leas), we pay a dear price to where ENCLOSE ii defined ai in the FIG voiding the Standard entirely. be able to handle the occasional long glaury md -ROT io equivalent to ROT string, given that WORD must handle it, ROT. A good case in point is the word and WORO is defined as at present. WORD. Since most FORTH implementors Thia new (WORD) extractr tha next have favored using the "free space" above If you discard the notion that a more token from the text itream, delimited by the dictionary to store tokens extracted or less unbounded "free space" exists c, and leave8 Its addrem & length on the 3y WORD, and further since their exper- somewhere in memory, the approach to stack. Actually, the token is msmly left ience seems to be centered around small WORD'S definition takes on a new facet. in tha input buffer (keyboard or diak) and a to medium sized application programs, it At Microsystems, we have developed pointer to it is given. Thw, no additional IS tacitly assumed that this free space is several large applications using FORTH, or temporary buffer is mded. The user arbitrarily large. In addition to storing which resulted in target compiled code In may now do anythinp he (she) want# with tokens at HERE, PAD is usually also de- the range of 32K to 48K bytes, exclusive the string, including moving it to HERE if fined to float above the dictionary in this of the dictionary headers and the FORTH desired (and if it will fit). "unbounded" free space. Therefore, operating sysem software. When appli- whether WORD handles tokens of length cations become that large, there isn't even For example, if you want to compile 128, 256 or even 1024 bytes is innocently room to hold all the names in memory at the token a8 6 "dotquote" string, a deflni- discussed with the idea that the only issue one time (even if constrained to 3 char- tion such as WORD, can be umd. involved is the length descriptor preceding acters and length), let alone room to bum I WQ(D. (c -- 1 the string! for large "free space" buffed Our im- plementati which is called (WORD) HERE OVER 1+ ALLOT SWAP OVER CI However, whether this token buff-er proFORTH", handles this problem by CWNT moa I and PAD float above HERE or are fixed means of multiple dictionaries and !mation buffers or some different scheme ROM/RAM segment control with selective If you want a blank-filled line put in is devised, they consume real memory and symbol purging. Names are classified as PAD, the following could be urd: are not really "free space". To illustrate, to their needed lifetimes during com- suppose we assume the traditional imple- pilation. When the names am no longer 1 TEXT ( c -- ) PAD C/L 2' BLANKS Tentation for a moment and use HERE as needed, they are purged and their memory (WORD) C/L WIN PAD Cl PAD the start of the token buffer used by space is reclaimed. This allows much of 'WORD. The PAD is then usually floated the memory devoted to dictionary headers COVKP CWOVE I at a location equal to HERE plus some to be reused many times during com- constant. If WORD must nandle tokens as pilation, thereby enabling very large ap- Far the routine compilerlinterpreter long as 255 bytes, then PAD must be plications to be compiled. job of extracting mail (31 characters or floated at least 256 bytes above HERE to lea) tokens from the text stream, the fol- prevent token extraction from corrupting The foregoing is not a commercial for lowing could be used: the contents of PAD. The 79-STANDARD proFORTH, but rather is intended to illus- requires that PAD be able to hold at least trate that the scope of usage to which t WORD I c -- a ) 54 bytes, so now we're at HERE- FORTH can be applied is very broad. In a (UORD) WDSZ WIN WBFR CI IBFR CWlT 1* 3ytes. situation where you have multiple diction- MOVE WBFR I aries and are fighting for every byte of If one is compiling a large application memory available, thinking in terms of orogram, the dictionary will grow until storing unbounded tokens at HERE and where WBFR is a "small" word buffer eventually HERE + '120 hits the peg floating PADS of arbitrary length becomes limited to WDSZ + 2. Note that except rvhether it is a fixed boundary or the very incongruous. Admittedly, I've des- possibly for the *If-imposed size limi- 3STACK bottom or whatever). When it cribed a somewhat extreme situation, but tation., the last definition satisfies the does, no more compilation can take place it is not as rare as yw may think. Micro- 79-STANDARD definition of WORD. even though there is at least 320 bytes of processor applications are getting more JnUsed dictionary left) without violating ambitious every day and sooner or later If you will carefully examine these fhe Standard. If you permit further com- you will have a crowded memory comtrucl, you can quickly discover that >ilation, the size of PAD begins to drop condition. I think FORTH should be able given (WORD) as the elementary form, the below the minimum 64, which is not al- to handle these situations gracefully, user can extract tokens of any size, put :owed. Even if you start automatically without having to deviate from the them wherever he wants, and format them reducing the PAD offset so that it remains Standard. with or without the trailing delimiter, or fixed in size, the token buffer begins for that matter, the leading count byte (or shrinking and can no longer satisfy the 256 When defining WORD, then, one ob- 16 bit word if you prefer:. In other words, oyte string requirement. jective should be to enable users to the user ought to be able to do essentially extract arbitrarily long tokens from the anything that he may desire, but, the im- I'm trying to illustrate that "free text stream but @ force the implementor plementor need not provide any special, space" is only "free" as long as all of to provide an arbitrarily long memory temporary buffers or arbitrary size just to

'ORTH DIMENSIONS In/5 Page 141 satisfy the Stnndard. of the people at FIG about thin and they CALL FOR PAJXRS were acutely aware of the problem but Using (WORD) aa the fundamental they are simply not set up to directly 1982 Rochester FORTH Conference token extractor allows implementon to reproduce liatingr into FD at the present m compile dot qwte strings, for example, time. They do the beat job they can with Data Bases and Process Control without the necd for any transitional buf- the NSOUEOS available to them, and they fers (we WORD,). On the other hand, if work darn hard at it. 1 can't fault them. May 17 through May 21, 1982 dot quote strings are acquired by the present form of WORD in the Standard, REPL ia a pseudonym for the Fig- University of Rochester then the token buffer must be at least as FORTH line editor definition, R . I used Rochester, New Ywk large as the lmgest dot quote atring, the pseudonym becauw FEDIT was the which is presently specified to be 127 first program I wrote in FORTH end 1 The second annual Rochester FORTH characters. really wun't familiar enough with Vocab- Conference will be held in May, and will ularies to comfortably UWI a word that was be honted by the University of Rocheater's One might argue that if the buffer is already used in the FORTH vocabulary. Laboratory for Laaer Energetics. Thls at HERE, there is no penalty since that is year's topics complement and extend the where the string must go anyway, and if it Let me know how it works for you If work described at the 1981 FORML Con- won't fit it can't be compiled. However, you would like a machine pmduced listing, ference and the previwr Rochester Con- this line of reasoning is again limited by a I could run one for you from my current ference. We believe that the areas of parochial view that all FORTH implemen- version. data bases and process control can be tations must be alike. If a system like uniquely dealt with using FORTH. proFORTkf ia being used, the target defin- Edgar H. Fey, Jr. ition body can optionally be compiled "in 18 Calendar Court Thare'is a call for papers m the fol- place" separate from the dictionary La Grange, IL 60525 lowing topia header. There may be room for the atring in the target segment of memory but not 1. Data Baaen, including, but not lim- enough in the dictimary. ited Lo: hierarchical, network and relatimal models; scientific use; In conclusion, let me say that if them procem control; and commercial is sufficient memory, the user may systems. declare all the buffen he wants, but we Here'. a short FORTH word of great shwld rot require that there buffers be 2. Process Cmtrol, including, but not utility that 1 uw havily in my SCNW.I preallocated by the implementor in order limited to: multitasking, meta- hope you like it. name ia CM, which to satisfy the Standard. Therefore, I aub- Its compilation, data acquisitim and stands for "convert to decimal". mit that my definition of (WORD) is a real time systems; video games. more fundamentally valuable function DECIMAL than WORD (a0 currently defined in the 3. Related concepts of: : CVD 79-STAM)ARDJ from whid all othera implementation, speed/space can be built without burning sometimes BASE @ SWAP OVER /MOD tradeoffq user interactions; de- precious memory space. There are a1- upnar tools; and graphics. ready enou@ buffen and auch required ROT /Moo (directly or indirectly) by the Standard. 10 + 10 + Papers will be handled in either oral Let's not arbitrarily insint m more by ac- wrima or poster rssions, although oral cidently defining words in wch a way as to ; papers will be refereed in accordance with force an implementor to provide them. conference directim, paper quality and I like to work in hxidacimal, but often topic. Plearc submit a word abstract make mistakea when using the words 200 I emphasize "possibly" because fortun- by 15, 1982. The oral papers dead- LOAD, UST, Md mny of the FORTH March ately the Standard ia not exdicit as to the lirm is April 15, 1982, and the poster lcrwn editor words beceure I'm thinking length of tokens that must'be handled by deadline is May Send ab- in decimal when tho aystem'a in hex. If 1 papers 1, 1982. WORD. atrecta and papers to the conference d do the following: chairman, Lawrence Forsley, by those :LIST CVDUST; dab. Plea= keep papers to a maximum coRREcTloNToFmcT of 10 printed pages. If this restriction causes a serious problem, contact us. Sorry you had tmuble with FEDIT. The thm 130 UST lists EM 130 whether Pm listing war retyped at FIG and wveral in decimal hex. It alao worka far my or For more information, please contact typos creeped in. They are: other bea, long 01 that base rccapb an the conference chairman at: the number. 1. SCR 64 Line 10: compile should be COMPILE Lawrence P. Forsley Aa to how it works, a little work will Laboratory for Laser Energetics 2. 65 Line 23: l+/MOD -Id be 1+ SCR show that CVD aplib a threa-diqit number University of Rochester 16 /MOD into its respective digits (IE, 130 becomes 250 Ead River Road 3. 67 Line 48: B/BUD -Id be SCR I, 3, and 0) and reaanemblw the diqib into Rochester, New York 14623 B/BW the number that ia, in decimal, the same 4. SCR 67 Line 49: :e shwld be :.€ as the keys prsawd by the user. 5. SCR 67 Line 50: + ALN should be +ALIN Crew Williama BYTE Publicationn You are perfectly right that yxlrce Po Box 372 text should be loadable. I talked to wme Hancock,NH 03449

~ege142 FORTH r3M3WOfUS llIl5 n A FORTH ASSEMBLER (now CONTEXT) 1. The comma how8 the conclurion FOR TkE6502 FORTH (chained to ASSEMBLER) of a logical grouping that would be by William F. Ragdale user'r (CURRENT If one exltd one line of classical mmbly FORTH (chained to user's vocd wurce code. INTRODUCTION try for literal number else, do error abort 2. "," compiles Into tha dictionary; This article ahould further polarize tha thur a comma impller the point at attitudes of thow outride the growing The above auqwnce ir the urual action which code 18 generated. community of FORTH userr. Some will be of Forth's text interpreter, which remain8 fascinated by a label-less, macro- in control during aaembly. 3. The ",' dirtinguilher op-codes assembler whose source code ir only 96 from posrible hex numbers ADC lines Ion$ Others will be repelled by During assembly of CODE definitiOn8, and ADO. reverw Poliah syntax and the absence of Forth continuer interpretation of each labels. word encountered in the input rtream (not NEXT in the compile mode). There wembler The author immodestly clalmr that thir wordr opacity operandr, address moder, Forth executer your word definitlm is the best FORTH assembler ever dirtri- and op-coder. At the conclurion of the under control of the addresa interpreter, buted. It is the only wch assembler that CODE dellnition a final error check veri- named NEXT. This ahort code routine detecb ail errors in op-code generation fies correct completion by "unrmudging" mover execution from one definition, to and conditional structuring. It is releawd the definition'r name, to maka it available the next. At the end of your code defini- to the public domain 80 a defenw mechan- for dictionary warcher. tion, you must return control to NEXT or ism. Three good 6502 assemblers were else to code which returns to NEXT. submitted to the FORTH Interest Group RUN-TIME, ASSEMBLY-TIME but each had some lack. Rather than RETURN OF CONTROL merge and edit for publication, I chose to One murt be careful to understand at publish mine with all the submitted fea- what time a particular word definition Most 6502 systems can rewme execu- tures plus several more. executes. During assembly, each as- tion after a break, since the monitor mves sembler word interpreted executes. Its the CPU register contents. Therefore, we Imagine having an assembler in 1300 function at that instant is called 'awmb- must return control to Forth after a bytes of object code with: ling' or 'assembly-time'. This function return from the monitor. NEXT is a con- may involve op-code generation, addresa stant that specifies the machine address 1. User macros (like IF, UNTIL,) de- celculation, mode selection, etc. of Forth's address interpreter (say finable at any time. $0242). Here it is the operand for JMP,. The later execution of the generated As JMP, executes, it assembles a machine 2. Literal values expressed in any code is called 'run-time'. This distinction code jump to the address of NEXT from numeric base, alterable at any is particulary important with the condi- the assembly time stack value. time. tionals. At assembly time eech such word (i.e., IF, UNTIL, BEGIN, etc.! itself 'm' SECURITY 3. Expressions using any resident to produce machine code which will later computation capability. execute at what is labeled 'run-time' when Numerous tests are made within the its named code definition is used. assembler for user errors: 4. Nested control structures without labels, with error control. AN EXAMPLE 1. All parameters used in CODE definitions must be removed. 5. Assembler source itself in a port- A8 a practical example, hem's a simple able high level language. call to the system monitor, via the NMI 2. Conditionals must be properly address vector (using the BRK opcode). nested and paired. OVERVIEW CODE MON ( exit to monitor ) 3. Address modes and operands must Forth is provided with a machine lang- RRK, NEXT JMP, END-CODE be allowable for the op-codes uage assembler to create execution pro- cedures that would be time inefficient, if The word CODE is first encountered, These tests are accomplished by written as colon-definitions. It is intended and executed by Forth. CODE builds the checking the stack position (in CSP) at the that "code" be written similarly to high following name "MOM' into a dictionary creation of the definition name and level, for clarity of expression. Functions header and calls ASSEMBLER as the comparing it with the position at ENO- t may be written first in high-level, tested, CONTEXT vocabularly. CODE. Legality of address modes and and then re-coded into assembly, with a operands is insured by means of a bit mask minimum of restructuring. The 'V is next found in FORTH and associated with each operand. executed to skip ti1 "),,. This method skips THE ASSEMBLY PROCESS over comments. Note that the name after Remember that if an error occurs CODE and the "1'' after 'Y" must be on the during assembly, END-CODE never exe- Code assembly just consists of inter- same text line. cutes. The result is that the "smudged" preting with the ASSEMBLER vocabulary condition of the definition name remains as CONTEXT. Thus, each word in the in- OP-CODES in the "smudged" condition and will not be put stream will be matched according the found during dictionary searches. Forth practice of searching CONTEXT BRK, is next found. in the assembler as first then CURRENT. the op-code. When BRK, executes, it as- The user should be aware that one sembles the byte value 00 into the dic- error not trapped is referencing a defini- tionary as the op-code for "break to moni- tion in the wrong vocabitlary: tor via 'INMI**. i.e., O= of ASSEMRLER when you want Many wembler words names end in O= of FORTH ",".The significance of this is:

PORTH DIMENSIONS 1/5 Page 143 (Editor's note: the listing assumes that EXAMPLES the figFORTH error memagas are already Here are examples of Forth vs. con- BOT LDA, LDA(0.X) available in the system, a8 follows: ventional assembler. Note that the oper- BOT 1+ ORA, ORA (1,X) and comes firat, followed by any mode SEC ORA, ORA(2,X) ?CSP ianues the error message "DEFI- modifier, and then the op-code SEC 1+ ORA, ORA (3,X) NITION NOT FINISHED" if the stack mnemonic. This makes best use of the position differa from the valw saved in stack at assembly time. Also, each as- To obtain the 14-th byte on the stack: the user variable CSP, which is wt at the wmbler word i8 met off by blanks, as is BOT 13 + LOA, creation of teh definition name. required for all Forth source text. RETURN STACK ?PAIRS issues the error message .AROL. RDLA "CONDITIONALS NOT IMPAIRED'' if it8 ~~LDY;LDYX~ The Forth Return Stack is located in two arguments do not match. DATA .X STA. STA OATA,X the 6502 machine stack in Page 1. It DATA ,Y CMP, CMP OATA,Y strrts at SolFE and builds downward. No 3 ERROR prints the error message 6 X) ADC, ADC (06,X) lower bound is set or checked as Page 1 "HAS INCORRECT ADDRESS MODE".) POINT )Y STA, STA (POINT),Y has sufficient capacity for all (non-- VECTOR ) JMP, JMP (VECTOR) recursive) applications. SUMMARY The object code of our example is: (.A distinguishes from hex number OA) By 6502 convention the CPU's register points to the next free byte below the bot- 305 983 40 4F CE CODE MON The words DATA and VECTOR specify tom of the Return Stack. The byte order 305D 4D 30 link field machine addresses. In the caw of "6 )X follows the convention of low significance 305F 61 30 code field ADC," the operand memory address Moo6 byte at the lower address. 3061 00 BRK was given directly. This is occasionally 3062 4C 42 02 JMP NEXT done if the umqe of a value doesn't justify Return stack values may be obtained devoting the dictionary space to a symbol- by: PLA, PLA, which will pull the low OP-CODES, revisited ic value. byte, then the high byte from the return stack. To operate on aribitrary bytes, the The bulk of the assembler conrirts of method iu dictionary entries for each op-code. The 6502 CONVENTIONS 6502 one mode op-codes are: 1) save X in XSAVE Stack Addreaainq BRK, CLC, CLD, CLI, CLV, 2) execute TSX, to bring the S DEX, OEY, INX, INY, NOP, The data stack is Located in z-page, register to X. PHA, PHP, PLA, PLP, RTI, usually addressed by "Z-PAGE,X". The RTS, SEC, SED, SEI, TAX, stack starts near WEand grows down- 3) usa RP) to address the lowest TAV, TSX, TXS, TXA, TVA, ward. The X index register is the data byte of the return stack. Offset stack pointer. Thus, incrementing X by the value to address higher When any of these are executed, the two removes a date stack value; docre- bytes. (Address mode IS corresponding op-code byte i8 aanembled manting X twice maker mom for one new automatically set to ,XJ into the dictionary. data dack value. 4) Restore X from XSAVE. The multi-mode op-codw are: Sixteen bit values are placed on the deck according to the 6502 convention; As an example, this definition non- ADC, AND, CMP, EOR, LDA, the low byte is at low memory, with the destructively tests that the second item ORA, S8C, STA, ASL, DEC, high byte following. Thir allows "indexed, on the return stack (also the machine INC, LSR, ROL, ROR, STX, indirect X" directly off a stack valw. rtack) is zero. CPX, CPY, LDX, LDV, STY, JSR, JMP, BIT, The bottom and second stack values CODE IS-IT ( zero ? ) are referenced often enough that, the wp- XSAVE STX, TSX, (setup for These usually take an operand, which port words BOT and SEC am included. return stack) must already be on the rtack. An addrer Using RP) 2+ LDA, RP) 3 + ORA, mode may also be Ipecified. If norm is ( or 2nd item's two bytes given, the op-cod um8 z-page or absolute BOTLDA, aswmblm LDA (0,x)and together) addressing. The addram modes are deter- SEC ADC, asembler AM= (2,X) OZ IF, MY, THEN, ( if zero, bump mined by: Y to one) BOT leaves 0 on the stack and wts the TYA, PHA,XSAVE LDX, (save Symbol Mode Operand addrew mode to ,X. SEC leaves 2 on the low byte, rstore data stack) stack alro wetting the address mode to ,X. PUSH JMP, END-CODE ( PU~ accumulator MWIO boolean) immediate 8 bits only Here is a pictorial repmentation of indexed X z-page or the stack in z-page. I Return Stack1 absolute indexed Y z-page or absolute O(K: high indexed indirect X z-page only sec low I indirect indexed Y Z-ww only indirect abmlute only bot high memory ZPega or bot low <=exoffset

abwlute ~ abova Mow,

Hare is an examples of code to "or" to the accumulator four byter on the deck:

Page 144 FORTH DIMMSlONS FORTH REGISTERS pointers for indsxed/indirect mddreuing or trol word= for temporary valuen. As an example of Several Forth registers are available use, see CMOVE in the system tOurc0 BEGIN, UNTIL, IF, ELSE, only at the assembly level and have been code. THEN, given names that return their memory ad- dresses. These are: The assembler word N returns the Here again, the assembler words end base addreas (usually $0001). The N Area with a comma, to indicate that code is IP address of the Interpretive spans 9 bytes, from N-1 thru N+7. Con- being produced and to clearly differen- Pointer, specifying the next Forth ventionally, N-1 holds one byte and N, tiate from the high-level form. address which will be interpreted N+2, N+4, N+6 are pairs which may hold by NEXT. 16-bit values. See SETUP for help on One major difference occurs! High- moving values to the N Area. level flow is controlled by run-time W address of the pointer to the code boolean values on the data stack. As- field of the dictionary definition It is very important to note that many sembly flow is instead controlled by pro- just interpreted by NEXT. W-1 Forth procedures use N. Thus, N may only cessor status bits. The programmer must contains S6C, the op-code for in- be used within a single code definition. indicate which statua bit to test, just be- direct jump. Therefore, jumping Never expect that a value will remain fore a conditional branching word (IF, to W-1 will indirectly jump via W there, outside a single definition! and UNTIL,). to the machine code for the def- inition. Examples are: CODEDEMO HEX UP User Pointer containing ad- 6 # LOA, N 1 - STA, PORT LDA, O= IF, THEN, dress of the base of the user (setup a counter) (read port, if equal to zero do ) area. BEGIN, 8001 BIT, PORTLDA, O= NOTIF, TMN, N a utility area in z-page from (tickle a port) (read port, if not equal to zero N-1 thru N+7. do ) N 1 - DEC, CPU Registers (decrement the counter) The conditional specifiers for 6502 are: When Forth execution leaves NEXT to O= UNTIL, NEXT JMP, END-CODE execute a CODE definition, the following (loop till negative) CS test carry set C=l in conventions apply: processor SETUP status 1. The Y index register is zero. It o< byte lass than zero N=l may be freely used. Often we wish to move stack values to O= equal to zero z:1 the N area. The sub-routine SETUP has CS NOT test carry clear C=O 2. The X index register defines the been provided for this purpose. Upon en- 0 G- 4. The accumulator may be freely F- F CONDITIONAL LOOPING used. E E D- D- A conditional loop is formed at as- 5. The processor is in the binary sec--> C- c- sembler level by placing the portion to be mode and must be returned in that B B repeated between BEGIN, and UNTIL,: mode. bat--> A- N--> A- 6 # LDA, N STA, XSAVE CONTROL FLOW (define loop counter in N) BEGIN, PORT DEC, XSAVE is a byte buffer in z-page, for Forth discards the uwal convention of (repeated action) temporary storage of the X register. assembler labels. Instead, two replace- N DEC, O= UNTIL, Typical usage, with a call which will ments are used. Fint, each Forth defini- (N reaches zero) change X, is: tion name is permanently includsd in the dictionary. Thin allows procedures to be Fint, the byte at address N is loaded CODE DEMO located and executed by name at any time with the value 6. The beginning of the XSAVE STX, USER'S JSR, as well as be compiled within other defini- loop is marked (at assembly time) by ( which will change X ) tions. BEGIN,. Memory at PORT is decrement- XSAVE LDX, NEXT JMP, ed, then the loop counter in N is decre- END-CODE Secondly, within a code definition, mented. Of course, the CPU updates its execution flow is controlled by label-leas statua register as N is decremented. N Area branching according to "structured pro- Finally, a test for Z=1 is made; if N hasn't gramming". This method is Identical to reached zero, execution returns to When absolute memory registers are the form used in colon-definitions. Branch BEGIN,. When N reaches zero (after exe- required, use the 'N Area' in the bae calculations are done at aasembly time by cuting PORT DEC, 6 times) execution page. These registers may be used as temporary deck values placed by the con- continues ahead after UNTIL,. Note that

:Page 14s BEGIN, generates no machine code, but is RETURN OF CONTROL, revisited FOOLING SECURITY only an assembly time locator. When concluding a code definition, Occasionally we wish to generate CONDITIONAL EXECUTION several common stack manipulstim often unstructured code. To accomplish this, we are needed. Thew functions vb already can control the euembly time security Paths of execution may be chosen at in the nucleus, 00 we may share their use checks, to our purpoae. First, we must assembly in a similar fashion and done in just by knowing their return points. Each note the parameters utilized by the colon-definitions. In this case, the branch of these returns control to NEXT. control structurer at assembly time. The IS chosen based on a processor status con- notation below is taken from the as- dition code. POP POPTWO remove one 16-bit rUck sembler glorary. The --- indicate3 as- values. sembly time execution, and separate input PORT LDA, O= IF, (for zero set) WPTWO remove two 16-bit stack rtack values from the output stack values THEN, (continuing code) valuea. of the worda execution. PUSH add two bytes to the data In this example, the accumulator is stack. BEGIN, =P --- addr8 1 loaded from PORT. The zero status is PUT write two bytes to the UNTIL, ==> addre 1 cc --- tested if set (Z=l). If so, the code (for data rtack, over the zero set) is executed. Whether the zero prarent bottom of the IF, ==> cc --- addrl 2 status IS set or not, execution will resume stack. ELSE, =3 addrl 2 --- addrE 2 at THEN,. THEN, =d addrI 2 --- Our next example camplemsnts a byte or addrE 2 --- The conditional branching also allows a in memory. The bytes' addrer is on the specific action for the false case. Here stack when INVERT is executed. we see the addition of the ELSE, part. The address values indicate the CODE INVERT ( a memory byte ) HEX machine location of the corresponding PORT LDA. O= IF, < for zero seD BOT X) LDA, (fetch byte addreued 'B'EGIN, 'IF, or 'E'LSE,. cc represents the ELSE, by stack) condition code to cslect the processor THEN, FF R EOR, (complementaccumu- status bit referenced. The digit 1 or 2 is lator) tested for conditional pairing. The test of PORT will select me of BOT X) STA, ( replace in memory two execution paths, before resuming POP JMP, END-CDDE (discard Tho general method of security control execution after THEN,. The next pointer. fmm stack, is to drop off the check digit and manipu- example increments N baaed on bit 07 of return to NEXT 1 late the addreaaes at assembly time. The a port: aecurity against erron is less, but the pro- A new stack value may mwlt fmm a grammer is usually paying intense atten- PORT LDA, ( fetch Me byte ) code definition. Wa could program placing tion to detail during this effort. CK IF, N OEC, ( if 07=1,decrement it m tb st8ck by: N) To generate the equivalent of the high ELSE, N INC, ( if 074, increment CODE ONE (put 1on the stack) level: N) DEX, DEX, ( make room on the THEN, ( continw ahead ) data stack) BEGIN WHILE REPEAT 1 # LDA, BOT STA, (store low byte) CONDITIONAL NESTING BOT I+ STY, ( hi byte rtomd from Y we write in assembly: since = zero) Conditionals may be nested, according NEXT JMP, END-CODE BEGW, OROP ( the check digit to the conventions of structured pro- 1, leaving add& gramming. That is, each conditional se- A simpler version could wa PUSH: quence begun (IF, BEGIN,) must be ter- CS IF, ( leaves addrl and digit minated (THEN, UNTIL,) before the next COOE ONE earlier conditional is terminated. An 1 # LDA, PHA, ( push low byte to 2, ELSE, must pair with the immediately mechine stack ) ROT ( bring addrB to bottom) preceding IF,. TYA, PUSH JMP, ( high byte to JMP, (to addrB of BEGIN, accumulator, puh to dab stack ) ENDIF, ( complete false for- BEGIN, < code always executed) END-CODE ward branch from IF, ) CS IF. The convention for PUSH and PUT is: It is essential to write the assembly THEN, 1. push the low byte onto the time stack on paper, and run through the 03 NOT UNTIL, ( loop till condition mrhine stack. assembly steps, to be sure that the check flag is mzero) 2. leave the high byte in the digit. are droppad and re-inserted at the

- p.ge 146 FORTH OlMENSloNs IU/S n Spoclfy hlexed X' addraring exocutlon contlnrnr *ad. rolver r pending forwerd branch mode fa the next op-codr gener- from IF. The velwr 2 are ued for ated. At mwmbly time, BfGIN, Ieaver error checking of conditional pair- the dictionary pointer addran lng. Specify Wdexed V addrewing ad& and thm value 1 for later mode fa the next op-code goner- tosting of conditlanuy pairing by EMECODE rtad. UNTIL,. An error check word marking the end of a CODE definition. Suc- Speclty accumulator addrewing BOT --- n (uwmbllnp) cenful execution to and including mode for the next op-codo gener- Uoed bring code aaembly In the END-CODE will unemudge the ated. form: moot recent CURRENT vocabu- lary definition, making it available - cc (uembling) SOT LDA, or BOTl+X) STA, for execution. END-CODE a100 Specify that the immediately fol- exit8 the ASSEMBLER making lowing conditiml will branch Addrema the bottom of the data CONTEXT the same as bared on the procerror otrtur bit dack (containing the low byte) by CURRENT. This word previously being negative (2.11, i.e., lea wlectlng tho ,X mode and leaving war named C; tha zero. The flag cc is left at 04, at uoembly time. Thlr valw aowmbly time; there is no run-- of n may be modified to another F, cc --- addr 2 (aooembly time effect on the stack. byte offwt into the data dack. time) Mutt be followed by a multi-mode __- addr 2 (assembly- -- cc (essembling) op-code mnemonic. time) Specify that the immediately fol- lowing conditional will branch a3oE A defining word wed in the form: Occurs within a code definition in baaed on the processor status bit the form: being equal to zero (Z=l). The corn . . . ;CODE parameter field will execute. when ELSE, is not present). At END-CODE The CONTEXT vocebulary is ELSE, execution rewmes at the Stop compilation and terminate a made ASEMBLER, to make corresponding THEN,. new defining word . Set available the op-code mnemonico. the CONTEXT vocabulary to AS- When assembling, IF, creates an SE MBLER, aacmbling to machine CPU n --- (compiling armblcr) unreoolved forward branch based code the following nrnmonics. An An maembler defining word urcd on the condition code cc, and exirting defining word must exist to crate arambler mnemonics leaves addr and 2 for resolution in name prior to ;CODE. Chat have only one addressing of the branch by the correponding mode: ELSE, or THEN,. Conditionals When later executes in may be nested. the form: EA CPU W, . That is, when aucmbles EA as a one byte op- is executed, the address code. IP --- addr (assembling) interpreter jumps to the code fol- VIed in a code definition in the lowing ;CODE in . cs --- cc (eoaembling) form: Specify that the immediately fol- ASSEMBLER in FORTH lowing conditiarcrl will branch IP STA, or IP )Y LDA, Make ASSEMBLER the CON- bored on the. proceaor carry is set TEXT vocabulary. It will be (C=l). Thc flag cc is left at as- A constant which leaves at as- searched first when the input iembly time; there is no run-time oembly time the address of the stream in interpreted. effect on the stack. pointer to the next FORTH ex+ cution address in a colon-defini- BEGIN, ---addr 1 (aosembling) ELSE, -- (run-time) tion to be interpreted. I- (run- t ime) addrl 2 --- addr2 2 Dccun in a CODE definition in (aacmblinq) At run-time, NEXT moves IP the form: Ocwn wlthin a code definition in ahead within a colon-definition. BEGIN, . . . cc UNTIL, the form: Therefore, IP points just after the At run-time, BEGIN, marks the cc IF,

TH DIMWSIWS m/S Page 147 loads the third byte ahead in the PDPTWO UNTIL, --- (run-time) colon-definition being interpreted. --- eddr (assembling) addr 1 cc --- (assembling) nl n2 --- (run-time) Occurs in a CODE definition in M/CW nl n2 --- (compiling assembler) A constant which leaves (during the form: An assembler defining word used assembly) the machine addreso of to create assembler mnemonics the return point which, at run- BEGIN, . . . cc UNTIL, that have multiple address modes: time, will pop two 16-bit values from the data stack and continue At run-time, UNTIL, controls the 1C6E 60 M/CU ADC, interpretation. conditional branching back to BEGIN,. If the processor status M/CPU creates the word ADC, PUSH --- addr (assembling) bit specified by cc is false, exe- with two parameters. When --- n (run-time) cution returns to BEGIN,; other- ADC, later executes, it uses A constant which leaves (during wise execution continues ahead. these parameters, along with assembly) the machine addrew of stack values and the contents of the return point which, at run-- At assembly time, UNTIL, as- MODE to calculate and assemble time, will add the accumulator (as sembles a conditional relative the correct op-code and operand. high-byte) and the bottom branch to addr based on the condi- machine stack byte (as low-byte) tion code CC. The number 1 is MEM Used within the assembler to set to the data stack. wad for error checking. MODE to the default value for direct memory addressing, z-page. PUT --- addr (assembling) up --- addr (assembling) nl --- n2 (run-time) Used in a code definition in the MODE --- addr A constant which leaves (during form: A variable used within the assembly) the machine addrean of assembler, which holds a flag the return point which, at run- UPLDA, or UP )Y STA, indicating the addressing mode of time, will write the accumulator the op-cock being generated. (as high-byte) and the bottom A constant leaving at assembly machine stack byte (as low-byte) time the address of the pointer to N --- addr (assembling) over the existing data stack 16-bit the base of the user area. i.e., Used in a code definition in the value (nl). form: HEX 12 R LDY, UP)Y LDA, RP) -- (asaembty-time) N 1 - STA, or N 2+ )Y bed in a code definition in the load the low byte of the sixth user ADC, form: variable, DP.

A constant which leaves the ad- RP) LDA, or RP) 3+ STA, W --- addr (assembling) dress of a 9 byte workspan in z- Used in a code definition in the page. Within a single code dcfini- Address the bottom byte of the form: tion, free use may be made over return stack (containing the low the range N-1 thru -7. See byte) by selecting the ,X mode and W 1+ STA, or W 1 - JMP, or SETUP. leaving n=$101. n may be modi- W )YAK, fied to another byte offset. Be- NEXT -- addr (assembling) fore operating on the return stack A constant which leaves at as- A constant which leave8 the the X register must be saved in sembly time the address of the machine addreg of the Forth ad- XSAVE and TSX, be executed; be- pointer to the code field (exe- drew interpreter. All code defini- fore returning to NEXT, the X cution address) of the Forth dic- tions must return execution to register must be restored. tionary word being executed. In- NEXT, or code that returns to dexing relative to W can yield NEXT (i.e., PUSH, PUT, WP, SEC --n (assembling) my byte in the definition's WPTWO). Identical to BOT, except that parameter field. i.e., n=2. Addregles the low byte of NOT ccl -- ccl (asrembly-time) the sacond 16-bit data stack value 2 I LDY, W )Y LDA, When asembling, reverse the con- (third byte on the data stack). dition code for the following con- fetches the first byte of the ditional. For example: THEN, --- (run-time) parameter field. addr 2 --- (awembly-time) O= NOT IF, ELSE,

Page 148 FORM DIMENSIONS m/3[115 I

FORTH Araemblcr for 6S02 by Y. P. Pagrd.1. July 1, 1980 SCR # 81 0 ( FORTH-65 ASSEMBLER YII-79JUWO3 ) 1 HEX

~ 2 VOCABULARY ASSEMBLER IUMEDIATt ASSENDLEI DK?XYITIOW8 3 4 ( REGISTER ASSIGNUENT SPECIFIC TO IMPLIIIIlTATIOl ) 5 EO CONSTANT XSAVE DC CONSTANT W DI COWSTAWT 01 I 6 D9 CONSTANT IP D1 CONSTANT N I 7 8 ( NUCLEUS LOCATIONS ARE IUPLEUSNTATIOY SPICl?Ic I 9 (DO) OE + CONSTANT POP 10 ' (DO) OC + CONSTANT POPTWO 11 ' LIT 13 + CONSTANT PUT 12 ' LIT 11 + CONSTANT PUSH I 13 ' LIT i8 + CONSTANT NEXT 14 ' EXECUTE NPA I1 - CONSTANT SETUP I5 SCR # 82 O( ASSEMBLER, CONT. WII-78OCTO3 ) 1 0 VARIABLE INDEX -2 ALLOT 2 0909 , 1505 , 0115 , 8011 , 8009 , IDOD , 8019 , SO80 , 3 0080 , 1404 , 8014 , 8080 , 8080 , lCOC , 801C , XI0 , 4 5 2 VARIABLE MODE 6 : *A 0 MODE I i :I I UODE 1 ; : NEN 2 YODK I ; 7 : .X 3 MODE 1 ; : .Y 4 MODS 1 ; : X) I &ODs 1 ; 8 : )Y 6 MODE 1 ; :) P MODE I ; 9 10 : BOT .I 0 ; ( APDRtSS TUE BOTTON OI TEE STACK *) I1 : SEC .x 2 . ( ADDRESS StCOWD ITUl OW STACK *) 12 : RP) .x 101 ADDRESS BOTTOM OI IITlllW STACK *) 13 14 15 SCR I 83 0 ( UPMODE, CPU 1 2 : UPMODE LP NODE @ 8 AND 0- tF 8 UODK +I Tall TPUW 3 1 MODE @ OF AND -DUP IP 0 DO DUP + LOOP TPUI G OVER I+ @ AND 0- ; 5 6 : CPU C@ C, MEU ; 7 00 CPL' BRI. 18 CPU CLC, D8 CPU CLD, 58 CPU CLI, 8 88 CPU CLV. CA CPU DEX, 88 CPU DEY, I8 C?U IlX, 9 C8 CPU INY. EA CPU NOP. 48 CPU PUA, 08 ccu rm, 10 68 CPU PLA, 28 CPU PLP. 40 CPU RTI, 60 CPO ITS, 11 38 CPU SEC, F8 CPU SED. 78 CPU SEI, M CPU TAX, 12 A8 CPU TAY, BA CPU TSX. 8A CPU TU, 9A CPU TXSs 13 98 CPU TYA. 14 15

FORTH DlMENSlONS 1U/5 149' SCR 4 84 0 ( M/CPU, UULTI-MODE OP-CODES UFR-79MAR26 ) 1: N/CPU 2 DUP I+ @ 80 AND IF 10 MODE +I THEU OVER 3 FFOO AND UPMODE UPMODE IF MEN CR LATEST ID- 4 3 ERROR THEN C@ MODE C@ 5 INDEX + ce + c. MODE C@ 7 AND IF MODE C@ 6 OF AUD 7 < IF c. ELSE , THEN THEW nEn ; 7 8 IC6E 60 wcpu ADC, lC6E 20 WCPU AND. ic6~co wcpu cnp. 9 1C6E 40 U/CPU EOR, 1C6E A0 M/CPU LDA, lC6E 00 M/CPU ORA, 10 lC6E EO wcpu SBC, 1C6C 80 U/CPU STA, ODOD 01 M/CPU ASL, 11 ococ ci wcpu DEC , ococ ~i U/CPU IUC, ODOD 41 n/cPu LSR, 12 ODOD 21 wcpu POL. ODOD 61 WCPU ROR. 0414 81 n/cpu STX. 13 0486 EO wcpu CPX, 0486 CO M/CPU CPY, 1496 A2 U/CPU LDX. 14 OC8E A0 U/CPU LDY, 048C 80 n/cpu STY, 0480 14 WCPU JSR. 15 8480 40 U/CPU JMP , 0484 20 n/cpu BIT,

SCR. I 85 0 ( ASSEMBLER CONDITIONALS WFR- 7 9MAR26 ) I : BEGIN, HERE I ; IMMED IATE 2 : UUTIL, ?EXEC >R 1 ?PAIRS R> C. HERE I+ - C. ; IMMEDIATE 3 : IF, C, HERE 0 C, 2 - I MME D I ATE 4 : Twu. ?EXEC 2 ?PAIRS UEAE OVER ce 5 IF SYAP I ELSE OVER 1+ - SWAP C1 THEN ; IMUEDIATE 6 : ELSL, 2 ?PAIRS HERE I+ 1 JMP, 7 SYAP HERE OVER I+ - SWAP C1 2 ; IMNEDIATE 0 : NOT 20 + ; ( REVERSE ASSEMBLY TEST ) 9 90 COUSTANT CS ( ASSEMBLE TEST FOR CARRY SET ) 10 DO CONSTANT 0- ( ASSEMBLER TEST FOR EQUAL ZERO ) 11 10 CONSTAYT O< ( ASSEMBLE TEST FOR LESS THAN ZERO ) 12 90 COPSTAUT >- ( ASSEMBLE TEST FOR GREATER OR EQUAL ZERO ) 13 ( >- IS ONLY CORRECT AFTER SUB, OR cnp. ) lb 15

SCR # 06 0 ( OSL OF ASSEMBLER WFP- 79APR28 ) 1 I BID-CODE ( END OF CODE DEFINITION *) 2 CURRRYT @ CONTEXT I ?EXEC ?CSP SMUDGE ; IMMEDIATE 3 b FORTU DEPIUITIONS DECIMAL 5 : CODE ( CREATE WORD AT ASSEMBLY CODE LEVEL *) 6 ?LXEC CREATE [COMPILE) ASSEMBLER 7 ASSEMBLER MEN ICSP ; IMMEDIATE 8 9 ( LOCK ASSEMBLER INTO SYSTEM ) 10 ASSEMBLER CFA ' ;CODE 8 + I ( OVER-WRITE SMUDGE ) I1 LATBST 12 +ORIGIN I ( TOP NFA ) 12 UBRS 28 +ORIGIN ! ( FENCE ) 13 YBRB 30 +ORIGIN I ( DP ) 1b ' ASSLMDLER 6 + 32 +ORIGIN I ( VOC-LINK ) 15 BERB FENCE I

110 FORTH DIMENSIONS Inl5 this that requires less typing and is also : TABLE more general. We will first define a word CREATE (---) called TABLE which will aid us in the cre- DOE9 ( NOEX --- VALUE ) ation of tables like the one above. What SWAP 1- 2. t @ i we will do is first place the initial vdues Henry Laxen of the TABLE on the stack, together with TABLE DAYS/MONTH Laxen and Harris, Inc. the number of the initial values. Then, we 31 ,2e, 11,30,3i ,30, will define TABLE to copy thew into the 31,31,30,31 ,30,31, One of the problems with FORTH, as dictionary. Here ia how it works: with every rich language, is that given an Now we have truly generalized the idea, there are many ways of expressing : TABLE ( Nn Nn-1 ... N1 n ---I problem and rolve it in an elegant way. it. Some are more eloquent than others, 0 DO, LOOP ; We have defined a new data type, called but it takes practice and experience to TABLE, which is capable of defining new create the poetry and avoid the mundane. CREATE 'DAYS/MONTH wordr. Part of the definition of TABLE 31 30 31 30 31 31 30 31 30 31 28 was specifying the tun-time behavior of This article is written to illustrate 4 31 12 TABLE the word being defined. This is the coda different ways of implementing a simple following the DOED. We then uw the , Table Lookup operation. The goal is the : DAYS/MONTH ( INDEX --- VALUE ) (comma) technique discovered above to following: we want to create a FORTH 1- 2* 'DAYS/MONTH + @ ; initialize the table. Note that word, named DAYS/MONTH which be- DAYS/MONTH is now just a special case haves as follows: Given an index on the of TABLE, and is in fact defined by the stack which is the month number, such as Now ?%is is considerably less typing than new defining word TABLE. 1 for January and 12 for December, we the first way of doing it, but notice that I want to return the number of days in that had to reverse the order of the days per The above examples illustrate the im- month, in a normal year. Thus if we exe- month since that is the way stacks be- mense divemity available in FORTH. cute 6 DAYS/MONTH it should return 30, have. 1 used CREATE instead of VARI- There is no obvious right or wrong, and the which is the number of days in the month ABLE because it does not allocate any simplest and usually most general solution June. I will use the Starting FORTH dia- space for the initial value, but otherwise to a given problem must be discovered, lect in this paper, not fig-FORTH, so if behaves just like VARIABLE. The acceas usually by trial and error. FORTH8 big- you try to type in the examples, they word DAYS/MONTH is identical to before. gest virtue, in my opinion, is that it makes probably won't work unless you are running the trial and error process extremely ef- a system that behaves as described in I am still not satisfied, however, so ficient, and therefore, allows people to Starting FORTH (or the 79-Standard). let's try it yet another way. Instead of experiment and discover the best solution defining TABLE to add valuea to the dic- for themwlves. Our first attempt at solving this prob- tionary with , (comma) why not just use , lem uses the FORTH word VARIABLE. directly? The code is as follows: CREATE DAYSIMONTH VARIABLE 'DAYS/MONTH 22 ALLOT 31 ,28 . 31 ,jO,31 ,30, HELP WANTED 31 , 51 , 30 , 31 ,30, 31 , 31 'OAYS/MONTH 28'DAYS/MONTH 2 + ! Programmers needted to produce new 31'DAYS/MONTH 4 + ! : DAYS/MDNTH ( INDEX --- VALUE ) polyFORTH systems and applications. 30'DAYS/MONTH 5 + ! 1- 2. 'DAYSIMONTH + @ : Two to three years extenrive FORTH 3l'DAYS/MONTH 8 + : experience working with minilmicro 30DAYS/MONTH 10 + ! computers and peripherals. T~DAYS/MONTH 12 + ! Now we are getting somewhere!! If we sl'OAYS/MONTH 14 + ! simply use the FORTH word , (comma) to Contact: Patricia Jones 3ODAYS/MONTH 16 + ! add the value to the dictionary, see how 31'DAYS/MONTH 18 + ! simple and readable it becomes. The FORTH, INC. 30'DAYS/MONTH 20 + ! values are just typed in and separated by 2309 Pacific Coast Highway 3l'DAYS/MONTH 22 + ! commas! Is it possible to improve even on Hermosa Beach, CA 90254 : DAYS/MONTH ( INDEX --- VALUE ) this? Funny you should ask. There is a (213) 572-8493 1- 2* 'DAYS/MONTH * g ; quality that can be abstracted from the definition of DAYS/MONTH, namely that There is nothing significant about the of table lookup. Wouldn't it be nice if we !apostrophe), I only prefaced the VARI- didn't need to create that extra name ABLE name with it because I want to use 'DAYS/MONTH simply so we could access the word DAYS/MONTH later. Now, what it later in our : definition. Well, that is figFORTH NOVA GROUP happened is that VARIABLE allocated 2 where our friend CREATE WED comes bytes in the dictionary for the value of in. DAYS/MONTH. The 22 ALLOT then allo- Mr. Francis Saint, 2218 Lulu, Wichita, cated another 22 bytes, for a total of 24 Instead of defining a particular in- KS 67211, (316) 261-6280 (days) has bytes, or 2.12 cells. We next proceeded stance of a TABLE, we will create a new formed a FIG Group to trade information to initialize the values that were allocated Defining Word called TABLE, which acts and assistance between fig-FORTH NOVA by explicitly calculating the offsets and as follows. It creates a new entry in the users. storing in the appropriate location. dictionary which when executed, uses the Finally, we defined DAYS/MONTH as a value that was placed on the stack 88 an Pub. Comment: Hope to see a new, colon definition which performs arith- index into itself and returns the contents clean listing. How about some other metic on the index, adds it to the start of of that location. It would be coded as fol- specific groups! the table, and fetches the result. lows:

Now, let's look at another way of doing

FORTH OIMRJSIONS m/S Page 151 THEGAhAEffREVERS M. Burton REVERSE is a number game written in SCR 228 FORTH, primarily 80 an exercise in array 0 ( Tho G.H of Rovorso [SEED. mVE8. W.DIM, Y/Nl 101201-I(Ps manipulation. The object of REVERSE is 1 to arrange a list of numbers (1 through 9) 2 0 VARIABLE SEm ( 80.d for numbor gonorotor ) in ascending numerical order from left to 3 0 VARIASLL WEB t Numbor of rovorsos SO far 1 right. Moveo are made by reversing a wb- 4 CR ." Phase dopross 8ny koy:" ( Fortiliso tho sod ) set of the list (from the left). For 5 KSY SCCD I example, if the current list is 6 7 : RW t R8ndw nurkr gonorotor rurgs -- rnde b 234516709 8 SCm 0 269 3 + 32767 W WP SEED I 32767 ; 9 and four numbem are reversed, the list A0 : DIH ( ROSOWO M intogor word arroy n -- I will be 11 ; 543216709 13 14 : Y/N t Got 8 Y or N rospoaso -- flag I then if five numben are reveroed, the 13 PAD eo EXPECT PAD co Q OL 9s A#) e9 - ; --> game is won. 125456709

To leave a game that is in progress, simply reverse zero numbers. REVERSE Clwary SEED -- The number seed forthe pacudorandom number generator. SEED is initialized as the REVERSE words are compiled, by hitting any key on the console. MOVES -- Keeps track of the number of moves mads in a REVERSE game. If more than fifteen mvea are made to win, you haven't got the hang of the game.

RND range -- random.number OCR 230 The pseudorandom number generator, 0 ( Tho Gro of Rovorso [ARRAY op.rations1 Ao1201-nw I courteay of FORTH DIMENSIONS. 1 RNO generates random.number in the 2 9 DIM ARRAY t Rosorvo 0 ton word array ) range 0 through range-1. RND is uaed 3 to scramble the number list. 4 : A@ t Fotch M uray word index -- arr.y.v81uo 1 5 2*ARMY+O; DIM n -- 6 A defining word med in the form 7 : Al t Otoro mn arroy vord arry.voluo\indox -- ) n DIM xxxx 0 2.ARRAY+I; Produces M n+l length word array 9 named XXXX, with elements 0 through A0 : AINIT Ilbiti81iSO ARMY -- I n. For the REVERSE application, 11 10 1 DO I W? A1 DP ; element 0 is not used. 12 13 : A. t ?rint ARRAY -- b Y IN -- flag 14 Q ." Tho list is #mu..." Solicits an input string from the con- 15 G 6 SPACEB 10 1 DO I A@ 3 .R WOP ; --> sole, then checks the first character of the string for an uppercase or lower- f ig-KMM Vorsion A. AS W. Burton

Page 152 231 cue IYI. If a lY' ir pmeont, tb flag o t tho 0-0 of Rovorso IMRAY opormtioaa, aont.1 100701-WD l mtuwd ir true. For my other chu- 1 =tor, the fiq ir falm. 2 : ASCILAIBLC t nir up tho uray vmluaa I -- INSTRUCT 3 l 9 DO I W l+ ( Colauloto K b -- 4 I A0 t Qot rnRAYtIl vmlu. b Prinb the rum of the game ndthen 5 WR h0 t Qot MMYtKl voluo ) ukr if inrtructiw am required. If 6 I At ( Storo MRAYtKl in AIlurtIl I yon, intructlotu am dirplayed. 7 YA? A1 -1 t Otoio ARMYtIl An AIlUrIKl ) 0 +Loo? ; ARRAY - 9 A tNl word uray thrt IXntcliM the 10 : QCTIN t Got wunt to rworao -- n ) numbor lirt thrt REVERSE work8 m. 11 BWIN a ." Rovorso how many? " Elomt zero of the ilrt ir not uoed. 12 ?AD 00 #PCCT PAD 0 40 - 13 DUP O< OVR 9 > OR W? Index - array.valw 14 IF ." Only 0 through 9 is mllavod. ' THU * Fateher the Index array.valw of 15 UNTIL CR ; --> ARRAY and Ioavc# it m the data otsck. SCR + 232 A! uray.valw index - o ( Tho Gro of Rovorso [ARMY opormtioas. aont.1 10070l-MPB ) Stom array.va1ue into the index ale- 1 mtof ARRAY. 2 : ULVRSL t Rovorso submot d ARMY n -- 1 3 W? 2 1 l+ 1 t Loop limits uo 1 to tn/ll+l I AM I 4 DO DUP I - l+ ( Colculoto inbr n-I+l ) Initializer ARRAY with the nunbra 1 5 DUP A0 IIYAP t Got ARMYln-I+ll 1 th- nlm in game wiming order. 6 I A0 t Got AMAYtIl 1 7 SUAP At t Storo AluAYtI1 in AIMrtn-I+ll ) A. - e I At t Storo MRAYta-I+ll Ln AlUAr111 ) Dirplryr ARRAY in n underatmdoble 9 LOOP DROP ; format. 10 11 : ACWSCK ( Chock for asuoAaLb~soq. -- f1.g ) AXRAMBLE I 12 1101DO Udng RW, scrambler the numbera in 13 I DU? A0 - Iw) ARRAY for a new REVERSE game. 14 UK)? : 15 --> GETIN -- n Sollcita the number of elements of the list to mvcrw. If any character other SCR + 233 thm 0 through 9 is entered, GETIN 0 Tho Gmof Rovorso IRIVUtSB dofinition1 1012m1-nn 1 printa "only 0 through 9 is allowed.", 1 md aollcib mother number. 2 : RNERSE ( Play tho gmo 1 3 INSTRUCT AINIT AREVERSE n -- 4 BEGIN Heverrer the nth length subsat of 5 ASCRANBLG 0 MVCS I ARRAY, rtarting from element 1. 6 BEGIN 7 A. GETIN DUP 0- ACHECK --flq 0 IF 1 eLsc Checks ARRAY for proper aacendinq 9 MRlWSE 1 MOVES +I ACHE= numerical order. If ARRAY is in the 10 Tnpl proper order, ACHECK returns a true 11 UNTIL flag. 12 A. CR ." You mado ., MOVES 0 . .* rovorsals.' CR 13 CR ." Coro to play again? ' Y/N 0- REVERSE -- 14 UNTIL The game dcfinitim. Usea all pre- 15 CR ." Thanks for ploying REVWSE... * CR ; ;8 viourly defined words to play the game of REVERSE. fig-FORM Vorolon 1.15 H. Burton 1 ok TI€ 31 CAW SCRN51 31 EV TONV LEUIS) Written by Tony Lewis 11/81 : HOUTO:l HOIY ( 31 CIWE-TONY LEWIS) .- 51 GlvE BY TONI LEWIS ':l' IS PLIVED WITH LI DECC OF 24 WDS The "31 Game" is an attempt to use CONTAININING PLV THE K€S TIRU SIXES. FORTH fundamentals to produce an enter- EWH OF TWO PLAVERS IYTERWTELV DRIYIS taining result. The object is to entice you CWDS FW THE DECK. ON CMD nT n TIM. b RUNNING TOT& IS LEPT OF THE CWIMED' into anlyzinq both the game itslef and the methods ueed to produce it. The game Sun OF THE CARDS Dk6bW-I. THE PLnVER Yo buffs might wish to know that 1 have been nwivEs AT THE sum OF 31 EXKTLV WINS. 50 IF NEITHLR FLAVPR CIW MhE 31 EXWTLV. an avid "player" (not gambler!) for over THEN THE PLAYER W40 MUST 00 Mh31 years and have made extensive practical LOSES' 1% OWE WV APF'EM TW EASV. BUT studies of various games. Any phone 11 IS DECEPTIVE. YEN [OR IF"] VW HAVE' communication is welcome. I am two WON TWEE GLlIiES. 1RV TO BEAT THE PtWGRW yearr behind in my written corres- FOF TM BIG BET' Bf TVPING IN 'B' pondence; so sending me letters which RL.THER TW V OR 'N. UMEN 'NU -7' require replies will prove futile. The pro- (01~sUP. THE 'BIG FIET IS n TWO O(VE FORTH. SERIES. YOU GO FIRST IN OIVE 1 IWD gram is my first effort in Haw- SECiUUD IN G&Mt 2. VW MAV EE SURPRISED" ever, I have had extensive experience with Ch Ch CR .' HI1 Wf bET TO BEGIN' rix different main frame assemblers plus a hET bFcff nocY 6 CV : -- little COBOL of the late 60's vintage. Kh.52 Any constructive suggestions on general 4 YOlcDS OF WISDM Z1 BY TONV LEWIS) style and technique are welcome, hut I am t TI+€ WSMR PAGE IS WIT. IT WESN'T not really interested in being told that I REWlRE IWV SkILL TO FIGURE WT -1 THE could have shaved 100 microseconds from CWSTWTS REALLY &RE' THEV ME ENCODED 50 TWT VW Clul ENTER IWD COMPILE THE my run time or saved fifteen bytes of Wtl€ WIT)(ouT DISCWERIlO IT6 PRINCIPLE. memory. In fact, there are indeed extran- REMEMEW. THE PURPOSE OF Tnxs PROJECT eous "Cr's" which were included to get WAS TG Ml VW TO FIRST EICMINE TI€ IMIU! bv PLhVING IT. THEN FIWRE OUT MOU TO good hard copy, also. (LPPROLLCH THE PRJkEM OF -1NG IT. AND FIWLV 00 L(Iu WD COW- VM This program was written in micro- MiTHODs TO MINE. THE GLVE IS MUSIN6 motion (c) FORTH-79 Version 1.2 to be AND IS n LITTLE KNOWN CINCH en^ BET. IF VW TWE THE 11- TO ENTER IT ONTO VOUI run on a 48K *Apple lI. FORTH DISC. VW SWOUD MU€ FUW BOTH WVZING IT IWD TCEN ENTERTAINING COA Therefore, the following words nre HUSTLING1 FRIENDS lylD FLylILV WITM IT. m-standard but included in the micro- OF cams YEN PUVING ni I) S(YI YOU WST USE I\ RE& DECh OF URDB Mi IT UWLD motion FORTH. PROEA6LV TEND TO DI8UWFc(YIE YlYiERIlO IF IOU YYY~LD BRING YOUR *MICRO* win v0u.b Home - position the cursor to the -- upper left comer of the CRT ond clev the SCR.5: CRT to blanks. ( ENCODED CaYSTIWTS 31 BY TONY LEYISI t NOIEI THEM CWSlIWTS ME USED ONLY and CH are wed to the TO CONCEIY THE SaUTION OF THE 6ME. CV position NOT TO WETHE CODING WlIRD TO FOLLOW') input cursor anywhwem m the text win- dow per Ex. 4 CV 10 CH moves the cursor LI CONSTIWT t I to the 4th (pun) row 10th column of Ll CONSTIWT c2 &I CONSllylT tZ. screen. u CONSTIWT t4 SETINV, SETFLASH, and SETNORM Hfr rat flags in the output wbroutiner t COMCONS Apple CD EF I tlb Bc I - 41CB - ' I1 ' which respectively cause a11 rubsaquent UC FE I EA CB I - 4K7 - . C2 ' characters to be displayed on the text CEEDe LYBDI - SFb- 'b3' screen inverse, flashing and rmrmrl mods EC M 8 CA DB I - IFDO - ' K4 ' 1 without affecting charcten already dis- DECInnL played. -- SCR*J4 In closing, I wish to thank Bill Rqsdnle ( SETUP W UTILITV WORDS 31-TONV LEYISJ for his gracious wort and I especially CREOTE DECI acknowledge the incredibIy patient treat- 'J. 4.4.4.4.4.4.0. ment 1 received from Phil Wewon of VMIMLE CAkDSWl VIYlIULE QIUESWON Micromotion as he neatly led me throuph I NWWfUi t FIRST. NEW DECC ) my FORTH initiation. 71WI2IDECk +4SYCIP'LOOP OCIYIDW(r' HCNlE 4CV:

Tony Lewis 8 y*YDECtuIc( CR CR 100 Mariner Green Or. ."THE DECI Woy UYI1I)INS Corte Madern, CA 94925 7 i DO I ( NOT J** I a DEct + co r DUC~ DO ) wp (415) 924-1481 IF 1* 1 Ck W J . LOOP (415) 924-4216 (late hours) ELSE WKlP THEN LOOP l?CH .* THE RUNNINO TOTIY IS " CMMa . : *Apple is I registered trademark of Apple : enwLnv Computer, Inc. i FLM EAD Knv) o CR CR --.' B6D TYPE-IN" WOWDECABUI : SCR4I60 MAINLINE UORDB CON1. 31 BY 1ONV L.EYIS) : HVBIOBETI CR CR hl DUP CWWSUM CS + CI - kI HOD - PEDIN CR CR WP UPMTEDEUSUW 0-

IF DROP k3 DUP WD~TEDEChSUM DROP THEN ." M* PLAY 16 . OHOWWCKIWI 3 I

I HVbIGIETZ CR CR IF DW WWTEMCKSUl DROP ELSt kl ChRDBUr( C3 k2 - I1 HOD - OW' UPDATEDEC#WU 0- IF DROP k4 LlLlP WDATEDLCKWM DRW IF ." ." T%N iLsE ." 0.'' THEN .I-MV PLnv IS * . SCKHIWCLSUM 3 I TCEN CR --\ ." VW YTYlN f YB10 " .* PLAY BIS IT. TMN ELBE NoRIIIys1 THEN THEN UNTIL I I 31rwls (uwlO31 coD€cow llnxNs1 :

FoRTHcussEs LAXEN AND HARRIS, bJc. 24x1 Southlend Drive Heyward, CA 94545 (415) 887-2894 Introductory cl-es Procaw control Application8 prognmming Systems level programming

GREG STEVENSON Anaheim, CA (714) 523-4202 Introductory classes

KNOWARE INSTITUTE OF TECH- NOLOGY Box 8222 Stanford, CA 94305 (408) 338-2720 Introductory classes Graphics classes

MNER ACCESS CORPORATION Belmont, CA (415) 591-8295 Introductory classes

FORTH, NC. 2309 Pacific Coast Highway Hennoaa Beach, CA 90291 (213) 372-8493 Introductory classes Advanced clauses SmATEDT'EKTRWCS 4010 GRAPHCS WITH FORTH by Timothy hang Screen @ 10 Portland, OR 97211 0 Video controls Lor Columorr HI?b4 TLJI 111OT111 t In this article, I am going to tell a true story. For those people wh think FORTH is a religion, they might just consider this to be my testimony.

Last November, I had accegl to a very little known, but well built microcomputer -- MX 964/2 by Columbia Data Productr, L?-: I Enit Inc. of Maryland. This little machine has two Z-BOA CWs. One is for the Host and the other for terminal. There are 64 K of RAM in the Host, and 32 K of the Ter- minal RAM is dedicated to the 512 x 256 bit mapped graphics. It also includes a 9" CRT, 2 double density drives, keyboard, 4 Screen 11 serial ports, and 4 parallel ports. It8 all in 0 * Grapbrc PaEkA(e - i T3K one piece. It boots up with whatever operating syitem is on the disk after powered up and the carriage return key has been pressed. Beautiful isn't it?

However, there is a big problem, as with most microcomputer companies. the instruction manuals are terrible. And I mean terrible! Let me just give you om examle: "For this information, please me figure -", only to find there was no such figure and no page number.

Graphics are om of the mast impor- tant featurea with this machim. 512 x 256 bit mapped graphic Is the best that can be expected under the price a1- lowance. There are quite a few wdl known microcomputera on the market claiming High Resolution Graphics. But tbHI* Resolution cmea am just like a big blob compared with the individual pixel that bit mapped. So, I have a nice machine with all the fancy graphic capabilitim, but lacking the key to open it. Anxiety mounts up quickly.

I have a friend who's an excellent 8080/Z80 assembly programmer. kb im- plemented UCSD PwcaI for a microcom- puter. Naturally, since he ww the flnt one, it seemed logical to seek his help. With a poorly written computer marnml

1% (we at least knew that the graphic part simulates Tektronics 4010), he spent a whole week just trying to draw one mere quare along the edges of the CRT. Seem- ingly It would be M easy job, but even so it never came near to what he would have liked. Later on, 1 apent a couple of weeks twiddling with Microsoft BASIC compiler and it alw, produced lousy results.

At the name time, I received my 8080 fig-FORTH lirting. So, 1 typed the whole 60 K of auembiy listing with the lousiest . .. text editor (Lo., ED. COM). It was a mon- ....,I IC I umental job. Nevertheless, I had the fig- FORTH up and running.

By now, I waa very desperate to get it going. Equipped with the FORTH power and the poor manual, I set forth to try the graphics again. Again, I sought help from a friend who works for Tektronics and is experienced with FORTH. With FORTH, the whole task turned into a very simple job, compamd to the previous attempts we

---I . had with the aasembly and BASIC. Thus, 21' . now 1 am steadfast in my belief in --- FORTH. . *Ti?: , Screen 10 and 11 sets up the variables and the Columbia Mx964 hardware depen- iireen t 16 dent words. The X-coordinate starts at 0 the lower left corner as 0, far right as 1025, while Y = 0 starts at the lower left comer to the top as 779. Screen 12 to 14 defines the basic words, which draw the 4 line, move the cursor, relative draw and move. Screen 15 defines the words to c draw a aquare and the erasing of it. Screen 16 lets me draw many squares. a P I know that there are still a lot of nice ;0 words that can be written, such as, to 11 draw triangles, curve lines, etc. But, from :1., ., this small exercise, I am totally convinced .. the FORTH is the one I will use from now ...I on. I.

r7 , i PLATANOS &-'BAhlANAS I ,& AWXOVERSIONffMASTERMMl SCR # 1s David Butler 0 ( Master Mind in Forth by David A. Butler DCIB-17nov80 1 Dorado Systems 1 --> L David a. Butler The writing of this program mrved as 3 33300 Rission Blvd my introduction to FORTH. Using the fig- 4 art 126 FORTH Installation Manual, 1 stumbled my 5 Union City. CA. 94587 way through the basic concepts of FORTH 6 ( 4 15 ) 407-6034 and eventually arrived at this video 7 Master Mind game. The game is derived 8 completely frum the original board version 9 ***I)* A note about style: If there is any. it is an accident. of Mmter Mind, therefore, ail credit for 10 This was my first arrlication in Forth. so it NY lack the game itmlf goer to the Invicta Garme 11 some eledance. Company. 1L 13 ***)+*Requirements: A video disrlay 80 x 24 characters. The program contaim many of the 14 cursor addressind and clear screen functions found in video editom, including 15 functions. cursor management and character col- lectioh The mquence of this computer SCR # 19 version of the game is as follow: After (3 ( Master Mind -notes- DLIB-17novSO ) displaying the directions, the program 1 --> prompb the player to enter his skill level. 2 This is an implementation of Raster Mind by Invicta. Then a 'secret code' is generated with the 3 The same is very rorular because it is easy to learn and a help of the player tapping the pace bar. 4 challense to rlav. There is a bit of luck to it. hut it IS The screen is cleared, and a 'mask' of the 5 mainly an exercise in losical deduction. A "secret" code is Master Mind playing board is dirplayed. 6 denerated. and it is "cracked" by analyzind a set of clues. The cursor ladat the location where the 7 8 Those familiar with the oridinal board uill have player is to begin entering his quean. The dame n*> program retains control of the cumor, re- 0 difficulty adJustin* to the computer version. To newcomers. ponding to tho player's key strokar. 10 follow the directions carefully and YOU will have it in no Backpacing and tabbing am allowed, en- 11 time. The Forth version is functionally identical to the 12 board version. It IS written in fid-Forth. and has been run 13 successfully on 6502. 8080, 280. and 68000 crocessors. It 14 is a dood demonstration rrodram as w11 as an enJoyable dame. 15 SCR # 20 0 ( Master Mind set UP some variables DCIB-17novSO 1 1 2 : TASK : ( FORGETTABLE MER 1 3 4 o vamasE COLORS 28 &LOT COLORS 30 ELMS 5 6 0 vmxa*E 2 &LOT o VCINIM~LEGUESS 'r KLOI 7 0 VCIRIABLE SECRET 2 ALLOT 8 0 VCIRXCIBLE BLKKER 0 VARIABLE WITEN 9 6 vaRxamE COLORS 11:) 11 3 VARIABLE CUR.RW 23 VARIABLE CUR.COL 12 I vamamE XLOC 1 vaRxamE YLOC o vmxataLE 170~ 13 --> 14 19 SCR il 21 0 ( Raster Mind set UP - cont. DAB-17novMJ ) 2 : C.CONSThN1 ."YELLOWRED BLACK GREEN WITE BLUE 3 4 0 VARIABLE COLOR.KEY 6 &LOT ( "colors" table 1 s 6 ( Use the sum 06 the ASCII code of the first 3 letters ) 7 ( 1.e. BLUE m "B" + "L" + "U" 46 + 76 + 85 = 227 ) 8 9 234 COLOR.KEY C' 219 COLOR.KEY l+C! 10 207 COLOR.KEY 2 + C! 222 COLOR.KEY 3 + C! 11 232 COLOR.KEY a + c! 227 COLOR.KEY s + c! 12 96 COLOR.KEY 6 + C! 13 14 0 VCIRIABLE MTTEMPPTS ( used to keep score 1 15 --> SCR # 22 0 ( Master Hind rromrt and randomize DA8-17nOV80 ) .bllnp the player to keep changing hi8 1 ( There definitions set the random valuor for the Sam ) purr until he ir ratisfied that it is conrir- 2 tent wlth the cher he ha8 thug far receiv- 3 I NEWCOUNT ( CCOLORW + 13 ) DUP #COLORS e < ed. A correct gww is the rerult of the 4 IF l+ ELSE DROP 1 THEN I plryer'r loglcrl deduction (or very good 5 luck) baaed on his pmviwr clues. The 6 : RAND 1 BEQIN NEWCOUNT ?TERMINAL UNTIL KEY DROP I directions on cmen 51 explain the mean- 7 inp Of the tWO type8 Of ChJe8. H I ASR.FOR.RANDOH .I' To randomize* tar sraco bar 4 tines." 9 4 0 DO RAND I SCQDE + C! LOOP CR 1 when the player dgnalr he is ready, 10 tho program compare8 the playerh guess 11 : C18K. FOR. LEVEL to the secret code which war rtored away 12 CR ."Level 1 or 2 7 I' KEY WP EMIT KEY EMIT aulier. clues are generated and dis- 13 YO = IF 7 #COLORS ! ELSE Q YCULLlRS ! THEN CR 1 plryed, indicating to the player how ciore 14 h I8 to the solution. The player ha8 ten 15 --:> chances to deduce the mcmt code. SCR # 23 0 ( Master Wind translate color to numeric DCIB-lhOV8C) Them am many improvements which 1 cwld k made to thir program to take ad- 2 : COLOR.FIND ( LCOLORYI ---- t3 TYPES COLOR F"I #) vantage of. more of FORTH'S built-in 3 1 - 6 a C.CONSlAN1 3 + + Q TYPE I vocrbuluy -- moot notably PAD and m- 4 Imtd words. For those short of memory, C; : TRANSLATE.CODE note that the directions could be short- 6 ( converts color Y from SCODE. to CWOR.KEY 1 mod, Iaft out, or mad from disk with no 7 ( numeric v4lue in array "SECREl" f change to the overall logic of the pro- 8 4 0 DO SCODE I + Ct! 1 - COLOR.KEY + C(L SECRE.1 gram. U I + C! LOOP : 10 Further note8 Md comments may be 11 found in the source acreens. 12 1 '? 14 : .J R:- R.' R:, CC:OMPILEI R sww .>R SWAP >.H sww i~ : 1s --_ :;l:R # 24 1.1 ( Master Mind cursor motion DCIB-17noveO 1 1 ( Of course. CRT dependent. Here IS Herth: ) - ( *** start IXT dependent wards 4*4 ) 3 : C'I-IHSI~IR ( CY] CXJ---L] AP30Ll.lTE CltRSClR FOSITIiIN ) 4 31 + SWW 31 + SV 27 €HIT FMI'I EMXI EWiT : 5 6. : 8:LEAR ( C:LEAR L-KT SC:RE.EN ) 27 EM1 f t.9 fllT : 7

( *it* end ot !::FC.l dePcnder*t words *** ) : SHI~IW.Ci>LCIRS ( pISF'LcIY l>OLClR CHOICE$; ) 7 1 ti6 I Z + 58 CURSOR I CTJLiM. FINCt LOOP 12 #I:.CILCIH!; @ 7 = IF 4 5'7 CIJRSCIR . " r:EtLfihiY>" ELSE THFN 1 .:: - 11 TF: I:UR'I;OR ." TAP between colors." 14 1 3 48 CUR>;ClR ." PkTIJRN to Set s-1 lJ25. " ? 17 -- .= -. -.I- R # 2:s 0 I Master- Wind hoard lrvnut mask T"2- 17r-nv90 ) 1 ,I : t(&R . " :I' : : DCISH . '* .-" : ( BOdRLI SVrltCDLC~ I ? : 1ITLE 21 .pAi:E!:; 4 . II ____---- r( A 5, T E R fl I N El ===='I : 5 : tI,qs;HER 2 zi 'i-1~80~BAR 32 I? DO . I* -01 Loop I.R : b : CLINE DUP 21 C'UHSCIR B&R 54 C:IJRSOk PAR : I

I .I 8 : 'jPACER 21 CURSOR .I' ______"'__-_---."------* : CBLOCI: DUP CLINE 1+ SPACER : : HItlD€N .3 23 CL1RSI:IR ." XXXYXX XXXXXX YXXXXX IYXIXX" : 11 12 : DISPLAY. BCiARD 13 C:LECIR TITLE DASHER HIDDEN 24 5 Ui.1 I CBLOCK 2 +LCIoF.' 14 SHOW. C-OLORS : 1s --:> 3CR 0 26 0 f Master Mind cursor trackins definitions D(18-17nov80 ) 1 2 : X XLOC Q : : Y YLM: B : 0 4 : XBIJMP X 52 = 'T IF 23 DUP CM.COL ! XLOC ! k. ELSE 1 XLOC +I x CIJR.CUL e 8 + = ? IF X CUR.COL ' THEN ::: ::: THEN i i,

13 : IJNBIJflPX X 23 IF SZ XLCX I ELSE -1 XLOC +! THEN i 11 11 : TAB CUR.COL B 47 = 13 IF 23 CUR.CUL ' 14 ELSE 8 CUR.COL +I 15 THEN LUR.COL Q XLOC ' DROP Y X CURSOR i --L::. SC:R W 27 Ct ( Master Mind character collection/editinr DCIB-17nov8G ) 1 : BCICC'SPACE X C1JR.COL e = 2 IF DROP 3 ELSE UNhUMPX Y X CURSOR SPACE Y X CURSOR DROP 4 3i' C:clLORS x + 2.3 - i" c THEN I 6. 7 : PROCESS ( [CHAR] -- [I PROCESSES CHAR, WNAGEY t.:URSOH ) :3 DUP EMIT COLORS X + 2.3 - C" XBUMP Y X CURSCIR : 9 10 : GET.CHCIk KEY DUP 127 = 11 IF BACKSPACE ELSE ClclP 9 = 12 IF TAB ELSE UUF' 1.3 = 1.3 IF 1 DONE ' DRDP 14 ELSE PROCESS THEN THEN THEN : 15 --> SCR 0 28 0 ( Master flind guess / row section l3AB-17r10v80 ) 1 2 '3 4 : INITIAL 2 3 + rxlP YLOC ' CUR.RW ' 23 23 XLClC S ' CUR.COL ! Y X CURSm b 30 0 DO 32 I COLORS + C! LOOP : 7 8 : OET.COLORS INITICU. 0 DONE ! BEGIN SitT.i'HAH DCJNE @ UNTIL i 4 10 : PARSE.CiUESS 4 0 Is0 I 8 COLLRS + C.e 11 I 8 0 COLORS I++ ce 12 I 8 CClLLW:-' 2 + + CB 13 + + I GUESS + C! LOW : 14 --> 1s SCR W 29 0 ( Master Mind Clue ¶eneration DAB-17nov80 ) 1 2 : CLUE.C:HECK 3 o BLACKER lee- o WHITEI; 1 ( INITIALIZE COUNTC: 4 4 0 ti0 5 SEC:RET I + C.e GUESS 1 + i(P = ( CHECK FOH UrREC:T HIT ) t IF 1 BLAC:KER +I 0 I WEYS + C! 7 THEN LOOP 8 4oDc1 GI-ESS 1 + I::@ 0 > IF ( IF NO HIT '5 4 0 DO 10 GUESS I + i:C SECRET J + CC = ( CHECK FUR WI IF. ) 11 IF 1 WHITE& +I 1 I GUESS + c:! LEAVE 12 THEN 12 LOOP THEN 14 LOW i 1s --:>

a SCR 4t 30 0 ( Master Mind rrerent clues DAB-l7novO 1 AHJouNaMpm 1 2 : GIVE. CLUES PARSE. QUESS CLUE. CHECK NEW JERSEV FIG CHAPTER BEING '3 Y 1 C:URSOR BLACKER a - .I' BLACK " FORMED 4 WHITER 0 . ."WHITE " I S : UNMCISk. .3 23 CURSOR lntemmted partiw drwld contact: 4 o DO I SCODE + cc COLOR.FIND I 3 - Geap 6. Lyon 7 IF . " " ELSE . " " THEN LOOP 23 1 CURSOR I 280 kbndonon st. 8 (212) 696-7- - by8 '3 : %GAIN 20 98 CURSOR .'I TYPE MCISTER TO" 21 58 CURSOR (201) 451-2905 - eve8 10 . " PLAY AGCIIN. " UNMSK 23 1 CURSOR ; 11 : LOSER 16 98 CURSOR ." NICE TRY PUT" 17 58 CURSOR BOSTON FIG CHAPTER SEEKING 12 .I' NO CIGAR." WGCIIN 1 MEMBERS 1 1: : WINNER 16 58 CURSOR ." PRECISELY. " MTTEWTS ? 14 .'I TRYS. 'I 7AGCIIN : lntemmted partiem &odd contacctt 1'; --:, R. I. hmmw Box 1S8, Blv. Sta. SCH # 31 P. 0. Andover, MA 01810 0 ( Plaster Mind Directions to rlaver lMB-17novM1 ) 1 (617) 3896000 x 198 - W& L.I . DIRECTIONS CLECIR CR CR CR OR CR (617) 664-5796 - home 3 10 0 DO LOOP " We1 comv to MCISTER MIND. CR CR . MOUNTAIN WEST FIG CHAPTER 4 ." The object of Master Mind 1s to break the secret code." ORGANIZDJC 5 CR ." The computer will rick the secret code. and YOU must" Two o+ aiven:" CR t. CH ." figure it out. kinds clues are lnteremted putiem in tha greater Salt Lake .i CK .I' (1) Y BLCICK means # correct " rR that YOU havv reds City ema mhould contacctt ::: ::: in both color and rorition." CR CR Bill l-bywood (2) Y WHITE have 0 of " OR ." mean5 that YOU reds the (801) 942-8000 10 correct color that lire incorrectly '* CR 11 P1.C.d. " CR CR TECHMCAL PRODUCTS W. MOVES 12 ." Be sure to spell the colors corructlv. You may tab .mound " 1:: 1C-H ." the 4 ~ositlonsuntil YOU"VC make Your hert duess." C:R New addrama 14 CR ." 'IY.PC CRETURNI to receive clues." CR C:H .*I Oood-luck." 15 I:R c'H : --> P. 0. Box 2358 BOUIB,NC 28607-2358 ,: ,: LR- # '3;. CI ( Master Mind ++ FlNAL ++ DLIB-17nov80 ) FIG NEW YORK ClTY MEETING 1 CONTACT .- :. ... Jamem Bamilc 4 40 Circle Drive Westbury, NY 115900 (516) 333-1298 7 DALLAS-FT. WORTH METROPLEX FIG MEETING CHANGE

Meetings now being held at: Software Automation, Inc. 1005 Businem8 Parkway 4 Richardson, TX E contact: Marvin Eider (214) 231-9142 Bill Driamel(214) 264-9680 TRANSFER OF FORTH SCREENS This insurer that the proper disk blocks If that is inconvenient, a variable contain- BY MOOEM are reddent. After the LIST, the receiver ing an offwt or rtarting receiver ocreen will reply "OK" followed by a carriage re- number could be added. Guy T. Crotke turn. WAIT makes the transmitter wait Forth Gear for this carriage return. This is the only The pmof that it work8 ia before you: San Dieqo, CA handshaking needed. Each lit-& text is the different Emen formato and distant sent preceded with the letter P and a screen ~'Wmbors reflect the fact that Here IS E simple but hopefully useful space, and followed by a carriage return. acreen 58 written on mY osI and rent set of definitions for serial transfer of WAIT causes the transmitter to wait for to my APPLE to be printed. 1 have rued FORTH screens between machines. the receiverto reply WOKII each lim these definitions to .end a 6502 aaaembler, Several of us in the San Diego FIG are in- is sent. SENO is a multi-screen tramit- a databarn manager, and several hundred terested in sharing software, but we have term Note that the range of wmem re- data entries between my machine8 with no been unable to do so because of all the ceivad and recorded on disk will corms- troubb. different disk formats in use. While only a pond exactly to tha screen numbers sent. few had access to similar machines, we took a poll and found that more than 90% had f?S-232 ports. The following two ri.il Screen lranster -- sending GTG 7-UZ-81 screens permit unidirectional transfer I HtX

with a modem over telephone lines at 300 -' : 50111'PUl 7. 2122 c1 ; ( StND OUTPUT TO SERIAL + CONSOLE t baud or hardwired at 19,200 baud. The '. : CULlTPUT 2 2x22 C' : ( SEND OUTPUl ONLY TO CONSOLE definitions are not particularly sophisti- 4 : SINPUT 1 2321 C' ; ( GET INPUT FROM SERlAL cated. Theye is no error checking or 5 : CINPIIT 2 2321 C' : ( GET ZNPUT FRW? CONSOLE ack/nack with retry. Since it is source o : 5UUl SOU'IPLIT 1:INPUT ; : SIN COUTPUT SINPUT ; code which is being transferred, some .' : 01.. ; : WAIT SIN QUERY ; editing will probably be necessary anyway, 8 : SEND .SCREEN ( SCRI --, nothing left J so such safeguards aren't worth the effort 9 SULJT DUP . ." COUTPUT LIST SOUTPUT " CH WA17 to write them. 1 0 111, 0 DO I SOUT . ." P 'I I OVER .LINE CR 11 WAIT CINPUT ?TERMINAL IF LEAVE THEN Loor : There are four definitions which are 12 : SEND I FIRS1 SCFW / LAST SCR* -- nothing left t entirely system dependent in each 1: 1+ SWAP DO I SEND.SCREEN 3TERMINCIL IF LEAVE THEN LOOP screen. These are SOUTPUT, COUTPUT, 14 SOLJT CR WWIl SOU1 :' FINISHED '' CR COUTPUl ; SINPUT, and CINWT. Respectively, they 15 DECIMAL :S direct output to the serial port, output to the console, input from the serial port, and input from the console. If your sys- tern doesn't use I/O flags or vectors, you bCh' 1 81-1 may have to write serial port drivers and 1.) ( CONSULEiSERIAL I/O ) point KEY and EMIT to them for 1 FORTH DEFINIlIONS HE4 SOUTPUT and SINWT. In screen 80, 2 : UNLINK FDFO 56 ! FDlB S8 ! ; these four words are defined for an .I. : SOGTPUT c2o1:) 56 1 ; APPLE running a serial interface in slot 4 : LCIUTPLJl FDFO 3b ! : two ( driver at SCZOO ). In screen 58, they 5 : SINPUT C200 38 ' : are defined for an Ohio Scientific with the b : ClNPUT FDlh 38 ' : normal serial port found in the personal 7 models. These are examples of vectored H EI)ITOR DEFINI T IONS and flagged 1/0 redirection. V It.# : FINISHED CINPUT COUTPUT FLUSH ; The remaining definitions should be 11 : P COUTPUT P SOUTPUT ; quite universal among fig ( and other ) 12 : RECEIVE COUTPUT SINPUT ; systems. Screen 80 contain8 all that is 1; FORTH DEFINITIONS EDITOR necessary to receive screens under the 14 DECIMCIL control of the sender. FIMSHED and 15 is RECEIVE simply redirect input and out- put. The word P redefines the fig editor word P to do the same thing except with I/O redirection. Note that these three definitions are simple and fool-proof enough that they could be sent to another WWANTED computer if that computer was first told to accept all input from the serial transfer Part-time - New Yar(rhbw Saay ~rse FORTH pmgrrmmsrr to im- line. Once these definitions were com- Amid internationally known sound plement Marx FORTH for TRS-80, -1% piled by the receiving system, screen ertist, Max Nwhaus, develop additional CP/M and other sydems. Royaltier paid transfer could begin. In screen 58, the eoftware for micro computer controlled for bed implementation with mob m- word WAIT waits for anything to be sent sound synthesis system. FORTH con- hencements. Great oppatmity for thc back from the receiver with a carriage trolling 32 synthesize? from CRT Light competitive programmer who, like mc. return on the end. The word OK is defined Pen Terminal. would like to make a living at home ad just in case the receiver sends one or more not have to move to California to do it. OK's back to the sender bring transfers. Moderate fees, travel possibilities, Cmtach SEND-SCREEN will send a screen to the hardware experience preferred. Marc Perkel receiver, one line at a time, by emulating Send informarim or resume to: Perkel Softwant Systems a user entering lines with the receiver's Max Neuheus 1636 N. Sherman line editor. First SEND-SCREEN asks the 210 5th Avenue Springfield, MO 65803 receiver to list the screen being sent. New York, NY 10010 (417) 862-9830

- Page FORTH DIMENSIONS floating-point format. Numbers can be a8 system. Related programs can be grouped large as 1E38, and (u rmall 18 1E-38. together in disk files, rather than in wp- arate vocabularies. (Multiple vocabularies SOR~ER-FORTH Transcendental functions find their moat usage in multi-uaer sys- by Quality Softwarn tems.) The floating-point format mentioned For about a year, I have been wing an above makes TramFORTH a natural lap- Compilation end weed excellent version of flg-FORTH tailored uage for trarucendental functionr. Func- for the Exidy Sorcerer. It is a product of tions included in the syrtem whlch are not Ail entrier in TransFORTH are com- Quality Software, 6660 Reseda Blvd., found in moat verdons of FORTH plied directly into 6502 machine language Suite 105, Reaeda, CA 91335. include: sine, coslne, tangent, arctangent, for greater speed. No addrew interpreter natural logarithm, exponential, quarn is used. Even immediate keyboard entries FORTH for the Sorcerer implements root, and powers. are compiled before being executed. This Release 1.1 of 8080 fig-FORTH. It in- means that ro,Jtines can be tested at the cludes a full screen editor and input/- Date structures knyboard for speed before being added as output routines for the keyboard, acreen, colon definitions. and both serial and Centronics printers. TransFORTH contalnr words that will The Sorcerer's excellent graphic8 are also store or fetch 5-byte floating-point TransFORTH is fast. It is not as fast available. valuea, 2-byte cells, and slpla bytes from an integer versions of FORTH, becausa it any location in memory. TrmaFORTH handles 5 bytes with every stack manipu- Disc storage is simulated in RAM. A does not have the fig-FORTH

FORTH DIMENSIONS IIIl5 PagW "Starting FORTH' compatible FORTH POLYMORPMC FORTH software for a 8080 or Z80 computer Abstract Systems, etc. system with the CP/M (TM) operating 1686 West Main Soad FLEXFORTH system. Portsmouth, RI 02871 (401) 683-0845 Complete compiler/interpreter, assem- Copyright (C) 1981 by Laxen and Harris, Ralph E. Kenyon, Jr. bler, editor, operating system for: Inc. All rights rererved. Product Description: FORTH (Polv- APPLE 11 computers $25.00 This FORTH implementation is com- Morphic fig-FORTH 1.1.0). 8080 fig- KIM computers $2 1.M) patible with the popular book "Starting FORTH 1.1 without asmb. or Editor (uses FORTH' by Leo Brodie. It is intended to PolyMorphic resident editor.) FLEX-FORTH is a complete structured be a companion to the book to aid leaning language with compiler, interpreter, FORTH. It is also a complete environ- A demo application which computes a editor, agembler and operating system for ment for developing and executing FORTH table of values for a general quadra:ic any APPLE II or APPLE 114 computer with programs. It containa: equation is included. 48K and diak or KIM with 16K of mem- Compilers ory. Moat application programs run in less Disk operating syrtem PolyMorphic Systems 8815, 8810 needs than 16K starting at 1000 HEX and often Full names stored, up to 31 characters only 16K. Documentation on FORTH not as little as 12K, including the FLEX- String handling included. FORTH system, itself. Enhanced error checking 16-bit and 32-bit integer arithmetic Manual: documentation covers parti- This is a full-featured FORTH follow- and input/output cular implementation details for fty- ing the F.I.G. standard, and contains a This is a single-user, single-task sys- FORTH to interface to the PolyMorphic Systems Microcomputer. Sorted VLIST 6502 assembler for encoding machine tem which is not ROM-able as supplied. included. language algorithms if desired. The Floating point arithmetic and CP/M file assembler permits macros BEGIN... UNTIL, access ere not wpported. BEG IN... AGAIN, BECIN...WHILE... Implementation document available separately. Separate document avaiiable REPEAT, IF... ENDIF, and IF...ELSE. .. This system as supplied runs comfort- for cost of postage. Product data avail- ENDIF. Editor and files ably in a 8080 or 280 computer system able PolyMorphic SSSD 5" diskette are linked to the Apple DOS 3.2. An ap- with at least 32K bytes of RAM memory, on format. 4 copies sold to date. Price: plication note for upgrading to DO5 3.3 is at least one floppy disk drive (8" single $40.00, includes shipping, diskette, (R.I. included. Object code on disk with uaer density, single sided, soft sectored format manual sells for $25.00. (APPLE) or on is ammad), and the "BIOS" part of the residents add 6% sales tax!. Warranty limited to replacement of a diskette cawette with user manual for $21.00 CP/M operating rystem. The use of a (KIM). damaged in shipment. (We'll try to fix any printer is wpported but not required. This bugs discovered.) Orders shipped out aoftware may be easily modified to use A complete source listing is available within 3 days of receipt (usually next day). other memory sizer or diak formatr. It to purchasers of FLEX-FORTH for requires 14K bytes of memory which in- $20.00. The mrce is valuable in both cludes 4K byte8 of didc buffers. ahowing how FORTH works and in giving t-EATH HB9 FORTH MCA examplea of FORTH code and integrated This FORTH rystem was adapted from aaaembly code. 8 Newfield Lane the fig-FORTH model but is not fully Newtown, Conn. 06470 compatible with that language dialect. It Order from: GEOTEC, 1920 N. W. ir also not fully compatible with the Milford Way, Seattle, WA 98177. sure MCA announces the availability of Be FORTH-79 Standard. The three dialects to apecify machine. FORTH for the Heath H89 computer. are similar, but the Starting-FORTH ver- MCA FORTH is 8080 fig-FORTH V1.l MARX FORTH Vl.1 sion har advantages over the othar two. configured to run on a single disk HE9 with Perkel Software Systems 32K or more of memory, utilizing HDOS 1636 N. Sherman Price: $33.00 - ph$2.00 - Patage and 1.6 or later. Springfield, MO 65803 (417) 862-9830 CP/M is a registered trademark of Digital MCA FORTH provides the standard Research, Inc. FORTH facilities plus the following Enhanced 280 figFORTH implemented special features: HDOS file manipulation for Northetar System enhancements in- 2. Learning FORTH capability, a control character to restart clude link fields in front of name for fast Learning FORTH ir a computer aided FORTH (recover from loops), on-line compile rpeed; dynamic vocabulary nlink- inatruction package that interactively tailoring of FORTH facilities (e.g., num- ing; coact; stgumants-mults with 'to' vari- teaches the student the fundamentals of ber of disk buffers), ability to hook to sep- ables: and more. 79-Standard package in- the FORTH programming language and arately assembled routines, and use of cludes eaay to use acreen editor. philoaophy. It consists of a set of Heath DBUG. FORTH acreens that contain program Ricer mm source code and instruction text. It is Items supplied with FORTH include the based on the book, "Starting FORTH," by fig-Editor, an 8080 structured assembler, Smart sgembler, meta-compiler and Leo Rrodie. It will run with any Starting and two games provided as examples of mrce code (in FORTH) aold separately. FORTH compatible system, as well as fig- FORTH programming. Call for information. FORTH system. The manual is only one page long and describer how to load the The documentation wpplied with MCA FORTH is suitable for experienced TM)NmPRooucTsFRoM system. After that, everything is self explanatory. It is wpplied on 8" single FORTH programmers; however, a bibli- uu

FORTH OIMENSIONS lnl5 NEwPRooucTsmoM one 8" diskette. Currently, there are approximately 75 in- brEER ACCESS CORWRATlON stallations, after 2 months on the market. Rice: si,mrn 1. Fig-FORTH compiler/interpreter for Ri@9Om Includes diakette, ROM, PDP-11 for RT11, RSXllM or stand- 5. Zilog 28002 Development Module fig- manual, shipping and taxes. alone with source code in native 88- FORTH RDM set. Conteins 79-Stand- sembler. Included in this package are ard FORTH with 28002 assembler and PET-FORTH, as all other DatatKmic aft- an assembler and editor written in editor in 4 (2716) PROMS. Rm: ware, carries a life-time guarantee. All FORTH and installation documenta- )zaom future versions will be distributed to the tion. Price: $90.00 registered owners without any coat what- cooE9 -soever. This is available on a one 8" single Arthur M. Gorski density diskette only. 2240 S. Evenston Avenue Delivery is immediate. Tulsa, OK 74114 Reference Manual for PDP-11 fig- (918) 743-0113 US dealers are invited. UK sole distrib- FORTH above. Price: $20.00 utor is Petalect Electronic Services Ltd, CODE9 is a M6809 Assembler for use 33/35 Portugal Road, Woking Surrey. You 2. Fig-FORTH compiIer/interpreter for with any fig-FORTH system. It features may also order directly from us. CPIM or CROMEMCO CDOS system all M6809 addressing modes except long comes complete with source code writ- relative branch instructions. It performs ten in native assembler. Included in syntax error checking at agKmbly time. Diskette of FORTH &#icotim Moddm this package are an assembler and Memory requirenents: 4.75K bytes free from editor written in FORTH and instal- RAM above FORTH. CODE9 is distribut- Timin Engineering Company lation documentation. Prii: $90.00 ed as a commented source lilting and 9575 Genessee Avenue, Ste. E-2 manual. Ri: tm#1 Sen Diego, CA 92121 All diskettes are single density, with 5- (714) 455-9008 I/&'' diskettes in 128 byte, 18 sector/- PET-FORTH track format and 8" diskettes in 128 by The diskette of FORTH application byte. 26 sector/track (IBM) format. modules, a new product by Timin Engin- Datatronic AB eering, is a variety package of FORTH Released on two 5-1/4" diskettes with Box 42094 source code. It contains hundreds of source in 8080 assembIer. 5-126 12 Stockholm FORTH definitians not previously pub- Sweden lished. Included on the diskette are data Released on one 8" diskette with (0)-8-744 59 20 structures, software development aids, source in 8080 assembler. Peter Bengtson string manipulators, an expanded 32-bit vocabulary, a screen calculator, a typing Released on two 5-1/4If diskettes with Product Description: Extended fig- practice program, and a menu gener- source in Z80 assembler. FORTH for the Commodore CBM/PET ation/selection program. In addition, the computer series. diskette provides examples of recursion, Released on one 8" diskette with , IEEE handling, strings etc. includes a METAFOHTH"&oss com- 3. Charles Moore, 63 min. Rice: sS#1 piler which produces a 28002 79- Manual is available separately. Standard FORTH compiler/interpreter 4. FORTH, Alan Taylor, 47 min. Rice: for the Zilog 28000 Development Separate prrchrs price ir $40.00. This is $Ism Module. Package includes a 28002 -not creditable towards later purchaw. assembler, a Tektronix download caplet8 .I)t s6sm program and a number of utilities. Product/Ordering Data: Shipped as disk- edu-FORTH ette and an accompanying recurity ROW 1142-A Walnut Street, t3J2 Released on two 5-114" diskettes or on holding part of the Kernel. Berkeley, CA 94709

FORTH DIMENSIONS III/S Peg= 165- FORTH

The following vendors have vedm of Software Fsd.~Um ClQlO FORTH available oc M armltmts. (FlG 44 University Emperical Rea. Grp. makes no judgment on y products.) or. Arlington H.IQM.. P, u#y P. 0. Box 1176 Milton, WA 98354 ALPHAMICRO (312) 259-1355 Professional Management brvim (206)631-4855 Techicol Roducta Arartradero Rd. 1109 Co. 724 P. 0. Box ~Bllmhmd- Palo Alto, CA 12983 94306 Caimville, FL Datricm (415)858-2218 32604 (904)372-8439 7911 NE 33rd Dr. Portland, OR Sierra Computer Co. 97211 Tom Zimmer (sox284-8277 617 Mark NE Falcoto Or. Albuquerque, NM 87123 292 Milpitar, CA 95035 Forward Technology 2595 Mmrtin Avanm APRE Santa Clara, CA lDpC Company mz 95050 (408)293-8993 P. 0. Box 11594 FSS Philadelphia, PA P. 0. Box 8403 19116 Rodtwell Intematiod (215) 676-3235 Austin, TX 78712 (512)477-2207 Microelectronics Dovim P.O. Box 3669 IlJS (Cep'n Software) AMheim, CA 281 Arlington Avenue 6mo&6w9 92803 Berkeley, CA 94704 Kenyon Micm8yrt.m (714) 632-2862 (415)525-9452 1927 Curtis Awnw RedmdoBeach,CA 90278 ZmnQx Corp. Dougherty Rd. George Lyms (213) 376-9941 6398 280 Henderson St. (Mlin, CA 99566 Jersey City, NJ TRsdo 07302 VUi&ydFORMRoductr (201)451-2905 The Micro works P. 0. Box 1110 hteractive Computu System, hc. Microblotion 001 Mu, CA 92014 6403 Oi Marco Rd. 12077 Wilhrrs Blvd 8506 (714) 942-2400 Tampa, FL 33614 Los Angela. CA 90025 (213)821-4340 Miller b4icmcompuL.r SrVier Mountain View Prua 61 Loke shon Rd P. 0. Box 46% CROSS CmPkmS Natick, MA 01760 Mantain View, CA wo40 Nautilus Systems (617) 653-6136 (415) 961-4103 P.O. Box 1098 Smta Crur, CA 95061 The Software Farm Supersoft Aemciates (408) 475-7461 P. 0. Box 2304 P.O. &r* 1628 Rwton, VA 22090 Champaign, R 61820 (217) 359-2112 POW~~ FORTH, Inc. Sirium Syrtems 2309 Pacific Coast Hwy. 7528 Oak Ridge Hwy. cmJtr*r Hermwa Beach, CA 90254 Knoxville, TN 37921 Creative Solutions, Inc. (213)372-8493 (615)693-6583 4801 Rand~lphRd. Rockville, M3 20852 LYNX rwn Dave Boulton 3301 Ocean Park I301 Eric C. Rohnke Smta Monica, CA 90405 540 S. RrrhView Clrcl. #61 581 Oakridge Or. (213)450-2466 Anhslm Hills, CA 9ZOB7 Redwood City, CA 94062 (415) 360-3257 M & B Desipn %turn softwar., Ltb FORTH 820 Sweetbay Drive P. 0. Bbx 397 Go Sumyvele, CA 94086 New W~mlnirtsr,8c 504 Lakemead Way vn4~7 CANADA Redwood City, CA 94062 (415) 366-6124 Merapolk Shew Labs, Ltd. aallmmmm 0. Box Ldorrtay Micmyr(mw Inner Accew P. 3471 Marine View Hayward, CA 94540 4147 Beethavm x 517K &Imont, CA (415)276-6050 Lor angel^ CA 90066 94002 (213) 390-9292 (415) 591-8295 Mmhstu John S. James The Softwaro works, Inc. Timin Engineering Co. P. 0. Box P. 0. Box 9575 AVO. IE-2 340 4386 Berkeley, CA Mountain View, CA 94040 Sm Disgo, CA 92121 94701 (408) (714) 455-9008 736-4938 Lum h Harris, Inc. ApgTdmpdup. 24301 buthld Drlve, 1303 law-11 l-kyward, CA 94%) Laboratory Software syrt.mr, -syI hc. (415) 887-2894 3634 Mandeville Cyan46 2150 Shttuck Amu Lor Angeles, CA 90049 Meley, CA W704 (415) 8436114 Microryatems, Inc. (213) 472-6995 2500 E. Foothill Blvd., #lo2 P.u&no, CA 09 D.cirion R.aurca Cap 91107 Consumer Computsn 28203 Ridgefmm Ct. (213) 577-1471 8907 LaMesa Blvd Rncho PI10 Vd,CA 9Q274 LaMara, CA 92041 (213) 377-3533 (7 14) 698-8088 FORTH mmEnSlOns

FORTH INTEREST OROUP Volume Ill P.O. Box 1 105 Number 6 San Carlos, CA 94070 Price: $2.50

168 Letters 170 Tec hnotes 174 Techniques Journal: Execution Vectors Henry Laxon 175 Charles Moore’s BASIC Compiler Revisited M.i chael Perry 180 8080 Assembler John Cassady 102 Skewed Sectors for CPM Roger 0. Knapp 106 Graphic Graphics w Bob Gotsch CLU 107 Cases Continued 195 FORTH Standard Team Meeting 196 1982 Rochester Conference FROM THE EDITOR FOATH OI~E~SII~S Hi! I'm happy to say that starting with this issue, I'll be nerving as regular editor of FORTH Dimensions. I'd like to thank Carl Street, the previous editor, who has been a great help to me during the transition. Carl has ma& several important contr!hu- Published by Forth Interest Group tions to FORTH Dimensions, such as the writer's kit for helping you wbmit articles. Carl will rejoin FORTH Dimensions RS our Volume Ill No. 6 MarchlApril 1982 advertising director beginning later this year.

Publisher Roy C. Martens I'd also like to thank Roy Martens, the publisher, for su9- Editor Leo Brodie gesting that I take the editork post, and for teaching me some of the facts of life in magazine publication. Editorial Review Board I hope to make this magazine as useful as possible to the Bill Ragsdale greatest wmber of people. Since most of our readers are still Dave Boulton learning FORTH at one level or another, 1 intend to encourage the Kim Harris publication of tutorials (such as Henry Laxen's excellent series John James which continues with this issue), application stories (sure, FORTH Dave Kilbridge is fun, but letb show the world what we can & with it!), exarnples Henry Laxen of well-written FORTH code (the best way to learn style IS by George Maverick reading elegant examples), and any ideas, discoveries, impressiorrs Bob Smith or feelings you care to express (this is ywr magazine, after all!). John Bumqamer Gary Feierbach In short, we'll be concentrating on how to use FORTH in Bob Berkey solving problems.

FORTH DIMENSIONS solicits editorial material, comment8 By contrast, system implementation details are more the and letters. No responsibility is assumed for accuracy of materlal renponsibillty of the individual vendors' documentation. In submitted. MOST MATERIAL PUBLISHED BY THE FORTH addition, the FORTH community boasts two organizations INTEREST GROUP IS N THE PUBLIC DOMAIN. Information in devoted to improving and extending the language: the Standards FORTH DIMENSIONS may be reproduced with credit given to the Team and the FORTH Modification Laboratory (FORML). Each author and the Forth Interest Group. of them grarps convenes annually, and the proceedings of these conventions (available thmugh FIG) are extremely valuable docu- Subscription to FORTH DIMENSIONS is free with membership mentr for the advanced study of FORTH. in the Forth Interest Group at 515.1Xl per year (527.a) foreign air). For membership, change of addreso and/or to abmit I'm looking to each of yw to help make this the kind of material, the address is: maquins you want it to be, by contributing articles, examples, and letters. We don't have a staff of writers, so everything we Forth Interest Group print comer from you. (If you want to contribute but don't know P.O. Box 1105 what or how, drop me a line. 1'11 send you the information kit that San Carlos, CA 94070 Carl put together, and answer any questions you may have.)

I hope you enjoy FORTH Dimensions. And remember, 1 hope to heu from all of yw. FORTH was created by Mr. Charles H. Moore in 1969 at the Leo Brodie National Radio Astronomy Observatory, Charlottesville, VA It was created out of dissatisfaction with available programming tools, especially for obeervatory automation.

Mr. Moore and several associates formed FORTH, Inc. in 1973 NEW POUCY fo the purpose of licensing and support of the FORTH Operating System and Programming Languege, and to wpply application The 79-Standard has been voted on and adopted to serve as a programming to meet customers' unique requinmenb. common denominator for transportable FORTH code and for future dincumtion of FORTH systems. Beginning with the next The Forth Interest Group is centered in Northern Callford& iswe, FORTH DIMENSIONS will give preference to articles that Our membership is over 3,500 worldwide. It was formed in 1978 adopt the 79-Standard by FORTH programmers to encourage use of the language by the interchange of ideas through seminars and publicatian. Listings which UCJ words that are not 79-Standard are welcome, but if possible explain such words in a brief glossary with a note that they are not 79-Standard. For instance, if your PUBUC NOTICE application addrews the name field of a definition (which is illegal in the Standard), you should supply a glossary description Although the FORTH Interest Group pscifies all Its pubk8- of NFA tims are non-copyright (public domain), aeveral exceptions exist. As a matter of record, we would like to note that the If powible, also include the definition of such a word. High copyright has been retained on the 6809 Aaaembly listing by level rarm is preferred, but if necessary, the definition may be Talbott Microsystems and the Alpha-Micro Aaaembly listing by written in assembler. Robert Berkey. Several conference papers have hsd copyright reserved. The general statement by FIG cannot be taken an We hope this policy will encourage unification, eliminate absolute, where the author states otherwise. ambiguity, and simplify explenations.

Page 167 FORTH DIMENSIONS Ill16 LETTERS

FORTH Applicatim ubmry wait state). I gueu I designed for geed. being edited ahould change. M vioiabs this rule* G daer not. >ear fig, hst want to stick up for the 01' 2-80. If other people can brag about how com- One further point: G inmrts the new As distributors in the u< for FORM pact their implementatiw am* can't I line g the current line, not under it. This IT., with a rapidly growing customer brag about how fast mine is? allows you to alter line 0, which M cannot. -ase, we are potentially interested in any Timln mncm aDplication software that is generally LOOPTEST 23 2.9 The next extension is BRING , which -seful. -TEST 5.9 7A gets several lines. It takes (block/line/ *TEST 44n 54.9 count-). I find G and BRING extremely Most of our customers are in the pro- /TEST 74.3 88.6 useful. Commenta are solicited. :ess control/industrial/scientific sectors hiich, by their nature, require fairly ape- Barudb 4.61 Mike Perry :.alized and customized software. Never- LOOPTEST 1.7 1.1 :heless, we are sure there are many areas -TEST 6.8 4.5 I agree: G is more satisfyinq from the

:f commonly useful software and that *TEST 17.5 11.7 uaer's point of view. With MI I find myself sxh software would be useful even if only /TEST 29.4 19.6 checking back and forth between the 3s a starting point or guideline, in order to source and destination blocks repeatedly. ;void too much reinvention of the wheel! Note - The problem of copying a line onto line Such software might be offered as free All times in seconds. Each test involves zero with I'M" reminds me of the =me md unsupported, at media cost, or as a 32767 iterations. problem one has with W" (also in the :.largeable product. Whichever way, it "Starting FORTH' editor). I'd like to point -'eeds to have at least some documenta- No, I don't use any pedal hardware. out a simple way to 8'push" a line onto line :.on,(i.e., overview and glossary) but it Istthe normal 2-80 instruction set. That zero, moving the current line zero and :xs not have to be a professional pack- mulitply threw me off when I first timed everything else down: :?e. it, but the cycles add up &out right. I just can't figure out why everyone elm is 0 T U This will be the new line zero We have an initial enquiry from a user so slow. OTXU #YO needs a 3-term controller program for servo control, and some process mathe- Idon't have mas storage. That's why I The second phrase swaps lines zero and --a:ics for numerical filtering and linear skipped the last two benchmarks. I store m.--ed. :onversion. As he said to us, "surely everything in EPROMs. Much faster than someone has done this before and written those clumsy mechanical devices. I up enough to be useful?". So can you FORTH in its ckm Write TIP? If you're offering something free, Allan Bonadio xrhaos we can do a trade for somethinq 1521 Acton St. Dear Fig, YJ wwld like. Berkeley, CA 94702 The two paragraphs below appeared in If people are interested in application Editor's Note: m article in BYTE Magazins on pg. 109 of ?Kchanging we would be happy to act as a the August 1980 issue. When it first -ode' for making contacts. And where Here is the code for the benchmarks appeared, 1 agreed with what it was saying aameone has some software that has a published in Volume 111, No. 1: but did not feel the need to point it out to Tarketable value, we are interested in others. Now, however, 1 think that it's xloing to create and promote viable :LOOPTEST time to remind all of us about FORTH and 2ackages. We'll not make any firmer plans 7FFF 0 DO LOOP ; what it isn't. Clearly it isn't any other I- suagestions until we hear from you! : -TEST language. 7FFF 0 00 I DUP - DROP LOOP ; Nic Vine : *TEST The most important criticiam of Director 7FFF- 0 00 I CUP DROP LOOP : FORTH is that its source pro- COMSOL : /TEST grams are difficult to read. Treway House 7FFFODO7FFF I / DROPLOOP; Same of this impression results Hanworth Lane from unfamiliarity with a lan- Chertsey, Surrey KT16 9LA guage different from others in common use. However, much of To 'W or not to it results from its historical Benchmark BattIes development in systems work end Dear Fig, in read-only -memory -based 3ear Fig: machine control, where very I would like to comment on the "Start- tight programming that sacrifices I believe that the primary considera- ing FORTH Editor." The "MI command is clarity for memory economy can '.on of an implementation be fluency of bad for reasons of safety and philowphy. be justified. Todayb trend is >se, and not speed or size except when It takes a line from the current am, strongly toward adequate com- soecific problems arise. But after reading and puts it "out there" somewhere. If it menting and design for readabil- :ie "Product Review" in FORTH Dirnen- goes to the wrong place (them things hep- ity. -ions IW1, page 11 and seeing some pen), good luck finding it. -enchmarks, I couldn't resist trying the FORTH benefits most from a same on my own home-brew implementa- A far better alternative b the inverse new, different programming "on: 4mM 2-80, S-100 bus (one wait command, which I call "G" for "get." G style; techniques blindly carried jtate on all memory ref%). These are the takes the seme parametera as M (block/ over from other environments -esults I got, plus another column correct- line-) and gets a line onlo the currant can produce cumbersome results. TJ for my slower clock (but not for the screen. I believe that only the amen

'ORTH DIMENSIONS 11116 Page 168 It atill eludes me as to why people local chapter% Secretary will make the insist on building things into FORTH which neceMery copier to distribute to members are "imports" from other language struc- Dear fig, of that Chapter. tures and that in most places do not have any logical place in FORTH. Surely they Greetings from the Frozen Wasteland! So, letb see those handouts from all would not be used by a good FORTH pro- the Cheptera! Write to: grammer. Take as a simple example spec- This letter is to inform yw of the ings. FORTH does not impose indentation formation of a Minnesota chapter of the John Cassady or strict spacing requirements as do some FORTH Interest Group. We have had two 339 15th Street other constructs, so why do people insist meetings so far, with attendances of Oakland, CA 94612 on indenting? I disagree that this contri- twelve and sixteen respectively. We plan butes to the readability of the language as to be meeting once a month. Anyone who FORTH is one of the most terse con- is interested should get in contact with US structs in existence. One might say that a first at the above address. Brain-System first attempt lo improve the readability of FORTH should center around removing the We hope to $tart some kind of news- cryptological do-dads that are used. For letter in the near future. I've heard that Dear fig, instance, I@'' should be renamed it's possible to get copies of program list- "FETCH'. Likewise, " : " should be re- ings and other handouts which have The special FORTH issue of Dr. Dobb's named "STORE" and "." changed to appeared at Northern California meet- Journal made a deep impression on me and "PRINT". ings. Cwld yw please let us know how we on my son. My son is since 12 years a go about getting copies? I have enclowd a system programmer and knows more than Obviously this is absurd and so is the SASE for you to respond. a dozen computer programming lan- notion of indentation and other pseudo ~u4es.I am a logician and engineer, code spacing requirements that some say con- one of our members is running a Con- designer and the developer of the only tribute to "good prograrnming style." ference Tree (a Flagship for The Commui- existing proto-model of Interdisciplinary Good programming style is writing clear, Tree Group) which we hope to use for Unified Science and Its computer- concise, fast code that does simple things interchange of ideas, programr, etc. at- compatible language, the UNICODE. and then usiT that and Other code to side the general meeting, end to comple- construct more complex definitions. This ment the newsletter. The phona number Thus, I represent a radically different is the premise upon which FORTH was for that Tree is (612) 227-0307. The path of scientific development--dlsre- based. I have seen readable code that was FORTH branch is very garse right now, garded by many because it does not sloppily written, too big for the job that it however, since we are Nst getting off the promise immediate financial returns. attempted to accomplish and in a single ground. word was abominable. However, it My approach is centered on a new and "looked neat and clean." We are also contacting local computer far more encompassing system-idea of the groups about jointly qonming FORTH temporary name "brain-system" having a When the FORTH 19 standard was tutorials for specific machines, and pro- physical-hetero-categorical genetically released I applauded. We are all aware of viding a public-domin, turn-key FORTH ordered sequence of models of logic. This the small ambiguities and possible defi- system that will turn on their machines. sequence has a specific case for present- ciencies in the standard. However, the We currently have such software for the day formal logic and a corresponding sim- standards team must be commended mere- Apple II, SYM-1, are clow on an Osborne- plified variant of the system-idea: this is ly becauae they exist and they at least 1, clone on an OS1, end are seeking out a &he system-idee of the digital computer. attempted to create a standard of some TRS-80 version. kind. Why then don't people write in stan- UNICODE is the first' gecific brain- dard code? It aggravates me to see code Well, that% our plans for the next few system programming language. It IS a in your journal prefixed or post-addended months. We wwld appreciate your cur- content oriented language, it has powerful by a phrase similar to "all you need to do rent mailing list of Minnesota rerkknts semantics and register-techniques. It has to bring this code up to the standard (55xxx and 56xxx zip codes, Ibelieve). "words" which are at the same time total is..." Why not write standard code in the programs for the generation of the invars first place? Hope to hear from you so& and "content" the term intends to com- municate. This letter is purposely provocative Mark Abbott and I sincerely hope that you decide to Fred Olmn I think to study UNICODE will lead to publish it. Through it 1 hope to force a re- Co-founders of MNfig unauspected breakthrwgh in the develop- evaluation of the way some individuals ment of programming, especially if think- look at FORTH. Some of us still think Happy to hear ebwt your new ing has been made elastic and modular by that FORTH is elegant because of its chapter! Your mailing liot is on its way. studying FORTH. simplicity. It is unfortunate that many And yes, handouts from the Northern Cali- refuse to see FORTH as the beautiful fornia Chapter meetings are availeble. I wwld like to receive the private language that it is, but see it only as Here's how to obtain them: addresses of a few creative FORTH fanr another language that they'd like to In the hope of your early reply, 1 remain... rese &lee John Camady of the Northern Cali- fornia chapter has agreed to serve ad a J.T. Currie, Jr. clearinghouse. The Secretory of any FIG Prof. Dipl. Ing. D.L. Szekely Virginia Polytechnic Institute Chapter cm mail, each mth, handouts P.O. Box 1364 Blecksburg, VA 24061 from his own Chapter's meetings to M. 91013 hrusalem, Israel Cassady. In return, John will send back December 1981 WeUexpressed, on both points! Regarding One set of all handwts he receives each the use of the 79-Standard, see our "New month, including those from the Northern Policy" at the front of this issue.--ed. California meetings. Even if a local Anyon, follow that?--ed. Chepter has no handouts, the Secretary must sent at least 8 pastcard to indicate the Chapter's continued interest. The

Page 169 TECHNOTES

px3Lo9~Lbn fa6502

Andy Bipps 41, Lode Way Haddenham Ely, Cambs cB6 3UL .EYTE t87.'LHCLOSE' England .vop.F L243 .VDRD **2 L DA Cr82 On converting my 6502 fig-FORTH JSR SSETUP (V1.1) to work with 256 byte disc mcton, I TXA SEC discovered (after many system hang-ups) SBC eS8 that WFR's 'ENCLOSE' primitive b not TAX guaranteed to work with die sector 8kw STY s3.x STY SI .x IIITIALISE AS BEFORE greater than or equal to 256 bytea in sirs. SETTING HI INDEX - d DEV his 'ENCLOSE,' Bill ums the 6502 Y DEC sn*3 In DEC Sl.x ?RIME THESE VAPIABLES FOR LOO? register to index through the input text L313 I NV stream, but this register is only 8 bib, II BNE XXXl I NC tN+3 II(CREMENT Hl ADDRESS if the text stream contains a block of I NC 81 .x AND HI INDEX delimiter characters, eq, 'space' bigger XXXl L DA (SW*S).V GET CHARACTER FROM lN?UT STREAM than 256, it will loop forever, as I fwnd to CW? SN IS IT DE-IMITLR 7 BE0 L313 LOOP IF TRUE my cost: s TV t4.X NOW-DELIMITIR SO ?UT FIRST L DA $1 .x RESULT ON I+€STACK When will this occur? Never from the STA t6.X terminal input buffer, which b only BO characters long. L3ll 1DA (SN*Z) .v GET CHAUMCTZR ASAlN BNE L327 BRANCH IF HOT 1. MULL With a disc sector size of 256 or STY t2.x STY s0.x TIDY LIP RESJLTS FOR 'PULL' EXIT bigger, if you have cn entire sector of L DA $1 .x spaces in a load screen, then the load will STA s3.x hang up on this chunk of spaces. TVA CWP $4 .x IF FIP.ST AN3 LAST INDEXES ARE EOUAL or... SNE L326 If your actor size is bigger than 256, then 1DA $1 .x CW? S6.X THEN any chunk of spaces 256 or bigger will BNE L326 hang it. I NC s2.x INSREWENT THIS RESULT BNE 1326 1NC s3.x I encountered this becaue I decided to L326 JWP NEXT emulate John &meal method used on the POP-11 version, where R/W' handles L327 PHA SAVE CHARACTER 1K STY t2.X every time, so as far as BLOCK, BUFFER, L DA $1 .x SAVE CURP.ENT IN?FX AS OFFSET TO and ENCLOSE are concerned, the dhc STA s3.x FIRST DELIMITER AFTI:!l TEXT 1NV block is 1024 bytes, and compiling hung up 8NE XXXS on any text gap bigger than 256 bytes! I NC $1 .x INCREMENT 1 WEX I NC SN*3 AND H1 ADDRESS xxxs r LA RECOVER C HAZAC TEF. Anyway, I ENCLOSE (ha ha) a revised version of the ENCLOSE primitive which I am now using, which !ws full 16 bit index- ing. I'm sure some assembly language progmmmer could produce a neater ver- sion, but at least I know that thh One CW? tW : IF NOT DELI~ITEP. works. BIE L318 : THEN Lo(, STY t8.X : ELSE Exi'r Keep up the good work. JWP NEXT

By the way, I'm williq to act as a fig software exchange/librery in the u<, unless there is someone already doing it?

FORM DIMENSIONS W6 Page 170 TRANSEN1 DEFINITIDNS Phillip Wasm

Editor’s Note: This article eppeared in FIRST 1000 - CONSTAW TAREA ( Transient area addruss ) the last issue, but, unfortunately, without VARIABLE I” TAREA TP ! ( Tramimt pointer 1 the source code. Here is the article as it t TRAPJSZENT f --- Am1 should have appeared. Our apologies. HERE TP B DP I i I PERMANENT ( ADDR --- ) HERE: TP ! DP I I These utiliites allow you to hsve tern- 8 DISPOSE ( --- porary definition (such as compiler TAREA TP ! W-LINK words: CASE, OF ENDOF, ENDCASE, EECIN DUP GODO, etc.) in the dictionary during BEGIN e w TAREA u( UNTIL DUP ROT WP o- compilation and then remove them after LINTIL DROP VOC-LINK compilation. The word TRANSIENT BEGIN DUP 4 - moves the dictionary pointer to the “transient area“ which must be above the. end of the current dictionary. The tern- UNTIL. DLJP ROT PFA LFA ! DUP Om porary definitions are then compiled into UNTIL DROP Q WP 01 this area. Next, the word PERMANENT UWIL CROP LCOnPILE FORTH DEFINITION8 t restores the dictionary to its normal location. Now the application program is ( Examr)* 1 compiled and the temporary definitions TRANS I ENT are removed with the word DISWSE. I CASE 8,. t DISPOSE will take a few seconds because : OF .., I it goes through every link (including vo- I ENDClF 8 * * t cabulary link3 and patches them to bypasa ; ENDCASE 8 all words above the dictionary pointer. PERMANENT : DEMO1 NOTE: These words are written in 1,. CASE MicroMotionb FORTH-79 but some *** OF WWF The non-79-Standard .words am used. eee OF ENDOF non-Standard words have the fig- ENDCASE # FORTH definitions. TRANSIENT t EQUATE ( N --- 1 CREATE t INMEDIATE DOES) B STATE 0 IF CCOWILE LITERAL THEN I 7 EQUATE SOME-LONC-WORD-WP1E f ERMANENT : DEMO2 ( SOME-LONC-WORD-NAME is conwild) SOME-LONC-WORD-M . t ( as a Iit+ral 1 D1-E ( RMV- th. ~0-s EWar =-LONC-WORD-NAPIED ) ( CAsc, OF^ ENDOF, and ENDCASE tb ) ( dictionary. 1 DEMO2 7 OX ( Test DEMO29 it mints a ~~vIc). 1

RENEW TODAY! NOVA bqa FORMSLndubComsr the boundary batwem n d -1 (- n+l in Beri(ey'r pqmd ia c- Jdm K. Gotwals Robert L. Smith cally. The implementation wnto be Computer Technology Department even more efficient than that dscr&d by South Campus Cwrb C Brodie end Sanderaon ("Division, Reh- Purdue biversity DO, LOOP, and +LOOP tions, and Loops," Rochester Confern, W. Lafayette, IN 47907 1981). The only apparent dimdvanteqe of There have been some complaints the implementation is that tha index is ebwt the way that +LOOP is defined in computed by addition or wbtraction. A I have just finished installing fig- the FORTH-79 Standard. The first novel feature of Berkeyb implementation FORTH on my NOVA 1200, using the obvious problem is that the Standard does is that when the word LEAVE is executed, listing 1 received from fig. Instead of not define the action to be taken when the the loop is terminated at that point Lo., running it standalone, as the fig listing increment n is equal to zero. Presumably LEAVE actually leaves). Berkey also does, I run it as a task under RDOS Rev. that was either an oversight, or a typogm- sugqests that for normal positive 5.00. phical error. The most likely correction is incrementinq loops that the index range to treat the n=O case the same as m, should include the upper limit, in a manner So far I have found four bugs or omis- since the arithmetic is defined to be two's more consistent with other languages as sions in the listing. They are as follows: complement, and for that arithmetic, the well as typical uae in the fig-FORTH sign of 0 may be considered to be posi- INDEX. Finally, he suggests a construct Page 10 of the listing - EMIT does not tive. I am aware of other possibilities, but ao that a loop may be skipped entirely if a increment OUT. they seem to be fairly difficult to imple- cwnting parameter is zero. ment or explain. [COMPILE 1 does not work properly. It The work disussed above is of poten- can be fixed by removing CFA, from The second point that is mentioned is tial interest to future directions in line 07 on page 42 of the listing. that the parameter range seems to have a FORTH. It shows that FORTH is still strange asymmetry. When a positive in- evolving, even though it cannot effect the VCCABULARY does not work proper- crement is used, the DO-LOOP index I current Standard. ly. This can be fixed by adding CFA may not reach the specified limit. How- between AT and COMMA on line 53 of ever when a negative increment is used, page 44. the index I may be equal to the specified increment. Users of fig-FORTH systems have pointed out that the fig +LOOP is symmetric in the sense that for either !FLUSH) can not be accessed until a negative or positive increments the limit missing <51> is inserted after FLUSH value is never reached. One may consider on line 13 of page 52. that the Standard version terminates when the boundary between the limit n and n-1 After installim fig FORTH, I entered is crossed, whether the increment is the CYBOS editor from the keyboard and positive or negative. used this editor to boot the fig editor listed in the installation manual. After Finally it has been noted that the this experience, I am somewhat pessimis- Standard LOOP and *LOOP depend on tic about FORTH's portability between signed arithmetic. Many, but not all, word and byte addressing machines. I had FORTHs use a modular or circular arith- to make quite a few changes before the metic on 00-LOOPS, allowing the index I fig editor wwld run. Some examples: to directly address memory. The use of I to address memory in a Standard LOOP BLANKS expects a word address and may result in a non-trannqortable program word count. unless a certain amount of care is taken. The Standard version is easier to define COUNT expects a word address and than one involving circular arithmetic. returns a byte address. Note also that the Standard version allows approximately twice the range of most HOLD and PAD both return word circular loops (such as in fig-FORTH). addresses. The best suggestions for new looping If any RDOS NOVA uSers wwld like a methods can be found in a paper given by copy of my "fig-FORTH," they should feel Robert Berkey at the recent FORML Podtian Wmbd free to contact me. Conference. The paper is entitled "A Generalized FORTH Looping Structure." I I am looking for a aoftware engineering recommend that readers interested in the position with another compmy that uses topic get a copy of this pwer and imple- FORTH. I would like to work for a firm ment his suggested words. I wqwld like to using FORTH to develop state-of-the-art slightly modify his rewlts for the current systems software; specifically, a FORTH- discussion. Berkey essentially 8hows a based developmcnt and -rating system technique for looping in which the incre- environment to compete head on with ment for +LOOP may alternate between UNIX. positive and negative values withwt necessarily terminating the loop. Modular Brent Hoffman arithmetic is used so that either signed or 13533 37th N.E. unsigned use of the index I may be Seattle, WA 98125 employed. The increment may be any (206)363-0642 value. The terminating condition is when

FORTH DIMENSIONS nIl6 Page 172 9900 nmco

%inr F. Lrnk Loemdeiner Rlnq 17 6501 Woerrstadt Carmaiiy

I haw had mrne trohle qetLiilq tny 99W FORTH running.

To ease the findiiiy of i:rrors I wrote a proqrein to diglay all irrportarit vectors (IP, W, CODE, ri, SP) and thL. first 7 stack contents. Even the stack's qrowintl is visible.

1 would like to cnttributc: it to YUI, JI you can offer it to ell YYIW) usera with H AM3M or similar board.

It was a qrnat luck for ine that I did not need the addresses >57C wid >5711, WH! could u& it for a branch to ttin STAIIJ!, prmram..- This ormram IS switc:trctd off hv the code HEX 455 %4 : and switched 00 by HEX 457 384 ! .

44 46 48 4A 4c 4E 3) 52

BE V1:l 92 94 9b ?n 9A 9C 9E AO a2 A4 A6

118 M aE 92 TEXT " u-" 84 63 lCXl " Lllnt-" 6C 54 lCX1 A=** C? S', ILXl " SI'-" A TECHNIQUES TUTORIAL: EXECUTION VECTORS t-kwlry Lmm Laxm a Hnrrlr hc. 24301 Southllnd Blva Haymrd,CA 94545

This month, we contlnw our axplorr- however, control cb~cbnwlll rrccoad DIE Is urdto and m UTW -,_o tion of FORTH pmgmmmlng technlqwr and will be lncnmented by 64, mJtlnq the termlrul md Mttiu FORTH by taking a look at a concept known 08 them dlsplayabb. into a clean stab. D(0CuTE: m a ack Execution Vectors. Thb la really a fancy lng word which Initlallrw itdf o o& name for very simple concept, ~wly There are mveral other FORTH words but hopefully will be dungad lmtar by (hr using a variable to hold a pointer to a that have proven uaful to vector. %ma umr. Word8 defined with EXECUTE: cm routine that is to be executed later. of thaw include: be changed with IS as follow:

It is only fair to warn you that the KEY input from keyboard primitive EXECUTE: EMIT dialect of FORTH that I am using is the CREATE change header structures one discumed in Starting FORTH by Leo (EMIT) IS EMIT (or perhaps) Brodie. It has several differences from LOAD ussful for many utllltler CONTROL-EMIT IS EMIT figFORTH, not the least of which is the R/W didc i/o primitive fact that in figFORTH EXECUTE operates What EXECUTE has done is combined on code field addremes (cfa's), while in the variable MITIO with Execution For example, if LOAD were vectored, the Vector name into name. is used as Starting FORTH EXECUTE operates on then by redefining it to print a one IS parameter field addrees (pfab). acreen a convenience, w that the user cm forget This instead of loading it, you could write a may not seem like a big deal, but if you the internal structure of words defined by print utility which prints acream in Id have ever fed EXECUTE a pfe when it EXECUTE:. Alw it provides m extremely was order by LOADing a load smen md rode- readable way of redefining Execution expecting a cfa, you have undobtedly fining LOAD to print. CREATE could be remembered the result. Anyway, my changed to add the screen number of each Vectors. Notice that as defined, IS may EXECUTE uses pfab. Its function is to only be uwd during interpretation. 1 leave &finition to the dictionary header tbt perform or EXECUTE the word that thb so it aa exercise for the reader to define it cwld later be retrieved with VIEW or an pfa points to. An example will clear this the equivalent. KEY may be changed to an IS that may be compiled within :defini- tions. up. Swpow we have the following: get its characters from a flle somewham instead of the keyboard. ohart, there : GREET HELLO, HOW ARE YOU' ; In Another approech to redefining execu- ." are a thousand and one ums for Execution ' GREET ( LEAVE THE PFA OF tion vectora is via the word ASSIGN. It vectors. GREET ON THE STACK ) could be defined as follows: EXECUTE ( AND NOW PERFORM IT ) But be careful, I may have opened Pandora's box with the above selling job. the result is: There is a price to be paid for execution vectors, and that is complexity, the arch- HELLO, HOW ARE YOU enemy of reliability. Every word that you decide to vector at least doubles the com- vhich is the same reauk as just typing plexity of the FORTH system you are GREET. running, since it introduces at least two or more states that the system can be in. The above may not seem too signifi- It would be used as follows: You must now also know what the version cant, bct the implicationr are tremen- is of each execution vector you are dous. Consider the following examples: using. If you have 3 different EMITS and 2 different KEYS and S different LO-, VARIABLE 'EMIT you have a total of 18 different states that the system can be in just thew :EMJT on ( CHAR --) vectors alone. So urn vectors garingly, 'EMIT @ EXECUTE; otherwbe yw will Ion, control of the complexity very very quickly. ' (EMIT) 'EMIT! When UPPER-ONLY is executed, EMIT Having decided to un execution vec- Iamume that (EMIT) is a routine which is redefined to execute the code followinq ton, we're now faced with different takes a character from the stack and the ASSIGN, which will convert all lower approeches towards implementing them. sends it to the terminal. By defining EMIT cam chamcters to upper caw, and send The one described above works, and is to use 'EMIT as an execution vector, we them to the terminal. Note that unlike IS, umd by many people, but it has unfor- now have the ability to redirect the output one ASSIGN may only be used within : defini- tunate property, namely the need to name tions. of FORTH in any manner we choon. For a variable which basically overhead. example, ruppoae we want all control is Here another way to accomplish the character8 that sent to screen to is That's ell for now, good luck, and my are the same thing withart.having to define a be prefixed with a caret. We could do the the FORTH be with you. variable. Consider the following: following:

I DIE I --- 3 I co(lIIQ-RIIT , om --- ) I -1. THIS YOUD W -0). 1 ow 32 t LY I < IF t Catro1 mu? ) 94 .. ) IEMITI I Vn, nit an I I Emcurer 64 ( -11 A - I I ( .nd cmrrt Lt I -re I -- I 7)IEN c.1 OIL , (EMIT) ; w.> I -- I a ElEEVR 1 ' QYTIYLfMlT 'EM11 ! 1 I. t cca --- I *!, Now all regular characters will fail the test, since they will be larger than blanks; FORM DIMENSlONS W6 Page 174 CHARLES MOORE'S BASIC COMPILER REVISITED Michd Perry

In this paper I will dincur neveml executed during complhtim must be The word which decider how long to interesting featuren of the "BASIC immediate. Thin uaa of the FORTH com- defer compilatim in DEFER. DEFER Compi!er in FORTH" by Charles Moore piler wan perhmn my gmateot lemon from lookn at two pairs of numbern m the (198i FORML Proceedings). studying thin BASIC compiler. The ordi- ntack. Each pair connintd of an addreso nary FORTH compiler in far more VOW- and e precedence value. If the precedence Why is a BASIC compiler interesting? tile thrn 1 had realized. If I had written of the top pair in larger than that of the There are a number of reasons. Foremost this compiler, it would doubtkrr have run lower, DEFER doer nothing. If tha top of them is that BASIC is in many ways in the executim state end would hevs procadence is lea than or equal to the one typical of a variety of popular languagen, been far more complicated an a mwlt. below, the addrerr part of the lower pair particularly FORTRAN, PASCAL, and in compiled, and its precedence is dis- ADA. Conspicuous features of them lan- Let's look at m example. The BASIC carded. DEFER will cmtinue to compile guages are algebraic notation, lack of statement until the upper precedence in larger than access to the underlying hardware, poor 10 LET X = A + B the Lower. input and output facilities, and nmaxten- will be compiied into object cads OqUiVa- sibility. FORTRAN and BASiC also suffer lent to the FORTH exprenim So how do you get started? Esnen- from poor structuring due to the extensive X A@B@+SWAP! tially, moot BASIC keywords (arch as LET) u& of GOTO. These languages ali tend to where X, A, and 8 ara varilbn. b Of execute START wqhich leaves NOTHING be best at solving equationn. Other prom- the varilblen (X) return m addma, th 0 m the ntack, where WTHlffi is the inent features of BASIC are it s une of rent return valuer (with a fetch). The add addreas of a do muling routine and 0 is its statement numbem as labels, low peed, is compiled after the fetchen of the vahn precedence. Thin pair will remain on the and its um of a few complicated functimn to be added. The equals becoma8 the ntack during the compilation of that (e.g., PRINT) rather thm many simple SWAP ! at the end. Ekcaus the murce statement, becaurs everything has higher ones. code (in BASIC) in in algebbnk notatim, than zero precedence. and the (FORTH) object code h in mveme Why is it slow? BASIC interpreten polilh order, mm way b needed to At the end of each line, RPN in execut usually convert source code ntatementa to change the order of operation8 when com- ed. It performn a 0 1 DEFER, which an intermediate form, where keyword8 piling the BASIC program. The mecha- forcer the compilatim of MY deferred become tokens. The token interpreter is ninm which controls the compihtim order wordn, becane every aperator ha8 a pre- slow because tokenn munt be deciphered in bawd m the idea of operator pme- cedence of at leaot I. RPN then connumes (translated into actions) at run time. This &me, which meam that nome operatorn the 0 and executen NOTMNC. Actually, BASIC to FORM compiler producer code am asnigned higher priority thm oth.rr. each ntatement in ended by the start of which runs unuwaily fant. This is becaum the next. BASIC keyword8 arch an LET it produces FORTH object code, im., aa- PRECEDOJCE execute STATEMENT, which cmtains quences of addrennen of code routines. RPN (to fininh the previoun statement) and The idm of operator precedence b a START (to begin the rwxt). You should look at the example pm- prominent feature of mo$t computer Ian- grams (blocks 80-82) before reading the guagen (FORTH in a notabla excsptiod. BRANCHING text. You will notice that each BASIC Operatlmn are not neceuerily performed program becomes a FORTH word named in the order you wily. An exampb will Three new branching primitive8 are RUN. It is executed by typing it8 name, help. The equation X s 5 + 7 2 cauld uad. They are compiled by varioun higher i-e., RUN. Wn in how BASIC ururlly mom either Xt(5+7)*2 or XIS+ Level wordn. JUMP is uned by GDTO. works: you type RUN to execute the (7 21, uwally the latter. In FORTH thin SKIP end JUMP am ursd by IF-THEN. program. It nerves to dsmmntmte that would be 72*5+X:whsrs the order in JUMP in cwrpiled followed by an abmolute from FORTH's point of view, BASIC only explicit. In a4ebnk Irw~uqen addreso. When executed it nimply loads known one "word," RUN. In it not mom method b needed to clarify the order of that addrem into the IP (virtual machine useful and flexible to let routinen have my evaluatim of operatorn in exprerim. inntmctim pointer). When SKIP executen, name, and to be able to execute any of That in what prscedonce doer. Each oper- it taken a boolean off the ntack. If true it them by typing itn name? Yes, and that in etim in arrignsd a precedence level. 8dd8 4 to th IP, dC@ing (UWdly) the a key feature of FORTH. Operatlonn with higher prscedence are following JUMP. performed earlier. How It Works (NEXT) in usd for FOR-NEXT loops. bring compiiatim of the BASIC pro- It b compiled followed by m obsolte I will refrain from commting m the gram (the FORTH word mmed RWthe addrow. When executed it taken three intrinsic value of a BASIC compiler; that compilation of many words in deferred. parametem from the ntack: final value of has already been covered well in Mooreb Thh allow the order of word8 to differ the loq, hdex, ntep nize, and the addrenn paper. Ttm principal featursn I will db- between the wrce code end the object of the veriabb containing the current cuss are the handling of operator prece- code. Tdce an m exanpb. TO dater vabo of the bop index. It addn the ntep dence, variables in algebraic equatim, cowpilation of '+I a new word ia created (p~pQC minurr) to the variable, md loopn and the use of the FORTH compiler. The which b immediate (md m mecub8 at until the Wax paam the limit. most important part of this BASIC com- compile time). When thb new word b piler is its ability to convert algebraic Adding GOSUB would require another mwted, it haven tb addrew of I+' on (infix) scurce code to reverr polish (pont- the stack, and an top It &aves the pme- bmrhhg primitive, CALL. fix) object code. denca vah of '+I. fhs &fining word PRECEDENCE creamn the new word an A BASIC proghm in compiled imide foilown: It 2 PRECEDENCE + * Thb the colon cbfinitim of a word Mmsd . creates a new, immediate word ~mdI+', RUN. Thls means that the FORTH nyatem which will leave the adcimn of the old is in its compile state, and any words to be word '+Iunder tha value 2.

Page 175 FORMDIhENsfoNS m/ 6 STATEMENT NUMBERS Notlce thrt tho .quL, .cI * role in this proma: waryU&q b -m Each BASIC statement must be pre- keywords (e.g., LET) md vut.blr ceded by a number. This number acts as a label, allowing branches between lines. In Futum Directions this compiler, the numericd value of the labels does not affect execution order. Many more featurer can artily be When a statement number is encountered, added to this BASIC compiler. &t why port.bl. it IS compiled in line as a literal. The bother? A much more fruitful line of 00- m address of LIT is compiled followed by the endeavor wwld be to make uw of the of 1- md L literal value 10. For example, when the lessons learned in this compiler to write ws qwmmc?w W statment "10 REM" is encountered, 10 is compilers for other, more uaeful, Ian- Whether the eorrpulrr - compiled as a literal. The keyword REM guages such as C. A C compiler which is uaeful or not, it b rmrolllr ,-a IS immediate, and so is executed. It easy to modify and extend, and just as them. beqins by executing STATEMENT, which, portable as FORTH is, could actually be (acreens on fobnuirq -1 amongst otber things, fetches the value of :he line number just compiled (lo), and enters it into the statement number table ~/\S,' along with the address (HERE) of the start of that statement. STATEMENT t9en deallocates the space used by the literal 10 (with a 4 ALLOT). It scans the table and resolves any forward references to the new statement. When a forward reference occurs, as in "GOTO 50" before Marc Perkel statement 50 is compiled, GOTO compiles Perkel Software Systems 'JUMP 0'. The zero will later be replaced 1636 N. Sherman by the address of line 50. The reference is Springfield, MO 65803 entered into the table with the address to ie patched instead of the actual address r.f statement 50. Additional forward -eferences to the same point will be This article is rn enhancement of the compiler necurity comes in. rhained to each other. To indicate that idea presented by Kim Heris at the this is a forward reference, the address in Rochester FORTH Conference (from the The word >RESOLVE is filling a gap :he table is negated. This means that Conference Proceedings, page 97). left by >MARK . If >RESOLVE were to 3AS!C programs must be compiled below Basically, the article proposes a wordset first check to make sure a gap was there ?COCH, so that all addresses appear to be of primitives for defining control words ( WP @ 0 ?PAIRS it wwld help enam Dosi!ive. Here simplicity was chosen over such as IF , ELSE, THEN, DO, LOOP, that the value on the stack was indeed left qenenlitv. BEGIN , WHILE , REPEAT , UNTIL , by >MARK. Likewise, if THEN ) or back to a location not answering a >MARK . This method :5ings to notice about variables. They are previously defined ( BEGIN <- UNTIL 1. allows dme compiler security where it is Immediate, and they know which side of There are two steps in compiling either important not to carry pairs on the stack. an equation they are on. Three types of kind of branch: marklog the first place variablps are supported: integers, arrays, compiled and then later nwlving the Example: and two dimensional arrays. Variables branch. Thh observation leads to four of must be declared (defined) before use. Kim's words: >MARK HERE 0,; The BASIC expressions: LET X = A + B >RESOLVE OUP @ 0 ?PAIRS HERE (where X, A, and E are variables) compiles >MARK Marks the source of forward SWAP !; into the following FORTH equivalent: branch and leaves a qep. RESOLVE Resolves forward branch and IF C, >MARK; the left of an equals sign, it must compile leaves a gep. ENOIF >RESOLVE; its address, and when on the right side, its ELSE C3 IF SWAP ENDF ; value (address, fetch). Also note that only

FORTH DIMENSIONS II1/6 Page 176 llicbrrl Pwry !98: 78 0 I Charles More's BLSlC co~pilw,lnpat and Output ) : : RSK .' -J ' WRY ; 2 : PUT (MI#) SYnP ! ; 3 : IINPUTI CWlPILE PUT ; 4 : (,I I n) (,I I4 OVER - SPACES TIP€ SPACE ; 5 : , I n) "NORE ' (,I I MFER ; IlWlEDlATE 6 : ' [CWIPILEI .' ZDROP ; IllllEDlATE 7 INPUT DEFlMlTIOffi bRIT)II(ETIC DEFlWlTlMls 8 : , '16N8RE RPN 0 (IWWT) 1 RDOFXSS ' ; IIIIILPIIITE : * Ian1 WP! ; IPRECEDEKE. 9 :tlInn-nl 1 WID0 IMRILOI I; 10 MITHETIC DEFlMlTlM 6 PRECEDENCE 111 1: : WllMT STATERENT EOllPILE CR ' (,I I ; IHEDIITE 5 PRECEDENCE 11 I? : IIIPUT STRTEAENT ?DROP CWILE RSK ' IIWUT) 0 IRUT 4 PRECEDENCE I 4 PRECEXEE ,! 4 PRECEDENCE I/ 1: ! ADDRESS ; IMDINE 3 PRECEDENCE + 3 PRECEDENCE - 14 2 PRECEDEKE ( 2 PRECEDENCE 15

80 81 0 Dwycr, page 17, Proqraa 11 SCR [ basic: array dno 1 ECR 1 IWTEMR J IWTELR K INTE6ER K ? ? ARlMV COOllDlllllTE 5 : R'JW STRRT 4 IC PRINT TIIS IS n CO~PIJTER* : RWI START 5 20 FOR K = 1 To 4 10 FORK = 1 TO 7 6 ?O PR!WT ' NOTHINS CW 60' 20 LET CWRDIllATE K = I 10 - K I 11 3 ;40 FOR J = : TO 5 40 PRINT CWlRDlMlE K + 5 8 5P PRX ' YRM' 60 WEIT K 9 69 EIT 3 80 EllD 10 70 LIT I! I: 80 END I? 13 RFW 14 !5

82 : ? : basic: inputlwint I SER 1 LNTEEER K 2 IWfE6E4 I ? INTE5EQ V Illllllllltlltllllllllllllllllllllllllllllllllllll 4 I I 5 : RUN STRRT I Kicharl Perrv I a :? IWPUT I , v I l44h Stinnage Are. I 7 20 LET r = 1 t v it 3 I BerLe!ev, Calif. 94102 I 8 40 PRINT X , V , k I 14151 52b-Wb I 9 80 END I I 1? ;s lllollllllllltlllllllllllllllllll~llllllllllllllI :I .A1.) 1. :4

llichael Psry l?El A ROUNDTABLE ON RECURSION

Recursion, as it applies to FORTH, is At the end of the definition, =mi- : SUM the technique of defining a word in such a colon again executes SMUDGE . This WP1- DUP IF RECURS SUM RECURS way that it calls itself. One of the nicest toggles the bit back to its original state, ENOff examples I've seen of a good use for so that the name is again findable. + recursion can be fwnd in Douglas R. 9 Hofstadter's book Godel, Escher, Bach. There are various means of circum- He describes a system which can produce venting FORTH's protection against recur- 1 uae the RECURS word in tree gramatically correct phrases out of parts sion. Here are two recent contributions search. of speech. from our readers:

I'll use FORTH to describe his example: A Rowmion Tschnisus Editor's note:

: FANCY-NOUN Christoph P. Kukulies The technique that is generally pre- 4 CHOOSE Aachen, West Germany ferred was decrribed by Joel Petersen in (select random number 0-5) the original article. It defines MYSELF as C ASE 0 OF NOUN ENDOF Here is my mlution to the problem of : MYSELF 1 OF recursion in FORTH shown in a poasible LATEST PF A CFA , ;IMMEDlATt NOUN PRONOUN way to implement the ACKERMANN'a VERB FANCY-NOUN ENOOF function (see FORTH DIMENSIONS, Vol. or, for mme other versions such as poly- 2 OF 111, No. 3, p. 89). FORTH: NOUN PRONOUN FANCY-NOUN VERB ENDOF First test if ywr FORTH-syatem is : MYSELF 3 OF "crashproof" with the following sequencer LAST @ @ 2t , ; IMMEDIATE NOUN PREPOSITION FANCY-NOUN ENGOF :CRASH [ SMUDGE 1 CRASH: MYSELF simply compiles the code ENDCASE ; SMUDGE CRASH field of the latest header in the dictionary (the word being defined) into the defini- Three of the four possible variations on After having recovered from CRASH tion. FANCY-NOUN include a call on FANCY- yoit should try this: VOUN itself. Case 0 might produce The problem with using the word "books." Case 1 might produce "man who (m n -> ACKERMANN (m,d SMUDGE insids a definition is 1) it's not reads books." But Case 1 might also :ACKERMAW ( m n - ACK) readable, since smudging has nothing to do oroduce something more complicated, like [ SMUDGE 1 SWAP DUP O= IF DROP 1+ with what the definition is about, and 2) 'man who reads books that explain alge- ELSE SWAP DUP its behavior is different on different sys- bra," if the iner call to FANCY-NOUN O= IF DROP 1 - 1 ACKERMANN tems. decides to get fancy. ELSE OVER SWAP 1 - ACKERMANN SWAP Simllarly, having to say RECURS Normally FORTH deliberately prevents 1 - SWAP ACKERMANN ACKERMANN RECURS is not quite as recursion so that you c8n call an existing THEN readable as simply MYSELF. word inside the definition of a new defini- THEN ; SMUDGE tion of the same name. For example: An even more readable solution is this: Be aware of typing + SHOW-STACY t SHOW-STACK ; 3 4 ACKERMANN . : :R [COMPILE] : SMUDGE; IMMEDIATE This example might be a redefinition :R; of plus to teach beginners what the stack SMUDGE [COMPILE] ;; IMMEDIATE locks like before and after addition. The Amthsr RecMim olus that is called in the middle of the Here a qmcial veraion of colon end of &finition is the oriqinal + , not the one Arthur J. Smith memicolon named :R and R; are defined to 7eing defined. Osahewa Canada LIG 6P7 allow recursion without any other hoopla.

FORTH prevents recursion with a word called SMUDGE . This word usually tog- Regarding the recursion probbm, I qles a bit in the name field of the word think that I have found a more elegant most recently defined. With this bit tog- solution. The aoohrtion involves an g!ed, the name is "smudged"; that is, un- immediately executed word to re- recognizable. In the definition of t above, SMUDGE the word being defined. the colon lays down a head in the diction- <%ry.and then executes SMUDGE before I define a word RECURS as follows: RENEW compilinq the rest of the definition. : RECURS SMUDGE ; IMMEDIATE When the second t is encountered, the RENEW TODAY I compiler searches the dictionary for a then UJI) the word to bracket the recuraive word of that name. The new head with self definition as in the example: the same name is bypassed only because it has been smudged.

Page 179 FORTH DtMavsloNs IU/6 8080 ASSEMBLER JohnJ.cacwdy 339 15th Street Oakl.nd,CA 94612

This 8080 assembler has been available in a slightly different form for approxi- mately one and one-half yeare. It appears to be bug-free. Screen 48 30H 0 ( FIGFORTH 8080 ASSEMBLER 1 81AUG17 JJC 80MAR04 ) ENDIF 's have been replaced by THEN, 1 HEX VOCABULARY ASSEMBLER IMMEDIATE : 8. DUP + DUP + DUP + ; and AGAIN has been removed in conform- 2 ASSEnBLER CFA ;CODE 8 + ! ( PATCH ;CODE IN NUCLEUS ) ance with FORTH-79. 1 have never had 3 : CODE ?EXEC CREATE [COMPILE] ASSEMBLER !CSP * IMMEDIATE occasion to use AGAIN : I doubt if 1'11 4 : c; CURRENT s CONTEXT I ?EXEC ?CSP SMUDGE ; ~MMEDIATE miss it. 5 : LABEL ?EXEC 0 VARIABLE SMUDGE -2 ALLOT [COMPILE] ASSEMBLER 6 !CSP * IMMEDIATE ASSEMBLER DEFINITIONS ! have removed the compiler security. 7 4 CONSTAN; H 5 CONSTANT L 7 CONSTANT A 6 CONSTANT PSM We frequent!y want non-structured control 9 2 CONSTANT D 3 CONSTANT E 0 CONSTANT B 1 CONSTANT C mechanisms at the code level. The 9 6 CONSTANT M 6 CONSTANT SP ' ;S OB + e CONSTANT (NEXT) ?PAIRS really gets in :he way. 10 : IMI Ce SWAC 8. + C, ; 1 have introduced three macros: NEXT 12 : 4MI C$ C, C, ; PSHl and PSH2. They emplace, respec- 13 : 5YI Ce C, , ; : PSHl C3 C, (NEXT) 1 - , ; tively, a jump to NEXT , a jump to the 14 : PSH2 C3 C, (NEXT) 2 - , ; : NEXT C3 C, (NEXT) , ; byte before NEXT and a jump to two bytes 15 ;S before NEXT . Literally, PSHl means push one level (HL) and fall into NEXT. I Screen 49 31H 5elieve this is a more traditional approach 0 ( FICFORTH 8080 ASSEMBLER 2 81MAR22 JJC 80MAR04 1 and the source code has a cleaner appear- 1 00 1MI N3P 76 1MI HLT F3 1MI DI FB 1MI EI ance. 2 07 1MI RLC OF 1MI RRC 17 1MI RAL 1F 1MI RAR 3 E9 1MI PCHL F9 1MI SPHL E3 1MI XTHL EB 191 XCHC The actual address of NEXT is stored 4 27 1MI DAA 2F 1MI CMA 37 1MI STC 3F 1MI CMC in (NEXT! . Its value is plucked from ;S . 5 80 2MI ADD 88 2MI ADC 90 2H1 SUB 98 2YI SBB technique was suggested by Patrick 6 A0 2YI ANA A3 2HI XRA BO 2MI ORA B8 2MI CWP Swayne of the Heath User's Group. I say 7 09 3MI DAD C1 3MI POP C5 3MI PUSH 02 3MI STAX "suggested" because Swayne's method is a 9 OA 3MI LDAX 04 3MI INR 05 3MI DCR 03 3MI INX bit different. 9 OB 3MI DCX C7 3YI RST D3 4WI OUT DB 4MI IN 10 C6 4MI AD1 CE 4MI ACI D6 4MI SUI DE 4HI SBI ! have left out the conditional 11 E6 431 AN1 EE 4MI XRI F6 4MI OR1 FE 4MI CPI CALLS. I never used them and they can 12 22 5MI SHLD 2A 5MI LHLD 32 5MI STA 3A 5YI LDA always be " C, I' 'd in. The conditional 13 CD 5MI CALL ;s jumps are, of course, handled automatic- 14 ally by the conditionals: IF WHILE and 15 UNTIL, in conjunction with the flag testers: 0 = CS PE 0 < and NOT . Screen 50 32H 0 ( FICFORTH 8090 ASSEMBLER 3 81AUC17 JJC 80MARO4 ) I have opted to retain the immediate 1 C9 1YI RET C3 5HI JMP- C2 CONSTANT 0s D2 CONSTANr CS instructions MVI and LVI as opposed to an 2 E2 CONSTANT PE F2 CONSTANT O< : NOT 9 + ; immediate flag #. 3 : MOV 8' 40 + + C, ; : MVI 8. 6 + C, C, ; : LXI 8' 1+ C, , ; 4 : THEN HERE SWAP ! : : IF C. HERE 0 , ; The 1MI 2MI etc stands for "number 5 : ELSE c3 IF SWAP THEN ; : BEGIN HERE ; one machine instruction" etc. The first 6 : UNTIL C. , : : WHILE IF ; cut of this assembler was written when 7 : REPEAT SWAP.C3 C, THEN ; three letter names were the craze. 8 ;S 9 ! have a selfish motive in publishing 10 this assembler. I hope that this will fluah 11 out assemblers for other processors end 12 that there will be a "rush to prklish." 13 There is a good reason to do this besides 14 vanity. If someone else publishes the 15 assembler for the "xyzl' chip that you use, and it becomes established, it means that you will have to change your code to CMI- form with the quirks of the "established" version. It pays to get there first.

FORTH DIMENSIONS In16 Page 180 Screen 51 33H 0 ( EXAMPLES USING FORTH 8080 ASSEMBLER 1 81AUG17 JJC 80HAR12 ) 1 FORTH DEFINITIONS HEX 2 CODE CSWAP ( WORD-I--- SUAPS HI AND LOU BYTE OF WORD ON STACK ) 3 H POP L A MOV H L MOV A H MOV PSHl C; 4 CODE LCFOLD ( FROM-2 QTY-1--- CONVERTS LOWER CASE TO UPPER ) 5 D POP H POP 6 BEGIN D A MOV E ORA Oo NOT 7 WHILE M A MOV 60 CPI CS NOT 8 IF 20 SUI A M MOV 9 THEN D DCX H INX 10 REPEAT NEXT C; 11 ;s 12 13 14 15 Screen 52 34H 0 ( EXAMPLES USING FORTH 8080 ASSEMBLER 2 81AUG17 JJC 80MAR12 ) 1 CODE CXOVE ( FROM-3 TO-2 QTY-l--- SAME AS IN NUCLEUS ) 2 C L MOV B H YOV B POP D POP XTHL 3 BEGIN B A MOV C ORA 0.r NOT 4 WHILE M A MOV H INX D STAX D INX B DCX 5 REPEAT B POP NEXT C; 6 CODE -CMOVE ( FROM-3 TO-2 QTY-l--- SAME BUT OPP DIRECTION ) T L L '1OV B H YOV B POP XCHC 3 4 !I' 3 DAD XCHG XTHL B DAD 3 9kGIV B A MOV C ORA O= NOT 10 WHILE H DCX M A MOV D DCX D STAX B DCX 11 REPFAT B POP NEXT C; 12 : MOVt ( FRO'I-3 TI-! J;Y-l--- SMART MOVE, DOES NOT OVERLAY ) 13 >R 2DUP R> ROT ROT - 14 IF -:MOVE ELSE CMOVE THEN ; 15 :S Screen 53 35H 0 ( EXAMPLES USING FORTS 8080 ASSEMBLER 3 81AUG17 JJC 80MAR12 ) 1 80 CONSTANT CMMD ( COMMAND BYTE 1 2 FO CONSTANT CMMDPORT ( COMMAND PORT ) 3 F1 CONSTANT STATUSPORT ( STATUS PORT 4 LABEL DELAY ( --- DELAY CONSTANT IN DE, DON'T USE THE STACK ) 5 BEGIN D DCX D A YOV E ORA O= UNTIL RET C; 5 CODE STATUS ( BIT MASK-I--- I i POF CYMD A MVI CYNDPORT OUT ? 113.4 . LK: 3ELAY CALL I 9 BEGIN 10 STATUSPORT IN L ANA 0- NOT 11 wrn. NEXT c; 12 ;s

Sbve of Gmtoatams sm.s inMRTH 0 L The Siovo of Eratosthmnr aftor J. Cllbrwtht WE 9/81 ) 18190 COSTANT SIZE SIZE STRING FLMS t Yk. anar Of (1- ) Mitchell E. Timin 2 : PRIME 0 Fuc8 SIZE 1 FIU ( start br rttlno tkr flm) 30 ( cmto counter which rcvim on tw of stack ) Timin Engineering Co. 4 SIZE 0 Do ( rwut follorlm loor Dip0 ti- ) S I FW CO < fetch next flro to tor of stack ) 6 IF ( If flro is tnn Lkm do the tollorlno: ) 7 ( calculate ths rriw ) The versim of Eratosthenes I OW 3 nurbrc enclosed 8 wp I* ( stack is1 countOP* niwr K ) S we was written for an implementation 9 =GIN WP SIZE < WILE ( rmat for K < 8190 ) of Timin FORTH release 3. I was pleased 10 0 oVoRIIQ)C! < clcrr Kth f1.o ) 11 wER* ( add rriw to K ) that it executed in 75.9 econds, as com- 12 pared to the 85 seconds of figFORTH. 13 DROP #K)p I* ( 6.W K L wive tm-t c-ter) Mine was run on a 4 MHZ Z-80 machine, 14 ENDIF a3 were the othern in the BYTE magazine IS LOOP 3 SPMES . .* PREMES I ( finishe dlvlu cocnt) article. m.36 0 ( testinn the sirvo alaoritk ) 0 MIABLE *ouI(T 1: BELL7rnIr.I The speed improvement is primarily 2. NEU-LINE a, 0 OUT I I he to the array handling capability of 3 8 NEU-LINE'? OUT 0 70 > IF W-LINE -IF I T:inin FORTH release 3. FLAGS is 4 1 PRXlQ-TEST BELL ( f1mt .M4 tb ) created with the &fining word STRING; S kl1 6 100 DO PRIlz LOOP BELL run tk. wimn flndrr 10 X ) n TAGS leaves the adder of the nth 7 ( above is for tiaino test, blow is for vallbtion 1 elsment of FLAGS. This calculatim B 0 m)(JhlT 1 NEU-LINE ( clear CotmtWD vtart nee line 1 occurs in machine code. 9 SIZE 0 00 ( chrck ouh flaa ) 10 IFLACS C@ ( u. if it's set 1 11 IF IOW* 3* ( calculate ths rriw ) 12 7 .R WN-LIE? ( diwlav it ) 13 1 KOUCT *! ( count It 1 14 WIF IS LOOP CR KW? .'PUIm ' I < d1Wlu tkr Cat)

"ege 181 FORTH DIMENS#3NS W 6 w SKEWED SECTORS FOR CPIM

.I. 737 In ward to Michael Burtmh article in LD DE.SETDSK : SEN3 DRIVE TO CP/H FORTH DIMENSIONS, nV2, pago 53, "h- CUL 10s--- creasing fig-FORTH Dink Accsr Speed," I POP RC ; RESTORE (IP) erclom a simple mod to the 8080 or 280 JP NEXT arsmbly lid to effect the CP/M &ow4 4 sector dbk VO. The FORM routinsr 1 TFTRL: DB fi.1 ,7 ,1?,1~,25,5,11,17.2? ,?,9 ? ured to tent the tcheme am included. Ttm Da 15.21 ,2 .PI 14,Zn. 26.6 ,!2 ,18.24 4,10,16,22 j firrt cluder rmen b offwt by 52 me- I or I tom w that the operating qrtsm & trm- 96 P'IH ; S-SKEW pmnt and ocreens 0 ad1 hold the dhc- G3 'S-SKE' AMED tory. I move the merqo rreens to 93 '\!'+FC)H SCRl 24 ad 25 leaving 2-20 for the D'; SETDRV-I:! i AFTER FORTH binary program run by CP/M or SSKEU: Db! s+ 2 CDOS. PCIP DE ; SECTPf! SEPJEt:TIF.L ' **SET DRIVEN LD HL ,TRTGL ; TPA!!SLATI?!I TABLE ABOVE In order to check my incream in dbk AD3 PI. ,DE ; ADD3 OF HEW SECTnR access. weed Itimed the following opera- L3 E,(HL) tion with a 10 sreen buffer: PlJSY DE ; SECTOR RANSLATED JP NEXT 20 210 10 MCOPY 20 210 10 MCOPY i 20 270 10 MCOPY

I Elq&d times were 204 ad 138 meondr DP R7 H : TlCSCALC for straight and akewed kctom mgec- ' TISCP.L ' tively. Note that this nflecta dbk accem 29 Teed for reed/write of reveral sequential kctors and in no way compenaater for inadequate planning or poor programming D" AT in other disk l/O applications. D;: ZBR.11 ,TSCALS-f DWRLE OEtISITY If this seem8 trivial, then you have no DM LIT,BUPDRZ need for CP/M file compatible VO. My motive for these changes ir the Qrin to write the assembler program for fig- FORTH via modem (easy to implement in FORTH) to friends md colleagues. AEJ added value my diak 1/0 can be faster. DU LIT,F'XDRV-l D!Y XIt! D!.! bUP ,DR1 VE DU

DA STIQE :9!!EP

11 CODE SET-DRIVE ( n --- ' 12 H PQP, B PUSP. L c LD, !Q ~fLDPI, !ns CALL. e POP. 13 ftEXT, C; 14 15

FORM DIMENSIONS IIl/ 6 P.ge 182 DlqrmLicrmDU

Timothy l-hmng 9529 NE Gortz Circle 2 : CTkRLE ( bytesire TABLE ) Portlmd,OR 97211 3 WILDS o 03 c, LnOP DOES> + to ; 4 22 16 10 4 24 !k 12 6 26 20 14 P 2 21 15 9 22 17 11 5 25 10 5 13 7 1 D 27 CTARLE S-SKEV ( for CP/H CliiStWS While I was In the praerr of explaining t)a diakiq to am friends, I found it. would be nice to show them acme sort of rmpmmtation which lirts all the dil buffer status. This hart program was than wrltta for this purpose.

The flgFORTH uses the memory above USER arm for the dilbuffer. This disk buffer fire8 h further divided into ueveral blocks with ths length of each block equal to B/WF + 4 bytes. There BE some im- plementations that set B/BUF to be 1024 \ bytes md am, like 8080 CP/M, that st It to be 128 bytes. Another consteqt beside B/WF frequently referred in diak- lq b the B/SCR (buffer8 per acreen). For B/BUF = 1024, the B/SCR = 1 md for B/BUF = 128, B/!iCR = 8.

Gch block needs 2 bytes in front of it m the header which containr the update bit (bit 15) md block number (lower 0-14 bltr). k ala nedr a Z-byte tail to end the bbck.

The word BLOCK will put the begin- ning oddrer of a given block (assuming the block number on rtack before exe- cuting BLOCK 1. With them simplc words, virtual memory can be utilized, but it is beyand the @cope of this short article.

SCR # 90 4'' The rhort program will display the rtatur of oech dil block until it ir cx- 0 ( .EUW TDH 7/11/81 hwsted or you terminate it by pnasing 1 DECIHAL any key. The first thing it does is print 2 : .SUPS ( dlaplay nflr of a11 buffer8 out the title line (line 4). Line 5 nts up 3 CR .* # Atldr(hex) Ud Eloak# So- -wb' the boundary fa the DO ... LOOP. Line 6 ci FIRST #BUFF l+ 1 DO' prints the buffer number while line 7 5 CR I 2 .R 2 SPACES printr tho beginning address of each buffer 6 DUP 2+ HEX 6 0 SYAP D.R DECIMAL 3 SPACIB in hex. Lines 8 ad9 check the buffer 7 DUP 0 32768 AND qhtesbtur If it has been updated, then 8 O= 0- 72 + PlIT 2 SPACB M " : " will be printed in the upd 9 DUP 32767 AND DUP 6 .R 4 SPA- column. Lines 10 end 11 calculate the 10 RhCR /llOD 5 .R & SPACES 2 .R bWnumber, acreen number and the -a& 11 172 + ?TERMINAL IF LEAVE THHEw mmbm. The mason for teh -rub it 12 rmp DROP CR ; because for my system, B/LBUF = 128. 17 8/xR = 8, there are 8 blocks to mJte a I& rrhob acreen. So, 1 thought it would be 15 Mier to know which *art of a given acreen the bkck I want. oc Lines 12 nd11 check the early termi- .BtPS mtion md finish the definition. # Adtlr(hex) Wpd Block# Screen -mh 1 3E82 720 90 0 2 YO6 721 90 1 7 PBA 722 90 2 4 4008 723 5 4092 724 g. 2 6 4116 725 7 b19A 726 90 8 121E 727 90 7 9 b2A2 0 0 0 FLOATING POINT ON THE TRS-80 Kalrnn Fajes Kalth Mlcmryderm W Box 5457, Station F Ottawa, Ontario K2C 3Jl Canada

Most FORTH systems have no pmvi- sions for handling floating piont numbem, RLOCK 9 although most popular micros have the 0 ( FTP #l :KIP 810816) FORGET FTASK : FTASK * HEX necessary routines hidden in thsir ROM- 1 ( SINGLE PRIEC. FLOATING POINT FOR TRS-80 IN MHSbRTH V1.8) based BASIC interpreter. Thew are fast 2:EXX D9C,; routines written in assembler. The foilow- 3 CODE F.& EXX OFBD CALL 28A7 CALL EXX NEXT ing is to demonstrate how these can be 4 CODE F#& EXX HL POP 2 RST OE6C CALL accesned and used to implement single 5 OAR1 CALL EXX NMT precision floating pint arithmetics for the 6 : Po DUP 2 + 8 SWAP 8 4 40AF CI ; TRS-80 in MMSFORTH, Version 1.8. 7 : PI DUP ROT SWAP t 2 + I 4 40AF CI ; 8 : A S 4121 Po * Single precision floating point data is 9 : F#O HERE 0 6VER 3E FILL BL WORD F#& A S ' stored as a normalized binary fraction, 10 : MIN 0 PAD DUP 1+ 63 EXPECT P#& .4 6 ; with an assumed decimal point before the 11 : F#l PAC0 SWAP (L) (L) (L) (L) most significant bit. The most significant ia : FR STATE co IF FBI i31.i~F#O TH~";' IHHEDIATE bit also doubles as a sign bit. 13 : F. S A F.& 4 40AF C: ; 14 : lOFT ; DECIHAL A binary exponent takes one byte in 15 each floating point number. It is kept in excess 128 form; that is, 128 is added to BLOCK 10 the actual binary exponent needed. 0 ( PLOT. PT. 62 :IF 810816) FORGET lOPT : lOFT ; The binary mantissa is 24 bits long, the 1 HEX most significant bit representing the sign 2 CODE F+br EXX DE POP BC POP 716 CALL EXX NMT bit. It IS stored as 3 bytes normally with 3 CODE P-& EXX DE POP BC POP 713 CALL WX NMT the least significant byte (LSB) stored 4 CODE P& EXX DE POP EC POP 847 CALL EXX NEXT first and the most significant byte (MSB) 5 CODE w& EXX DE POP BC POP 8A2 CALL EXX NFXT last, followed by the exponent. 6 :F+ SA F+& AS; :F- SA F-6 AS; 7 :In SA In& AS; :F/ SA F/& AS; hmbers should be entered using the 8 DECIHAL notation specified for the TRS-80 L2 9 ( SAHPLE AND TEST ROII'FINE) BASIC. Integers and dobule precision 10 : FTEST FCIN CR F# 2 F+ FB 200.OE-2 F- numbers are converted to and stored in- 11 F# 5000.1 P P# 5.0001E+3- F/ ternally as single precision numbers. 12 PAD F! PAD Po P. ; 13 ;S The complete vocabulary and listing of 14 the source screens for either MMSFORTH IS or figFORTY (specify) is available for $7 (US.) from Kalth microsystems. It in- cludes both single and double precision, trigonometric and log functiom, floating point constant, variable and stack opera- F# ( --F) F TEST ( - 1 tors, conversion routines to/from integers Takes a number from the current A sample program to demon- (FORTH type) and floating piont numbers. buffer, converts it to single pre- strate the use of these floating cision floating point number and point operators. It asks for a GLOSSARY leaves it on the stack. floating point number from the keyboard, manipulates it using all Single Precision Floating Point F # IN ( -F) the operators defined and prints Anks for a floating pint number the renult. (It should be the name Fc (FlF1-F) Add from the keyboard, and leaves it number that was nupplied.) ( F=FZ+Fl ) on the stack. Notes: A -- 16 bit addrenn F- (FZFl--F) Slrbtract F@ ( A-F) ( F=Fl-Fl ) Floating point fetch. Takes a F, F1, F2 -- are single precision floating point number from floating pint numbers (two 16-bit F+ (F2Fl--F) WIt ip 1y memory at addrenn and leaves it words each). ( F=FZ*Fl ) on the stack.

F/ (FlF1-F) Divide F! (F A --) ( F=FZ/Fl) Floating point store. Stores the floating point number on stack in memory at location A.

FORTH DIMENSIONS IIII6 Page 18C TURNING THE STACK INTO LOCAL VARIABLES Marc perkel Perkel s0ftw.m sytltamr 1636 N. Sh.rma Springfield, MO 65803

Occasionally in writing a definition, I 5CR # B find that 1 need to do unwieldly stack 0 ( 8**< ARGUMENTS-RESULTS >%8% ) juggling. For example, swose you come 1 VARIABLE CAR01 VARIABLE KT03 into a word with the length, width, and 2 : +ARG CREATE I DOES. P LAROY F SWAP - CT03 @ +DUP height of a box and want to return the 3 IF 0' IF tI ELSE 1 ENDIF ELSE F ENDIF 0 LTOI I i volume, surface area, and length of 4 edqes. Try it: 5 0 tARG S1 2 tARG S2 4 tARG S3 6 tARG S4 6 0 tARG S5 A +ARG S6 C tARG S7 E tARG S8 For this kind of siuatim 1 developed 7 10 +ARG S9 ( $TO VARIABLES% ) my ARGUMENTS-RESULTS words. The 8 middle block fo the triad shows my slu- 9 : TO 1 CTOI 1 i ( XSE S STORE FLAG FOR tARGX ) I tion to the box problem. A : tTO -1 CTOI ! i ( S +STORE FLAG FOR +RRG$ ) %SE I F The phrase '9 ARGUMENTS" assigns C : ARGUMFNTS R> CARGI F 'R R 7% SPI! DUP CARG3 I 12 - SF@ SJPP the names of local variables 1 through 9 to I) - 2/ 0 DO 0 LOOF 0 CTOI i nine stack positions, wtih S1, S2 and S3 t E : RESULTS 2t CARGI @ SUAF - SPO - ?/ t returning the top 3 stack values that were F 0 DO DROP LOOP R R' CARG3 I 'R i there before 3 ARGUMENTS was exe- I cuted. s4 through S9 are zero-filled and e the stackpointer is set to just below S9. P 6 S1 thorugh S9 act as local variables a returning their contents, not their 1 addresses. To write. to them you preceda SCR # C t t them with the word " TO 'I. For example, 0 ( AROUHENT EXAMPLE --- FOX COMES IN UIrH HEIGHT, LENGTH u 5 TO 54 writes a 5 into S4. Execution of 1 8 WIDTH ANtl LEAVES VOLUMEt SURFACE AREA 8 LENGTH OF EDGES ) S4 returns a 5 to the stack. ? b 3 : BOX 3 ARGUMENTS C After all calculating ir done, the 4 VOLH ) Si S2 S3 % t TO S4 phram "3 RESULTS" leaves that many F SURF ) Sl $32 2 % % S3 S3 2 t 8 S1 S3 2 t X t t TO S'., c results on the stack mlative to the stack 6 EDGE ) S1 4 % S2 4 t S3 4 % t t TO S3 positim when ARGUMENTS was axe- 7 55 TO 52 cuted. All intermediate stack values are 9 54 TO Sl 9 n lost, which is good becauaa you can leave 9 3 RESULTS i the stack "dirty" and it dam't matter. A U B d ir C m 0 E U F el tC m 9'

th SCR # 20 ve 0 : T4SK i 9r 1 : nISK@l 5 ARGIJHENTS db 2 S1 S2 0400 U/MLln 1t TO Sl TO S? to 3 PEGIN S4 0 he 4 UHI1.F S1 BLUCK F? t S3 Is s S'i IF SWAP UPDATE ENDIF DI 6 S4 0400 52 - HIM DUP TO S6 CMCWE g: 7 S6 +TO S3 8 56 NEGATE +TO $4 9 1 +TO S1 th a 0 TO S? urn B REPEAT Ui C 0 RESULTS i ari D : DISK@ 0 DISK@' i OA E : DISk' 1 DISK@l : F --.

ias FORTH DIMENSIONS IIV6 GRAPHIC GRAPHICS Bob Gotrch Calltornia College of Arts and Crafts

Accompanying these comments are several graphic specimens drawn on Apple computer using FORTH and printed on a dot-matrix printer. They range from logo- type design to experiments in geometry and pattern. One can generate real-time motion graphics on the Apple in which color and action partially compensate for the low resolution of 280 by 192 pixela. Hardcopy, whether prinwt or color photo, im't the final product. The interactive, sequenced and timed display on the acreen is the designed product, likely to diaplace the medium of print on paper in the future.

While these graphic samples cwld have been programmed in other languages, 1 have found the advantages of using FORTH are both practical and expressive: immediate and modular ex- perimentation with the peculiarities and limitations of the Apple video display, and orchestration of complex viwal effects with self-named procedures rather than the tedious plots and pokes to undis- tinguished addresses. With this ease of wieldiog visual ideas, FORTH might lead to a new era of computer graphics, even creative expression.

It may remain individual and personal expression, however, withwt graphics standards. Transportability of grahics- generating code may be neither possible nor desirable considering the differences in video display generation, alternate character sets, shape tables, display lists, interrlpts, available colors, etc., between microcomputers. Each has some individ- ual features to exploit. Most have, how- ever, such limited memory for graphics as to make machine-dependent economy an overriding aspect of programming for graphics.

Despite the rarity of FORTH graphics thus far, I'm convinced it is m excellent vehicle for bringing out undiscovered graphics potential of each micro. In ad- dition, the visibility gained by some effort to evolve grahic ideas in FORTH wwld help in both spreading and teaching the language. Perhaps this issue of FORTH DIMENSIONS will stimulate just such activity.

Editor's Note: The author te11s me that Osborne/McGraw-Hill publishers have used his patterns, generated on Apple n using Cap'n Software FORTH, as cover artwork for their book "Some Common BASIC Programs":

- _-l______l______...-.. - FORTH DIMENSIONS In/6 Page 186 CASES CONTINUED

Editorb Note: In Volume I& Mder3, FORTH DIMENSIONS pblished the muits of FIG%CASE Statement Contest. As we had hoped, the variety of reapmres has stimulated further work m the abject. Here am four additional CASE cmatructes sdmitted by our readen.

f3cln-b CASE fw we0 0 ( CASE STATEMENT BY CHARLES EAKER FD I1 3 39 JJC 81AUG09 1 1 : CASE ?CWP CSP e ICSP' 4 ; IMMEDIATE John J. Carredy 2 CODE (OF) H POP D POP - 8 + CALL L A MOV H ORA 0. 3 IF B INX B IlX NEXT ENDIF D PUSH ' BRANCH JMP C; Here k an 8080 (280) version of the 4 : OF 4 ?PAIRS COMPILE (OF) HERE 0 , 5 ; IMMEDIATE keyed case statement by Charles Esker 5 : ENDOF 5 ?PAIRS COMPILE BRANCH HERE 0 , that was prklished in FORTH DIMEN- 6 SWAP 2 [COMPILEI THEN 4 * IMMEDIATE SIONS W3, page 37. I have found it very 7 : ENDCASE 4 ?PAIRS COMPILE h0P useful. 8 BEGIN spc CSP e = o= 9 WHILE 2 [COMPILE1 THEN 10 REPEAT CSP I : IMMEDIATE 11 : TEST CASE 41 OF ." A " ENDOF 12 42 OF ." B " ENDOF 13 65 OF .I c ENDOF EWDCASE : 14 ( 41 TEST A OK 1 15

urn* CASE AupmartDd Alfred J. Monroe 3769 Grandview Blvd. Lor, Angelas, CA 90066

I was delighted with Or. Edtar's CASE construction (FORTH DIMEN- SIONS, Vol. II, NO. 3, p. 37) md imple- mented it immediately. Recently I have found it desirable to augment CASE with three additional constructs in order to treat ranges of variables. It has occurred to me that other FORTH usem may be interested in the same extension, henee this short note.

Screen 144 lists Or. Enkerb CASE construct with one slight modificatim. OF has been modified to uw (OF). The original OF compiled to ten bytes. The revised OF compiles to six bytes. Thb forty percent reduction in code L not as impressive as that which occun udng Or. Eaker's CODE word (OF) cmstruct,but it does have the advantage that it b highly portable. (OF) tests fa equality end leaves a true or false flag on the stack. Note that it drops the test valw if the test is true.

Screen 145 lists the extension8 that I have found useful, OF, md RNG- OF.

SEND A CHECK TO FIG TODAVI MAKE THIS YOUR BEQINNING! RENEW NOW

.-.

> RENEW TODAY!

FORTH DIMENSIONS IW6 Page 188 CASE ea 8 Defining Word 106 Dan Lerner 0 ( CASE NANE 1 A IS FUNCTION-A PAIR = VALUE-A After reading the CASE conteat artl- 2 E IS FUNCTION-B ADDR OF FUNCTION4 cles and looking for a ainple function, I 3 c IS FUNCTION-D am compelled to submit a simple CASE 4 ETC . statement. These words are feat to e OTHERS ERRORFUNCTION ) compile and execute, compact, simpla, 6 generate minimum code, and very aim- 7 : CASE CREATE HERE 0. I ( AT CONPILATION BUILDS HEADERvLINK ple. There is no error checking since the 8 POINTS TO ADDR OF P OF PAIRS form is 50 simple the most novice pro- 9 HERE SET TO ADDR OF VALUE-1 ) grammer can use it. 10 DOES ) ( AT EXECUTION, ADDR OF +OF PAIRS) 11 i ROT ROT DUP 2+ SWAP C CASE GOT0 is analogous to vectored 12 0 DO 2DUP C = IF DUP 2+ C ( COHPAIRS INPUT VALUE ) in other languages. Its usage with my 13 EXECUTE ROT DROP 0 ROT ROT ( WITH VALUE A, B, C, ETC, AND ) words is: 14 LEAVE ELSE 2+ 2+ THEN LOOP ( EXECUTES ASSOCIATED FUNCTION ) 15 ROT IF C EXECUTE ELSE DROP THEN DROP i CASE NAME A IS FUNCTION A B IS FUNCTIONB C IS FUNCTIONC 107 (etc.) 0 ( CASE WORDS ) OTHERS ERROR FUNCTION 1 : IS , ' i+ ? ( HERE, PAIR9 -- HERE, NEXT-PAIR9 ) 2 : OTHERS , swap T I ( HERE, C-OF-PAIRS ) General usage wwld be as a menu 3 selector; for example, you print a menu: 4 5 1 BREAKFAST 6 2 LUNCH 7 3 DINNER El 9 SELECTION --> 10 11 The user types a number which goas n 12 the stack, then executes the CASE word 13 MEAL. MEAL selects BREAKFAST, 14 LUNCH or DINNER, or ABORTS on 15 error. The source is:

CASE MEAL 1 IS BREAKFAST 2 IS LUNCH 3 IS DINNER OTHERS NOMEAL

Yw have previously defined BREAK- FAST, LUNCH, DINNER and No MEAL.

How CASE is Structured THIS IS THE END! CASE builds an array using IS end THE END OF VOLUME III OTHERS to fill and complete the values in the array. At execution, the DOES> THE END OF YOUR MEMBERSHIP? portion of CASE takes a value from the '- DON'T LET IT HAPPEN1 stack and looks through the array for It. A match executes the word, no match RENEW TODAY! executes the word after OTHERS in source .

The form of CASE is a new clam of words, as CONSTANT , VARIABLE , MSG , etc. ape. The code executed to teat the array is minimal.

"age 189 FORTHOEMENSSONS III/6 CASE8 xxxx cfal cfa2 ".. cfan ; WE9 part of the compiler. Hence if we simply change tho dsfinitim of tho DOE9 to define a caw mlector word nmmd part of CASE8 , wa csn transform it into a E.H. Fey xxxx. general purpow caw compiler.

When the new word, xxx , is executed The hMti-Rmpoaa Cam Conpbr htmductial in the form The method utilized to develop a The CASE CONTEST held by FIG last k xxxx ( k=l,2,. ..,n) generalized cam compiler is to compile a year ended with some excellent number for the cam type as the first byte contributions to the FORTH literature. the k'th word in the list will be executed. in the parameter field of xxx . At The judges noted however that few people For example, deflns the following words, execution time, the number is retrieved tried tc devise a gefteral case Structure COW ,CHICK , PIG ,and BARN : and uwd to wlect the appropriate DOES> encompassing both the positional type, part for the cam type of xxxx . The type where the case is selected by an integer : cow ."Moooooo" : number is tranaparent to the uaer. denoting its position in the list of cases : CHICK ."Peep" ; (ala FORTRAN's cemputed GO TO), and : PIG ."Oink" ; The definition of the new caw the more general keyed type of structure, CASE: BARN COW PIG CHICK ; compiler is: where the case selector key is tested for a match in the case words key list. If we now execute the aequence 2 : MCASE: WILDS SMUDGE !CSP BARN , Oink will be typed. Similarly 1 HERE 1 C, 0 C, 1 This article discusses a general case BARN will type MooOOoo. DOES> DUP C@ OOESPART ; structure which combines the positional and keyed types. Like FORTH itself, the Although there are no error checkr, where DOESPART is a case selector word case structure is extensible. I have added this case structure u easy to uk, executes defined by CASE:. a third type called range where the case fast and requires a minimum of dictionary selector key is tested to be within the space for each case word, xxx. Bilobran, The

:

FORTH DIMENSIONS Il'U6 Page 190 and Dff ] is a cam wlector word Lfid 165 0 ( GEUEIUU. CASE STRUCTUUE EHF iomm 1 by CASE: . 165 1 163 2 ( EXECUTION VAUIhBLES AN:, ARRAYS ala Kir Harris( Bvte Aur '8C 1 DEFAULT: fire checks to aee that you 163 3 ( CP 184 alss see R, A. NcCourtI FD 1114 PP 109. EHF 5/11;a1 ) are in the compile state since you should 165 4 be compiling xxxx , It then enters the end 165 5 of list terminator, EOL , to the diction- 165 6 : IX ( k rfa...ad: 1 ( CoaPutes abr of index I( = 1r2tl..tn 1 ary. Finally it takes the parameter field 163 7 WAF 1 RAX ( ..,rfa huaxl ) address of xxxx left on the stack by the i65 8 1-DUF'tti ( ..+rfatXk-13 1 :i:x in the fO7h: k xxx,: Execution of Cea Sebctor 166 5 ( will rrociuce the we:ution of cfak 8 k= lr?r.tt,n ) 166 6 All case elector words, xxxx , defined 166 7 : LIST: IX F i by MCASE: are executed in the form: 166 a ( Used in forr: LIST: xxxx L ni t h2 I n3 I.... I 3 i ) 166 9 ( to create P list of constants Whed xxxx , Exeaitins ex>:>: i k xxxx 166 10 ( in the forr: k xxxx ulil leave nl Ofi the stask, ) 166 11 where the key, k , is an integer. The 166 12 : XEOVAR: (LIST DOES @ EXECUTE i interpretation of k in selecting the cam 166 13 ( Used in the forr: XEQVAR: xxcx cfa i ) depends on the case list type. 166 14 ( to create an execution variable xxxx vith an initia; vaiuo i 166 15 ( cfa usich is an existinn uord. Executins XXEX causes --I With three case list typm and two 167 0 ( cfs to be executed, The word cfa LIY be charm6 br usahs 1 options for each type, there are actually 6 167 1 ( INSTALL nnnn AT xxx)ox where nnhn is the new uorb. i different form of cane lists availeble. 167 2 Let's consider first the lista with single 167 3 : INSTALL ( rlrcfa)LCS)!WLEI ' STATE E IF COZPILE CFA ELSE CFA word execution elements. 167 4 THEN i INMfiIAiE 167 5 SingbwIYdExa!utiun~b 167 6 : AT ( Cfait.1 CCONPILEI ' STATE P IF CJWPIiE 2t COW:iE ! 167 7 ELSE 2t ! THEN i ItiXPiCITE (1) Positional type 167 a 167 9 : (4TKIN) ( I( cfa pfa...) R3: 1 RAX 2 S t ! i ( Stores cfa at 1 MCASE: is umd in the form: 167 10 ( 8br82KtPfa uhore W=lr2t.+.tn Cowiied bu ATAiN , ) 167 it MCASE: xxxx cfal cfd ... cfm 167 12 : 'ATKIN ( k cfa...) CC!l?l?ILEl ' STATE 0 IF C3RPILE (ATKIk) DEFAULT: cfad ; 167 13 ELSE (ATKIN) THEN i IHiiE3IA:E 167 14 ( Use6 in fo?a: I( IHSTALL cfa AThIN xxxx ) When xxxx is executed in the fmk 167 15 ( uhrre xxxx is an execIition array defined bu CASE: t cfai --, xxxx ,the caae cfak will be selected if 168 0 t is the neu word to be installed as eierrnt k=lt2ttr.tn 1 k=l, 2, ...,n . Otherwise tha dcfwlt 168 1 case, cfad, will be elected md 168 1 : mi i --'> executed. 168 s 168 4 ( NOTE: NcCwrt's iwlerrntation of the f'onction INSTALL ATKX. (2) Keyed type 163 5 ( does not u!r& inside : definition. The above docs, 168 6 MCASE: xxxx KEYED 168 7 HCASE: 9 A GENERALIZED EXTENSION Of CASE: [ kl , 1 cfal 168 8 [ k2 , ] cfa2 168 9 1. Throe twos of case stucturer: ... 168 10 a* POSITIOMAL ( default 1 [ ko , 3 cfan 168 11 be KEYED DfFAULT: cfad ; 163 12 C. RANGE 166 13 2, Two skucture options for each two: When xxxx is later executed in the 168 14 a. SIN=LE Y3RD EXECUTION ( dofault ) form k xxxx , the cam cfai will k 169 15 b, HIGH LEUEL HEAOERLESS COPE SEOEIYCE executed if a value of k=ki Is found in 169 0 the list. Othemiw, the dsfwlt cam, 169 1 ( hfine WESPAR1 and LPEFI as Execution uraw to be filled 1 cfad ,will be executed. 169 2 ( in later 1 169 5 169 4 CASE: DOESFART D3N DUN Dun DJ!l DUN D33 G'JIZ i ( 6 Cases ) 169 S 169 6 cA8E: LDEFJ DUN DUN DUN PJR DU5 D!IR Of& i 169 7 169 8 : MA#: ( The Swrrahzrd case cobriler ) 169 9

Page 191 FORTH DfMbr(Si0NS W6 149 10 1 Cc ( Default 8 1 ) 0 Ct ( Nubbe: of cases in list = 0 ) (3) Rangetype 149 11 149 12 3 ( Enter cowlie state for list 1 DOES) ( Gets ) MCASE: xxxx RANGE 149 13 WP ce lure DOESPART i ( Executes rrprorrirte search ) I L1 , Hi , 1 cfd 149 14 149 13 -- r L2 , H2 , 1 Cfd 170 0 f DEFAULT: ( CfPo*+) ( fbndatO."Y Word Used ibftQ: cr~eli&tia) .... ( KASE: Ltinition. Cowales is [b,m,ICfm 110 1 an . EOL I HERE OVER CP DEFAULT2 cfrd ; 170 2 ?CONP ( ..,rfi, ai:h twe ) 176 3 IDEFI i IHMDIATE For thL type each of the n cmtrler to 17C 4 UYEG ( ( Used after n%SC: KW: to sot CbCCtYP0'5/ the cam list conrirb of a pair of 170 5 : rfooo.rfo) OVER CI i IHHEDIATE value8 specifying the upper adlower 170 6 3 limits of the range , Li and Hi , 170 7 RANGE ( Pfa ODDP~~)( Usad after HtASE: ):>:):A to set turM i followed by the execution element, 170 8 : cfai. 170 9 5 OVER C! 1 INMEDIATE 176 10 N? ( Pfrl~tnPfr f) ( Checks for valid casezosntt I uith 1 When xxxx is later executed In the 170 11 : n n form k xxxx , the caw cfai wlll k 170 12 ( count in CBSe list uith rfa specified. True if valid. 1 selected if the condition 170 13 OVER OVER it ce ( pfa n count ) 170 i4 OVEh 1 C >R ( rfa n count R>, OR Or i Li <= k <= Hi 170 :Z > --> 17i G is found during a search of the list. If 171 1 ( POSITIO?(AL TYPE WITH SIKiE Y9RD EXECUTION OPTIONc TYFE 1 ) not, the default caw, cfd , wlll be 171 2 executed. 17; 3 : PSFIND ( n Pfa.0.) lure 1 case for DOESPARTt finds and ) 171 4 ( executes case n 0: defaclt if nR 6 t SiiAF DROF' R> ( et6~titb c 1 elements as previously defined FORTH 171 8 THEN 1 - DUP t t words, the elements may be pecifled nr a 171 9 e EXECUTE i sequence of FORTH words in the form: 171 1G 171 ;; : PSDEF ( rfa adrdsf...) ( Counts # cares entered and stores 1 W ...... seq ...... ;H 171 ;2 ( in carecocnt at rfatl * The address of the default cfa is) 17; 13 ( at adrdef = rfat6tXn-13 ) or as 17; i4 OVER 6 t - 2 / ( ...Pfi n-1 ) 17i is It SYAF' 1t C! i - -> DEFAULT: .....seq.... ; 172 c 1;: 1 i INSTALL PSCIND bTh1N DIE5"k?; where .... seq .... is the sequence of 1:: ? 1 INSTALL PBDSF ATA!N LGEFJ sxecutab!e FORTH words. 17; 3 .--I .I d. 4 ( POSITIO!;X- TYE GiTH Hii3 LEVEL DEF IN LIST, TYFE 2 1 Again we have the three applicable 172 5 case list types, the default type, position, 17: 6 : 2FIND ( n rfa.r.abrrl) ( Find; ad5j:oss~sdrn P of nth hilh ) the keyed type and the renge type. 172 7 ( ieve; c03r se~1~ience~5t~t at Ffa O+ list. Return &fabit; Examples of the structure of each of these 172 a ( code adFe5s if n::: 0: rLcaiecojr,: ) types is 172 7 N? O= IF ( def 1 ?R B!iJ? I? lt iX 1t R; THEK ( ..,ntf rfa 1 172 1C SUFI? rE 4 t 0 BEGIN it ( ...~fat4 ltSave ntf# (1) Positional type 172 11 R OVER = O= ( ..,rfat4 1 f ) 172 1: WHILE ( cow& aot=ntf MCASE: xxxx 172 13 * -- H: ...seq l... ;H *I& 14 H ...saq 2... ;H 17; i5 ... 173 0 H: ...seq n... ;H 173 1. ( 2 caselist, Ffa . E1:esute default If out of ranse. 1 DEFAULT: ....seqd.., ; 173 2 2FINC EXECL;TE i 173 3 (2) Keyed type 173 4 173 5 MCASE: xxxx KEYED 173 b [ kl , 1 H: ...-1,. ;H 173 7 [ k2 , 1 i-t ...q2., ;H 173 8 ... 173 9 kn , 1 H: ... seqn,. ;H 173 1C DEFAULT; ... qd.., ; 173 I1 173 12 i73 13 173 14 173 15 174 6 174 i 174 2 174 3 174 4 174 S

FORTH DIMENSIONS 116 Page 192 174 b (3) Range type 174 7 174 8 MCASE: xxxx RANGE 174 9 [ L1 , Hi , I H ...ma... $4 174 10 [ ~2 , H2 , I H: ...seql. .. ;H 174 11 ... 174 12 [ LJ-I , l-h , 1 H: ...sqn... ;H 174 13 DEFAULT: ... seqd... ; 174 14 ;74 15 The interpretation of k in caw ii5 C selecting is the same as previously i73 i discussed for the single word execution of ::s 2 -fc the same case type. The only difference *#J. 3 is that a FORTH sequence, ...seqi-. is 1:: 4 .-c c executed instead of a single FORTH word, A, .I .I cfai . 1;: 6 lX i Examplea :;5 6 175 9 .-I.A Examples of all 6 possible A, J A', .7* ,, combinations of case structures are givm &#.I AA on Screens 180 and 181. If the screen is 1:: :2 loaded and examples tested, typical 1:s ;3 tlxecution results should be: ;,-:;4 ;75 1z EXECUTE RESULT TYPED i:u 0 i:i 1 1 BARN MOO i;b 2 2 BARN OINU i:4 3 18 BARN PEEP (Default) ;;c. 4 176 5 1 zoo PEEP PEEP PEEP iib 6 5 zoo PEEP PEEP MOO 176 7 -6 ZOO 01M 01lW 01w i76 0 (Default) 176 9 i76 11; 1 FARM OM(Default) 176 1; 77 FARM MOO 176 iZ 136 13 -10 CASE MOOOINK PEEP 176 14 (Default) 176 15 77 CASE MOOoooOOO iii G i77 1 -10 CORRAL PEEP PEEP 177 2 -1CORRAL OMOINK 177 3 309 CORRAL PEEP OM( MOO 177 4 .-7 310 CORRAL MOO (Default) *,I 5 177 6 COMMENTS 177 7 177 8 1. Kim Herrid caw compiler, CAK: 177 9 avoids the uw of OVER = IF mop 177 10 ELSE... THEN for every case as used in i77 11 .?7 4, many of the other CASE conrtructs. Ad2 *A The result is shorter compiled code in 1;: ;3 the application. The compiler, ;?7 :4 MCASE: presented here is an extension 177 i5 of CASE: and conaquently shares this 1X 0 feature, 176 1 S IMSTA-L RSFIND ATIIN D9ESPATIT 178 2 S INSTALL RSDEF ATKIN CDZF3 2. The compiler, CASE: and the 178 3 Execution Array introduced by MA. 17C 4 ( RkNiE OfTION YITH HIGH LEVEL DEF IN LIST, TYPE 6 1 McCourt in FD II/4 pp 109 pro i76 5 functionally equivalent. Furthe?, the i7C 6 : RHFiNU ( K Pfa... ) ( Searches two 6 list for. first oxurr - t Execution Variable, XEQVAR , Of 178 7 ( cnce of I( uithin Pair of ranae values. If fomd, executes) McCourt turns out to be a deg~nemte 178 8 ( tollowins high level seouencev else executes dof seaue:lcc) case of CASE: with only rn element 17r 9 Zt BEGIN 1 >F: US? F EOL - ( ...ti ad71 f ) in the case list. The dsfinitions 178 ib IF ( not ED-) OVER OVER RANGE? ( ...k adri s ) 178 I1 IF ( in ranre) 6 t ( .. .I( adFlt6 1 : XEQARRAY CASE: ; 178 12 ELSE R.; 1 - 3R 4 t e THEN ( ,..h adrnxt 1 : XEQVAR

P.ga 193 FORTH DIMENSlUNS W6

:c are flg-FORTH tunctluwl equlvabnta 178 11 of McCwrtb definition. l-bnce 178 1s CASE: can be umd a8 an Execution 179 0 Array a8 8ugga8tad by McCwrt. fho 179 1 definition8 of AT , ATKN Md 179 2 INSTALL on rreenm 167 and 168 can 179 3 be uaed ala McCwrt to change the 179 4 elements in CASE: lilt words. 179 S are uccd in the form 179 6 177 7 k INSTAL yyyy ATKIN xxxx l7P 8 179 0 to change the k'th aiement in a cmo 179 10 list, xxxx defined by CASE: to the code iip ii field address of yyyy . Now whenever 1;f i: k xxxx is encountered, the word yyyy 175' i3 will he executed rnther than the 177 14 oriqinal word in the kith porkion of the 179 :5 caw List. 1c3 0 1CP 1 tlsinq the previous CASE: example of 1c;i 2 BARN, if we execute lC3 3 ic7 4 2 INSTALL. COW ATKIN BARN 183 'j ics I the second case in BARN will be 18; 7 changed from PIG to COW. Later 18; s execution of 2 RARN unyywhan in the 185 9 progrein will then type MoooooO 16; 10 instead of Oink. 183 1; 160 i: Althouqh this is non-structured 1c; i3 proqramrninq, it is atill a valuable 1C1 i4 pmqramminq tool hen uaed 12'; 15 properly. Thr! present definitions of 18i 0 INSTALI. and ATKIN can be ua?d 181 1 within a color^ definition. 18i 2 181 5 Please note that the use of the 18; 4 Fxecution Array in the develapment of 181 5 MCASII: on acreen 169 is purely 16i 6 stylistic. It is not a necessary'feature 1CI 7 of the development. 181 8 If1 9 3. The essentially uniqiie feature of 161 14 FOHTI-i is that it is extendabic by the 1Ci 1; user. With m expandinq FOIITH 1:; 1: literature, it is clear to this author 161 13 that FORTH will iinprove with tiim 181 14 faster than all other lanqu~ges and 1El 15 that there is iw upper limit to its iinpmveineiit. It has hen leg, than 18 months since I first qot FCRTH up and runninq. In that ahort period of time, thanks to the flq literature, the FORTH system I have runiinq now is, in my opinion, vastly superior to any other Innqoaqqc? I have ever seen. Aml it will qot hetter:

_------FORTH DIMENSIONS IN6 Page 194 A FORTH Standards Team meeting will be held in Bethesda, MD, from May 11 through May 14. The meetiq is Open to FORTH DIMENSIONS the current Standards Team members and a limited number of observers. The site will be the National 4H Center, a self- VOLUME IV contained educational facility, just outside Washington, DC. The campus-like Center has meeting rooms, dining facilities and c'ormitory accommodations. BEGINS NEXT ISSUE This four-day meeting will allow world-wide Team members to consider proposals and corrections for the current FORTH Standard and develop future stan- dards policy. Participation is possible by submittal and attendance. Written sub- mittals received by April 30 will be distributed to attendees before the meeting. Late receipts will be distribued at the team meeting. Those wishing to attend must apply without delay, as apace is severely limited.

Applicants (other than team members) must sllbmit a biography by April 15 for consideration by the credentials com- mittee. You should include:

1. Your skills and comprehension of multiple FORTH dialects and their application. From the Editor: 2. Why your views are repremntative of a significmt portim of thc Beginning with the next iaaue, each FORTH community. editim of FORTH DIMENSIONS will high- light a apecial theme. Our May/hne issue Accommodations are $41 to $47 per will feature several articles on complex day, per person, including meals. Send a arithmetic routines in FORTH such as refundable $100 deposit (md biography for fixed-point trig, quare root, and floating observers) to the meeting coordinator. point. Of course, the remainder of each You will receive further details on choices issue will contain the usual technotes, in housing and meals. product reviews, tutorials, letters, etc.

Sllbmittals are eaaential if Team Suggestions for future themes include: actions are to represent the broadening scope of FORTH uaers. Specific cm- Process Control Applications sideratim will be given to m addendrm Database System Applications correcting FORTH-79, the Team Charter, Teaching FORTH and alliance with other standards group% Data Acquisition and Analysis Those not attending may receive copies of FORTH in the Arts stbmittals by sending $30 to the meeting CP/M coordinator. Laboratory Workstations Serial Communications All submittals and reservations should Metacompilation and its Alternatives be directed to the meeting coordinator: The FORTH Environment

Pam Totta Your input to these topics is greatly Creative Solutions needed! 4801 Randolph Road Rockville, MD 20852 (301) 984-0262 RENEW TODAY!

Page 195 FORTH DIMENSIONS 1/6 LECTURES ON APPLIED FORTH

I two dry 8ominrr on Forth and It$ rpplkruOn and tho 1982 ROCHESTER FORTH CONFERENCE ON DATA BASES AND PROCESS CONTROL Ury 17 through Urg 21, 1982 University of Rochortor Rochestor, New York

k part of the 1982 Rochester FORTXI Conformca 011 Data Bare. md Prows Control thore will be a two day rdmr on Applied FORRI. Hauqerr and pro- gramera will find there lectures vory usoful for omloring FORTH appliutiolu and programing concepts. Each lecturer will rlao lead a Workfng Group at the subrequent Conference. Participants ihould ham a copy of Leo Brodie'r book, Startiax FORTH, which ir available from Xountain View Preoa, PO Box 4656, nt. View, CA 94040 for $16.00. Lecturers for the two day seminar are: Lao Brodie, author of Starting FORTH, on ''Beginning FORTE". Kin! Harrir, of Luen 6 brria, Inc., on ''FORTE Programing Stylo". &.nr Niouwenhuijzen, of the Univeroity of Utrecht, on ''FORTH Pro8rlriag Environment 'I. Lorry Forsley, of the Laboratory for hear dnorgotico, on "Ext.nriblo Control and Data Structure". David Beers of Aregon Syrtem, Inc., OD "A Leqe Programing Project Cue Study: Building a Relational Databua in FORTE". Steven Marcus of Kitt Peak National Obaervatory, on "hsclblera 6 Croor Assemblers". James Hamood of the Inatitute for htrommy at the University of buaii, on "Computation Tradeoffs". Roger Stapleton of St. Andrews Obsematory, Scotland, on '%rdwme Control with FORTH". Raymnd Desaey of Virginia Polytechnic Inatitute. on "Concurrency. Wet- working and Instrument Control". REGISTRATION FoRn (must be received by April 23, 1982) Name Address city S tateZIP Phone (Days) ( 1 - CBOICES TO BE MADE - Applied FORTH Seminar. May 17 6 18 $200.00

- 1982 Rochester FORTH Conference, May 19-21 100.00

Bouning for: (circle dates) Hay 16 17 18 19 20 21 $ 13.00/porroa dbl - 16.50/perrm 001 TUTU AUOUNT ENCLOSED $ We cheh payable to: "University of Rachester/FORTB Werenco" Send check and Registration to: Hrs. B. Rueckert. Lab for Laser Energetic., 250 B Rivor Rd. Rochmta, 1R 10623 For inforumtion call: Barbara Ruadrcrt (716) 275-2357

FORTH DIMENSIONS IW6 PW1% NEW PRODUCTS

Marx FORTH far Northabr file of ecmma), d Apple 3.2 md 3.3 Mcz, ms, UDS FORTH now Available dlaka; inquite about other formal.. Marx FORTH is a fast, powerful FORTH m now running M Zilog MCZ, FORTH system written in 2-80 code. Bsn curry ZDS, and Multitech U3S microcomputer Pack age includes se If -compiler, complete Curry AItocletes rystems. It has compiler, editor, source code, screen editor, and "smart" PO Box 11324 amembler, text interpreter, and VO drives assembler. Some of the features include Palo Alto, CA 94306 for floppy diak, Centronics printer, and calls to the N+ directory functims allow- RS232 Qvices. ing creation, deletion and listing of directories and ease of writing FORTH Assembly wurct listing is available programs that operate on files created b) now for $10. Source code on didette is N* BASIC. Some of the performance fea- NEwBaok: htroductimroFoRTH $50 (specify WZ, mS, or UDS). berh tures include very fast compile speeds, manual will accompany each order. very fast math, 31-character variable Introduction to FORTH, 8 142-e length names, case compiler security, textbook by Ken KnecM, pmmb the send checks to Thomas Y. Lo, Electri- arguments-results, link field in front of moat complete information available on cal Engineering Department, Chung Yuan name, and many machine code definitions the MMS FORTH version of ule FORTH Christian Lhivenity, Chung Li, Taiwan, for high speed. language. It is written for my- who Rapllblic of China. wants to learn how to write computer The self-compiler allows you to change mftware udng FORTH. anything. !f you donZ like how I do it, change it! Add anything you want. Price No previous knowledge of FMiTH is SoftwM for 09 C1P is $85 on N* single density diskette. required, but some exposure to Micromft Source listinq available separately for $25. Level n BASIC will be hepful. AlLhargh Shoot The Teacher - Find the teacher and Perkel Software Systems the book is designed psificslly for the shoot him with your water pistol. 1636 N. Sherman MMFOHTH venion of FORTH for ths (Teaches basic grephing) $6.95 Springfield, MO 65803 Radio Shack TRS-80 Models I md 1% most (117)862-9830 program axampler can be adapted to run Speed0 Math - Race the computer with m other microcomprtela that u- dif- your car. (Drills basic addition and ferent versions of FORTH. multiplication) $6.95 FORTH Rogmmming AiL Kadaze Education Pack - Four pro- FORTH Programming Aids are high grams in m. Addition, X Tables, level FORTH routines which enhance the Spelling, end Place Value Drill. Answer a development and debugging of FORTH question and your men go an their last programs and complement cross compiler miasion. $11.95. and meta compiler operations with the RENEW NOW following features: That% Crazy - A takeoff from a famous TV Show when you rid your life to jump - A command to decompile high level over can and a canyon. A spelling FORTH words from RAM into struc- program that provides hwrs of enter- tured FORTH source code including tainment. IS11.95 (specify grade level) structure cantrol words. ?his command is useful to examine the FORTH for Oh& *btific Wmt Ads Life Skilh - A program that actual source code of a FORTH helps slow reedera understand the Want word, or to obtAln variations of We've received from Technical Ads. Five levels of difficulty. $7.95 FORTH words by deconpiling to Products Co. a copy of their newsbtter. disk, editing, and recompiling the Thb iawe contains product MWI and Rescue Ship - Transport injured mldiers to modified mrce code. update srsem for FORTH-79. We the hopital. &rt the enemy has covered applaud thir intat of good customer the ocean with mines. One of them could - A command to find words called by a support, but note technical errors in dastroy you. specified word to $ mating levels. definitiin of meral atmdard WO& ( WORD, R@ ,DS-CODE ,ZCONSTANT Addition - $11.95 - Commands to patch improvements ,D< 1. lhb OSI-FORTH operatsr with Wtnctim - $11.95 into compiled words and to merge Ohio Scientific 05-650 3.3 operating Multiplication - $11.95 infrequently called words for in- aystsm mleaa. (all three on tape - $28.00) creased program speed. Their new addrew ia Technical Plea= include $1.00 to cover postage and - Complete source code and 40-page Products co, ax 2158, Boans, Nc hndling md send to: manual are provided. 28607 -ad. Hanry Svec Requires a FORTH nucleus udng the 668 Shemrw Terrace fig-FORTH model; a minimum of 3K bytes London Ontario Canada and a recommended 1SK bytes of free dic- N6H 3K1 tionary space. $150 single CW license; $25 for manual alone (credit applied toward program purchase). California residents add 6.5% tax. Add $15 for RENEW TODAY! foreign air shipments. Available on 8-inch =/sd disks (FORTH screens or CP/M 2.2

Page 197 FCXN !XMD\ISIONS IW6 FORTH VENDORS

Th followlnp vrdon how vrnlm of Sottwrn Fdnrotlon OQlO FORTH avalllbk or sm Cmuttnta. (FIG 44 lJnlvomlty Or. Emporlcrl Roa. Ow. m&ar no judgmrnt on my producto.1 Arlington blghtr, II m P. 0. Box 1176 (512) 259-1555 Milton, WA 98354 KPHAMlCRO (206) 6514055 Pmferimal Maqonmnt Sorvlcn TIchnlcrl Roduct8 Co. 724 Anrtndem Rd 1109 P. 0. Box 12985 Flrm*.n.Boar&mld- Palo Alto, CA 94506 Crinavill0, FL 526w Omtrlcon (408) 252-2218 (9w)572-8459 7911 NE 53rd Or. Portlmd, OR 97211 Sierra Compubr Ca Tom LImnur (soy) 284-8277 617 Mvlc NE 292 Falcrta Dr. Albuquerqw, NM 87123 Miipitm, CA 95055 Forward 1.Chnology 2595 Mortin Avmw ApRl mz Smtr Clara, CA 95050 IDPC Ccmpmy FSS (4W291-8995 P. 0. Box 11594 P. 0. Box 0403 Philadelphia, PA 19116 Aubln, TX 78712 Rockwell Inkmtlorul (215) 676-3235 (512) 477-2207 Mlcrc~loctmnicrDovim P.O. Box M69 US(Cq’n Softwmro) 6ao&cuo, mlm,CA 92005 281 Arlinptm Avenue Tolbot Mlcroy*M* 014) 652-2062 Borkelsy, CA 94704 1927 Curtlm Avwu (415) 525-9452 R.dmdo8..ch,CA 90278 2.nd.X corp. (213) Y76-9941 6398 Doughorty Rd. c.orgs LY- Dublln, CA 94566 280 l-bnderwn st. TRRSID kmey City, NJ 07x2 Th. hncm Wab(Cola c0mplt.r) VawyOtFoRTH~ (201) 451-2905 P. 0. Box 1110 ht.Nctln conlputer syrtm#, Inc. DsIMor,CA 92014 6403 Dl MUM Rd. MlmMotion (714) 942-2000 Tampa, FL 3M14 12077 Wilrhiro Blvd. 1% LaAnpslm, CA 90025 MII~CWMlcnmnpumr %?vim Mountain View Pma (213) 821-4Y40 61 Lake Shore Rd P. 0.Box 4656 Notick, MA 01760 Mountoin View, CA 9Qwo CROSSMMPLERS (617) 651-6156 (415) 961-4103 Nmtilua Systewm P.O. Box 1098 The kftwue Farm srpsmft Aroclrt.. Sanb CNZ, CA 95061 P. 0.- 2m4 P.O. Box 1628 (408)475-7461 Rdm, VA 22090 cmpig,, n 61820 (217) 359-2112 mm Urlua syrtem FORTH, Inc. 7528 0.k RieHwy. crmlt.nol zM9 Pacific cant Hwy. Kmxvillo, TN 37921 Creative Solutiam, k. Her- Beach, CA 90254 (615) 69Y-6583 4801 Randolph Rd. (213) 372-8493 Rocltville, MD 20852 6502 LYNX Glc C. RWe oavo earlton 3301 OC- P& #mi 540 S. Rmch View Circle 161 581 Ookrldgo Dr. Sant. Monlcs, CA 90405 ANhsim Hllla, CA 92087 Redwood City, CA 94062 (213) 450-2466 (415) 368-3257 Sstum Software, Ltd. M&BDsalg, P. 0. Box 397 Leo Bmdie 820 Sweatbay Drive Irbw Weatminister, BC 9720 &den Avmw Sumyvale, CA 94086 VX4Y7 CANADA Chatrworth, CA 91511 (213) 99-302 Maopallr alwzmmm Show Lab$, Ltd. L&oratwy M1cmryrt.M Go FORTH P. 0. Box 3471 4147 Besthoven St. 504 Lakemaad Way Hayward, CA 94540 LaAngalg, CA 90066 Redwood City, CA 94062 (415) 276-6050 (213) 390-9292 (415) 566-6124 Nnthstr Timin Engineering Ca lmer Amma The Software Wakr, lnc. 9575 AVO. K-2 517K Marina View P. 0. Box 4386 Sm Diepo, CA 92121 Belmont, CA 94002 Mountain View, CA 94WO (714) 455-#)08 (415) 591-8295 (408)736-49x Appltationmqr Laxen & Herrb, Inc. mP-11 Innosyr 24301 Sarthlond Drive, 1303 Labbaatory Soft- Systems, br. 2150 Shattudc Avenue Hr/ward,CA 94545 MY4 Mmdoville Cmym Rd. Berkeley, CA 94704 (415) 887-2894 LaAngelm, CA 90049 (415) 843-8114 (213) 472-6995 Micmayatmna, Inc. Decision Reaurrsr Cap. 2500 E. Foothill Blvd., 1102 w 28203 Ridgatem Ct. Pasadena. CA 91107 Consumer Crmplten Rancho Palo Verd~,CA 90274 (213) 577-1471 8907 Lahha Bivd. (213) 377-3533 Lab,CA 92041 (714) 698-8088 FIG CHAPTERS

How to form a FIG Chapter: swthwest Phoenix Peter Bstsr at (602) 996-8398. 1. You kick on a time and place for the first meeting in your area. (Allow at least Tulsa 8 weeks for steps 2 and 3.) 3rd Tues FIG Meeting, 750 p.m, The Computer Store, 4343 So. Peoria, 2. Send FIG a meeting announcement on one Tulsa, OK. Bob Gih, (918) 599- side of 8-J2 x 11 paper (ens copy is 9304 or Art Goraki, (918) 743-0111. enough). Alao send list of ZIP numbers that you want mailed to (uee first three Austin John Hettings, (512) 327-5864. digits if it works for you). Dalh 3. FIG will print, address and mail to Ft. Worth members with the ZIPS you want from 4th Thur FIG Meeting, 7:OO p.m., Software San Carlos, CA. Automation, 1005 Burinem Parkway, Richardmn, TX. Marvin 4. When you've had your first meeting with 5 Elder, (214) 231-9142 or Bill Driaael or more attendees then FIG will provide (214)264-9680. you with names in your area. You have to tell us when you have 5 or more. Mountain West Salt Lake City Northern California Bill Haygood, (801)942-8000 4th Sat FIG Monthly Meeting, 1:OO p.m, at ~arth~endshopping Ctr., Heyward, Mid Atlsntic CA. FORML Workshop at 1o:m am. Potomac Joel Shprentz, (703)437-9218. Southern California New Jersey George Lyons (201)451-2905. Loa Angeles 4th Sat FIG Meeting, 11:OO a.m., Allstate Nsw York Tom ;lung, (212)746-4062. Savings, 8800 So. Sepulveda, L.A. Philip Wasaon, (213) 649-1428. Midwest Detroit ban Vieau, (313)493-5105. orange county 3rd Sat FIG Meeting, 12:M) noon, Fullerton Mirmsmta Savings, 18020 Brockhorst, Fountain 1st Mon FIG Meeting. Mark Abbott (day& Valley, CA. (714)896-2016. (612) 854-8776 OT Fred Ol-, (612) 588-9532. Call for meeting place Sm Diego or write to: MNFIG, 1156 Lincoln 'i Thur FIG Meeting, 12:OO noon. Guy Avenue, St. Paul, MN 55105. Kelly, (714) 268-3100, ~4784for dte. Foreiqn Australia Lance Collinr (03) 292600. Northwsst Seattle Chuck Pliske or Dwight Vandenburg, England FORTH Interest Group, c/o 38, (206) 542-7611. Wwrley Road, Frimley, Camberby, Surrey, GU16 5AU, Engld New Ensland Boston FORTH Interest Group, B.ba-bldg. 1st Wed FIG Meeting, 7:oO p.m, Mitre Corp, 8F, 3-23-8, Nishi-Shimbashi, Cafeteria, Bedford, MA. Bob Minato-ku, Toyko, 105 hpm. Demrow, (617) 389-6400,x198. Canada - Qusbec Boston Gilles Paillard, (418) 871-1960 Q 3rd Wed MMSFORTH Usen Gmup, 7mp.m, 643-2561. Cochituate, MA. Dick Miller, (617) 653-6136 for site. w. &.mwnyWolf Gervert, Roter Hshn 29, D-2 Hsmburg 72, Wort Garrne,(040) 644-3985. t

SIGN UP A FRIEND START A FIG Q1ApTER PUT TBE ORDBR FORM a 'lgg -IN BOAUD I

Page 199 FORTH MMbrls1oNs In/6