Home

3 - Forth

image

Contents

1. 15 16 18 521 APPLE II AUG 81 0 04 15 16 18 922 ECLIPSE OCT 82 02 15 16 18 923 IBM PC MARCH 84 15 16 18 524 NOVA MAY 81 02 0000 eee 15 16 18 525 PACE MAY 79 isses 15 16 18 526 PDP 11 JAN 80 Lise 15 16 18 527 e VAXIDOT BOS Lines uec sat eet 15 16 18 528 Z80 SEPT 82 esee 15 16 18 Ee eC BOOKS ABOUT FORTH 200 ALL ABOUT FORTH 2 25 26 35 __ Glen B Haydon An annotated glossary for MVP Forth a 79 Standard Forth 205 BEGINNING FORTH 17 18 21 Paul Chirlian Introductory text for 79 Standard 215 COMPLETE FORTH 16 17 200 Alan Winfield A comprehensive introduction including problems with answers Forth 79 220 FORTH ENCYCLOPEDIA 25 26 35 Mitch Derick amp Linda Baker A detailed look at each FlG Forth instruction 225 FORTH FUNDAMENTALS V 1 16 17 20 Kevin McCabe A textbook approach to 79 Standard Forth 230 FORTH FUNDAMENTALS V 2 13 14 16 Kevin McCabe A glossary 233 FORTH TOOLS 2 19 21 23 Gary Feierbach amp Paul Thomas The standard tools required to create and debug Forth based applications 237 LEARNING FORTH 17 18 21 Margaret A Armstrong interactive t
2. LOADING O gt IN 1 BLK IMMEDIATE Qe 1 4 5 6 7 8 CSONeUW PUN So 25 FSEUDO INTERRUFT SERVICE ROUTINE CRC 34702 EHS 26MAYS4 F RTH 79 CODE FISR CSR IN READY ANI FISR BUFFER H LXI Oo D MVI D DAD LF CFI Oz IF END OF LINE A SUR FISR_BUFFER STA THEN ZERO BUFFER FOINTER CHARS Z LHLD H INX CHARS Z SHLD INCREMENT CHARS L A MOV H ORA IF CARRY TO HIGH WORD CHARS LHI D H INX CHARS SHLD THEN THEN BACE END CODE Os IF SERIAL FORT READY M E MOV E INR E M MOV INC PTR 2 M A MOV DATA OUT QUTFUT CHAR 926 FSEUDO INTERRUFT CRO 29294 RASE 3 HEX SERIAL FORT EHS OSSEFS8Z F RTH 79 CREATE INIT ARRAY OUTPUT TO CSR TO INITIALIZE Z8O SIO 18 C 04 C 44 C O1 C OO C OZ C C1 C OS C EA C HERE INIT ARRAY CONSTANT INIT ARRAY LENGTH INIT SERIAL Grose ly INIT ARRAY LENGTH DO INIT ARRAY I C3 CSR F LOOF BAUD 200 2400 BAUD SET 4800 BASE 9600 b 19200 BAUD F A FSEUDO INTERRUFT BYTE BENCHMARK C CRC242100 TO RUN WITHOUT PSEUDO INT 8190 CONSTANT SIZE VARIABLE FLAGS 2 DO FRIME Cm PISR_BUFFER C 10 Oo DO FLAGS SIZE i FILL SET ARRAY SIZE O DO FLAGS I Ca IF I DUF DUF I BEGIN DUF SIZE lt WHILE OVER FLAGS C DROF DROP 1 THEN LOOF CR PRIMES LOOF UNPATCH 0 0 CHARS D OVER 4 SPACES CHARS Da D CHARS OUTPUT FORTH Dimensions 32 Volume VII N
3. NUMED XDIGIT Delete last digit NUMED ADDPT Oo IF 1 NUMED ADDFT THEN 32 NUMED EDLINE NUMED ADDPT C 3 Delete last char Set to blank 1 2 4 S 6 F 7 8 9 NUMED SIGN sign Set sign NUMED SIGN TNLUMED CMD zcommandlist Get a command 10 O s Zesc r 1 X 2 4cr sign S setsign char 4 add digit 11 SIGNED SLCT SELECT Get valid keystroke z Dur 3 IF EXIT THEN Return a control key gt IF SIGNED SLCT DROF C 4 EXIT THEN Return a digit So IF O ELSE 1 THEN 3 Return a sign 1009 mmi essere ssa ses NUMED 18TDIGIT NUMBER EDITOR oO Ha 2 NUMED 18TDIGIT char Add ist digit 3 NUMED CLARBUF Clear edit buffer 4 NUMED 3 Add the digit S 6 NUMED REJECT char Rejects full buffer 7 DROP BELL Say all full 8 9 NUMED NOTHING Do nothing i 1o 11 xx i3 14 DU T EL cso sae A EE EET 1009 sess ese SSeS eee Se SSS SSS NUMBER EDITOR NUMED SO NUMED SO nxtstate State O control z SNUMED CMD DUF gt R Save copy of cmd code 3 CASE Legal actions 4 OF NUMED RESET ENDOF 5 1 GF NUMED XDIGIT ENDOF 6 2 OF NUMED NOTHING ENDOF Fa 3 OF NUMED SIGN ENDOF B 4 OF NUMED ISTDIGIT ENDOF F ENDCASE 1o R 11 DUF 2 IF DROF 3 EXIT THEN Accept value 12 TNUMED FULL IF DROF 2 EXIT THEN Maxdigits reached 3 DUF O
4. S SWAP set S into definition HERE EXECUTE now execute this colon definition THEN 3 COUNT HERE OO JO0U 40b FORTH Dimensions 14 Volume VII No 3 Screen 53 0 MACRO 3 1 END MACRO 2 END MACRO addr 3 COMP 4 CSP 5 COMPILE 6 7 8 7S HERE OVER SWAP 1 C IMMEDIATE UNSMUDGE R gt DROP STATE OFF stop compiling a macro error if not compiling error if stack position not same replaced by the following start addr calculate byte count install count in new definition make new definition immediate make new definition available prepare to exit from COMPILER stop compiling macro words end addr exit from COMPILER IMMEDIATE same effect on the stack The differen ces come when they are compiled into a program to be run later In the case of the code definition for ROT the compilation address of ROT is compiled into the program We as sume here the usual fig FORTH type of implementation Then when the program is run the address interpreter transfers control to the machine code of the definition which is run This is the fastest In the case of the colon definition for ROT the compilation address of the word is again compiled into the program But this time when it is run the address interpreter must first nest down by placing a return on the return stack corresponding to the colon Then it must execute the body of
5. 214 642 5495 Committed to Excellence FORTH Dimensions instead of the other methods for defin ing synonyms It produces synonyms that run faster than colon definitions give no problems with the return stack have the same immediate or nonim mediate action of the original word can always be executed from the con sole or compiled just as could the old word and take up less space in mem ory because their parameter fields con tain just one address rather than two or three A synonym facility has obvious utility for providing abbreviations of words for use at the console as SYNONYM SYN SYNONYM SYN P PRINTER SYN D DUMP But the use of abbreviations on screens should generally be avoided in the interest of readability they could make a program rather cryptic The proper use of synonyms on screens can enhance the readability of a program Normally the names of the definitions that are part of an applica tion program are carefully chosen to reflect their function relative to the ap plication But mixed in with these application relative words are Forth relative words like DUP and 2DUP or and c Understanding the meaning of these relative to the application re quires not only understanding the logic of the application program but also the particular way in which the application functions are mapped onto Forth Thus readability and understan dability suffer With the judicious use of synonyms the logic of th
6. Contact Luis Javier Parra B Aptdo Aereo 100394 Bogota 214 0345 ENGLAND Forth Interest Group U K Monthly Ist Thurs Ip m Rm 408 Polytechnic of South Bank Borough Rd London D J Neale 58 Woodland Way Morden Surry SM4 4DS FRANCE French Language Chapter Contact Jean Daniel Dodin 77 Rue du Cagire 31100 Toulouse 16 61 44 03 06 GERMANY Hamburg FIG Chapter Monthly 4th Sat 1500h Contact Horst Gunter Lynsche Common Interface Alpha Schanzenstrasse 27 2000 Hamburg 6 HOLLAND Holland Chapter Contact Adriaan van Roosmalen Heusden Houtsestraat 134 4817 We Breda 31 76 713104 FIG des Alpes Chapter Contact Georges Seibel 19 Rue des Hirondelles 74000 Annely 50 57 0280 IRELAND Irish Chapter Contact Hugh Doggs Newton School Waterford 051 75757 or 051 74124 ITALY FIG Italia Contact Marco Tausel Via Gerolamo Forni 48 20161 Milano 02 645 8688 JAPAN Japan Chapter Contact Toshio Inoue Dept of Mineral Dev Eng University of Tokyo 7 3 1 Hongo Bunkyo 113 812 2111 ext 7073 REPUBLIC OF CHINA R O C Contact Ching Tang Tzeng P O Box 28 Lung Tan Taiwan 325 SWITZERLAND Swiss Chapter Contact Max Hugelshofer ERNI amp Co Elektro Industrie Stationsstrasse 8306 Bruttisellen 01 833 3333 SPECIAL GROUPS Apple Corps Forth Users Chapter Twice Monthly 1st amp 3rd Tues 7 30 p m 1515 Sloat Boulevard 2 San Francisco CA Ca
7. This utility was developed under MicroMotion Forth 79 on the Apple H Certain implementation specific words were used which should be mentioned Cursor positioning and video at tributes are used by NUMED Specifical ly the four words CV CH INVERSE and NORMAL are present Most versions of Forth have some sort of equivalent Glossary entries are CV row Put cursor on given row CM col Put cursor on given column INVERSE Use inverse video NORMAL Use normal video 1003 Primitives OQ NUMBER EDITOR start 1 2 CREATE NUMED SAVESTR 16 ALLOT Initial string 3 CREATE NUMED EDLINE 16 ALLOT Edit string 4 VARIABLE NUMED MAXDIGITS 12 NUMED MAXDIGITS S VARIABLE NUMED SAVESIGN Initial sign 6 VARIABLE NUMED SIGN Current sign 7 VARIABLE NUMED ADDFT Add pointer 8 VARIABLE NUMED DISPLAY Display word vector 9 46 CONSTANT Decimal point ascii 10 16 STRING SIGNED SLCT xyz 0123456789 SIGNED SLCT S 11 27 SIGNED SLCT DROP C esc charo 12 24 SIGNED SLCT DROF i C X chari 13 13 SIGNED SLCT DROF 2 C cr char2 14 gt 100 NUMED CLRBUF NUMED RESET gt NUMBER EDITOR 1 2 NUMED CLREUF Clear editing buffers 3 NUMED EDLINE 16 32 FILL Blank out edit line 4 O NUMED ADDPT Add point at begining 6 NUMED RESET Reset to initial value 7 NUMED CLRBUF Clear edit buffer 8 16 NUM
8. With an unusually powerful set of tools and an unusually easy way of helping you to use them Thetotal software environment for IBM PC XT TRS 80 Model 1 3 4 and close friends Personal License required MMSFORTH V2 4 System Disk TRS 80 Model 1 requires lowercase DDEN 1 40 track drive Personal License additional modules FORTHCOM communications module 49 95 UTILITIES EXPERT 2 expert system DATAHANDLER DATAHANDLER PLUS PC only 128K req FORTHWRITE word processor Corporate Site License Extensions Bulk Distribution trom 500 50 units eSome recommended Forth books STARTING FORTH programming THINKING FORTH technique BEGINNING FORTH r MMSFORTH 16 95 Shipping handling amp tax extra No returns on software Ask your dealer to show you the world of MMSFORTH or request our free brochure MILLER MICROCOMPUTER SERVICES 61 Lake Shore Road Natick MA 01760 617 653 6136 Volume VII No 3 15 FORTH Dimensions FEATURES FORTH 79 Standard Sub Set Access to 8031 features Supports FORTH and machine code interrupt handlers System timekeeping maintains time and date with leap year correction Supports ROM based self starting applications COST 130 page manual 30 00 8K EPROM with manual 100 00 Postage paid in North America Inquire for license or quantity pricing Bryte Computers Inc P O Box 46 August
9. it ti Structures 1 26 Pascal 4 9 Perkel M 2 18 Perry M 6 21 Pollard s Monte Carlo Factorizer 6 25 Procedural Arguments 2 10 Pruitt C 6 16 Quicksort and Swords 5 25 Ragsdale W F 1 8 1 10 2 37 3 30 5 9 6 7 Recursion 4 19 Re Defining a Colon Word 3 20 Reiling R R 2 9 3 9 Rogers H H 6 11 Ruehl T M 1 20 Schmauch E 3 20 Screen Dump TI 99 4A 6 11 Semaphores 4 23 SOFTNET High Level Packet Communication 5 32 Sorts Quicksort and Swords 5 25 Standards Forth see also 79 Standard 83 Standard fig FORTH Forth 83 Program to Run Forth 79 Code 4 28 Upgrading Forth 79 Programs to Forth 83 Tan L 6 9 Techniques Tutorials Debugging Techniques 2 38 3 32 Mixing CODE With High Level Forth 4 37 YACS 6 38 Telecommunications Simple Modem I O Words 5 13 SOFTNET High Level Packet Communication 5 32 Tevet A 5 30 Texas Instruments see TI 99 4A Think Like a User Write Like a Fox 3 23 TI 99 4A Screen Dump 6 11 Ting C H 1 12 TRACE Augmented 5 9 Upgrading Forth 79 Programs to Forth 83 3 26 Why Forth Isn t Slow 5 30 Zander J 4 23 5 32 Volume VII No 3 35 FORTH Dimensions THE FORTH SOURCE MVP FORTH Stable Transportable Public Domain Tools You need two primary leatures in a software development package a stable operating system and the ability to move programs easily and quickly to a variety of computers MVP FORTH gives you both these features and m
10. C e i SS SSS SS SSeS e SHAS SSS SS p SS SSSI SS SL SS SS SK SAS IS SSS ST SS SSS EO Oe zmmimeummmem mmueu InmADELIDPDInmnInI O NUMBER EDITOR NUMBER EDITOR 3 NUMBER EDITOR row col dvall dval2 Full edit J NUMED INITIAL Prepare to edit 4 OVER OVER INVERSE NUMED DISPLAY EXECUTE Display dvall 5 O BEGIN Initial state is S0 6 NUMED STATES Execute state 7 3 PICK 3 PICK NUMED DISPLAY EXECUTE Display result 8 DUP 3 UNTIL Go until state 3 reached 9 DROP Drop extra state value 10 NORMAL NUMED DISPLAY EXECUTE Display final dval2 11 NUMED ACCEFT Accept the result 12 13 14 15 a a a a a a e e e e ie e o e e e FORTH Dimensions 40 Volume VII No 3 Michael Ghormley San Jose California With this issue we say goodbye to John Hall as the International FIG Chapter Coordinator John has served in this capacity for more than two years and has done a sterling job For the entire FIG membership I wish to thank you John for your enormous contribution of time and energy I hope that in the future I can do as well We wish to welcome two new FIG chapters Holland FIG Chapter Breda Holland FIG des Alpes Annely France Atlanta FIG Chapter Ron Skelton reports that Rick Nixon has developed a Forth 83 for the Com modore 64 which follows Mastering Forth except for an improved editor The price is 20 which includes ongo ing support Rick
11. Note on Formatting Text This tutorial derives from my computer conferencing program Communilree Second Edition which needs to read files transmitted by phone from different operating systems with or without hard returns and displays them on terminals of different sizes The program cannot ask what kinds of files they are the same procedure must work in all cases The biggest problem which we ignored in this tutorial example was determining when carriage returns are hard Tables poetry legal text with numbered lines character graphics and other such material must preserve the existing line structure all end of line indicators in the file must cause a new line in the output so carriage returns are considered to be hard But for listing straight text which may have been sent with one line length and now may be formatted to another the pro gram should recompose the line endings until the end of paragraph The solution chosen was to let the user set the terminal line length not only to a usual range of values 20 132 but also to zero Zero means to respect the existing line structure make a new line at every end of line and not otherwise as the program example presented in this article does Any non zero line length value will cause text to be reformatted unless a paragraph break is indicated by an end of line followed by either a blank or another end of line For poetry tables etc we advise u
12. Signature Volume VII No 3 Addressing the Marketplace Dear Marlin The biggest and most common mistake that can be made in a com puter design is that of not providing enough address bits This deserves to go down as one of the classic statements of the century Although originally referring to com puter hardware I believe that it applies just as well to the Forth virtual mach ine Elsewhere in the same volume I found the startling information that on the average for a given price range machines increase their virtual memory address by one bit per year and their physical memory address by one bit per two years It is already the case that machines with a 64K memory are becoming restricted to the very low end of the marketplace Increasing numbers of people are buying machines with much larger memories and if they can t make effective use of this memory with Forth they will use something else Of course various thirty two bit Forths are available commercially but no provision was made in the Forth 83 Standard for addresses to be other than sixteen bits Although the next revision of the standard will undoubtedly do something about this it could well be too late and we will have a proliferation of incompatible solutions to the problem So I think it would be good to have some discussion about this here in Forth Dimensions which reaches the widest Forth audience and maybe get some conce
13. Volume VI Index This reference guide to Volume VI was prepared as a service to our readers and to all members of the Forth Interest Group Items are referenced by issue number and page number 79 Standard An Augmented TRACE 5 18 Automatic Capitalization in Forth 1 20 Forth 83 Program to Run Forth 79 1 20 Forth List Handling 1 36 Forth Semaphores 4 23 In Word Parameter Words 6 9 Mathquiz 6 13 Re Defining a Colon Word 3 20 Think Like a User Write Like a Fox 3 23 Upgrading Programs to Forth 83 3 26 83 Standard Enhanced DO LOOP 6 18 Forth 83 Program to Run Forth 79 Code 4 28 Forth Control Structures 2 20 Long Divisors and Short Fractions 3 10 Pollard s Monte Carlo Factorizer 6 25 Quicksort and Swords 5 25 A Simple Data Transfer Protocol 2 32 Simple Modem I O Words 5 13 Upgrading Forth 79 Programs to Forth 83 3 26 ANDIF and ANDWHILE 4 33 Anonymous Variables 1 33 Anway A 1 22 Apple IIe Screens for 1 22 Applications Mathquiz 6 13 Tutorial Simple Modem 1 O Words 5 13 Ask the Doctor Astronomical Problems 3 30 Forth and the AIM 65 2 37 How to Learn Forth 5 9 Learning Forth 6 7 Moving to ROM 1 10 An Augmented TRACE 5 18 Automatic Capitalization in Forth 1 20 Baden W 5 25 Berkey R 3 26 4 28 Capitalization 1 20 CASE Statement YACS 6 38 Chen S S 6 9 China Tour 1984 FORML 5 38 6 33 CODE Mixing With High Level Forth 4 37 Colon Word 3 20 Control Structures 2 20 Data Transfer 2 32 Debugging An Augm
14. one Forth has primitives for DNEGATE D OR and 0z while D Do and D are defined as colon definitions These lat ter could be defined instead as macros MACROD DNEGATE D MACRO D0 OR O MACRO D D DO END MACRO END MACRO END MACRO When Dz is used in a program it would compile not the compilation ad dress of D but the compilation ad dresses of DNEGATE D OR O So we see that macros compile in line code even when nested and with that comes a speed advantage But like colon definitions they also bring the same advantages of structured pro FOR TRS 80 MODELS 1 3 4 4P IBM PC XT AT amp T 6300 ETC WHICH ONE Which microcomputer word pro cessor lets you create and edit without retyping but won t slow down your creative process Knows when to capitalize the first letter while replacing one phrase with another Can outdent as well as indent Will do typesetting at your command even with propor tional characters right justifica tion and tabbed columns Lets you use the same extra capacity data disks on IBM PC and TRS 80 And eases your learning with common sense keystrokes Help menus good examples and a pro fessionally authored manual Hint it can integrate to communi cate from home to office and will interface with a database for form letters data tables and more It s the professional s word pro cessor for your IBM PC Compaq or TRS 80 Model 1 3 or 4 F ORTHWRIT E
15. run multiplied by 100 As can be seen from the table the benchmark runs at approximately two thirds of full speed with the speed gradually decreasing with increasing baud rate Worded another way the pseudo interrupt driven serial output slows the benchmark by only one third The character output efficiency for baud us oZ CD n4 Bj n E 21 FSEUDO INTERRUPT CRC 10792 BASE 3 HEX FATCH UNFATIH EWS 29AUGOZ FO RTH 7 CODE PATCH FFA C3 JMF A MVI NEXT STA NEXT i STA H A MOV END CODE H FOF ks NEXT 2 STA A MOV NEXT JME CODE UNFATCH NEXT Ca A MVI NEXT 2 Cd A MVI 6 9 NEXT STA NEXT 2 NEXT STA 1 C3 A MVI NEXT JMF NEXT te STA 2 END CODE CURRENT CR 22 FSEUDO INTERRUFT CRC 7942 BACK ASSEMBLES THE THRE PATCHED OVER IN NEXT AN MACRO BACK EHS 29A6UGg3X FORTH 759 ONE BYTE A JUMP INS TIONS THAT TO NEXT 23 ARE BASE CONTEXT 3 CURRENT 2 DECIMAL ASSEMBLER DEFINITIONS BACK G eee C NEXT C3 t ca T 24 C3 5 JMF 3 LITERAL LITERAL LITERAL CONTEXT BASE C HZI PSEUDO INTERRUFT CRC 4O0007 DON T WAIT FOR CHAR IN kKEY I Q0 VECTORING EHS 29 AUGaS FORTHE CF M WHERE NEXT WON T BE EXECUTING OREY I O BEGIN TTERMIRMAL UNT IL ZKEY s ty KEY FATCH KEY I O0 CFA KEY UNFATCH KEY CFA BUFFER ETC EHS 2 z6MavY84 FORTH 79 4 FSEUDO INTERR
16. so that the DOES part of MACRO will be executed when the mac ro is later interpreted from the console or a screen and the words of the definition will then be moved out ap propriately END MACRO then drops its own return off the return stack so that control will return to MACRO when END MACRO is finished Then compilation is stopped When control returns from END MACRO the word DOES alters the code field of the macro being defined so that the DOES part of MACRO will be executed later when the macro definition is used TRAADOM Oe Chet m SOTA or expen Computing sive royaity Systems or licensing Limited lets arrange you choose ments As between either the versatile figFORTH model or tne popular 79 Standard Each version is available for a number of pop ular computer long as your applications programs do not offer the end user access to the basic FORTH system you are free to make as many copies systems of the com including piled FORTH the IBM PC system as XT and AT you please or compa and tibles the distribute TRS 80 them as Model 1 III you wish and 4 4P FORTH or any from computer system SOTA 1s the running CP M FORTH of version 2 x choice for both or CP M Plus the novice and version 3 x experienced Whats more TRS 80 programmer SOTA doesnt Make it your require you choice now to enter into Order your any awkward copy today When you order fro
17. 13 lt gt AND IF None of these DROP 1 THEN NEW LINE Start a new line if not more than 2 in a row LINES 2 lt IF 13 DOS EMIT 10 DOS EMIT 1 LINES THEN OUT No P Maybe output the character KEY F83 gt IF KEY DROP KEY DROP THEN Toggle pause 127 AND Clear parity bit if set DUP 32 IF KILL THEN Change unwanted char to 1 DUP 12 IF DROP 10 THEN Change formfeed to linefeed DUP 10 IF DROP 1 LINES O IF NEW LINE THEN THEN DUP 13 OVER O OR IF DROP 1 NEW LINE ELSE 0O LINES t THEN New line if CR or Null DUP 1 lt gt IF DOS EMIT ELSE DROP THEN HH 5 A FDOS8 BLK Main loop to read the file READ FILE gt P List the OPEN file INITIALIZE DOS O LINES BEGIN READ RECORD WHILE There ia more data RECORD RECORD LENGTH OVER SWAP DO I C OUT LOOP REPEAT 18Aug85 JJ Optional F83 code for saving program to be used from DOS To use the program from DOS say LIST filename BOOTUP 99 3 DEFAULT to open filename for input READ FILE O O BDOS Return to DOS BOOTUP IS BOOT 3 NEW ERR Cnn f NEW ERR IS ERROR SAVE SYSTEM LIST COM IF O O BDOS ELSE 2DROP THEN 8 Volume VII No 3 been packed more tightly to save space for publication Turnkey Operation The second part of the last screen has optional code to make this program usable as a DOS command The F83 word BOOT controls action of the system on startup here it is set to open a filename given i
18. 1984 debugging 200 by Derick amp Baker 25 C 1981 Rochester Proceedings MVP FORTH Cross Compiler for CP M Programmers Kit Generates Ew FYS FORTH from the Netherlands C 1981 C 1982 O 1983 headerless code tor ROM or target CPU 300 J User Manual 25 O 1984 each 25 MVP FORTH Meta Compiler or CP M Programmer s kit Use for C Source Listing 25 Bibliography ot FORTH 17 applications on CP M based computer tw FORTH Tools and Applic D The Journal of FORTH Includes public domain source 150 by Feierbach 19 Application amp Research The Complete FORTH by Winfield 16 D Vol 1 1 Vol 1 2 MVP FORTH PAOS Prolessionat Application Development System for IBM MEWO Learning FORTH by Armstrong 17 O Vol 2 1 O Vol 2 2 PC XT AT or PCir of Apple il 11B or Ile An integrated system for customizing your O Understanding FORTH by Reymann 3 EWO vol 2 3 each 15 FORTH programs and applications The editor includes a bi directional string O FORTH An Applications Approach CJ METAFORTH by Cassady 30 search and is a word processor specially designed for fast development PADS has by Toppen 20 Threaded Interpretive Languages 25 almost triple the compile speed of most FORTH s and provides fast debugging C FORTH Applications by Roberts 13 Systems Guide to tig FORTH techniques Minimum size target systems are easy with or without heads Virtual Mastering FORTH by Ting 25 overlays can be compiled in object code PADS is a true professional de
19. OVER 3 OR IF DROF EXIT THEN esc sign 14 DUF 1 OVER 4 OR IF DROF 1 EXIT THEN X digit 15 ee ESSERE SSS Sees 010 sees ee SSeS SSS SSSR SS SST O NUMBER EDITOR NUMED S1 1 s NUMED S1 nxtstate State 1 control 2 NUMED CMD DUP gt R 3 CASE 4 OF NLUMED RESET ENDOF we 1 OF NUMED XDIGIT ENDOF 6 2 OF NUMED NOTHING ENDOF 7 OF NUMED SIGN ENDOF 8 4 OF NUMED ENDOF 9 ENDCASE 10 R gt 11 7NUMED FULL IF DROP 2 EXIT THEN Maxdigits reached 12 DUP O IF DROF EXIT THEN esc Undo 13 DUF 1 OVER 2 gt OR IF DROF 1 EXIT THEN X digit 14 DROP 3 4 CR Accept is Volume VII No 3 39 FORTH Dimensions the append digit word while other ac tion words take no parameters at all The resulting code is not as elegant as it might be but I saw no overriding reason to change it Configuring NUMED NUMED is normally configured to accept a ten digit value displayed in the 10 2 format mentioned earlier This may not always be desirable of course You may wish to reconfigure the editor before editing a field To do this you need to create a new display word then change the display vector to point to it and change the acceptable number of digits NUMED 10 2 is the default display word and NUMED DISPLAY is the vector NUMED MAXDIGITS is a variable containing the maximum number of digits accepted for a value For example to edit a field in the form xxx xx with all f
20. background processing concurrently with I O but requires greater hardware know how Here is an intermediate technique which uses simple polling and allows background processing like interrupts An Approach to Reading Programs by Kim Harris amp Michael Ham What increases productivity reduces development time and contributes to programmer training Formal code inspections facilitate the difficult task of truly comprehending a program and help programmers learn from their colleagues techniques and skills Volume VI Index by Julie Anton Trying to remember where in Forth Dimensions that article or piece of code was printed or if a particular subject was covered This subject author title index was prepared as a reader service Number Editing Utility by Ken Takara Crashproofing an application often means shielding the program from bad numeric input and providing in progress editing features to the user Vectored execution makes this technique powerful and general enough for many uses DEPARTMENTS 41 41 42 Letters Editorial Macronautics Application Tutorial Universal Text File Reader by John James Advertisers Index Chapter News by Michael Ghormley FIG Chapters Journal Forth Application AND Research The aim of the Journal is to provide a reliable source of state of the art techniques and applications of Forth to scientific and industrial problems The Journal s edi torial review boar
21. compatibles Compare BYTE Sieve Benchmark jan 83 HS FORTH 47 sec BASIC 2000 sec with AUTO OPT 9 sec Assembler 5 sec other Forths mostly 64k 55 140 sec FASTEST FORTH SYSTEM AVAILABLE TWICE AS FAST AS OTHER FULL MEGABYTE FORTHS TEN TIMES FASTER WHEN USING AUTO OPT HS FORTH complete system only 270 Visa Mastercard HARVARD SOFTWORKS P O BOX 69 SPRINGBORO OH 45066 513 748 0390 FORTH Dimensions WONBOUAWNHRO O Transform input character and maybe write it 3 A FDOS8 BLK Universal text file reader This screen has words specific to F83 Note that we are relying on the F83 word OPEN After you open a file with OPEN lt name gt the FCB address will be in the F83 variable FILE DOS EMIT c 2 BDOS DROP 128 CONSTANT RECORD LENGTH CREATE RECORD RECORD LENGTH ALLOT Buffer for DOS to use SET RECORD X cmm P Tell DOS to uae RECORD for buffer RECORD 26 BDOS DROP FILE RESET P Set sequential record number in FCB O FILE Q 32 C READ RECORD 18Aug8S JJ ws SS LS amp DOS function call 2 P Read 128 bytes O succesa FILE 20 BDOS i lt gt 1 means no more data at all INITIALIZE DOS oes P Prepare DOS for sequential I O SET RECORD FILE RESET r 4 A FDOB8 BLK 18Aug85 JJ VARIABLE LINES Counter to prevent multiple lines KILL cl c2 P Kill unwanted control characters DUP O lt gt OVER 10 lt gt AND OVER 12 lt gt AND OVER
22. most of the discussion in Forth Dimensions is technical e g the best CASE or LEAVE construct Where are the articles on application programs in Forth Possibly it is because hackers myself included en joy working on small system utilities more than writing application pro grams Thankfully you have published sev eral good application programs Three articles were especially interesting FORTH Dimensions Macronautics We had a hunch our readers would benefit from macros back when we first published Jeffrey Soreff s article Forth Dimensions V 5 Mirabile dictu Macros reappear in this issue in a number of places one letter from a reader shares two macros with us to aid program legibility an article uses the technique to obtain benchmarks of Forth words and from the University of Chicago Professor Victor Yngve delivers a different method for creating macros and proposes an innovative use of them but be sure to read his Synonyms first Afterwards dig out Soreff s original article and the follow up by Don Taylor VII 1 compare them use the techniques draw some conclusions and send your written results to us And who will be the first to share his tookit of macros with the FIG community With this issue a new coordinator will be reporting on the international network of FIG chapters John Hall has stepped down from the position in Letters continued from page 5 Simple Modem I O Quicksor
23. on the stack as input to VARIABLE T WORD NOW NEGATE T original body of word gt NOW T Figure One WORDn NEXTNO LITERAL MARKSTART gt R original body of word gt R MARKEND Figure Two Avg Msecs 5416 000 1 516 0 733 0 650 0 0 000 Summary Figure Three INC ADDR i SWAF NEXTNG N WORD DUF SWAF INC IMMEDIATE MARESTART i N N FREEZE DUF DUF USES INC NOW NEGATE SWAF TCUM UNFREEZE 3 MARKEND N FREEZE NOW SWAF TCUM UNFREEZE H ss CCOMFILE 3 IMMEDIATE CCOMPILE CCOMFILEJ NEXTNG CCOMPILE LITERAL COMPILE MARESTART COMPILE bR 3 IMMEDIATE COMPILE R gt COMFILE MAREEND CCOMPILED s 3 IMMEDIATE SCR 3S6 TIMER MACRO TESTING TASK 3 ay Be 3 DUP DUF 3 TWO 7 TZ 234 1000 DO DUF 2 DROF DUF DUF DROF DUF TWO e DROF LOOF DROF TS SUMMARY a M M M PH M o M M Volume VII No 3 25 FORTH Dimensions FORTH Dimensions TOTALCONTROL with LMI FORTH For Programming Professionals an expanding family of compatible high performance Forth 83 Standard compilers for microcomputers For Development Interactive Forth 83 Interpreter Compilers 16 bit and 32 bit implementations Full screen editor and assembler Uses standard operating system files 400 page manual written in plain English Options include software fl
24. or out of a control construct are UNTIL 2 LOOP LINK otherwise allowed When compiling DO R gt 2 ROT SWAP DUP gt R ROR structured constructs all forward or referencing can be handled on the 700 20UP stack since multiple constructs within IF 2DROP Ip amp R a word will be nested rather than over lapping For example when compiling ELSE R gt 2 ROT SWAP DUP gt R gt ROR a BEGIN will invoke HERE leaving the address of the next word to be com THEN piled Later UNTIL compiles a 7BRANCH followed by the address left on the stack by BEGIN it is where 2BRANCH Figure Four will conditionally branch to If another BEGIN is encountered before VARIABLE LOOP LINK T UNTIL it too will leave the address of its forward reference on the stack Since the forward reference address on the DO EHIT LOOP LINK T amp HERE LOOP LINK T 9 top of the stack goes with the second BEGIN the first UNTIL encountered LOOP EHIT LOOP LINK T must terminate the second BEGIN UNTIL D gt 4 UER construct causing it to be nested inside BEGIN De A HERE THERE ORE noon ee the first one Similar reasoning applies IF NIP THEN A gt D to the other Forth control constructs except LEAVE UNTIL THERE 2 LOOP LINK T Since multiple LEAVEs can occur within a DO LOOP along with other con i structs and since DO LOOPs can also be Figure Five nested the simple structured scheme FORTH Dimensions
25. s home phone is 404 377 3509 Brian Walsh provided a comparison of fig FORTH Forth 79 Forth 83 and HP 71B Forth East Tennessee FIG Chapter Norman E Smith writes that Richard Spille talked on the operation of the Forth inner interpreter Paul Satterlee presented a high level floating point package and Dick Tracey demonstrated Forth on a TI 99 44 Boston FIG Chapter The report from Bob Demrow is that their group is developing a controller project for the Plymouth Carver Plan etarium as a public service project It is being coordinated by Russell Blake Also Al Grant spoke on the Rockwell R65F11 chip set Richmond FIG Chapter Donaid Full reports that John C Lundin Jr is giving a tutorial on data structures Donald Full presented new words called conditional comments which may be passed over or compiled depending on a value on the stack Phil Smith brought a Rockwell R65F11 based single board computer for inspection Advertiser s index Bryte Computers 16 Dash Find amp Associates 12 Forth Interest Group 21 24 Forth Dimensions 44 FORML Conference 33 FORTH Inc 18 Forth Institute 4 Hartronix 10 Harvard Softworks 8 HiTech Equipment 2 Laboratory Microsystems 26 MCA 41 MicroMotion 20 Miller Microcomputer Services 15 Mountain View Press 36 Next Generation Systems 20 Parsec Research 27 Shaw Laboratories 20 Sota 17 FIG Forth for the Compaq IBM PC and compatibles 35 Operates under DOS 2 0
26. screens could be preloaded in the system Or for the occasional applica tion that needs the extra memory synonyms not used by the application could simply be commented out before loading the conversion screens The definition of SYNONYM on screen 46 is programmed entirely in Forth 83 and should be completely portable across Forth 83 systems The routine provides a good exercise in the use of the defining word technique in Forth The programming is fairly straightforward except that the em bedding of DOES twice in an IF ELSE THEN construct after a single CREATE may raise some eyebrows It is perfectly legal however and works beautifully It allows the single defin ing word SYNONYM with a single CREATE to make two different families of words a family with the behavior of immediate words for synonyms of im mediate words and a family with non immediate behavior for synonyms of nonimmediate words This is necessary because the usage chosen of SYNONYM lt new name gt lt old name gt puts the new name first as is done with colon VARIABLE CONSTANT and CREATE so it is not known which class the new word should belong to until after the new name field has been Volume Vil No 3 created and the old word has been found in the dictionary The routine first creates a name field and link field for the new word Then in the body parameter field it com piles the compilation address CFA of the old wo
27. technique is similar to that used in the article Tracer for Colon Definitions Forth Dimensions V 2 Screen 52 contains some words used to measure time These will be system dependent The words shown here are for the Commodore 64 which has an interrupt driven three byte jiffy counter at locations 160 162 Location 162 is incremented once each interrupt cycle approximately sixty per second Only the lower two bytes of this count er are used here giving a timing range of over 1000 seconds FREEZE and UNFREEZE prevent the overhead time consumed by the timing macros themselves from accumulating into the measured time FREEZE moves the current time value into the variable VNOW while UNFREEZE resets the jiffy clock back to its value when FREEZE was executed In some systems these words might be written to actually stop Volume VII No 3 Macros SCR SS O i WORD TIMER MA CROS 1 i 2 161 CONSTANT VARIABLE VNOW s INITNOW JIFFY 3 FREEZE JIFFY VNOW UMFREEZE VNOW JIFFY 3 NOW VNOW DUF CG 256 SWAF i C JIFFY ARRAY CREATE z ARRAY USES ZO ARRAY TCUM 2 VARIABLE WORDS INIT WORDS LOAD 54 LOAD 2 ALLOT DOES SWAF Be 0 USES 40 ERASE TCUM 40 ERASE 3 S59 LOAD INIT INITNOW amp on C WORD TIMER MACROS 2 1000 6 SCONSTANT CONV 0 CONVERT TQ MILLI SECS Trar TAYE N D N D TECUM amp DLE CONV Les 3 TTOT ROT U
28. the stack and the DO LOOP remains struc tured T LOOP COMPILE TARGET LOOP LOOP EHIT T T LOOP COMPILE TARGET LOOP LOOP EHIT T LEAVE T DO COMPILE TARGET DO DO EHIT T T 200 COMPILE TARGET 700 DO EHIT T Figure Six HERE LOOP LINK T The implementation of DO LOOP given here avoids having to place the forward reference for LEAVE on the return stack resulting in a two item use of this stack as did pre 83 Forths The tradeoff is a somewhat more com plex compile time activity This im plementation should be easy to adapt to the current DO LOOP constructs since the run time words LOOP LOOP LEAVE and J which are CODE words and thus machine de pendent require very little modifica tion The loop index word 1 remains unchanged For J reduce the indexing into the stack by 2 since the LEAVE ad dress is no longer there For LOOP and LOOP the change is simple At the end of each of these words the items used by the DO LOOP are pulled off the return stack For 8080 imple mentations the 6 D LXI in LOOP EXIT should be changed to 4 D LXI For the 650X LOOP EXIT contains six PLAs Remove two of them Similarly for LEAVE two fewer return stack pulls are needed The problem of unstructured for ward references left on the parameter Stack by LEAVE is eliminated by build ing a linked list of these references When Loop or LOOP is encountered it follows the
29. the group stays together and actually examines each word Without such a reading code inspections quickly degenerate into Next is screen 10 any comments No Screen 11 Screen 12 The process goes faster but the code is not really examined or under stood Inspectors The remaining team members are inspectors They fol low the code as the reader reads it they ask questions of the author and point out what they question or don t understand Some inspectors may be asked to pay special attention to pro gram functions in their area of exper tise e g drivers data base design quality assurance integration testing All members of the team check the code for style Are the names well chosen Are stack diagrams present and accurate Are comments present and helpful To prepare for a code inspection each person should spend two hours carefully reviewing the code to get familiar with it and to get some grasp of how it does what it does The reader of course may have to prepare in greater detail since to paraphrase the code requires a good understanding of its intentions Preparation is vitally important to the success of the code inspection The meeting should be limited to two hours people cannot focus with any intensity for a longer period of time Experience shows that a line of Forth code requires on the average about thirty seconds in this kind of review this means a screen can be covered i
30. third column When DUP is encountered during compilation the words in the DOES expression in MACRO first column move the compiled code for DUP IF DUP THEN from the body of the macro definition into the program column four which is the same result as if DUP IF DUP THEN had been encountered during compilation instead of 7DUP Figure One Screen 51 0 MACRO 1 1 Usage MACRO EXEC MACRO LMI 2 80 FORTH 3 01 2 23 85 MACRO name END MACRO Like lt name gt start compiling a macro error if not executing CSP moved to line 13 after HERE CURRENT current vocabulary CONTEXT Q CLR HASH CONTEXT becomes context BUILD create heading for macro SMUDGE make macro unavailable 1 ALLOT space for byte count in macro HERE for use by END MACRO CSP save stack position for check COMPILER start compiling words into macro CODE replaced by does as follows addr Screen 52 O MACRO 2 MACRO cont DOES pfa STATE Q IF move words of macro into place is macro being used while compiling pfa 1 n here OVER ALLOT Space for macro words in program SWAP CMOVE move macro words into program ELSE interpreting CR HERE set colon definition cfa at HERE COUNT SWAP OVER n pfa 1 n HERE 2 address for macro words SWAP CMOVE move macro words into definition HERE 2 address for S in definition
31. 0 THEN ii LOOF Keep looking z IF DROF 1 THEN Failure flag return failure 13 4 gt Data entry SELECT 1002 1 2 SELECT string offset Return position in string of char 3 BEGIN 4 OVER OVER KEY Dup strings get key is INSTRING See if it s in the string 6 DUP 1 Not found yet 7 WHILE 8 DROF Drop key and keep trying 9 REFEAT 1o R DROF DROF R Keep only position offset 37 FORTH Dimensions Valid keys are defined as follows Keys 0 9 Numeric digit c Accept current value esc Get initial value X Delete last digit Change sign to positive Change sign to negative The actions of the keys are best described by referring to the state diagrams Figure One Note that if the first key pressed is a digit the initial value is cleared and replaced by whatever the user enters Notes on the Display The default display word is set to show a thirteen character field ten digits and a decimal point a dollar sign and either a plus or a minus Obvious ly this was developed for business ap plications The format is 10 2 ten digits with two to the right of the decimal point The display is vectored so you aren t stuck with only a 10 2 dollar for mat You can write your own display word based on the default word then tell NUMED to use it instead I ll talk about that in the Configuration sec tion Implementation Dependencies
32. 20 O 8087 Support IBM PC or 8086 100 D 9511 Support 280 or 8086 100 O Color Graphics 280 or 8086 100 O Data Base Management 200 Key to Vendors MVP FORTH Software A transportable FORTH HW Hawg Wild Software Codes CQ MVP FORTH Programmer s Kit including disk documentation Volumes 1 2 amp 7 of LM Laboratory Microsystems F Floating Point MVP Series and Starting FORTH OCP M OCP M 86 02100 DApople MM MicroMotion G Graphics CISTM PC OIBM PC XT AT amp compatibles OPC MS DOS MOsborne Pink Noise Studio T Tutorial ClKaypro CJMicroDecisions CDEC Rainbow ONEC 8201 CITRS 80 100 PS Par Sec X Other Extras New CHP 150 OHP 110 CO Macintosh O Atari 600 800 1200 O ADAM 175 oO MVP FORTH Enhancement Package lor IBM PC XT AT Programmer s Kit includes full screen editor MS DOS file interface disk display and assembier operators 110 FORTH MANUALS GUIDES amp DOCUMENTS MVP FORTH Floating Point and Matrix Math for IBM PC XT AT with 8087 EWC Thinking FORTH by Leo Brodie author CJ 68000 fig Forth with assembler 25 or Apple with Applesoft 85 of best selling Starting FORTH 16 C FORML Proceedings MVP FORTH Graphics Extension for IBM PC XT AT or Apple 65 CJ ALL ABOUT FORTH by Haydon O 1980 C 1981 Vol 1 MVP FORTH Programming Aids for CP M IBM or APPLE Programmer s MVP Glossary 25 C 1981 Vot 2 O 1982 Kit Extremely useful tool for decompiling callfinding translating and O FORTH Encyclopedia twC 1983 C
33. 28 Volume Vil No 3 T LEAVE COMPILE LOOP LINK T TARGET T no longer applies For example con sider this word WORD DO BEGIN LEAVE UNTIL LOOP To implement LEAVE have it compile LEAVE which at run time pops the DO LOOP items off the return stack and branches to the forward address just after LOOP This address is contained in the memory location following LEAVE An obvious but unsuccessful way to then resolve the forward reference created after LEAVE is to put the address after LEAVE on the stack so that LOOP can put the address after LOOP into the address after LEAVE that is resolve the forward reference But UNTIL would use the address left by LEAVE to resolve the forward reference of BEGIN instead This control flow is unstructured due to LEAVE DO LOOP Implementations To solve this compile time problem the Forth 83 implementations have DO push an extra item on the return stack which it gets from the location following DO in the threaded code This item is the address used by LEAVE Thus the forward reference for LEAVE is compiled by LOOP which puts it in the address following DO Any LEAVES within the DO LOOP com pile LEAVE but no forward reference following LEAVE It is at run time that LEAVE gets its forward reference from the return stack and branches to it At compile time LEAVEs do not leave forward reference addresses on
34. 3 Pro gram to Run Forth 79 Code Forth Dimensions V1 4 3 Ragsdale William F fig FORTH Installation Manual Glossary Model Editor San Carlos CA Forth Interest Group 1980 4 Derick Mitch and Linda Baker FORTH Encyclopedia The Com plete Forth Programmer s Manual 2nd ed Mountain View CA Mountain View Press 1982 Volume VII No 3 Forth Timer Iram Weinstein McLean Virginia There comes a time in the develop ment of many applications when every thing works and attention turns to speeding up the run time The first step in this phase of development is to determine which words contribute most to the running time of the ap plication A typical scheme for this might involve temporarily changing the definition of each word to be tested as in Figure One where NOW is a word that puts the current clock time on the stack After recompiling and running the application with this augmented defini tion of WORD T will contain the ac cumulated time used by WORD Each word in the application can be tested in turn The inconvenience of having to insert temporary modifications into colon definitions combined with the desire to count the number of uses of each word in the application led to screens 52 55 shown here These screens define a set of Forth macros Forth Dimensions V 5 that redefine the defining words and to automati cally insert the timing actions into any words subsequently compiled The
35. 4099 Potomac Chapter Monthly 2nd Tues 7 p m Lee Center Lee Highway at Lexington St Arlington VA Call Joel Shprentz 703 860 9260 Richmond Forth Group Monthly 2nd Wed 7 p m 154 Business School Univ of Richmond Call Donald A Full 804 739 3623 WISCONSIN Lake Superior FIG Chapter Call Allen Anway 715 394 8360 MAD Apple Chapter Contact Bill Horzon 129 S Yellowstone Madison WI 53705 FOREIGN AUSTRALIA Melbourne Chapter Monthly 1st Fri 8 p m Contact Lance Collins 65 Martin Road Glen Iris Victoria 3146 03 29 2600 Sydney Chapter Monthly 2nd Fri 7 p m John Goodsell Bldg Rm LG19 Univ of New South Wales Sydney Contact Peter Tregeagle 10 Binda Rd Yowie Bay 02 524 7490 BELGIUM Belgium Chapter Monthly 4th Wed 20 00h Contact Luk Van Loock Lariksdreff 20 2120 Schoten 03 658 6343 Southern Belgium FIG Chapter Contact Jean Marc Bertinchamps Rue N Monnom 2 B 6290 Nalinnes Belgium 071 213858 CANADA Nova Scotia Chapter Contact Howard Harawitz 227 Ridge Valley Rd Halifax Nova Scotia B3P2ES 902 477 3665 Southern Ontario Chapter Quarterly Ist Sat 2 p m General Sciences Bldg Rm 312 McMaster University Contact Dr N Solntseff Unit for Computer Science McMaster University Hamilton Ontario L8S4K1 416 525 9140 ext 3443 Toronto FIG Chapter Contact John Clark Smith P O Box 230 Station H Toronto ON M4CSJ2 COLOMBIA Colombia Chapter
36. 492 Cincinatti Chapter Call Douglas Bennett 513 831 0142 Dayton Chapter Twice monthly 2nd Tues amp 4th Wed 6 30 p m CFC 11 W Monument Ave Suite 612 Dayton OH Call Gary M Granger 513 849 1483 OKLAHOMA Central Oklahoma Chapter Monthly 3rd Wed 7 30 p m Health Tech Bldg OSU Tech Call Larry Somers 2410 N W 49th Oklahoma City OK 73112 OREGON Greater Oregon Chapter Monthly 2nd Sat 1 p m Tektronix Industrial Park Bldg 50 Beaverton Call Tom Almy 503 692 2811 PENNSYLVANIA Philadelphia Chapter Monthly 4th Sat 10 a m Drexel University Stratton Hall Call Melonie Hoag 215 895 2628 TENNESSEE East Tennessee Chapter Monthly 2nd Tue 7 30 p m Sci Appl Int l Corp 8th Fl 800 Oak Ridge Turnpike Oak Ridge Call Richard Secrist 615 693 7380 TEXAS Austin Chapter Contact Matt Lawrence P O Box 180409 Austin TX 78718 Dallas Ft Worth Metroplex Chapter Monthly 4th Thurs 7 p m Call Chuck Durrett 214 245 1064 Houston Chapter Call Dr Joseph Baldwin 713 749 2120 Permian Basin Chapter Call Carl Bryson Odessa 915 337 8994 UTAH North Orem FIG Chapter Contact Ron Tanner 748 N 1340 W Orem UT 84057 VERMONT Vermont Chapter Monthly 3rd Mon 7 30 p m Vergennes Union High School Rm 210 Monkton Rd Vergennes VT Call Don VanSyckel 802 388 6698 VIRGINIA First Forth of Hampton Roads Call William Edmonds 804 898
37. ASKA Kodiak Area Chapter Call Horace Simmons 907 486 5049 ARIZONA Phoenix Chapter Call Dennis L Wilson 602 956 7678 Tucson Chapter Twice Monthly 2nd amp 4th Sun 2 p m Flexible Hybrid Systems 2030 E Broadway 206 Call John C Mead 602 323 9763 ARKANSAS Central Arkansas Chapter Twice Monthly 2nd Sat 2 p m amp 4th Wed 7 p m Call Gary Smith 501 227 7817 CALIFORNIA Los Angeles Chapter Monthly 4th Sat 10 a m Hawthorne Public Library 12700 S Grevillea Ave Call Phillip Wasson 213 649 1428 Monterey Salinas Chapter Call Bud Devins 408 633 3253 Orange County Chapter Monthly 4th Wed 7 p m Fullerton Savings Talbert amp Brookhurst Fountain Valley Monthly 1st Wed 7 p m Mercury Savings Beach Blvd amp Eddington Huntington Beach Call Noshir Jesung 714 842 3032 San Diego Chapter Weekly Thurs 12 noon Call Guy Kelly 619 268 3100 ext 4784 Sacramento Chapter Monthly 4th Wed 7 p m 1798 59th St Rn A Call Tom Ghormley 916 444 7775 Bay Area Chapter Silicon Valley Chapter Monthly 4th Sat FORML 10 a m FIG 1 p m ABC Christian School Aud Dartmouth amp San Carlos Ave San Carlos Call John Hall 415 532 1115 or call the FIG Hotline 408 277 0668 Stockton Chapter Call Doug Dillon 209 931 2448 COLORADO Denver Chapter Monthly Ist Mon 7 p m Call Steven Sarns 303 477 5955 CONNECTICUT Central Connecticut Chapter Call C
38. Calendar clock 4HR backup 44K Byte ram 200NS 32K Byte EPROM operating system IK X 32 microprogram memory 70ns H4TH 10 DESKTOP Dual 0 8m Byte floppys HATH OI processor Three user slots Two expansion slots Power amp cooling H4TH 20 DESKTOP 10 m Byte Winchester 0 8 m Byte floppy HATH OI processor 300K byte RAM expandable 2m byte Three user slots One expansion slot Power amp cooling A forth engine consisting of a state of the art integrated hardware software system giving unsurpassed performance for professionals and their applications from a company that is totally dedicated to the forth concept and its implementation HARTRONIX Inc FORTH Dimensions 1201 North Stadem Drive Tempe Arizona 85281 10 602 966 7215 Volume VII No 3 Synonyms and Macros Synonyms Victor H Yngve Chicago Illinois A startling thing beginners at Forth learn quite early is that a function can easily be renamed for convenience For example S STACK edit EDIT Or even to make a point with other beginners PRINT FETCH This is fine as far as it goes and it is widely used But the technique will not always work Consider this attempt at defining a fig FORTH R as R in a Forth 83 system so as to make it easier to convert an old program to run on a new system R R This will not work because the ex ecution of R will place a return on the return stack covering up the item
39. DO LOOP Dennis L Feucht VARIABLE LOOP LINK Beaverton Oregon i When the Forth 83 Standard was DO EHIT TRUE LOOP LINK HERE LOOP LINK 1 0 released it was accompanied by a well DO COMPILE DO DO EHIT IMMEDIATE written public domain model which could run on CP M systems Another 700 COMPILE 2700 DO EHIT IMMEDIATE model was provided by Laxen Perry Tracy et al for the Apple II and other 650X based computers Both imple LERUE now compiles LERUE and links in the following address mentations of Porth mandie DO LOOP LERDE COMPILE LERDE HERE LOOP LINK Forth 83 definition for LEAVE differs LOOP LINK from that of Forth 79 or fig FORTH necessitating a different approach to IMMEDIATE DO LOOP implementation Structured vs Unstructured Constructs In pre 83 Forths LEAVE would cause Figure One Figure Two LOOP EHIT SWAP CONDITION LOOP LINK a DO LOOP to be exited when the pro BEGIN DUP gt R HERE 2 OVER Re DUP gram flow reached LOOP In Forth 83 the loop is left immediately Although IF NIP THEN A gt O the Forth 83 LEAVE is more versatile than the previous one it also has the effect of unstructuring the DO LOOP construct Other Forth control con z structs such as If ELSE THEN or BEGIN LOOP COMPILE LOOP LOOP EHIT IMMEDIATE UNTIL are structured in that they have LOUP COMPILE LOOP LOOP EHIT IMMEDIATE one entry and one exit No branches Figure Three into
40. ED ADDFT Fointer to end of string 9 NUMED SAVESTR NUMED EDLINE 16 CMOVE Restore initial str 10 NUMED SAVESIGN NUMED SIGN Restore initial sign POOS EI O NUMBER EDITOR NUMED INITIAL NUMED ACCEPT 1 2 NUMED INITIAL dval Set initial value 3 NUMED SAVESTR 16 32 FILL Clear holding buffer 4 NUMED CLREUF Clear edit buffer S 2DUP O D IF 1 ELSE THEN NUMED SAVESIGN 6 lt 5 gt DUP gt R dval gt string 7 NUMED SAVESTR SWAP CMOVE Save initial value string 8 NUMED RESET R gt NUMED ADDPT 3 Initial add point 9 10 NUMED ACCEPFT dval Accept the edited value 11 O NUMED EDLINE 1 CONVERT DROP string dval 12 NUMED SIGN G6 IF DNEGATE THEN Get sign 13 14 15 Sessa SSsSe Sess SSeS sss NUMBER EDITOR 1006 sS 2csesssmms tems eSB SSeS NUMED FULL NUMED o 1 2 NUMED FULL 3 flag True if buffer is full NUMED ADDPT NUMED MAXDIGITS lt NOT 4 5 NUMED char Add digit to string 6 NUMED EDL INE Edit line 7 NUMED ADDPT C Append to add point 8 1 NUMED ADDPFT Increment add point 9 10 gt 11 12 13 14 FORTH Dimensions 38 Volume VII No 3 MicroMotion Forth also has a set of string handling words I ve used S and STRING to create a single dimension array of characters for my own word SELECT STRING is a defining word that makes space fo
41. FORML PROCEEDINGS 1981 2V 40 43 45 Nucleus layer interactive layer extensible layer metacompilation system development file systems other languages other operating systems applications and abstracts without papers 312 FORML PROCEEDINGS 1982 25 28 35 Forth machine topics implementation topics vectored execution system development file systems and languages applications 313 FORML PROCEEDINGS 1983 25 28 35 ___ Forth in hardware Forth implementations future strategy programming techniques arithmetic amp floating point file systems coding conventions functional programming applications 314 FORML PROCEEDINGS 1984 25 28 35 Expert systems in Forth using Forth philosophy implementing Forth systems new directions for Forth interfacing Forth to operating systems Forth systems techniques adding local variables to Forth o o ROCHESTER PROCEEDINGS The Institute for Applied Forth Research Inc isanon profitorganization which supports and promotes the application of Forth It sponsors the annual Rochester Forth Conference 321 ROCHESTER 1981 Standards Conference 25 28 35 1 79 Standard implementing Forth data structures vocabularies applications and working group reports 322 ROCHESTER 1982 Data bases amp Process Control 25 28 35 Machine independence project management data structures mathematics
42. G AIDS 8088 ASSEMBLER eGRAPHICS amp SOUND eNGS ENHANCEMENTS eDETAILED MANUAL elNEXPENSIVE UPGRADES eNGS USER NEWSLETTER A COMPLETE FORTH DEVELOPMENT SYSTEM PRICES START AT 70 NEW HP 150 amp HP 110 VERSIONS AVAILABLE aD a NEXT GENERATION SYSTEMS P O BOX 2987 SANTA CLARA CA 95055 408 241 5909 Mulituser Multitasking for 8080 Z80 8086 Industrial Strength FORTH TaskFORTH The First Professional Quality Full Feature FORTH System at a micro price LOADS OF TIME SAVING PROFESSIONAL FEATURES x Unlimited number of tasks x Multiple thread dictionary superfast compilation x Novice Programmer Protection Package x Diagnostic Tools quick and simple debugging x Starting FORTH FORTH 79 FORTH 83 compatible x Screen and serial editor easy program generation x Hierarchical file system with data base management Starter package 250 Full package 395 Single user and commercial licenses available If you are an experienced FORTH programmer this is the one you have been waiting for If you are a beginning FORTH programmer this will get you started right and quickly too Available on 8 or 5 disk in various formats under CP M 2 2 or greater and 5 4 MS DOS FULLY WARRANTIED DOCUMENTED AND SUPPORTED DEALER VISA INQUIRIES 29 was INVITED Shaw Laboratories Ltd 24301 Southland Drive 216 Hayward California 94545 415 276 5953 FO
43. May April from 1979 80 through 1985 85 50 59 90 Available until November 29 1985 uu c PUBLICATIONS SURVEY If you would like to suggest any other publication for review by the FIG Publications committee for inclusion in the Forth Interest Group Order Form please complete the information below and return to FIG Title Author Publisher Comments Your comments on any of the publications we currently carry are most welcome please complete information below Title Comments Volume VII No 3 FORTH Dimensions FORTH INTEREST GROUP P O BOX 8231 SAN JOSE CALIFORNIA 95155 408 277 0668 Name Company Address City State Prov ZIP Country Phone TEN TITLE AUTHOR QTY e oe ES SEI 107 MEMBERSHIP UNIT SEE BELOW NEN CNN 10 MEMBER DISCOUNT C Check enclosed payable to FORTH INTEREST GROUP MEMBER eee Card HANDLING FEE 2 00 Expiration Date MEMBERSHIP FEE 20 27 33 Signatu re LU NEW O RENEWAL TOTAL PAYMENT MUST ACCOMPANY ALL ORDERS MAIL ORDERS PHONE ORDERS PRICES POSTAGE amp HANDLING SHIPPING TIME SALES TAX Send to Call 408 277 0668 to place All orders must be prepaid Prices are Prices include shipping A Books in stock are shipped California deliveries Forth Interest Group credit card orders or for subject to change without notice Credit 2 00 handling fee is within five
44. RTH Dimensions 20 Volume VII No 3 FORTH INTEREST GROUP MAIL ORDER FORM P 0 Box 8231 107 MEMBERSHIP in the FORTH INTEREST GROUP amp Volume 7 of FORTH DIMENSIONS No sales tax handling fee or discount on membership See the back page of this order form The Forth Interest Group is a worldwide non profit member supported organization with over 5 000 members and 80 chapters FIGmembership includes a subscription to the bi monthly publication FORTH Dimensions FIG also offers its members publication discounts group health and life insurance an on line data base a job registry a large selection of Forth literature and many other services Cost is 20 00 per year for USA Canada amp Mexico all other countries may select surface 27 00 or air 33 00 delivery San Jose CA 95155 MEMBERSHIP IN THE FORTH INTEREST GROUP 408 277 0668 The annual membership dues are based on the membership year which runs from May 1 to April 30 When you join you will receive issues that have already been circulated for the current volume of Forth Dimensions and subsequent issues will be mailed to you as they are published You will also receive a membership card and number which entitles you to a 10 discount on publications from FIG Your member number will be required to receive the discount so keep it handy HOW TO USE THIS FORM 1 Each item you wish to order lists three different Price categories Column 1 U
45. SA Canada Mexico Column 2 Foreign Surface Mail Column 3 Foreign Air Mail 2 Select the item and note your price in the space provided 3 After completing your selections enter your order on the fourth page of this form 4 Detach the form and return it with your payment to The Forth Interest Group or AE IE M QOO OOAnO XXLLLLOLULULUOGELILLULLLHCIEAGRREALLOBE KLLLLLLULE GGid PE H ENEEE NCC A ee FORTH DIMENSIONS BACK VOLUMES The six issues of the volume year May April 101 Volume 1 FORTH Dimensions 1979 80 15 16 18 102 Volume 2 FORTH Dimensions 1980 81 15 16 18 103 Volume 3 FORTH Dimensions 1981 82 15 16 18 104 Volume 4 FORTH Dimensions 1982 83 15 16 18 105 Volume 5 FORTH Dimensions 1983 84 15 16 18 106 Volume 6 FORTH Dimensions 1984 85 15 16 18 ASSEMBLY LANGUAGE SOURCE CODE LISTINGS Assembly Language Source Listings of fig Forth for specific CPUs and machines with compiler security and variable length names 913 1802 MARCH 81 15 16 18 514 6502 SEPT 80 issues 15 16 18 515 6800 MAY 79 0 eee 15 16 18 516 6809 JUNE 80 000 0 00008 15 16 18 517 8080 SEPT 79 0 eee 15 16 18 918 8086 88 MARCH 81 15 16 18 519 9900 MARCH 81 15 16 18 1 920 ALPHA MICRO SEPT 80
46. SES DUF 1000 SWAF Ux HEADER WORD 13 GFACES USES AVG MSECS 3 PMT Zt Wf 46 HOLD 6 S TYPE R ADDR NCHAR NWIDTH OVER SPACES TYFE 3 DATA N e DUF BUSES 7 N TAVG FMT 12 TYFE R CR 3 SCR 54 WORD TIMER MACROS 23 FIND amp CONSTANT DOCOLON CHECK NFA NFA EXAMINES WORD FOR DOCOLON IN CFA IF FOUND RETURNS NFA ELSE SCANS LINKAGE UNTIL DOCOLON IS FOUND BEGIN FFA DUF CFA amp DOCOLON NOT IF LFA Q ELSE NFA 1 ENDIF UNTIL SUMMARY CR CR HEADER CR CCOMPILE FORTH CONTEXT Q WORDS amp CHECK DUP ID 14 OVER C6 127 AND SPACES I i DATA FFA LFA 1 LOOF DROF INITNOW d 10 40 0i Bii Continued on page 25 19 FORTH Dimensions MasterFORTH Portable programming environment Whether you program on 3 the Macintosh the IBM PC a Apple li series a CP M sys tem or the Commodore 64 your program will run un changed on all the rest If you write for yourself MasterFORTH will protect x your investment If you write for others it will expand your market place TM MasterFORTH is a state of the art implementation of the Forth computer language Forth is interactive you have immediate feedback as you program every step of the way Forth is fast too and you can use its built in macro assembler to make it even CP M faster MasterFORTH s relocatable utilities transient definitions and headerless code let you pac
47. UFT CRC 55411 MAKE BUFFER CREATE 24 WORD C i ALLOT 15 C 10 C MAKE BUFFER FISR BUFFER I AM RUNNING THE PRIME NUMBER BENCHMARK COUNT BYTE WILL BE USED AS BUFFER FOINTER CONSTANT CONSTANT CONSTANT CONSTANT CONSTANT DVARTABLE BAUD DATA CSR READY LF CHARS Volume Vil No 3 31 FORTH Dimensions rates 1 000 to 9 600 is around ninety nine percent I am puzzled by the character output efficiency over 100 percent for 19 200 baud If the ef ficiency is really 100 percent the time would have to be in error by almost four seconds I have confidence that the precision of my timings was greater than this The only other possibility I can think of is that when the Kaypro serial port is set for 19 200 baud it ac tually outputs characters slightly faster than that I admit this explanation is not very satisfying and invite readers to Offer other suggestions In conclusion the pseudo interrupt driven serial output slows the bench mark by only one third while delivering an output efficiency of ninety nine per cent This demonstrates that the tech nique is a viable alternative to traditional I O methods Two final notes will help those plan ning to implement this in MVP FORTH I had to increase the memory available to Forth with the following LIMIT 16384 LIMIT CHANGE Also my version of MVP FORTH did not contain gt in the kernel It is easily defined as follows
48. Volume 7 Number 3 September October 1985 2 50 Dimensions Synonyms and Macros Pseudo Interrupts Universal Text File Reader Code Inspections me ForthCard STAND ALONE OPERATION STD BUS INTERFACE EPROM EEPROM PROGRAMMER RS 232 VO PARALLEL I O ROCKWELL FORTH CHIP The Fortheard provides OEMs and end users with the ability to develop Forth and assembly language programs on a single STD bus compatible card Just add a CRT terminal or a computer with RS 232 port connect 5 volts and you have a self contained Forth computer The STD bus interface makes it easy to expand Download Forth source code using the serial port on your PC Use the onboard EPROM EEPROM programming capability to save debugged Forth and assembly language programs Standard UV erasable EPROMs may also be programmed with an external Vpp supply Evaluation Unit 299 Part STD65F 11 05 includes ForthCard Development ROM 8Kbyte RAM Manuals OEM Version as low as Part STD65F411 00 4 99 does not include memory or manuals NEW Options and Application Notes Electrically Eraseable PROMs EEPROMs FREEZE the dictionary in EEPROM save in non volatile memory to be restored on power up Download Software for your IBM PC or CP M Non Volatile CMOS RAM with battery 2K 8K optional Clock calendar Fast 2MHz clock 4MHz crystal Disk Controller Card 5 Self Test Diagnostics Parallel printer interf
49. a ME 04330 207 547 3218 FORTH Dimensions gramming in the source code of the program This brings benefits in ease of programming in readability and in ease of program maintenance When should a macro be used A macro definition should be used to provide the structured programming advantages of a colon definition where a colon definition cannot be used for some reason For example a colon definition inside a loop cannot use and J to access the loop indices be cause the return placed on the return stack by the colon definition would interfere In such cases the only recourse has been to program the words of the colon definition explicitly in the interior of the loop This may introduce considerable clutter into the loop that the colon definition would have removed if it could have been used With a macro one can have the in line code that is needed while at the same time retaining the advantages of structured programming As discussed in the previous article on synonyms macros can also be used to help increase the readability under standability and maintainability of a program for it becomes possible to write the logic of an application in application relative words with most Forth relative words removed to a pre amble by means of colon definitions macros and synonyms A macro definition should always be used instead of a colon definition for routines of two or more words when execution speed considerations
50. ace Ask about our ForthBox A complete STD bus oriented system including the ForthCard Disk Controller Disk Drive s STD Card Cage Cabinet and power supply CALL TODAY FOR COMPLETE INFORMATION HiTech Equipment Corporation 9560 Black Mountain Road San Diego CA 92126 619 566 1892 FORTH Dimensions 2 Volume VII No 3 FORTH Dimensions Published by the Forth Interest Group Volume VII Number 3 September October 1985 Editor Marlin Ouverson Production Cynthia Lawson Berglund Forth Dimensions solicits editorial material comments and letters No responsibility is assumed for accuracy of material published Unless noted otherwise material published by the Forth Interest Group a non profit organization is in the public domain Such material may be reproduced with credit given to the author and to the Forth Interest Group Subscription to Forth Dimensions is free with membership in the Forth Interest Group at 20 per year 33 foreign air For membership change of address and to submit material for publication write to Forth Interest Group P O Box 8231 San Jose California 95155 ISSN No 0884 0822 Symbol Table Simple introductory tu torials and simple appli cations of Forth i l Intermediate articles and code for more com plex applications and tutorials on generally dif ficult topics Advanced requiring stu dy and a thorough under standing of Forth Cod
51. acro definition is later interpreted from the console or screen in compile state the DOES gt part of MACRO moves the words of the macro definition as a block into the program being compiled to be later executed in line rather than being called by nesting to a lower level as with a colon definition In execute state it moves the words of the macro definition into a tem porary colon definition constructed at HERE and executes it To this end the address of the run time code for colon is obtained by CR and set in place at HERE Then the compiled macro words are moved into the following locations Finally the address of S is set in place at the end Then this tem porary colon definition is executed These definitions of MACRO and END MACRO have been checked out under Laboratory Microsystems Z 80 Forth 3 01 a Forth 83 implementation These words are of necessity imple mentation specific since they make assumptions about the return stack and they address into the parameter field of the word being compiled The assumptions they make however are not at all unusual It was initially thought that MACRO and END MACRO should be patterned after an array definition with CREATE using and to start and stop compila tion But it soon developed that one would want more of the features of colon and semicolon in the definitions so it seemed better to pattern them af ter the definitions of colon and semi colon found in th
52. al special Forth issue which includes source code listings for various Forth applications 422 DR DOBB S 9 82 00 0 5 6 7 423 DR DOBB S 9 83 008 5 6 7 424 DR DOBB S 9 84 2 5 6 7 HISTORICAL DOCUMENTS 501 KITT PEAK PRIMER 25 27 35 One of the first institutional books on Forth Of his torical interest 502 FIG FORTH INSTALLATION MANUAL 15 16 18 Glossary model editor We recommend you purchase this manual when purchasing the source code listings REFERENCE 305 FORTH 83 STANDARD 15 16 18 1 The authoritative description of 83 Standard Forth For reference not instruction 300 FORTH 79 STANDARD 15 16 18 The authoritative description of 79 Standard Forth Of historical interest 316 BIBLIOGRAPHY OF FORTH REFERENCES 2nd edition Sept 1984 15 16 18 An excellent source of references to articles about Forth throughout microcomputer literature Over 1300 references MISCELLANEOUS NEW FIG T SHIRT 601 T SHIRT SIZE Small Medium Large es and Extra Large White design on a dark blue shirt 10 11 12 602 POSTER BYTE Cover 616 HANDY REFERENCE CARD FREE 683 FORTH 83 HANDY REFERENCE CARD FALL SPECIAL Bou Dimensions BACK VOLUMES 1 6 containing the six issues of each volume year
53. and working group reports 323 ROCHESTER 1983 Forth Applications 25 28 35 Forth in robotics graphics high speed data acquisition real time problems file management Forth like languages new techniques for implementing Forth and working group reports 324 ROCHESTER 1984 Forth Applications 25 28 35 Forth in image analysis operating systems Forth chips functional programming real time applications cross compilation multi tasking new techniques and working group reports 22 Volume VII No 3 THE JOURNAL OF FORTH APPLICATION amp RESEARCH A refereed technical journal published by the Institute for Applied Forth Research Inc 401 JOURNAL OF FORTH RESEARCH V 1 41 15 16 18 Robotics 402 JOURNAL OF FORTH RESEARCH V 1 2 15 16 18 Data Structures 403 JOURNAL OF FORTH RESEARCH V 2 1 15 16 18 Forth Machines 404 JOURNAL OF FORTH RESEARCH V 2 2 15 16 18 Real Time Systems 405 JOURNAL OF FORTH RESEARCH V 2 3 15 16 18 Enhancing Forth 406 JOURNAL OF FORTH RESEARCH V2 4 15 16 18 Extended Addressing REPRINTS 420 BYTE REPRINTS ssesssss 5 6 7 Eleven Forth articles and letters to the editor that have appeared in Byte magazine 421 POPULAR COMPUTING 9 83 5 6 7 Special issue on various computer languages with an in depth article on Forth s history and evolution DR DOBB S This magazine produces an annu
54. any extras This public domain product includes an editor FORTH assembler tools utilities and the vocabulary for the best selling book Starting FORTH The Programmer s Kit provides a complete FORTH for a variety of FORTH DISKS J APPLE by MM C APPLE by MMF amp amp 3 ATARI vaf ORTH O ATARI by PNS F G amp X O C64 by HES Commodore 64 cartridge computers Other MVP FORTH products will simplify the development o your applications NEW C64 with EXPERT 2 by PS MVP Books A Series a Vol 1 All about FORTH by Haydon MVP FORTH glossary with cross references to tig FORTH Starting FORTH and FORTH 79 Standard 2nd Ed 25 MVPGF amp X O CP M by MM DJ CP M by MM F O HP 75 by Cassady Timex by HW cassette OQ T S 1000 2X 81 C 2068 O 280 by LM O 8086 88 by LM C 68000 by LM D VIC FORTH by HES VIC20 Cartridge 25 30 100 100 250 20 O Extensions for LM Specify IBM 280 or 8086 O Software Floating Point 100 C Vol 2 MVP FORTH Assembly Source Code Includes IBM PC O HP 85 by Lange CP M and APPLE listing tor kernel 20 0 IBM PC by LM C Ew Vol 3 Floating Point with source code by Koopman 25 a iBM PC by MM O Vol 4 Expert System with source code by Park 15 EWO Macintosh by MM o Vol 5 File Management System with interrupt security by Moreton 25 a Vol 6 Expert Tutorial for Volume 4 by M amp L Derick 15 CI Ew ol 7 FORTH GUIDE to MVP FORTH by Haydon
55. as it stands Volume VII No 3 Delete Last Digit Accept Sign esc Restore initial Value Delete Last Digit AX Digit Y Clear Initial Value amp Append Digit Restore Initial Value Xv Accept Sign Delete Last Digit esc Restore Initial Value Max Digits Reached NUMED State Diagram Figure One Display format 5 2 Position the cursor Point to the editing buffer Convert to a binary value HOLD 9 4 4 NUMED SIGN SIGN gt TYPE NUMBER EDITOR S 2 format 5 2 NUMED 5 2 CFA NUMED DISFLAY S NUMED MAXDIGITS NUMBER EDITOR NUMEDIT S 2 row col CH CV O NUMED EDLINE 1 CONVERT DROF lt H os s oU row col dvali dval2 Editor call Set display vector Set the digit count Call the editor Create a display word for the 5 2 format Now create a word to set the display vector set the digit count and call the number editor Figure Two mm 100 memmmmm memAm dncmcm mmc O Data entry INSTRING 1 2 INSTRING string char position or 1 3 O 4 ROLL 4 ROLL Duplicate string 4 OVER SWAP Start stop address in string 5 DO For each entry in string 6 OVER I C IF Found it 7 SWAP DROF LEAVE Return its offset and quit flag 8 ELSE Not found yet 9 1 Increment offset pointer 1
56. colon definition does and this can sometimes be an ad vantage Except for this a macro definition can be used like a colon definition It is written in the same way except the word MACRO is substituted for the colon and END MACRO is substituted for the semicolon The expression MACRO lt name gt END MACRO compiles a macro definition into the dictionary When the word so defined is later interpreted from the console or from a screen it will either be executed like a colon definition or when com piling the compiled words of the mac ro definition will be moved in line into the body of the word being compiled To take an example some Forths include as a code definition primitive the word ROT which is the opposite of ROT in that when it rotates the top three elements on the stack it leaves the top one the deepest For Forths that do not have this word the textbook way of defining it uses a colon definition ROT ROTROT An alternative way would be to define it as a macro MACRO ROT ROT ROT END MACRO When executed from the console the three definitions of RoT all have the compiled call to DOES machine code words for executing macros or moving them into c OBRANCH cDUP machine code for OBRANCH immediate compilation address of Operation of a macro definition The expression MACRO DUP DUP IF DUP THEN END MACRO compiles into the dictionary the macro definition for DUP in the
57. compiled be different and if this different com pilation address is executed it will run slower And the new word will be marked immediate even though it will have the same action immediate or nonimmediate as the original word By means of SYNONYM one can make a synonym for any word in the diction ary One can even make synonyms of synonyms with no run time penalty It is actually possible to switch the names of two words proving that the tech nique is completely general suppose two words A and B have actions X and Y Then using an intermediate name C one can define SYNONYM CA SYNONYM AB SYNONYM BC Now A has the function Y and B has the function X When should this method of defin ing synonyms be used One can make a strong case for including this word in a system for its general utility and in or der to rationalize and clean up one corner of Forth Having the word in the system it should always be used Volume Vll No 3 11 FORTH Dimensions DASH FIND amp ASSOCIATES Our company DASH FIND amp ASSOCIATES is in the business of placing FORTH Program mers in positions suited to their capabilities We deal only with FORTH Programmers and companies using FORTH If you would like to have your resum included in our data base or if you are looking for a FORTH Programmer contact us or send your resum to DASH FIND amp ASSOCIATES 808 Dalworth Suite B Grand Prairie TX 75050
58. d friendships there but if we don t get the chance then come to the FORML conference in November Marlin Ouverson Editor VII 1 The article by Jeffrey Soreff V 5 is one of my favorite Forth ar ticles I have found the following mac ros to be helpful in making my code more readable by eliminating o IF and O WHILE IF NOT COMPILE 0 COMPILE IF IMMEDIATE WHILE NOT COMPILE 0 COMPILE WHILE IMMEDIATE I would like to thank the staff of the Forth Interest Group for all its great work and services Sincerely Ed Petsche Greenport New York Editor s note For more on the Case of the Right Bracket see the letters section of our last issue FORTH Dimensions Volume Vil No 3 Application Tutorial Universal Text File Reader John S James Santa Cruz California File incompatibilities stil cause seri ous problems For example files up loaded from different operating sys tems may have different ways of mark ing the end of a line and the software available may not be able to list them with legible results Even files pro duced on the same operating system may contain non standard codes inter nal to certain word processors for such functions as tabs and underline And you may occasionally want to read files not intended as text files to see for example what operator and error messages an object program con tains This tutorial shows you how to write a simple program to s
59. d in price Foreign orders pay in US funds on US bank Include lor handling and shipping by AIR 5 lor each item uder 25 10 lor each item between 25 and 99 and 20 for each item over 100 All prices and products subject to change or withdrawal without notice Single system and or single user license agreement required on some products MOUNTAIN VIEW PRESS INC PO BOX 4656 MOUNTAIN VIEW CA 94040 415 961 4103 Number Editing Utility Ken Takara San Jose California When writing interactive applica tions one often needs numeric data to be entered by a user at the keyboard Unfortunately most builtin input routines do not provide the kind of data checking and display formatting usually wanted In BASIC for example you might code 10 INPUT X The user then types HI PM KEN and the program blows up In Forth you would say something like PAD 80 EXPECT PAD NUMBER which has the sole advantage of not crashing when the user enters some other arbitrary sequence of key strokes In this little article I describe a simple data entry utility written just to handle certain numeric entry problems Naturally it is written in Fortran I call the utility NUMED How To Use It You call NUMED passing it the row and column position on the display at which it should appear and a double length initial value NUMED displays the initial value in inverse video You can then edit it replace it or accept it
60. d increase by simply recoding his loop by hand as a long string of primitives But he would lose the read ability and ease of programming and maintenance provided by the struc tured nature of Forth A macro facility gives Forth imple mentors some extra flexibility by pro viding another possibility besides colon and code definitions for sequences like z NOT NOT AND NOT SWAP DROP ROT ROT OVER OVER and so on One of the advantages of using macros over code definitions in an implementation of Forth is that they are high level This means that it would be easier to move the implementation to another processor The use of macros might be par ticularly significant in a Forth imple mentation built around a hardware Forth machine that has only a few dozen words coded in microcode It would provide another option besides colon definitions for the rest of the words Volume VII No 3 A macro facility can play a part ina kit to allow programs written in one dialect of Forth to run in a system im plementing another dialect Here speed considerations and noninterfer ence with the return stack would pro vide important advantages In one program of this sort an overall speed penalty of roughly 50 has been reported A recoding using macros and synonyms should reduce the penal ty substantially A macro definition like a colon definition can contain one or more words or even none That means a one word macro co
61. d is drawn from the foremost workers in Forth in the U S Europe and Canada Past issues had in depth coverage of such topics as Robotics Data Structures Forth Computers Real Time Systems and Extended Address Computing The Journal is open to all new work in Forth as well as the entire range of threaded interpretive languages and Forth like systems Volume 3 The Journal is beginning its third year of publication Published quarterly the Journal contains applications and techniques papers technical notes review papers algorithms book reviews and conference abstracts Renew your subscription for Volume 3 of the Journal of Forth Application and Research Here s what you ll find in Issue fH Forth Based Software for Real Time Control of a Mechanically Scanned Ultrasonic Imaging System Fast and Flexible Forth Programming in a Femto second Laser Lab Stack Frames and Local Variables Should VARIABLE Be an Immediate State Sensitive Word Readable and Efficient Paramet Access via Argument Records Run Time Error Handling in Forth Proceedings Rochester Forth Conference 1985 Rochester Forth Conference Proceedings The Proceedings of the 1985 Rochester Forth Confer ence will appear as a Special Issue of Volume 3 of the Journal The conference had a theme of software management and engineering and how to improve software productivity Invited papers discuss a space shuttle experiment using Forth the aut
62. days of receipt add 6 San Francisco P O Box 8231 customer service Hours card orders will be sent and billed at required with all orders of the order Please allow Bay Area add 7 San Jose CA 95155 Monday Friday 9am 5pm current prices 15 minimum on charge 4 6 weeks for out of stock PST orders Checks must be in US drawn books delivery in most on a US Bank A 10 charge will be cases will be much sooner added for returned checks 9 85 Continued from page 19 and restart a real time clock NOW sim ply places the frozen time value on the Stack INITNOW resets the jiffy timer Screen 52 also contains the nonstan dard word ARRAY Other familiar but nonstandard words are D S and U Forth Dimensions V All other words are in Forth 79 Screen 52 fin ishes by setting up two arrays to store the number of uses and accumulated time for up to twenty words and defin ing the variable WORD used to count the number of words being timed All these are initialized to zero by INIT Screens 53 54 define a display of the measured timings We will come back to these screens later Screen 55 does all the work The ob ject is to modify the definition of each new word compiled as shown in Figure Two Since NEXTNO is an IMMEDIATE word it executes at the compile time of WORDn with the result that the current value of WORD is com piled by LITERAL as an in line literal During later execution of WORDn this value is placed
63. e implementations where LSIZE is greater than sixteen A further possibility is to make the decision implementation dependent in which case we would need yet another fetch and store operation for compilation addresses and another constant giving the length of a compilation address I think my suggestion is the simplest Another headache concerns arith metic operations on certain well known processors where the designers have inflicted us with a basically sixteen bit design but kludged to pro vide a longer address the term seg ment sounds nice but doesn t change the facts The most efficient solution would be for etc to remain sixteen bit operations even where LSIZE is longer Thus high order bits of the result would be invalid I think we should reject this approach even at the expense of an execution time penalty the elegance of Forth would be compromised and address arithmetic would be a nightmare It sa pity but that s probably the best we can do with awkward underlying hardware Happy Forthing even to those with 8086 8088s Michael Hore Numbulwar NT Australia Reference 1 C G Bell and J C Mudge The Evolution of the PDP 11 in D P Siewiorek C G Bell and A Newell eds Computer Structures Principles and Examples McGraw Hill 1982 p 776 More Applications Please Dear Mr Ouverson As a newcomer to Forth I find it interesting that
64. e and examples con form to Forth 83 stand ard Code and examples con form to Forth 79 stand ard Code and examples con form to fig FORTH Deals with new propos als and modifications to standard Forth sys tems Dimensions FEATURES 35 37 Synonyms and Macros Part I by Victor H Yngve A ROT by any other name is it the same Investigation into this seemingly innocuous subject leads to productive new insights into how Forth works and how to make it work for you Synonyms and Macros Part II by Victor H Yngve This tool creates high level macro definitions with the readability of colon definitions and some increase in execution speed Installing macro tools is a great way to learn about the insides of your Forth implementation Forth Timer Macros by Iram Weinstein We asked for readers uses of Forth macros what better than tools to improve the performance of the rest of your code When the engine is installed and you re ready to fine tune look for these in your desk side toolbox Improved Forth 83 DO LOOP by Dennis L Feucht The parsimony of the two item DO LOOP is possible in Forth 83 at the expense of slightly more complex compile time procedures This im plementation requires minimal modification to the machine dependent run time words of previous Forth 83 DO LOOPs Metacompiling words are also provided A Forth I O Technique Pseudo Interrupts by Ed Schmauch Using interrupts allows a CPU to do
65. e applica tion program can be written mainly in application specific terminology with the translation into Forth relative words being given in a preamble con taining colon definitions synonyms and macros Macros will be the topic of the second of these articles I wonder since there is no run time penalty for using synonyms if it would be possible or desirable to develop multi purpose routines For example a routine might operate in single preci sion or in double precision depending on which preamble is used or on which vocabulary it is loaded under Or a routine might sort bytes words double words fields or pointers to 12 strings A synonym facility would also make possible the easy preparation of bilin gual Forth systems for other languages such as Portuguese Turkish French Dutch or Finnish The synonyms listed on the translation screens would resemble the entries in a traveler s pocket dictionary SYNONYM SI IF This might lead to new national stan dards of Forth nomenclature in lan guage areas where the political linguis tical and educational realities favor or even dictate the use of the local lan guage Remember that readability like beauty is in the eye of the beholder This alone independent of the other obvious merits of Forth as a teaching language might give Forth an edge in the local schools over other languages where changing the names of com mands is not as easy The translation kit
66. e implementation making the appropriate modifications The lines on the screens with com ments beginning with a single hyphen are copied with LMI s permission intact from the definitions of colon and semicolon The lines with com ments beginning with an asterisk show modifications The rest of the lines have been added to implement the spe cial features of MACRO and END MACRO 18 Thus to get the definitions to work on a different system obtain a listing of the definitions of colon and semi colon in your implementation or at least obtain the compiled code using a decompiler or memory dump Then identify the various functional parts of these definitions as implemented in your system referring to the fig FORTH model 4 or other sources if needed for help in understanding them Then make the modifications indicat ed This process should not be diffi cult and will be a learning experience if you don t yet know much about the Forth compiler On sixteen bit machines where it is advantageous or required to have ad dresses start at sixteen bit word boun daries change the 1 ALLOT on screen 51 to 2 ALLOT and add 1 after the DOES gt on screen 52 It is an interesting aspect of the Forth 83 Standard that SYNONYM could be written entirely within the standard but MACRO and END MACRO could not References 1 Soreff Jeffrey Macro Expan sion in Forth Forth Dimensions V 5 2 Berkey Robert Forth 8
67. ented TRACE 5 18 Techniques 2 38 DO LOOP Enhanced 6 18 Enhanced DO LOOP 6 18 Ericson K 2 32 The Far Right Stuff 6 21 Feucht D 2 32 fig FORTH fig FORTH Interpreters 1 12 Forth P Code Interpreter 4 9 Local Definitions 6 16 More Screens for the Apple 1 22 Quicksort and Swords 5 25 TI 99 4A Screen Dump 6 11 Forchheimer R 5 32 FORML 1984 Asilomar Conference 5 34 China Tour 1984 5 38 6 33 Forth 79 Standard see 79 Standard Forth 83 Program to Run Forth 79 Code 4 28 Forth 83 Standard see 83 Standard Forth Control Structures 2 20 Forth in Rehabilitation Applications 2 28 Forth List Handling 1 36 Forth P Code Interpreter 4 9 Forth Semaphores 4 23 Gates W C 1 24 4 33 Goppold A 5 18 Grossman N 3 10 6 25 Hall J D 1 39 3 35 4 40 5 41 6 40 Ham M 3 23 4 19 Harralson D W 2 20 High Level Packet Communication 5 32 Hore M 6 18 In Word Parameter Words 6 9 Interactive Editing 1 24 Interpreters fig FORTH 1 12 Forth P Code 4 9 Jaffe D L 2 28 James J S 5 13 Laxen H 2 38 3 32 4 37 6 38 List Handling 1 36 Local Definitions 6 16 Long Divisors and Short Fractions 3 10 Lotspiech J B 1 20 Luoto K W 1 26 2 10 Mathematics Long Divisors and Short Fractions 3 10 Pollard s Monte Carlo Factorizer 6 25 Mathquiz 6 13 Monroe A J 4 9 More Screens for the Apple 1 20 Morgenstern L 1 33 Morton L D 6 13 Olofsson B 1 36 P Code Interpreter 4 9 Parameters In Word 6 9 Parnas
68. ext introduction to the basic concepts of Forth Includes section on how to teach children Forth 240 MASTERING FORTH 18 19 22 Anita Anderson amp Martin Tracy MicroMotion A step by step tutorial including each of the commands of the Forth 83 International Standard with utilities extensions and numerous examples 245 STARTING FORTH soft cover 20 21 22 Leo Brodie FORTH Inc A lively and highly readable introduction with exercises 246 STARTING FORTH hard cover 24 25 20 Leo Brodie FORTH Inc 255 THINKING FORTH soft cover 16 17 20 Leo Brodie The sequel to Starting Forth An intermediate text on style and form 265 THREADED INTERPRETIVE LANGUAGES 23 25 28 ___ R G Loeliger Step by step development of a non standard Z 80 Forth 270 UNDERSTANDING FORTH 3 50 5 6 Joseph Reymann A brief introduction to Forth and overview of its structure FORTH Dimensions Gee FORML CONFERENCE PROCEEDINGS FORML PROCEEDINGS FORML the Forth Modification Laboratory is an informal forum for sharing and discussing new or unproven proposals intended to benefit Forth Proceedings are a compilation of papers and abstracts presented at the annual conference FORML is part of the Forth Interest Group 310 FORML PROCEEDINGS 1980 25 28 35 Technical papers on the Forth language and extensions 311
69. from the return stack and MARKEND adds the current time to the accumulated time All that remains is to put together these timer words into macros that replace and Before redefining the macro is defined This is just a synonym for and is needed so that the definition of will not include all the timer words Creating the macros is simple Just follow the rules developed in Forth Dimensions V 5 precede each IMMEDIATE word by COMPILE precede all other words by COMPILE and declare the macro IMMEDIATE After loading these screens load and run the application you want to time and then execute SUMMARY to produce a display of all the colon defined words in your application with the number of uses and average time per use for each word Screens 53 54 contain the definitions of SUMMARY and support ing words Everything here is straight forward except CHECK perhaps which scans the dictionary linkage skipping over constants variables and other word types until a colon defined word is found CHECK returns the NFA of this word Screen 56 contains an example ap plication of these macros Three words that multiply by two are defined The first 2 makes use of a built in CODE definition The other two are self explanatory The word T2 exercises each of the multiply by two words 1000 times on the same problem SUMMARY prints the results as shown in Figure Three When using the timer macros you may wa
70. g other people s programs is essential in program maintenance and revision and it also plays a valuable role in programmer education by allowing programmers to learn from the tech niques and skills embodied in their colleagues creations as well as from their mistakes and oversights Formal code inspections efficient ly facilitate the difficult task of truly comprehending a program This technique has the added advantage that the use of an inspection team means several people learn the program at one time The team approach also ensures that the program is inspected from various viewpoints thus inefficiencies and errors are more likely to be detec ted Code inspection provides an excel lent way for members of a FIG chapter to work together through the examples of Forth code published in Forth Dimensions and other journals This technique helps the chapter members learn from the code and from each Other A code inspection team consists of four to six members more or fewer hinder the process Larger FIG chap ters can form several inspection teams In a company environment it is impor tant that supervisory or management personnel not be on the team since their presence has a chilling effect on the frankness of the criticism and on the open give and take of the process Specific roles are assigned in ad vance to individual team members Author One team member takes the role of author of the code Ideally of c
71. harles Krajewski 203 344 9996 FLORIDA Orlando Chapter Every two weeks Wed 8 p m Call Herman B Gibson 305 855 4790 Southeast Florida Chapter Monthly Thurs p m Coconut Grove area Call John Forsberg 305 252 0108 Tampa Bay Chapter Monthly 1st Wed p m Call Terry McNay 813 725 1245 GEORGIA Atlanta Chapter Call Ron Skelton 404 393 8764 ILLINOIS Cache Forth Chapter Call Clyde W Phillips Jr Oak Park 312 386 3147 Central Illinois Chapter Urbana Call Sidney Bowhill 217 333 4150 Fox Valley Chapter Call Samuel J Cook 312 879 3242 Rockwell Chicago Chapter Call Gerard Kusiolek 312 885 8092 INDIANA Central Indiana Chapter Monthly 3rd Sat 10 a m Call John Oglesby 317 353 3929 Fort Wayne Chapter Monthly 2nd Wed 7 p m Indiana Purdue Univ Campus Rm B71 Neff Hall Call Blair MacDermid 219 749 2042 IOWA Iowa City Chapter Monthly 4th Tues Engineering Bldg Rm 2128 University of lowa Call Robert Benedict 319 337 7853 Central Iowa FIG Chapter Call Rodrick A Eldridge 515 294 5659 Fairfield FIG Chapter Monthly 4th day 8 15 p m Call Gurdy Leete 515 472 7077 KANSAS Wichita Chapter FIGPAC Monthly 3rd Wed 7 p m Wilbur E Walker Co 532 Market Wichita KS Call Arne Flones 316 267 8852 LOUISIANA New Orleans Chapter Call Darryl C Olivier 504 899 8922 MASSACHUSETTS Boston Chapter Monthly 1st Wed Mitre Corp Cafete
72. ilation address of Q oil Operation of a synonym of an immediate word The expression SYNONYM SI IF compiles into the dictionary the immediate synonym definition of SI in the third column When SI is encountered during compilation the first DOES expression in SYNONYM first column is executed which obtains the compilation address of IF from the body of SI and executes it This provides the immediate action of executing IF The execution of IF compiles the compilation address of OBRANCH into the program fourth column and arranges for compiling a branch offset after it the same as when IF is encountered while compiling Figure Two References 1 Huang Timothy First Chinese Forth A Double Headed Ap proach Dr Dobb s Journal Vol 9 No 6 June 1984 Volume Vil No 3 13 FORTH Dimensions Synonyms and Macros Macros Victor H Yngve Chicago Illinois One of the many advantages of Forth is the ease with which new fea tures can be added to the language Described here is a facility that pro vides Forth with high level macro definitions in addition to the colon definitions and code definitions al ready available This offers some addi tional possibilities and tradeoffs A high level macro definition has the readability of a colon definition but like a code definition it provides some increase in execution speed though not as much It does not place a return on the return stack like a
73. inals use only seventy nine Users who notice or care can ask for eighty one References 1 Microsoft Corporation Disk Operating System Technical Reference publ by IBM Corpora tion This manual explains DOS calls You can also find this infor mation in various books about MSDOS or programming the IBM and compatibles 2 The F83 source code is an excellent source of information for the in termediate or advanced student All of the source is supplied with this public domain system The command VIEW name will show the screen where a word is defined and then you can use the words AL to get to the shadow documen tation screen If you are running F83 but don t have the source files handy the command SEE name provides a convenient decompila tion Volume VII No 3 FORTH Dimensions FORTH IS NOW VERY FAST Sieve 1 3s pass Compile 300 screens minute Drop 1 82 us Concurrent I O 250K baud DEVELOP YOUR APPLICATIONS IN A TOTAL FORTH ENVIRONMENT MICROPROGRAMMED BIT SLICE FORTH ENGINE Microcoded forth kernel Microcoded forth primitives Multi level task switching architecture for real time applications Optional writable control store H FORTH OPERATING SYSTEM Hierarchical file system Monitor level for program debug Multi user multi tasking Target compiler O management Forth 83 Compatible H4TH 01 OEM SINGLE BOARD Floppy disk controller 2 channel SIO to 38 2K baud
74. ion address of the new word is obtained by tick and then either executed or compiled and ex ecuted later one or the other of the DOES expressions will fetch the com pilation address of the old word from the body of the new word and execute it just as if the compilation address of the old word had instead been obtained directly by tick but because of the ex ecution of the DOES gt expression it will run slower in compiled SYNONYM into Ec BRANCH Sz words for immediate action of synonyms words to compile OBRANCH c BRANCH HE immediate compilation address of Q HP ou Operation of a synonym of a nonimmediate word The expression SYNONYM R R compiles into the dictionary the nonimmediate synonym definition of R in the third column When R is encountered during compiling the second DOES expression in SYNONYM first column is executed which obtains the compilation address of R from the body of R and compiles it into the program fourth column This is the same result as when R is encountered while compiling When R is encountered in the noncompiling state the DOES expression obtains the compilation address of R from the body of R and executes it just as if R had been encountered Figure One in compiled SYNONYM into program call to DOES machine code words for R non immediate action of synonyms Re immediate comp
75. iple nulls in certain files And if a carriage return is followed in the original file by a linefeed that linefeed will be ignored so that single spaced text files will not come out as double spaced We won t reformat word pro cessor document files without hard returns Almost all terminals will scroll automatically when neces sary Words may be split at end of line but they will still be readable See note below about a better way to format text to various line lengths e This program ignores backspace to avoid loss of information caused by unintended backspace in non text data e We change formfeed to linefeed to avoid waste of paper when printing object programs or other non text files ignore other non printable characters However you might want to print them as dots or as some other character to show where they were The Code This particular implementation is for the well known F83 system It should run on any PC compatible machine and should not be difficult to convert to any Forth system on any computer providing you know how to open a se quential file read records and detect end of file We chose not to go through Forth I O the word BLOCK because many Forth systems don t provide any way to read an incomplete final block of a file not created for a Forth environment The first screen isolates most of the code which is specific to F83 If you aren t using F83 you will need to write
76. is code is shown in screens 24 27 The message I AM RUN NING THE PRIME NUMBER BENCHMARK followed by a car riage return and line feed is placed in an output buffer by screen 24 The pseudo interrupt service routine screen 25 continuously outputs this message When the last character of the message the line feed is transmit ted the buffer pointer is reset to zero so the message will be restarted from the beginning PISR also counts the number of characters output so character output efficiency can be evaluated Screen 26 has the code to initialize and set the baud rate on the serial port This code and parts of PISR are hard ware dependent Be sure to modify them to suit your hardware before you attempt to implement them INIT SERIAL only needs to be executed Baud Time Percent Characters Output Rate Seconds Full Speed Output Efficiency 96 No output 132 9 100 0 1 200 183 5 72 4 21 792 99 0 2 400 185 0 71 8 43 852 98 8 4 800 187 5 70 9 88 860 98 7 9 600 192 6 69 0 182 632 98 8 19 200 205 5 65 0 400 252 101 9 Summary of Benchmark Performance Table One FORTH Dimensions 30 Volume VII No 3 once after the computer is booted BAUD SET is used whenever you want to change the baud rate Screen 27 con tains the BYTE benchmark Line 4 zeroes the buffer pointer zeroes the character counter and enables the pseudo interrupt Line 15 disables the pseudo interrupt and prints the num ber of characters transm
77. itted The rest of the code is from BYTE except that the sieve is executed ten times to add to the precision of the timings Besides enabling and disabling the pseudo interrupt the benchmark code makes no reference to the serial output process As with true interrupt driven I O pseudo interrupts operate with out requiring the attention of the main line code Note that KEY PATCH was not necessary since the benchmark never gets input from the keyboard To run the benchmark without pseudo interrupts comment out lines 4 and 15 except the semi colon Table One shows pseudo interrupt performance for serial output baud rates ranging from 1 200 to 19 200 Also shown is the time for the bench mark with no concurrent pseudo interrupt driven output The bench mark was run twice at each baud rate to lessen the possibility of an error The serial output was observed on a Lear Siegler ADM 5 terminal The per cent of full speed is calculated by divid ing the time for the benchmark without pseudo interrupt driven output by the time for a particular run and multiply ing by 100 One might expect to divide the time for a run by the time without pseudo interrupt driven output but we are interested in speed which is the reciprocal of time The character out put efficiency is the number of charac ters output divided by the maximum number of characters that could be output at the given baud rate in the time required for the benchmark to
78. ive digits dis played see Figure Two Glossary SELECT s addr len index Given a string accept a keystroke represented within the string and return its index within the string NUMBER EDITOR dvall row col dvall Call the number editor The field will be displayed on the video screen at row col in inverse video Digits will enter the display in calculator format On exit the double value result is returned NUMBER EDITOR NUMED S2 NUMED S2 nxtstate State 2 control 2 NUMED CHMD DUP R 3 CASE 4 0 DF NUMED KESET ENDOF 5 1 DF NUMED XDIGIT ENDOF 6 2 OF NUMED NOTHING ENDOF 7 3 OF NUMED SIGN ENDOF 8 4 OF NUMED REJECT ENDOF 9 ENDCASE 10 R gt 11 DUF O IF DROP EXIT THEN esc Undo 12 DUF 1 IF DROF 1 EXIT THEN X Delete 13 DUP 2 IF DROF 3 EXIT THEN CR Accept 14 DROF 2 3 Sign digit is O NUMBER EDITOR NUMED 10 2 1 2 NUMED 16 2 row col Display value S CH CV 4 NUMED EDLINE i S CONVERT DROF DABS lt HB HOLD 48 36 HOLD NUMED SIGN SIGN gt 7 13 OVER SPACES TYPE 3 8 9 NUMED 10 2 CFA NUMED DISPLAY 10 11 em 12 13 14 iS O NUMBER EDITOR NUMED STATES 1 2 NUMED STATES state nxtstate Full state control 3 CASE 4 OF NUMED SO ENDOF 5 1 OF NUMED S1 ENDOF 6 2 OF NUMED S2 ENDOF 7 ENDCASE 8 9 10 gt 11 12 13 14 15
79. k a lot more program into your memory The resident debugger lets you decompile breakpoint and trace your way through most programming prob lems A string package file interface and full screen editor are all standard features MasterFORTH exactly matches the Forth 83 Standard dialect described in Mastering Forth by Anderson and Tracy Brady 1984 The standard package in cludes the book and over 100 pages of supplementary documentation MasterFORTH standard package IBM PC and PC Jr MS DOS 2 1 Apple il At He fie re aes FE hs CP M 2 x BM 3740 8 p Commodore 64 Extensions floating Point 1984 FVG standard Graphics Apple fi series Module relocator with utility sources Printed source isting ue Publications Mastering Forth additional copies Thinking Forth by Leo Brodie Forth 83 international Standard Rochester Bibliography 2nd ed 1984 Rochester Conference 1984 FORML Conference 12077 Wilshire Bivd 506 5 NGS FORTH A FAST FORTH OPTIMIZED FOR THE IBM PERSONAL COMPUTER AND MS DOS COMPATIBLES STANDARD FEATURES INCLUDE e79 STANDARD eDIRECT I O ACCESS eFULL ACCESS TO MS DOS FILES AND FUNCTIONS eENVIRONMENT SAVE amp LOAD eMULTI SEGMENTED FOR LARGE APPLICATIONS eEXTENDED ADDRESSING eMEMORY ALLOCATION CONFIGURABLE ON LINE eAUTO LOAD SCREEN BOOT eLINE amp SCREEN EDITORS eDECOMPILER AND DEBUGGIN
80. ll Robert Dudley Ackerman 415 626 6295 Baton Rouge Atari Chapter Call Chris Zielewski 504 292 1910 FIGGRAPH Call Howard Pearlmutter 408 425 8700 Volume VII No 3 FORTH Dimensions FORTH INTEREST GROUP FALL Special FORTH Dimensions DACK VOLUMES I 6 599 FOREIGN SURFACE MAIL CO 90 FOREIGN AIR MAIL USA AND CANADA Containing the six issues of each volume year May April from 1979 80 through 1984 85 AVAILABLE UNTIL NOVEMBER 29 1985 FORTH INTEREST GROUP s uds P O Box 8231 ES b cits San Jose CA 95155 San Jose CA Address Correction Requested
81. lving ROBOTICS INSTRUMENTATION PROCESS CONTROL GRAPHICS and more is now available for IBM PC PolyFORTH II offers IBM PC users Unlimited control tasks Multi user capability 8087 mathematics co processor support Reduced application development time High speed interrupt handling Now included at no extra cost Extensive interactive GRAPHICS SOFTWARE PACKAGE Reputed to be the fastest graphic package and the only one to run in a true multi tasking environment it offers point and line plotting graphics shape primitives and interactive cursor control PolyFORTH Il is fully supported by FORTH Inc s Extensive on line documentation Complete set of manuals Programming courses The FORTH Inc hot line Expert contract programming and consulting services From FORTH Inc the inventors of FORTH serving professional programmers for over a decade Also available for other popular mini and micro computers For more information contact FORTH Inc 2309 Pacific Coast Hwy Hermosa Beach CA 90254 213 372 8493 RCA TELEX 275182 Eastern Sales Office 1300 N 17th St Arlington VA 22209 703 525 7778 IBM PC is a registered trademark of International Business Machines Corp FORTH Dimensions Nothing is compiled at the end of the macro definition that would corres pond to the s or other word that is compiled at the end of a colon defini tion by the semicolon When the m
82. m SOTA both the fig model and 79 standard come complete with the following extra features at no additional charge full featured string handling assembler e screen editor floating point double word extension set relocating loader beginner s tutorial comprehensive programmer s guide exhaustive reference manual unparalleled technical support source listings unbeatable price ORDER FORM GENTLEMEN Rush me my order DEnctosedis my Ocheck Omoney order D Please bill my OVISA D MasterCard for 89 95 Please send me 0 79 Standard FORTH O figFORTH model for the UIBMPC OXT OAT and compatibles OTRS 80 Model O Model 11 C Modei4 Model 4P OCP M Versionzx OCP M Plus Version 3 x For CP M versions please note 5 1 4 formats only and please specify computer type NAME STREET CITY TOWN STATE S ee CARD TYPE M EXPIRY CARD NO SH ce iao B i ORDER 13 roughton Street Vancouver British Columbia fea Canada V6 288 rder an or one f 604 688 5009 State of the Act since 1981 x2 0 Ji Ve Y Computing Systems Limited TOTAL US funds IBM TRS 80 and CP M are registered trademarks of International Business Machine Cor poration Radio Shack end Digitel Research Tespectively Volume VII No 3 17 FORTH Dimensions PolyFORTH Il the operating system and programming language for real time applications invo
83. mory Extended Math Functions Full String Handling e All Commodore File Types Fast ML Floating Point amp Integer Math Trace amp Decompiler e Conversational User Double Precision 2E 38 with Auto Sci Not Conditional Macro Defined Commands n e Logx Loge Sin Cos Tan SQR 1 X Assembler Matrix and Multidimensional Lattice Math Algebraic Expression Evaluator Great Documentation e Easy to Read 350 pg Manual with Tutorials SUPERFORTH 64 Al LISP g 7 LOGO 2 s NX 3 Source Screen Provided 2 ae S seed e Meets all MVP Forth 79 FORTRAN z Industrial Standards ASSEMBLER Personal User Support Power of Languages Constructs Programming Time A Total SuperForth 64 is more SuperForth 64 Saves You Integrated Package powerful than most other Time and Money for the Commodore 64 computer languages Ordering Information Check Money Call See a MOUNTAIN VIEN SPECIAL 415 961 4103 i VISA MasterCard Ree Con um ME INTRODUCTORY OFFER MOUNTAIN VIEW PRESS INC No billing or unpaid PO s California PO Box 4656 residents add sales tax Shipping costs 9900 Mt View CA 94040 in US included in price Foreign orders on y Dealer f pay in US funds on US bank include 203 Value ealer tor for handling and shipping 10 Limited Time Offer PARSEC RESEARCH Parsec Research Drawer 1776 Fremont CA 94538 Commodore 64 TM of Commodore Volume VII No 3 27 FORTH Dimensions Improved Forth 83
84. n about seven minutes The result is that a review of Forth code cannot normally cover more than about seventeen screens in any session twenty is prob ably the maximum After the code inspection the author revises the code to take into account the comments and criticisms offered by the inspection team Compared to un inspected code the code resulting from this process of review and revision shows a number of improvements The style and factoring are better and more understandable which makes subse quent maintenance and revision much easier Reviewing the code with other programmers catches problems that would normally show up only later when the various separate modules would be integrated problems like the use of the same name for different functions redundancy with other mod ules as when a programmer redevelops a routine that another programmer has already written and tested inconsis tency in data values and mismatches of context or side effects Experience has shown that formal code inspections increase productivity reduce develop ment time and cost and contribute to programmer training and education The literature on code walk throughs and team programming is extensive good starting place for the interested reader is The Psychol ogy of Computer Programming by Gerald Weinberg M MM M M M M o Maa FORTH Dimensions 34 Volume VH No 3
85. n the DOS com mand line as a default input file then to execute READ FILE to run the program then to return to DOS The F83 word IS provides a convenient way to change the meaning of certain other words in F83 such as BOOT which have been set up to allow this kind of re vectoring The word ERROR should also be re vectored since otherwise an attempt to list a non existent file would leave the user in Forth not in DOS The system call 0 0 BDOS returns control to DOS The word NEW ERR has a confusing stack effect when there is no error it must dispose of three arguments since other words in this system expect ERROR to use three But there is no need to drop these extra arguments in the case that 0 0 BDOS is executed when there is an error since then the program is finished anyway Notice that this program uses the old DOS calls before hierarchical directories Therefore it will work with old versions of DOS such as 1 1 as well as with all later versions If you are using a later version of DOS such as 2 1 note that the LIST command which this program creates cannot accept a pathname It can list files in a hierarchical directory either by having a copy of LIST COM in the same directory as the file to be listed or by using the DOS command PATH And it can redirect its output into a file which can prove useful for cleaning files before uploading if they have parity bits set or contain other non text characters
86. nch offset is moved copied bodily into the program so that the words of the macro definition can then be executed in line at a still later time when the program is run Since the code is copied in this way to a different location to be run it must not contain any absolute branch addresses but only relative branch addresses off sets if the implementation provides them or else no branches at all Although synonyms may be defined for immediate words as well as for nonimmediate words there would be no advantage in using a macro defini tion to replace a colon definition that is marked immediate and this possibility is not provided for The definitions shown in screens 51 53 are fairly straightforward First MACRO compiles a name and link field for the heading of the macro defini tion It then allots space in the body of the definition parameter field for a count byte Then the compiler is called which starts compilation and the words of the definition are compiled into the macro in the same way in which they would be compiled into a colon definition Compilation is stopped by END MACRO which calculates the number of bytes of dictionary space used for com piling the words of the macro and places a length byte in the space pre viously allotted for it The length byte and the words of the definition then constitute a string that can be moved out of the definition as needed The macro definition is then made immediate
87. ne preserves the values in any registers which are used by the Forth inner interpreter With MVP FORTH on a Z 80 machine I must preserve the value in the BC register pair since this is the Forth instruction pointer The pseudo interrupt service routine must end with the macro BACK screen 22 which assembles the three patched over one byte instructions and a jump to location NEXT 3 UNPATCH screen 21 returns NEXT to its normal form ef fectively disabling the pseudo interrupt Note that this technique applies only to those Forth systems which use a call to a central NEXT not to those which compile that code with each word In my CP M version of Forth KEY VO screen 23 can be necessary since KEY uses CP M to get a character from the console If no character is present CP M waits until one is input During this time NEXT is not being ex ecuted rendering the pseudo interrupt inactive KEY VO waits in Forth until a character is present and then executes KEY ensuring that execution is con stantly passing through NEXT KEY is vectored through the variable KEY allowing easy definition of KEY PATCH and KEY UNPATCH to vector execution to KEY VO and back to KEY respec tively Both to demonstrate the use of pseudo interrupts and to evaluate their performance I have written code to run the prime number sieve benchmark BYTE January 1983 concurrently with pseudo interrupt driven serial output Th
88. nsus I am going to open the discussion with a proposal I don t mind getting shot down in flames so long as we are at least considering the question 1 Existing working standard pro grams should still produce correct results as far as possible Votume VII No 3 2 A cell on the parameter or return stack will be large enough to hold an address This will be at least sixteen bits but the actual size will be implementation dependent It will be available in a constant named LSIZE with the L standing for long 3 and will still transmit sixteen bits This way sequences such as DO Q 2 LOOP will still work 4 If more than sixteen bits are available in a stack cell will sign extend A new operator Ug will fetch sixteen bits but will supply high order zeroes This is consistent with the existing set of unsigned operators On sixteen bit Forths Ug will be an alias for 5 New operators Lg and L will transmit a full stack cell i e LSIZE bits 6 Existing double operators e g 2SWAP and D will still operate on two stack cells 7 A compilation address will stay at sixteen bits This last point at least is debat able It would preclude allocating very large arrays within the dictionary so that the dictionary can remain within 64K An alternative would be to increase a compilation address to LSIZE This however would expand the dictionary considerably in thos
89. nt to define additional applica tion words These will be automatically assigned word numbers as they are compiled and will be added to the summary However if you go back and redefine one of your words it is necessary to execute INIT and then recompile your entire application Volume VII No 3 Now You Can Add E ARTIFICIAL Ne INTELLIGENCE To Your Programs Using a Powerful Combination By Elliot Schneider amp Jack Park Heres Your Chance to Profit by being on the Forefront Write 5th Generation Software Learn How To Easy Graphics amp Sound Words Create Intelligent Construct e Hires Plotting e Turtle Graphics Programs Rule Bases Windows Koala Pad Graphics Build Expert Systems Do Knowledge Split Screen Integrator Write Stand Alone License Engineering e Printer Plotter Ctrl e Hires Circle Line Arc Free Programs Use Inference Engines Sprite amp Animation Music Editor Write Intelligent Programs For Editor e Sound Control e Home Use Data Analysis Easy Control of all I O e Robotics e Business e RS232 Functions Interrupt Routines Medical Diagnosis Real Time Access all C 64 Peripherals Education Process Control Utiliti ntelligent CAI Fast Games WUES e Scientific Analysis e Graphics Interactive Interpreter e Interactive Compiler e Data Acquisition Financial Decisions e Forth Virtual Memory e Romable Code Generator Full Cursor Screen Editor 40K User Me
90. nto the threaded code in DO Since the arguments used by DO are on the return stack it would not be properly set up Metacompiler Considerations To metacompile this DO LOOP con struct transition words similar to DO DO LEAVE LOOP and LOOP are need ed Error checking has been omitted from the implementation given and the variable LOOP LINK T has been ad ded The words given in Figure Five go into the vocabulary of the metacom piler The word THERE takes a compile time target code address and offsets it to the corresponding run time address The following words go into the TRANSITION vocabulary which con tains defining and compiling words found in the target source code The T and T words indicate this see Figure Six All T definitions are made im mediate by T and TARGET does a COMPILE from the TARGET vocabulary which acts as the symbol table for target words Volume VII No 3 29 FORTH Dimensions A Forth I O Technique Pseudo Interrupts Ed Schmauch Ponca City Oklahoma Traditionally there are two methods of computer input output I O poll ing and interrupts Polling is easier to implement but has the disadvantage of completely tying up the CPU during I O The use of interrupts allows the CPU to do background processing concurrently with the I O but requires a more detailed understanding of the hardware Using Forth I have devel oped an intermediate technique which require
91. o 3 venth Annual FORML CONFERENCE The original technical conference for professional Forth programmers managers vendors and users November 29 December 1 1985 Asilomar Conference Center Monterey Peninsula overlooking the Pacific Ocean Pacific Grove California This year s theme SOFTWARE TOOLS a Forth natural Present your favorite Forth tool and publish it in the conference proceedings or present a paper on another Forth topic You will meet other Forth professionals and learn about the latest in Forth applications techniques and directions To get your registration packet call the FIG Hot Line 408 277 0668 or write to FORML Registration Forth Interest Group P O Box 8231 San Jose CA 95155 265 Double Room 315 Single Room Limited availability 200 Non conference guest Share a double room Registration includes room meals conference materials and social events Registration Registration and abstracts are due October 15 and final papers are due November 1 1985 Make your reservation now and get your registration packet Space is limited advance registration is required FORE Volume VII No 3 33 FORTH Dimensions An Approach to Reading Programs Kim Harris Palo Alto California Michael Ham Santa Cruz California Programmers frequently need to un derstand in detail a program that was written by someone else Understand in
92. oating point arithmetic coprocessor support symbolic debugger native code compilers and graphics support For Applications Forth 83 Metacompiler Unique table driven multi pass Forth compiler e Compiles compact ROMable or disk based applications Excellent error handling e Produces headerless code compiles from intermediate states and performs conditional compilation Cross compiles to 8080 Z 80 8086 68000 and 6502 No license fee or royalty for compiled applications Support Services for registered users Technical Assistance Hotline Periodic newsletters and low cost updates Bulletin Board System Call or write for detailed product information and prices Consulting and Educational Services available by special arrangement a Laboratory Microsystems Incorporated 7 Office Box 10430 Marina del Rey CA 90295 Phone credit card orders to 213 306 7412 Overseas Distributors Germany Forth Systeme Angelika Flesch D 7820 Titisee Neustadt UK System Science Ltd London EC1A 9JX France Micro Sigma S A R L 75008 Paris Japan Southern Pacific Ltd Yokohama 220 Australia Wave onic Associates 6107 Wilson W A MARKSTART which increments the ap propriate element of USES and sub tracts the current time from the total time accumulated for WORDn The word number is pushed onto the return stack and we are ready for execution of the main body of WORDn Afterwards the word number is recovered
93. of all attendees though most still participate fully In addition to a complete schedule of meetings full participation includes walks through windswept trees over It Would Have Been Grand Dear FIG I always enjoy Henry Laxen s col umn After reading the YACS Yet Another Case Statement VI 6 VII 1 tutorials a few times I tried to implement the code on my Kaypro using LMI s Z80 FORTH version 3 Though this version complies with the 83 Standard does not work as described in Mr Laxen s column I replaced line four with the following code segment BEGIN gt MARK CSP 1 STATE INTERPRET DUP WHILE gt RESOLVE REPEAT and it now works I was also glad to see macros ad dressed again Forth Dimensions looking the Pacific Ocean conference grounds filled with deer racoons and sand dunes and tasty meals A few non programmer family members or spouses are usually present just to en joy the locale For details about the November 29 December 1 event call the FIG Hotline at 408 277 0668 We are experimentally providing an index to advertisers in this issue The table of contents lists its location we hope this makes it easier for you to find the particular vendor or product that was advertised in here some where Finally this issue is going to press just before the seventh annual Forth National Convention so cover age of that event will be delayed until next issue I look forward to renewing ol
94. olve most of these problems one to read almost any text file and do the best it can to give a reasonable result And it meets the design goal of not asking the oper ator anything about what kind of file is being listed The operator may not know We use F83 here to show how to get started with sequential file I O and how to turn your programs into DOS commands which can be useful outside the Forth environment What the Program Does Here are several common file com patibility problems and ways the pro gram handles them e If the parity bit is set on any char acter the program clears and ig nores it The program cannot know what character if any indicates end of file So it ignores them all and lists everything until the file read oper ation detects end of file Usually the final block is filled out with end of file characters or nulls blanks or something else fairly harmless e Different end of line indicators must be handled Common ones are a carriage return followed by a linefeed a carriage return alone e We and a null alone Word processor document files sometimes have no end of line indication except at the end of paragraph We will take carriage return null and linefeed as meaning end of line and we will then supply a carriage return and linefeed However more than two carriage returns in a row will not be supplied sacrificing triple spacing to avoid problems such as mult
95. omation of an airport with Forth and Forth in the development of MAGIC L and HFORTH A business applications language Proceedings available as a single issue 20 FORTH Dimensions Subscription Rates Vol 3 Corporate Institutional 100 Individual 40 Outside N America add 20 for airmail charges Prepaid subscriptions only in US funds on a US bank or by international money order payable to Journal of Forth Application and Research Inc Back issues available at 15 each add 5 for foreign airmail Send all orders to Journal of Forth Application and Research PO Box 27686 Rochester NY 14627 USA Order Form O Subscriptions Volume 3 1985 Issues 1 4 O Institutions Corporate 100 O Individuals 40 O Subscriptions Volume 4 1986 Issues 1 4 O Inst tutions Corporate 100 O Individuals 40 O Subscriptions outside N America please add 20 per volume for airmail Vol 1 1 Robotics 15 Vol 1 2 Data Structures 15 Vol 2 1 Forth Machines 15 Vol 2 42 Real Time Systems 15 Vol 2 3 Enhancing Forth 15 Vol 2 4 Extended Addressing 15 Back issues outside N America please add 5 per issue for airmail Four or more back issues 12 each issue Four or more issues outside N America 16 each includes airmail Rochester Forth Conference Proceedings 20 Please send further information on the Institute s publications and activities 00 00 0000000 Name Address Amount Enclosed VISA MC Exp
96. or later uses standard DOS files Full screen editor uses 16 x 64 format Editor Help screen can be called up using a single keystroke Source included for the editor and other utilities Save capability allows storing Forth with all currently defined words onto disk as a COM file Definitions are provided to allow beginners to use Starting Forth as an introductory text Source code Is available as an option A Metacompiler on a host PC produces a PROM for a target 6303 6803 Includes source for 6303 FIG Forth Application code can be Metacompiled with Forth to produce a target application PROM FIG Forth in a 2764 PROM for the 6303 as produced by the above Metacompiler Includes a 6 screen RAM Disk for stand alone operation 45 An all CMOS processor board utilizing the 6303 Size 3 93 x 6 75 inches Uses 11 25 volts at 12ma plus current required for options 240 360 Up to 24kb memory 2kb to 16kb RAM 8k PROM contains Forth Battery backup of RAM with off board battery Serial port and up to 40 pins of parallel 1 O Processor buss available at optional header to allow expanded capability vla user provided interface board Micro Computer Applications Ltd 8 Newfield Lane Newtown CT 06470 203 426 6164 Foreign orders add 5 shipping and handling Connecticut residents aad sales tax e Bau Chapters ALABAMA Huntsville FIG Chapter Call Tom Konantz 205 881 6483 AL
97. ourse the actual author will play this role but in the absence of the true author a stand in will suffice The purpose of the author is to be the expert who answers questions about the code why a given approach was taken what considerations led to the development of a particular word The author s ultimate responsibility is to make the appropriate changes to the code Moderator The moderator s role is to keep things moving and to keep the inspection session on track The idea of the code inspection is to understand the code and to point out ways in which it falls short errors inefficiencies and the like This meeting though is not the place to write new code or to develop alternate solutions The mod erator is a facilitator who keeps the meeting focused on its purpose Also every suggestion and correction must be recorded during the meeting so that it will not be forgotten The moderator is responsible for the minutes of the meeting Reader One team member reads the code aloud paraphrasing it in terms of its purpose rather than merely echoing the actual definitions Instead of Next is SUM COUNTS ONE RECORD COUNT STORE BEGIN FETCH RECORD the reader says something like The next word begins with the first record for each record it reads the total and in crements the count box By para phrasing the code the reader focuses the group s attention on the meaning of the code by paraphrasing it aloud
98. out weigh the extra bytes of the in line code produced To get an initial idea of the speed tradeoff some timing tests were carried out In the implementation used 0 and O were all defined as code definition primitives The speed of the code definition 0 2 was then compared with an equivalent macro definition MACRO MO 0 END MACRO and with an equivalent colon definition 0 0 The execution times came out to be almost exactly in the ratio of 1 2 4 with the macro definition saving about 16 a minute of execution time per million iterations over the colon definition using a 4 MHz Z80 system This was the time spent nesting down and com ing back up The timings and the ratios might be quite different for different processors and different Forth imple mentations especially for processors better adapted to coding the Forth in ner interpreter than is the Z80 This means that the macro facility has a potential for speeding up pro grams by speeding up their frequently executed inner loops that contain colon definitions Simply recode the colon definitions as macros It would also be worthwhile to examine the other words used in the loop to see whether they have been implemented as primitives or as colon definitions For example in one Forth 0 is a primitive while in another it is a colon definition Re define as macros all that are colon definitions Of course the user could achieve the same spee
99. pointers of this list backward resolving references The first reference is always created by DO or DO DO requires a forward reference but DO does not However to keep LOOP simple a spurious reference is compiled for DO also though it never uses it To handle nest ed DO LOOPs multiple lists of forward references are created The variable LOOP LINK is used to point to the head of the current list When DO is encount ered LOOP LINK is pushed on the para meter stack and is initialized to HERE the address following DO LOOP uses the pointer in LOOP LINK to resolve ad dresses then pops the stack into LOOP LINK LOOP LINK then points to the last unresolved forward reference location of the next DO LOOP out DO and DO compile a zero after DO a zero ter minates the linked list Their defini tions are shown in Figure One LEAVE now compiles LEAVE and links in the address shown in Figure Two As described LOOP or LOOP compiles its run time word resolves the list of forward references with the BEGIN UNTIL loop in LOOP EXIT then restores LOOP LINK from the stack see Figure Three DO and DO place a true flag on the stack for error checking which is absorbed by CONDITIONAL Finally the run time words for Do and DO are shown in Figure Four Notice that the ELSE part of DO is just DO It might be tempting to substitute DO instead but the top of the return stack would then contain the return pointer i
100. r a character string For ex ample 10 STRING MUSH creates a dictionary entry called MUSH with space for ten characters When you type MUSH it leaves the address of the first character and the length of the string on the stack You could ap proximate it with CREATE MUSH 10C 10 ALLOT and then when calling MUSH type MUSH COUNT to get the string pointer and length The word S moves a character string into the array part of the string vari able Some versions of Forth have the word to compile a string into the dictionary You will note that I have to patch some characters into the selection string This is because it is difficult to include things like esc cr and X as character literals in Forth SELECT SELECT is a small utility with uses outside the NUMED package Given a string of characters SELECT accepts only those keystrokes whose characters are included in the string It returns the index of the character within the string This is permits the routine using SELECT to CASE on the keystroke frequently done in menu driven pro grams Implementation Notes NUMED has been implemented as a state machine where each state consists of an action part within the CASE and a transition part Some action words within a state require the keystroke index as input while some do not Digits for example must be passed to L007 sessSmerrsese cee eee SSS NUMBER EDITOR NUMED XDIGIT NUMED SIGN NUMED CMD
101. rd Then in the code field it compiles the address of one of the two DOES expressions in the defining word Which one is compiled depends on whether or not the old word was im mediate There is an error exit in case the old word could not be found in the dictionary The result is shown in the third column of Figure One for a synonym of the nonimmediate word R and in the third column of Figure Two for a synonym of the immediate word IF The new word is made immediate so that the proper DOES part of the de fining word will always be executed when the new word is interpreted from the console or from a screen If the old word was immediate one of the DOES gt expressions the first one will fetch the compilation address of old word from the body of the the new word and execute it If the old word was not immediate the other DOES expression the second one will either fetch and compile the compilation address or it will fetch and execute the compilation address depending on whether or not the interpreter is in the compile state Thus when the new word is inter preted from the console or from a screen the appropriate DOES part will either compile or execute the old word just as if the old word had been interpreted And since what is compiled is the same as what would have been compiled had the old word been used as shown in the figures the run time behavior will be identical to that of the old word If the compilat
102. ria Bedford MA Call Bob Demrow 617 688 5661 after 7 p m MICHIGAN Detroit Chapter Monthly 4th Wed Call Tom Chrapkiewicz 313 562 8506 MINNESOTA MNFIG Chapter Even Month Ist Mon 7 30 p m Odd Month 1st Sat 9 30 a m Vincent Hall Univ of MN Minneapolis MN Call Fred Olson 612 588 9532 MISSOURI Kansas City Chapter Monthly 4th Tues 7 p m Midwest Research Inst Mag Conference Center Call Linus Orth 816 444 6655 St Louis Chapter Monthly ist Tues 7 p m Thornhill Branch Library Contact Robert Washam 9 Weis Dr Ellisville MO 63011 NEVADA Southern Nevada Chapter Call Gerald Hasty 702 452 3368 NEW HAMPSHIRE New Hampshire Chapter Monthly 1st Mon 6 p m Armtec Industries Snepard Dr Grenier Field Manchester Call M Peschke 603 774 7762 NEW MEXICO Albuquerque Chapter Monthly Ist Thurs 7 30 p m Physics amp Astronomy Bldg Univ of New Mexico Call Rick Granfield 505 296 8651 NEW YORK FIG New York Monthly 2nd Wed 8 p m Queens College Call Ron Martinez 212 517 9429 Rochester Chapter Bi Monthly 4th Sat 2 p m Hutchinson Hall Univ of Rochester Call Thea Martin 716 235 0168 Rockland County Chapter Call Elizabeth Gormley Pearl River 914 735 8967 Syracuse Chapter Monthly 3rd Wed 7 p m Call Henry J Fay 315 446 4600 OHIO Athens Chapter Call Isreal Urieli 614 594 3731 Cleveland Chapter Call Gary Bergstrom 216 247 2
103. s no more understanding of the hardware than polling but allows background processing like interrupts I have dubbed the technique pseudo interrupts The technique takes advantage of Forth s threaded nature The inner in terpreter routine NEXT is patched to execute a code word with every execu tion of NEXT Because Forth code is threaded execution is constantly pass ing through NEXT The code word that is patched in will therefore execute with great frequency This pseudo interrupt service routine can poll I O port regis ters a single time and take any neces sary action This gives a form of polling which is neatly interleaved with Forth execution This technique does not match the rapid response and CPU efficiency of hardware interrupts but offers an improvement over traditional polling techniques by allowing high speed 1 O with background processing occurring simultaneously Screens 21 23 show the basic pseudo interrupt words I am using the Forth 79 Standard MVP FORTH version 1 01 03 on a Kaypro II portable computer PATCH screen 21 expects the parameter field address PFA of the pseudo interrupt service routine on the top of the stack and patches a jump to this location over the three one byte instructions at the beginning of NEXT For example if the pseudo interrupt service routine is named PISR one should enter PISR PATCH to enable the pseudo interrupt Make sure the pseudo interrupt service routi
104. s will work and it is not at all clear how to define synonyms for them One must conclude that the situation is less than satisfactory For one and the same function namely simply de fining a synonym or alias for a word there are three different methods and they are all hedged by ifs and buts It makes the language harder to learn and harder to use The word SYNONYM presented here provides a single simple way for defin ing synonyms The usage of the word is SYNONYM lt new name gt lt old name gt A Forth 83 style glossary entry is provided on screen 47 A word defined by SYNONYM is func tionally identical to the word it is a synonym of and it runs just as fast The only differences are that the com pilation address obtained by tick will lt old name gt Forth 83 11 28 84 vhy make header for new word old word found yes compile its cfa make new word immediate was old word immediate yes set new to execute no set new to check state and compile if compiling or execute if executing old word not found I A defining word used in the form old name Create a dictionary entry for new name so that when lt new name gt is later used it will have substantially the same action that old name would have had If lt old name gt was the action will be immediate otherwise not During compilation the action is to compile the same thing that lt old name gt would have
105. sers to start every line with at least one blank since lines beginning with a blank will not be reformatted onto previous lines But since users won t always do so the CommuniTree system comes up with the line length defaulted to zero Since most users these days have the same terminal line length eighty characters and because those who don t can specify their line length the only remaining problem concerns internal word processor document files which have no end of line until the end of a paragraph But most terminals scroll automatically if more than eighty characters are sent in a line so the data isn t lost and the only problem is that words will be divided in the middle i e wrapped incorrectly Users can set their terminal line length to its ac tual value not zero if this lack of proper word wrap bothers them But since most upload programs provide end of line characters the problem seldom arises One final adjustment On many terminals if you format text to the full line length there will be extra blank lines inserted in the printout after those lines which happen to go to their full length Writing into the last position on the line causes an automatic scroll as it should but the terminal software isn t smart enough to suppress a single linefeed character which arrives immediately after the terminal has supplied its own new line So we set the line length to one less than the user requests eighty column term
106. t and Swords and A Forth Spreadsheet I hope you can get John S James to continue to write on the modem I O words Perhaps he could develop code words for an interrupt driven input buffer and then go on to develop a complete Forth communications program with file transfer modem control everything This is a large project to put in the public domain I hope someone is willing to write the necessary series of articles Thank Craig A Lindley for his Forth spreadsheet and please keep publishing the application programs Thanks for your effort in publishing Forth Dimensions Sincerely Ramer W Streed North Mankato Minnesota order to spend time planning this year s FIG convention and to spend more time with his duties as a member of the FIG Board of Directors Michael Ghormley will be charging ahead with the chapter work now and is already working with the individual chapter coordinators Mike brings abundant energy and creativity to his post and we look forward to working with him FORML s annual conference at Asilomar on California s Monterey peninsula is fast approaching For those of you haven t yet attended one this is an intimate conference for ad vanced Forth practitioners Its size per mits close interaction between attend ees many of whom are very experien ced Forth programmers with tech niques to share and proposals for open consideration Presentation of a paper is no longer required
107. that the program will behave reasonably even if there are strings of hundreds of carriage returns or nulls LINES treats the linefeed character even more se verely suppressing it if even one new line has just occurred The purpose is to prevent the normal carriage return and linefeed format from always generating double spacing Incidentally most programmers prefer more white space in their code than is shown here This example has a M Volume VII No 3 FORTH Dimensions PRIME FEATURES Execute DOS level commands in HS FORTH or execute DOS and BIOS functions directly Execute other programs under HS FORTH supervision editors debuggers file managers etc Use our editor or your own Save environment any time as COM or EXE file Eliminate headers reclaim space without recompiling Trace and decompile Deferred definition execution vectors case interrupt handlers PORTH Full 8087 high level support Full range transcendentals tan sin cos arctan logs exponentials Data type conversion and I O parse format to 18 digits plus exponent Complete Assembler for 8088 80186 and 8087 String functions LEFT RIGHT MID LOC COMP XCHG JOIN Graphics amp Music Includes Forth 79 and Forth 83 File and or Screen interfaces Segment Management Full megabyte programs or data Fully Optimized amp Tested for BM PC XT AT and JR COMPAQ and TANDY 1000 amp 2000 Runs on all true MSDOS
108. the colon definition which means execut ing the primitive ROT twice Then it must retrieve the return off the return stack nesting back up corresponding to the semicolon This is the slowest In the case of the macro definition of ROT the compilation address of ROT is not compiled into the program In stead the compilation addresses of ROT ROT from the body of the macro are compiled This takes up more room in the program but when it is run the nesting down and up are eliminated The speed of this is intermediate be tween the code definition and the colon definition The macro facility has few restric tions Anything that can be program med as a colon definition that results in position independent code in the body of the definition can be programmed as a macro That means that even such constructs as make END MACRO immediate IF ELSE THEN and DO LOOP can be included in a macro if the Forth implementation uses relative branch addresses offsets Not all Forths do To find out whether your implementa tion compiles position independent code compile TRIAL TRIAL IF DROP THEN IF DROP THEN If the code is position independent a memory dump will show that the two compiled definitions are identical ex cept for their link fields In particular the branch addresses will be offsets and will be the same probably 0004 Macros can be embedded in macros to any level desired For example
109. uld be used in place of a synonym That is not normally ad visable however As a rule of thumb always use a synonym to replace a colon definition with one word in it and a macro to replace a colon defini tion with two or more words in it It is instructive to compare the dif ference between macros and syno nyms The action of a synonym with regard to the immediate nonimmed iate distinction is deferred where the action of a macro is not Suppose we define SI as a synonym of IF SYNONYM SI IF As we saw in Figure Two of the previous article the compilation ad dress of IF is compiled into the parame ter field of SI even though IF is an immediate word Then when SI is used in a program it has the same effect that using IF would have had Namely it executes as an immediate word and compiles a conditional branch into the program and arranges for a branch offset This conditional branch will be executed at a still later time when the program is run But when IF is compiled into a macro for DUP MACRO DUP DUP IF DUP THEN END MACRO the IF will have its immediate action now and a conditional branch with its branch address will be compiled into the macro definition in exactly the same way that it would be compiled into a colon definition See Figure One of this article Then when the macro DUP is used in a program the body of the macro definition compiled for DUP including the conditional branch and its bra
110. velopment by Anderson amp Tracy 18 EWO Inside F83 Manual by Ting 25 system Specify Computer 500 Beginning FORTH by Chirlian 17 FORTH Notebook by Ting 25 a MVP FORTH MS DOS file interface for IBM PC PADS 80 FORTH Encycl Pocket Guide 7 Invitation to FORTH 20 a MVP FORTH Floating Point amp Matriz Math see above 85 And So FORTH by Huang PDP 11 User Man 20 a MVP FORTH Graphics Extension see above 65 A college level text 25 6502 User s Manual by MVP FORTH EXPERT 2 System for learning and developing knowledge based FORTH Programming by Scanlon 17 Rockwell Intl 10 programs Both IF THEN procedures and analytical subroutines are available STARTING FORTH by Brodie Best FORTH 83 Standard 15 Source code is provided Specify C Apple DIBM or OCP M Includes MVP instructional manual available FORTH 79 Standard 15 Books Vol 4 amp 6 100 soft cover OQ Mew Wavd Kefe Word Processor tor the IBM PC XT AT with 256K MVP FORTH compatible kernel with Files Edit and Print systems Includes Disk and Calculator systems and ability to compile additional FORTH words 150 each 25 Installation Manuat lor fig FORTH 15 Source Listings of fig FORTH Specity CPU or Computer 15 Ordering Information Check Money Order payable 10 MOUNTAIN VIEW PRESS INC VISA MasterCard American Express COD s 5 extra Minimum order 15 No billing or unpaid PO s California residents add sales lax Shipping costs in US include
111. wanted Then how about R COMPILE R IMMEDIATE This will work fine here but the technique will only work while compil ing it cannot be used for the s and edit examples which are to be executed from the console Consider the case of DUP COMPILE DUP IMMEDIATE This will work when compiling but one would want it to work from the console too so try DUP DUP But this is less than optimal for a word that might be compiled into an inner loop because it will run slower on account of the extra nesting and un nesting of the colon definition In cases like this neither method is completely adequate since the choice of the best method of definition will depend on how the word is to be used Note too that neither technique can be used for immediate words For these one needs ENDIF COMPILE THEN IMMEDIATE And if you don t happen to remem ber whether the word you want to Screen 46 0 Usage SYNONYM lt new name gt SYNONYM CREATE 32 WORD FIND DUP IF SWAP IMMEDIATE 1 IF DOES gt EXECUTE ELSE DOES STATE IF e ELSE EXECUTE THEN THEN ELSE 1 ABORT THEN not found Screen 47 0 SYNONYM Glossary entry SYNONYM SYNONYM lt new name gt immediate 24 2 WNAFADWANAHDUN PWN make a synonym of is immediate or not you will have to look it up Fur thermore for any words that are both immediate and operate on the return stack it may be that none of these method
112. whatever words are necessary for sequential I O on your system Or you could do it the easy way and use BLOCK if your system can read partial blocks which may be at the end of a file Notice that we did avoid the work of opening a file from scratch by using an OPEN which this Forth system already provides for access to files of screens Since that OPEN was intended only for random I O we had to initialize one more field in the file control block that s the purpose of the word FILE RESET Incidentally the word DOS EMIT in the first screen is almost identical to the Forth word EMIT supplied by the system But DOS EMIT uses the DOS call instead of the BIOS call to write a character to the screen The practical difference is that with DOS EMIT you can have the output printed by turning on the printer through DOS by using whatever key or combination of keys your system provides for this purpose The word OUT in the second screen filters the stream of characters and changes any which should be ignored to 1 which is not a possible ASCII value Then it prints all except those it changed to 1 The first line of 70UT allows any key to toggle a pause so users can stop the display and have time to read the information before it scrolls off the screen Users can end the listing with control C The variable LINES keeps count of multiple new lines in a row After two no more new lines are generated We suppress additional new lines so

Download Pdf Manuals

image

Related Search

Related Contents

Samsung SPH-L710RWBBST User's Manual  MASTER CONTROL MV-58 Owner`s Manual  Guide d`informations de sécurité  Bedienungsanleitung Pool-Charly  取扱説明書 LEDシーリング  取扱説明書 - 日立工機  Document  情報公開・個人情報保護審査会第1部会開催記録 1 日時 平成  DISTRIBUTED CONTROL OF A SEGMENTED AND SHAPE  ONE2ACT Eval user manuaa for etacher and student  

Copyright © All rights reserved.
Failed to retrieve file