Home
V4N2 - Forth
Contents
1. 300 00 FORTH Programming Aids by Curry Associates Includes Translator Callfinder Decompiler and Subroutine Decompiler 40 page manual Used with Cross Compiler to generate minimum size target applications Specify Z 80 or 8086 FORTH screen file or fig FORTH style CVS OC co fee esiodnirng kde tease ea ae as nes oe Se a 150 00 Z 80 Machine Tests Memory disk console and printer tests with all source code Specify CP M 2 2 or CP M 1 4 cece 50 00 AMD 9511 arithmetic processor S 100 interface board Assembled and tested without AMD 9511 200 00 Assembled and tested with AMD 9511 02 cece eee 350 00 PC FORTH distributed on 5 inch soft sectored double density diskettes All other software distributed on eight inch soft sectored single density diskettes North Star and Micropolis formats available at extra charge Prices include shipping by UPS or first class mail within USA and Canada Overseas orders add US 10 00 per package for air mail California residents add appropriate sales tax Purchase orders accepted at our discretion No credit card orders Z 80 is a trademark of Zilog Inc IBM is a trademark of International Business Machines Corp CP M is a trademark of Digital Research Inc Laboratory Microsystems 4147 Beethoven Street Los Angeles CA 90066 213 306 7412 FORTH Dimensions 2 Volume IV No 2 Letters Making It In Japan Dear FIG According to a re
2. FORTH DIMENSIONS VOLUME IV NUMBER 2 2 50 INSIDE HARDWARE CONTROL 2 FORTH in the Computer Toolbox 04 Mark Bernstein ccccceeeeeeeeees 6 The FORTH Step Stepper Motor Control Martin B Petri amp Leo Brodie 12 Handling Interrupts in FORTH seese Stephen Melvin 0 0 cece 17 _ FEATURES Source Screen Documentation Tool Kim Harrris ccccessceesesscssessseseeseeeee 230 The Art of ReCursion cccssseeeeeseeees Bob Gotsh c ccccsceseseseeseseeeeen 240 A Recursive Decompiler c cscseeseeeeee Robert D Ackerman ccsecees 28 DEPARTMENTS TE S aori enn ne eer EE ene oe re err mere eer ee eee 3 Standards COrner ccsccescssccssecsecenenseeeees Robert L Smith a n 19 A Techniques Tutorial Defining Words II Henry Laxen cccceeeeeeeteeees 20 Tocha OSa E etd sense ccece E anionic eee 30 New Products ReVIOWS ccccccccccsceccesecccescessscescsesssssessncassecscsecsteessceesseeesersaeeess 32 ME oe gipa im r A la pin E ME I EAN tl AAA IE RTT RI iG MCSA TEE TCLS a AGE Wel RINT Ri EAA A TE a a AE OTE ln ERR NEE TEA om SO 02 het 51 Bae e 2186 002 DIA 5552 05 25 6 4 DEE Keyway jor 404 WOODALFF KEY 3HOLES EQUALLY SPACED hey attached 1D saa HARDWARE CONTROL fo ora meh AO Scr Nite Kp ae RRP PR IE ELC THORP ET Dae Pe tran heme RCO ASPET
3. 3 The motor control commands used in WIGGLE are described in M Bernstein s Stepper Motor Control A FORTH Approach MICRO February 1982 4 M Bernstein and D P Gerrity Micro computer Interfacing FORTH vs BASIC MICRO June 1982 pg 77 5 Peter M Kogge An Architectural Trail to Threaded Code Systems IEEE Computer March 1982 p 22 6 James R Bell Threaded Code Com _ munications of the ACM 16 June 1973 p 370 J B Phillips M F Burke and 7 G S Wilson Threaded Code for Labor atory Computers Software Practice and Experience 8 1978 p 257 Mark Bernstein is a graduate student in Harvard s Department of Chemistry His current research combines ultrafast lasers and sensitive microphones all controlled by a FORTH based micro computer to study fast chemical reactions o 11 TO HORSE IS COMING COME TO YOUR IBM P C s CALL REWARD INCREASED PROGRAMMING PRODUCTIVITY BOUNTY of BENEFITS to those who JOIN FORTH Inc AVAILABLE AT SELECTED COMPUTER TRADING POSTS Volume IV No 2 The FORTH Step Stepper Motor Control Application by Martin B Petri Text by Figure 1 Martin B Petri amp Leo Brodie Stepper motors supply the muscle for computer applications with compli cated movements such as computer disk drives and printers industrial robots telescopes laser systems etc P Unlike regular motors st
4. 3 Y COUNT 4 IF 1 Y COUNT Y DIR 2 5 IF 12 Y PTR i Y POSITION amp ELSE 16 Y PTR i Y POSITION 7 THEN 8 ELSE 20 Y PTR 9 THEN 10 11 Y STEP sets the forward or reverse bit pointer if there is 12 more steps to do and adjusts the position variable else 13 it sets the stop pointer gt 14 15 S Screen B O The FORTH Step 7 of 10 OZJUNB2MBP gt i 2 XY STEPPER 3 MAX TIME STEP TIME Setup for timer 4 Y COUNT 2 X COUNT get x y counts 5 MAX want the larger of the 2 6 DUP duplicate if not zero gt 7 IF DO this is the number of loops 3 X STEP Y STEP get bit patterns 9 XY RUN and step the motors 10 LOOP 11 THEN 12 i13 XY STEPPER assumes the X amp Y counts and direction flags gt 14 were set before entry 15 S Listing continued on page 16 tioning device An example applica tion might be a drill press which must drill a series of holes in a circuit board This routine will control the stepper motors that position the board under the drill bit before each hole is drilled In this application it isn t necessary to produce diagonals other than 45 degree angles see Fig 2 Because there is no time penalty we ve chosen to simply interlace the pulses to the two motors so that when both are run ning they run in step with one another Any other approach would involve unnecessary complexity Since we are powering the coi
5. amp 8080 processors The _ See TS eee SS ee ee single sided e o a a u single you keying the FIG FORTH model and many published FIG FORTH screens onto diskette and You receive TWO 8 inch diskettes readable by Digital Research CP M or Cromemco CDOS and contains 8080 source I keyed from the published listings of the FORTH INTEREST GROUP enhanced version in ZILOG 280 mnemonics density soft sectored FIG plus a translated This Gisk also contains executable FORTH COM files for 280 2nd disk contains FORTH readable screens including a extensive FULL SCREEN EDITOR plus many items published in FORTH DIMENSIONS including a FORTH TRACE utility a mode data base handler an 8080 ASSEMBLER and formatted memory dump and I O port dump words The disks are packaged in a ring binder along with a complete listing of the FULL SCREEN EDITOR and the FIG FORTH INSTALLATION MANUAL the language model of FIG FORTH a complete glossary memory map installation instructions and the FIG line editor listing and instructions This entire work is placed in the public domain in the manner and spirit of the work Copies may be distributed when proper notices are included it is based on See ee au o au upon which USA Foreign AIR Above described package escsacasessoesoseso SDO 60 E Printed 280 Assembly listing w xref 15 18 Zilog mnemonics
6. Contact FIG Hotline 415 962 8653 Orange County Chapter Monthly 3rd Sat 12 noon Fuller ton Savings 18020 Brockhorst Fountain Valley 714 896 2016 San Diego Chapter Weekly Thurs 12 noon Call Guy Kelly 714 268 3100 x4784 Massachusetts Boston Chapter Monthly 1st Wed 7 p m Mitre Corp Cafeteria Bedford MA Bob Demrow 617 688 5661 x198 Michigan Detroit Chapter Call Dean Vieau 313 493 5105 Minnesota MNFIG Chapter Monthly 1st Mon Call Mark Abbot days 612 854 8776 or Fred Olson 612 588 9532 or write to MNFIG 1156 Lincoln Ave St Paul MN 95105 New Jersey New Jersey Chapter Call George Lyons 201 451 2905 eves New York New York Chapter Call Tom Jung 212 746 4062 pe Volume IV No 2 FORTH Dimensions Fig Chapters Oklahoma Tulsa Chapter Monthly 3rd Tues 7 30 p m The Computer Store 4343 So Peoria Tulsa OK Call Bob Giles 918 599 9304 or Art Gorski 918 743 0113 Oregon Portland Chapter New Chapter Call Timothy Huang 9529 Northeast Gertz Circle Portland OR 97211 503 289 9135 Pennsylvania Philadelphia Chapter New Chapter Call Barry Greebel Continental Data Systems 1 Bala Plaza Suite 212 Bala Cynwid PA 19004 Texas Austin Chapter Call John Hastings 512 327 5864 Dallas Ft Worth Chapter Monthly 4th Thurs 7 p m Soft ware Automation 1005 Business Parkway Richardson TX Call Marvin Elder 214 231 9142 or Bill Drissel 214 264
7. Box 4545 Mountain View CA 94040 USA or telephone Mr Roy Martens at 415 962 8653 FORTH Dimensions Volume IV No 2 A Techniques Tutorial Defining Words Il Henry Laxen Last time we took a look at defining words and went through two simple examples One was a defining word that sent strings of characters to the terminal and the other one gave suitable responses to simple com mands This time I will continue on the theme of defining words and look at a more meaty example We will con struct a defining word that constructs defining words Try saying that 5 times real fast backwards One of the problems with many of the published examples on defining words is that they seem to be trivial at first glance You get the feeling that you are being cheated when you see a 1 line definition of ARRAY or VEC TOR After all we know how com plicated arrays and vectors are and it doesn t seem possible that they can be implemented so trivially in FORTH Well today s example is a little rougher but if you just keep a few sim ple principles in mind it will be easy to follow In a nutshell defining words consist of 1 The word CREATE which when executed takes the next word in the Laxen amp Harris Inc 24 0 Set Theory 1 VARIABLE TENS 2 VARIABLE CLASS O CLASSE 3 VARIABLE NULL 0 NULL 4 LINK addr HERE OVER 5 CLASS CREATE DOES CREATE LINK DOES 2 MENBER Sn pf
8. IBM PERSONAL COMPUTER MORE SPEED 10 20 times taster then interpreted BASIC MORE ROOM Very compact compiled code pius VIRTUAL MEMORY makes your RAM act larger Variable number of block buffers 31 char unique wordnames use only 4 bytes in header MORE INSTRUCTIONS YOUR commands to its 79 STANDARD pius instruc ton set Far more complete than most Forths single amp double precision arrays string handting clock graphics IBM low res gives 16 color or 200 tint display MORE EASE Excellent full screen Editor structured amp modular programming Word search utitity THE NOTEPAD letter writer Optimized for your TRS 80 or IBM with 7 ca repeats upper lower case dispiay driver full ASCII MORE POWER Forth operating system Concurrent interpreter AND compiler VIRTUAL 1 0 for video and printer disk and tape Lee byte hard disk available li BORO cr BOBS 8088 Assembier aboard 280 Aatembie also available for TRS 80 intermix 35 to 80 track disk drives IBM can read write and run M 3 Disks M 3 disks can read write and run M 1 disks IMS FORTH THE PROFESSIONAL FORTH SYSTEM FOR TRS 80 amp IBM PC Thousands of systems in use MMSFORTH Disk System cones i disk drive 32K peo V2 0 Radio Shack TAS 80 Model or Il 128 V2 1 IBM Personal Computer 80 col fae ETRA 249 95 AND MMS GIVES IT PROFESSIONAL SUPPORT Source code provided MMSFORTH Newsletter Many demo programs aboard MMSFORTH User Group
9. and businesses using Forth We intend to publish papers not el x only by professional Forth programmers but also by people who have used Forth as a tool to facilitate their ERE own work The journal will try to represent the growing Forth community and provide a forum for EA 5 original work a A 1983 The Institute will also undertake publication of the proceedings of the conferences it sponsors The 1982 Rochester Forth Conference Proceedings should be available in September from Mountain View Press if you are interested in helping to further the Forth concept through a unique organization please contact Thea Martin Executive Director EE The institute for Applied Forth Research Inc RE 70 Elmwood Avenue ME Rochester New York 14611 716 235 0168 FORTH Dimensions host institution and others Further in recognition of the fact that many students trained in the sciences have not had a chance to apply that science within the constraints of industry we are arranging summer _ The journal will appear twice the first year and quarterly thereafter The first issue will come out in January me Volume IV No 2 U S Arizona Phoenix Chapter Peter Bates at 602 996 8398 California Los Angeles Chapter Monthly 4th Sat 11 a m Allstate Savings 8800 So Sepulveda Blvd L A Philip Wasson 213 649 1428 Northern California Chapter Monthly 4th Sat 1 p m FORML Workshop at 10 a m Palo Alto area
10. decompiled This allows you to weave your way through the threaded inter pretive code down to any level you want On occasion it is desirable to know what words a given word is made up of and what words those words are made up of in turn Thus the word GOESINTO which naturally calls for recursion I used MYSELF defined with a few standard FIG words GIN keeps track of indentation Goes IN DIN does an indentation Does IN dent GCHK does special cases par ticulary where a word is followed by a literal or a one bite literal called CLIT in Lyon s FORTH The main word GOESINTO is straight forward For a colon definition it goes through each code field printing a name and waiting for a key A Q ends execution a carriage return calls GOESINTO recursively printing out the names in the last word shown any other key continues until a S signals the end of a colon defini tion or CODE signals a drop into machine language from high level One improvement I envision is be ing able to back up one level rather than quiting altogether This would avoid the problem of having to avoid error and other words which use words which use themselves You could back up one level rather than quiting not being able to finish the original word Another improvement would be to use a fence to avoid see ing low level words of no immediate interest To use this utility with a Starting FORTH system change the ticks
11. delay was inserted into FIRED after which FORTH double checked was the trigger signal still active After an hour or so of tinkering mostly spent fine tuning the delay time the com puter was able to ignore the noise pulses without missing a single genu ine shot Continued on next page FORTH Dimensions Volume IV No 2 Computer Toolbox continued from page 7 Abstract Devices Most instruments are conceptually simple they either generate data for the computer to read or they take in structions from the computer and act upon them We would like to treat in struments like memory to be read and written at will In FORTH terms we like to think of PRINT and PLOT and DISKI of VOLTS of 7BUSY or FIRE Of course the detailed operation of many real devices is complicated by details of interfacing and lack of stan dardization Typically a single experi ment may include a dozen different instruments each demanding unique data formats and transmission pro tocols Some instruments accept num bers in binary some insist on BCD others require ASCII strings Data in compatability poses a serious obstacle to communication since a program mer frequently faces a bewildering array of detail which she must remember without fail at all times FORTH encourages designers to use instruments via device drivers These procedures translate data from standard FORTH internal representa tion into the
12. set direction forward THEN 14 X STEPS calculates the of steps and direction to move 15 3S Screen 10 O The FORTH Step 9 of 10 OZJUNG2MBF gt PY STEPS i Y pos Y POSITION 2 get old count gt new pos old pos DUP Q lt see if negative number gt IF MINUS get compliment Y COUNT set the count O Y DIR set direction reverse ELSE Y COUNT set the count 1 Y DIR set direction forward THEN 1 2 3 4 5 6 7 8 9 FORTH TUTORIAL SYSTEM by Laxen amp Harris Inc Two 8 CP M disks with documentation and a copy of Starting FORTH by Brodie An inexpensive way to start learning and programming in FORTH steps and direction to move Screen ii O The FORTH Step O2ZJUNS2MEP 10 of 10 t X co erd Y ca ord calculate Y steps X STEPS calculate X steps gt XY STEPPER and move there GOTO XY is the high level word expecting X amp Y co ordinates gt GOTO XY Y STEPS INCHES 1000 amp TENTHS 100 amp HUNDREDTHS 10 amp 3 ONTARA WUN Conversion routines assumes i step 001 inch 95 s X PLOT O Y COUNT X POSITION 3 X STEFPS XY STEPPER 3 Y PLOT oO X CDUNT Y POSITION Y STEPS XY STEPPER j INCHES X PLOT or 5 TENTHS Y PLOT RAN BE USEI im CME AORA nie MOUNTAIN VIEW PRESS INC P O Box 4656 Mountain View Calif 94040 415 961 4103 End of listing FORTH Dimensions l 16 Volume IV
13. speed and greater complexity of the soft motor position The microprocessor ware Producing a 45 degree diagonal then a straight line Fig 2b runs no based chip will then produce the slower and allows software simplicity In the latter case both motors run at appropriate number of signals on the full speed in step with one another until the correct y coordinate is reached control lines to move the motor to the then the Y motor shuts off stated position FORTH Dimensions 12 Volume IV No 2 Screen i O The FORTH Step i of 10 O2JUNSZMBF gt 1 4 CONSTANT PORT A address of motor 1 0 port 2 10 CONSTANT MIN TIME t minimum Q Step time 3 10 CONSTANT ACC TIME acceleration interval time gt 4 15 CONSTANT ACC STEP acceleration steps 5 ACC TIME ACC STEP MIN TIME calculation for amp CONSTANT MAX TIME maximum Q Step time 7 O VARIABLE STEP TIME holds current Q Step time 8 O VARIABLE X POSITION current X position 9 O VARIABLE Y POSITION t current Y position 10 O VARIABLE X PTR x phase table pointer gt 11 O VARIABLE Y PTR y phase table pointer 12 O VARIABLE X COUNT of steps to go 13 O VARIABLE Y COUNT of steps to go 14 O VARIABLE X DIR direction flag 15 O VARIABLE Y DIR direction flag 3S Screen 2 O The FORTH Step 1 2 ACCELERATOR 3 STEP TIME 3 4 ACC TIME 5 MIN TIME MAX b STEP TIME 7 8 9 XY MOTORS 10 Ca SW
14. t provide easy access to the return stack So category 1 seems to be favorable since loading the IP directly shouldn t pre sent a problem However there are three basic methods within group 1 They are 1 loading the IP and jumping to EXECUTE 2 loading the IP and jumping to DOCOL and 3 loading the IP and jumping to NEXT Continued on next page Volume IV No 2 Handling Interrupts in FORTH continued from page 17 If EXECUTE is used then the top of the data stack must be initialized Further more to use DOCOL would require a PFA or something to be treated like a PFA to be passed However the third method doesn t require any other initialization Now the question arises of passing control back to the restore and return routine steps 6 and 7 To do this a pointer to a pointer to the ex ecutable code must be left somewhere that the IP will point to after the inter rupting word is finished The easiest way to do this is simply to set up a place in the dictionary with the inter rupting word s code field address CFA followed by the return routine s CFA recall that a CFA is a pointer to a code field which points to ex ecutable code Then by initializing the IP to the address of the first loca tion and jumping to NEXT execution will naturally continue with the return routine after the interrupting word is done A final consideration of the inter rupt processing scheme is how to achie
15. 1 FORTH lets a user define macro operations without significant effort In the example WIGGLE wiggles a translation stage over a precisely controlled distance an operation useful in testing and lubricating the motor ing a commonplace everyday activity We build programs to run experi ments often on the spur of the moment using existing FORTH and assembly language procedures Sim ple program building tools including decent editors and modular device drivers help make programs easy to write and easy to document for later reference Most programs are short take a few minutes to write and test and are simple to understand and use for most laboratory procedures are fundamentally simple The complexity of lab computing lies not in the complexity or subtlety of individual procedures but in the vast variety of procedures which may be required mic Hersam Hama Toolbox Components Given adequate tools it is almost always easier to build a simple home made program than to subvert a com plicated program free system which doesn t quite do its appointed task FORTH by providing powerful mechanisms for program construc tion facilitates impromptu program ming and experimenting and so promotes creativity in the lab Most obvious and perhaps most useful is FORTH s inherent macro facility Any important sequence of operations can be given a name and treated as a logical unit Listing 1 Temporary macros can be d
16. 6 years I am writing to you because having read Leo s book I had some serious misconceptions about how fig FORTH operated I was only able to clear these up after I spent much time and effort reading both ASM 86 and FORTH sources If you are able to integrate the information provided below with the installation guide others who follow the same route did i e Brodie fig FORTH will have much less trouble with Starting FORTH than I The most important things e The treatment of the disk in fig FORTH appears to be completely dif ferent from that described in chapter 10 of Brodie This distinction becomes important as soon as you want to copy blocks and maintain the disk because the techniques Brodie describes don t work A section which describes how fig FORTH treats the disk and what the extra bytes in a disk buffer are for referred to in 5 0 of the installation manual would clear this up if added to the installation manual e EXECUTE or tick work differ ently In Brodie the following works GREET Hello speak FORTH OK GREET EXECUTE Hello speak FORTH OK pg 216 In fig FORTH you have to say GREET CFA EXECUTE to get FORTH to return Hello I speak FORTH leave out CFA and FORTH crashes Aside from the above there are two other areas where naming conven tions differ fig FORTH DP is FORTH 79 disk related words BLK BLOCK SCR etc don t work as expecte
17. 9680 Utah Salt Lake City Chapter Call Bill Haygood 801 942 8000 Vermont ACE Fig Chapter New Chapter Monthly 4th Thur 7 30 p m The Isley Library 3rd Floor Meeting Rm Main St Mid dlebury VT 05753 Contact Hal Clark RD 1 Box 810 Starksboro VT 05487 802 877 2911 days 802 453 4442 eves Virginia Potomac Chapter Monthly ist Tues 7p m Lee Center Lee Highway at Lexington St Arlington Virginia Call Joel Shprentz 703 437 9218 eves Washington Seattle Chapter Call Chuck Pliske or Dwight Vandenburg 206 542 7611 35 FOREIGN Australia Australia Chapter Contact Lance Collins 65 Martin Rd Glen Iris Victoria 3146 or phone 03 292600 Canada Southern Ontario Chapter Contact Dr N Solnseff Unit for Computer Science McMaster University Hamilton Ontario L858 4K1 416 525 9140 x2065 Quebec Chapter Call Gilles Paillard 418 871 1960 or 643 2561 England English Chapter Write to FORTH Interest Group 38 Worsley Rd Frimley Camberley Surrey GU16 5AU England Japan Japanese Chapter Contact Masa Tasaki Baba Bldg 8F 3 23 8 Nishi Shimbashi Minato ku Tokyo 105 Japan Netherlands HCC FORTH Interest Group Chapter Contact F J Meijer Digicos Aart V D Neerweg 31 Ouderkerk A D Amstel The Netherlands West Germany West German Chapter Contact Wolf Gervert Roter Hahn 29 D 2 Hamburg 72 West Ger many 040 644 3985 SPECIAL GROUPS ___ Apple Corps FORT
18. MMSFORTH products under development FORTH BOOKS AVAILABLE MMSFORTH USERS MANUAL w o Appendices 17 50 STARTING FORTH best Sind ost te 15 95 THREADED INTERPRETIVE LANGUAGES advanced analysis ot FORTH interals 6 0 6 ee eee 18 95 PROGRAM DESIGN amp CONSTRUCTION intro to structured programming good for Forth 13 95 FORTH 79 STANDARD MANUAL 79 STANDARD word set etc 005 13 95 FOATH SPECIAL ISSUE BYTE Magazine Aug 1980 A collec tor s stem for Forth users and beginners 4 00 ORDERING INFORMATION Software prices include manuals and require signing of a single computer license for one person support Describe your Mardware Add 2 00 S H plus 3 00 per MMSFORTH and 1 00 per additional book Mass orders add 5 tax Foreign orders add 20 UPS COD VISA amp MIC accepted no unpaid purchase orders please Send SASE for free MMSFORTH information Good dealers sougn Get MMSFORTH products from your computer dealer or MILLER MICROCOMPUTER SERVICES B8 61 Lake Shore Road Natick MA 01760 617 653 6136 Volume V No 2 e The Institute for Applied Forth Research Inc Purpose w in the past decade the Forth programming language has emerged as a powerful tool for applying ae O computers However we feel a lack of application oriented information has reduced its general Eee acceptance Recognizing this we have chartered a
19. NEXT A routine that advances the IP and jumps to the code pointed to by the location pointed to by the location pointed to by the previous value of the IP DOCOL The DOES gt portion of A routine which loads the IP with a parameter field address PFA passed to it after first pushing the previous contents of the IP onto the return stack FORTH Dimensions Figure 1 INTERRUPT HANDLING ODE RETURN PSW POP H POP D POP B POP RET END CODE ODE INTSRV B PUSH D PUSH H PUSH PSW PUSH t INT B LXI NEXT JMP END CODE POT CCOMPILE3 CFA INT 3 TEST 35S CITSRY 3 3 SETINT C3 OVER C 1 INTSRV SWAP 3S The word compiled by A routine which loads the IP with the value on top of the return stack Editor s Note In 79 Standard and Star ting FORTH this word is called EXIT EXECUTE A routine which jumps to the location pointed to by the location pointed to by the value on the top of the data stack The processing of an interrupt in FORTH requires seven basic steps 1 upon receipt of an interrupt passing control to the interrupt service routine 2 saving the state of the processor 3 passing control to FORTH 4 executing the FORTH word 5 returning to the interrupt service routine 6 restoring the state of the processor and 7 returning to the routine that was interrupted The term interrupting word will be used to refer to the FORTH word which is intended to be executed upon recei
20. O FORTH 79 Standard a publication of the FORTH Standards Team 15 18 O Kitt Peak Primer by Stevens An indepth self study primer 25 35 O BYTE Magazine Reprints of FORTH articles 8 80 to 4 81 5 10 D FIG T shirts O Small DO Medium OLarge D X Large 10 12 O Poster Aug 1980 BYTE cover 16 x 22 3 5 O FORTH Programmer Reference Card If ordered separately send a FREE stamped addressed envelope TOTAL NAME MAIL STOP APT ORGANIZATION if compeny address ADORESS CITY STATE ZIP COUNTRY VISA MASTERCARD EXPIRATION DATE Minimum of 10 00 on charge cards Make check or money order in US Funds on US bank payable to FIG All prices include postage No purchase orders without check California residents add sales tax ORDER PHONE NUMBER 415 962 8655 FORTH INTEREST GROUP PO BOX 1105 SAN CARLOS CA 94070 FORTH INTEREST GROUP BULK RATE P O Box 1105 on ao san Carlos CA 94070 Permit No 261 Mt View CA 0582 5 R L SMITH ESL SUBSIDIAR OF TRa PO BIK 510 SUNNYVALE CA 94986 Address Correction Requested
21. and enjoy able There was however at least one error that may have been brought to your attention by now On the chance it was not a working listing of the Fig FORTH version of the Ackermann function from page 89 follows Ackermann function ACKERMANN SMUDGE KJ F 1 CALLCNT OVER IF DUP IF OVER OVER 1 ACKERMANN ROT ROT DROP 1 SWAP ACKERMANN ELSE DROP 1 1 ACKERMANN ENDIF ELSE SWAP DROP 1 ENDIF SMUDGE This was transferred to a text file from a FORTH screen that executed FORTH Dimensions SCR 49 O U FIXED 1 CODE U N 1 SEC 2 LDA SEC 2 STY SEC 3 LDA SEC 3 STY 10 LDA N STA BEGIN SEC 2 SEC SEC 2 LDA SEC LDA N LDA SEC STY SEC ROL POP JMP END CODE DECIMAL 37S STY ROL 2 3 4 a 6 7 8 9 CS IF greater than or equal to 8000H will exhibit the symptoms Tracing thru the machine code of U step by step for the two examples above I found that at the 13th itera tion in the division loop the MS word of the dividend assumes the value of 8000H Since the divisor is BEADH the carry to the quotient is not set The MS word of the dividend is then shifted left and since the arithmetic is with the same results published so be assured it is typographically correct May I suggest that the same procedure could make your publication easier to publish and increase the integrity of its contents Thanks for your letter Regarding your final comment
22. ie JPR ld ARIE FCT ga a f t i i i 10 190 32 aed THREAD PM 4 Ae ae ee Z 80 and 8086 FORTH FORTH Application Development Systems including interpreter com piler with virtual memory management assembler full screen editor line editor decompiler demonstration programs and utilities Standard random access disk files used for screen storage Extensions provided for access to all operating system functions 120 page manual Z 80 FORTH for CP M 2 2 or MP M ce cece ence eens 50 00 8086 FORTH for CP M 86 0 cece cc eect e eee eeeneenas 100 00 PC FORTH for IBM Personal Computer 0008 100 00 Floating point extensions for above systems Specify software floating point AMD 9511 AMD 951 2 or Intel 8087 support additional 100 00 Nautilus Cross Compiler systems allow you to expand or modify the FORTH nucleus recompile on a host computer for a different target computer generate headerless code and generate ROMable code with initialized variables Supports forward referencing to any word or label Produces load map list of unresolved symbols and executable image in RAM or disk file Prerequisite one of the application development packages above for your host system Z 80 host 8080 or Z 80 target 0 ccc cece eens 200 00 Z 80 host 8080 Z 80 or 8086 target eee eee 300 00 8086 or PC FORTH host 8080 Z 80 or 8086 target
23. peculiar language under stood by individual instruments map ping the real complicated device onto a simple abstract device that behaves the way the user expects Device drivers hide implementation details so that users need not remember or understand exactly what data format each instrument requires In addition to simplifying the pro grammer s task device drivers help the system adjust to new and modified equipment Device specific informa tion is restricted to the device driver and not allowed to propagate through out the toolbox system If every program that used the printer handled that printer s peculiar ities then replacing the printer would mean modifying every individual pro gram Bizarre devices should not be permitted to contaminate and infect system software their needs should be respected but their oddities ought to be quarantined within device drivers where they can be monitored and modified when necessary Abstract devices can also provide powerful conceptual aids Figures 3 4 For example our toolbox hardware XY x coord y coord gt moves the plotter pen to a position x coord y coord measured relative to XORIGIN YORIGIN Later we realized that turtle graphics were better than cartesian plot routines for some jobs So the pen became a turtle whose current heading is stored in a variable HEADING and which responds to com mands FORWARD LEFT and RIGHT
24. same or not 149 ISJUNB2HHL Set Theory ITEN CLASS NULL LINK 5 addr Notice we have two levels of definition going on here The first level is the name of the class and the second is the individual elements of the class For example the name of a class could be COLOR and the elements of the class COLOR could be RED WHITE and BLUE One way to implement this is to create a defining word called GLASS which creates classes of things such as COLOR Now COLOR itself can be another defining word which creates items belonging to its own CLASS Only one question remains before we can implement the CLASS concept and that is the matter of representation There are several ways we could indicate that an item is a member of a CLASS for example each class could define an array with items belonging to the class being elements of the array Another approach is to store a CLASS identifier with each element of the class The approach we will take is to create a linked list of items belonging to a particular class The advantages of this approach are that we do not need to specify the size of the class at compile time we do not need to store redundant information and it is very easy to implement Now let s take a look at the code in Block 24 We will represent each class by a unique class number and each 16JUNB2HHL Uniquely identifies the nage as an ites nusber Uniquely identifies the class as a class nuaber Always ze
25. the Apple or IBM Personal Computer with single disk MicroSPEED II includes 2 MHz math processor Micro SPEED II includes 4 MHz math processor I Applied Analytics Incorporated 18910 Brookridge Drive j Upper Marlboro Maryland 20772 301 627 6650 j Im interested My computer is i Please send me m MicroSPEED II 495 00 160 Page Manual 15 00 I i l l l lI l l Detailed Information l l l I l l l State Zip Phone No Use this coupon to order or for more information m yao p 29 Volume IV No 2 Technotes 6502 S U BUG Jack Haller Boonton NJ I have discovered a bug in the fig FORTH 6502 ASSEMBLY SOURCE LISTING RELEASE 1 1 involving the word U I came across this problem while trying to implement Glen Hayden s A Serial Day Date Com pression which appears in the 1981 FORML Proceedings After typing in Mr Hayden s screens and running them I noticed that after a certain date the program came back with errone us dates Upon further debugging I traced the problem to the word U and proceeded to test I found that the following terminal entries provide a valid illustration of the problem 1007671 36525 U 27 OK Quotient is correct 1007672 36525 U 24 OK wrong should be 27 Apparently any unsigned divisor BACK TO ACKERMANN Don Russ Lake Forest IL I recently received Volume III which was most interesting
26. to bracket ticks gt 1 Robert Dudley Ackerman is head of the San Francisco Apple Core FORTH Users O FORTH Dimensions 28 Volume IV No 2 TEST FLY 20 MILLION JET ON AN APPLE YES WITH MICROSPEED At the Bethesda Naval Research Center they ve discovered the power of MicroSPEED The Navy s engineers use this remarkable hardware software combination to fly an advanced fighter aircraft in real time even making vertical landings on a simulated carrier deck A crash is merely another learning experience and an opportunity to modify the research aircraft inside the Apple to improve tomorrow s combat planes Surprised that such a sophisticated task is possible on the Apple So were the Navy s officials and many others who have discovered THE MICROSPEED DIFFERENCE This extraordinary Language System exploits the real potential of the microcomputer for the first time The difference between MicroSPEED and other programming lan guages is that with MicroSPEED there is virtually no limit to what you can achieve It may well be the ultimate language for the Apple H and III and soon the IBM Personal Computer MicroSPEED literally combines the performance of a minicomputer with an exhaustive set of user friendly capabilities Name City FORTH Dimensions _______MicroSPEED II 645 00 Company Address APPLE IS A TRADEMARK OF APPLE COMPUTER INC hardware mat
27. we agree in principle Unfortunately the quality of your printer was such that we could not reproduce your listing Writers please use black ribbon on plain white paper Editor FLUSH IS TOO MUCH Bruce Walker San Pedro CA FLUSH in the FIG model of FORTH writes out the memory buffers and invalidates them at the same time so that the next time one is needed it has to be reread from disk again That is logically fine but leads to quite a lot of I O and in the normal edit compile test edit sequence can be frustrat ing The enclosed code writes out the buffers but leaves the buffers still 30 A ASL A ROL HEX SEC SEC SEC 1 SEC 1 LDY STA i DY STA N 1 TAY PHA FLA THEN N DEC O UNTIL SEC 3 ROL BOT ROL SBC SEC SBC STA ROL only to 16 bit precision what should be 10000H becomes 0000H and the next iteration is not valid In order to put forth a solution I have written a modified version of U which uses an extra byte of precision where needed above I do not claim that my analysis or solution is the definitive one but only would like to inform any user about the possible problem marked as valid This protects you against disasterous edits or test cases which run away but still keeps I O to a minimum Curiously SAVE BUFFERS the FORTH 79 standard analog of FLUSH is silent on whether the memory buffers are valid after its execution I believ
28. what is C doing in IF what is C3 why aren t the control words immediate In E H Fey s article on a general case statement on page 194 screen 171 line 7 there should be a 1 be tween the DUP and the C Of course the DEFAULT at the bottom of the col umn before should be DEFAULT So much for minor errors Everyone I talked to said it was the best issue of F D yet published We like lots of code and ideas to look at and think about Robert Dudley Ackerman San Francisco Apple Code FORTH Users Thanks for the comments R D Regar ding Marc Perkel s article on control structures Marc was referring to although he didn t say so the ASSEMBLER s structures See John Cassady s 8080 assembler in the same issue and Marc s article will make a whole lot more sense C3 is an 8080 JMP instruction in hex Also thanks R D for your article on the recursive decompiler which appears in this issue Editor Poor Documentation Dear FIG I purchased a fig FORTH model and machine readable source code from Mountain View Press late last year Earlier in the year I purchased Leo Brodie s Starting FORTH on the basis of a recommendation that it was the best introduction to FORTH available While I was am a novice FORTH programmer I am not a novice com FORTH Dimensions puter programmer system designer having been involved in systems soft ware development for both minis and micros during the last
29. 1 Rochester Univ O Systems Guide to fig O APPLE Il by Kuntzee 90 Systemse 90 Proc FORTH O ATARI by PNS 90 E 6800 by Talbot O Using FORTH 25 E cantec FORTH O CP M by Microsystems 100 O A FORTH Primer 25 Manual 12 O CROMEMCO by Inner Microsystems 100 Languages O PDP 11 FORTH User s ACOB 100 0 280 by Laboratory D AIM FORTH User s Manual O MP 85 by Lange 90 Microsystems Manual 12 O CP M User s Manual O IBM PC by Laboratory 8086 88 by Laboratory C APPLE User s Manual Micrometion Microsystems 100 Microsystems 1 MicroMotion O FORTH 79 Standard 15 TRS 80 User s Manual O FORTH 79 Standard Enhanced FORTH with F Floating Point G Graphics MMSFORTH 19 Conversion 10 T Tutorial S Stand Alone M Math Chip Support X Other O Tiny Pascal in Extras 79 FORTH 79 Specify Disk Size fig FORTH 10 5 ilies ee on BR 40 O TRS 80 1 or ill by Miller O Installation Manual for fig FORTH contains FORTH 5 M Microcomputer Services model glossary memory map and instructions 15 O CP M by MicroMotion F X amp 79 130 F amp 79 140 C 6809 by Talbot Micro systems T amp X Source Listings of fig FORTH for specific CPU s and computers The Installation Manual is required for 150 implementation Each 15 O H89 Z89 by Haydon T amp S 250 Z80 by Laboratory Mi ry Micro O H89 Z89 by Haydon T 175 systems F amp M 150 1802 C 6502 CI 6800 CJ AlphaMicro 8086 88 by Laboratory O soso 8086 88 19900 O APPLE il O PACE
30. AP Ca ii PORT A F 12 STEP TIME 2 13 Oo DO LOOP 14 15 3S Screen 3 2 of 10 O2ZJUNS2MBP get old value subtract acceleration time gt but MIN TIME is minimal value save new value Accelerate the Q Step time until MIN TIME is reached x addr y addr xy phase set the new phases gt get time value and wait it out gt Move stepper 1 Q step and wait SUBSTITUTE for XY MOTORS O The FORTH Step 1 2 3 4 y bit x bit 5 BINARY 2 BASE 7 XY MOTORS 8 Ca 16 CR 9 BINARY 4 R 10 4 SPACES 11 Ca 4 R 12 DECIMAL 13 STEP TIME 3 14 4 SPACES U 15 5 Screen 4 O The FORTH Step 3 of 1 2 CTABLE BUILDS DOES 3 4 HEX CTABLE PHASES 5 05 C 07 C GAC O46 C 6 OA C OF C OS C ob C 7 OG C 096 C O amp C OG C 8 9 50 C 90 C A0 C GO C io AO C 90 C FOC 0 C i114 60 C 69 C 60 C 6 C i2 DECIMAL 13 i4 S FORTH Dimensions Substitute this screen for XY MOTORS to get a visual gt display of the motor bits and time delay gt timer x addr y addr x addr y phase display in binary seperator display x phase back to decimal get timer value and display it gt 10 O2ZIUNGB2MBF X Forward X Reverse X Stop Y Forward Y Reverse Stop Listing continued on next page 13 Older driver designs
31. CFA of the interrupting word initialized to BELL Then there is a jump to NEXT which will cause the interrupting word to be executed by the FORTH system Finally RETURN will be executed which is the opposite of line three followed by a return instruction Note that the CFA and the ter minating of INT are never used and to save space they could be eliminated for example if the in line two is replaced by SMUDGE then no will be compiled into the dictionary In fact the header could be eliminated also but retaining it makes things easier by allowing to be used PUT is fairly straightforward It simp ly stores the CFA of a new word into the location pointed to by the PFA of INT See Figure 2 for an example of how it is used The word TEST simu lates an interrupt and is hardware dependent It should be rewritten to reflect what an interrupt does preten ding that the machine is executing S In this example the PFA of is pushed onto the data stack which in this case is the same as the 8080 s stack in order to fake a PC push Then INTSRV is jumped to TEST can be entered directly from the terminal to test the system see Figure 2 SETINT is specific to the 8080 It puts a jump to the PFA of INTSRV at a cer tain location in memory For example typing 20 SETINT would set up for a RST 4 instruction SETINT must be modified to accommodate whatever method is used to define the interrupt service address Im
32. CI 6809 O NOVA OC PDP 11 LSI 11 O PET by FSS F amp X 150 Microsystems F amp M 150 CROSS COMPILERS Allow extending modifying and compiling for speed and memory savings can also produce ROMable code eRequires FORTH disk Ordering information Check Money Order payable to MOUNTAIN VIEW PRESS INC VISA MasterCard or COD s accepted No billing or unpaid LI CPIM 200 L IBMe 300 PO s California residents add sales tax Shipping costs in US inciuded in O H89 Z89 200 C 8086 300 price Foreign orders pay in US funds on US bank include for handling and O TRS 80 I 200 Cl Z780 200 shipping by Air 5 for each item under 25 10 for each item between 25 Northstar 200 O 6809 350 and 99 and 20 for each item over 100 Minimum order 10 All prices and products subject to change or withdrawal without notice Singie system O fig FORTH Programming Aids for decompiling and or single user license agreement required on some products callfinding and translating 150 DEALER amp AUTHOR INQUIRIES INVITED THE FORTH SOURCE MOUNTAIN VIEW PRESS INC PO BOX 4656 MOUNTAIN VIEW CA 94040 415 961 4103 FORTH Dimensions 10 Volume IV No 2 Computer Toolbox continued from page 8 A turtle device without concern for the hardware which underlies these essentially simple concepts Command Driven Systems Rigid command structures may simplify programming but ultimately they lead only to frustratio
33. COMPILE one word or a range of words at one time even the whole FORTH system This decompliled output may be sent by FPA options to the console printer or to disk DECOMPILE is useful for looking up words or for obtaining variations of words by decompiling to disk editing and recompiling SUBROUTINE DECOMPILER The subroutine either within the context vocabulary or across all decompiler finds words called by a specified vocabularies Useful to locate and merge infre word to all nesting levels This makes FORTH quently calied words or to see which words will PROGRAMMING AIDS especially useful for be affected by changing the specified word metacompilers or cross compilers and for finding words called within a loop The found words one translation of the high level FORTH words in may be DECOMPILEd to disk RAM This is sometimes called decompilation CALLFINDER This set of routines is designed to but the output is not suitable input for a FORTH find the calls to a specified word or set of words compiler Useful for debugging patching into compiled words etc System Requirements FORTH nucleus based on the fig FORTH model or 79 STANDARD a minimum of 3K bytes and a recommended 13K bytes of free dictionary space Ren Curry 415 322 1463 or Tom Wempe 408 378 2811 eect meee eee eee eee eee Yes send me a copy of FORTH PROGRAMMING AIDS including all source code and the 40 page manual O fig FORTH model 150 Calit residents ad
34. DUAL TASKING FORTH Now you can run your process control programs in background while still using your FORTH system in the normal way Background and foreground tasks may each be written in high level FORTH They can execute simultaneously and exchange data The foreground task can control the background task currently available as a custom installation only Write for our FORTH information booklet QT imin Engineering Co oO O 6044 Erlanger St San Diego OO CA 92122 714 455 9008 NM FORTH Dimensions NEW PRODUCT ANNOUNCEMENTS PROGRAMMABLE CONTROLLER WITH SOLID STATE DISK Controlex Corp s CS105 an intelligent controller intended for industrial and process control applications operates in ROM resident FORTH to allow program development directly on the CS105 System memory is configured as a solid state disk to provide fast access and high reliability in hostile environments where rotating memories are failure prone The system includes RS 232 serial port cassette interface printer interface real time clock host target switch and protected programming switch for EEPROMS The CS105 serves as its own development system in the host mode obviating an emulator and the need for downloading to the target machine Compiled applications may be saved in the nonvolatile portion of the solid state disk When the host target switch is in the target position the system can easily be configured to boo
35. FOR WARD is built out of XY which in turn was built from DAC Only DAC knows the intimate details of the plotter in terface and users can choose to think of the plotter as either a Cartesian or Continued on page 11 includes a pair of DACs What could be more obvious than to connect them to an XY recorder Of course we don t want plotting programs to know about the details of the DAC interface these are hidden in DAC DAC millivolts chni gt Sets the output of digital to analog channel chnl to the indicated voltage Much of the time though we want to send the plotter to a designated point on the paper Also we don t really want to keep talking about DAC channel 1 when we mean the X coordinate So after a few days we wrote XY TURTLE INTERPRETER XY PLOTTER DAC DATA FILE PLOTTER Figure 3 Device drivers promote modular independence by separating hardware from application software Hardware changes impact only device drivers not user software In addition applications can treat hardware as conceptually simple abstract devices like the turtle rather than depending on physical hardware characteristics Command Channel RIW Data Channel IEEE 488 Interface BLOCK BUFFER Channel Figure 4 A classic example of an abstract device is the FORTH mass storage im plementation Programmers almost always work with BLOCK which maps the disk into a conceptually simple format Withi
36. H Users Chapter Twice monthly 1st amp 3rd Tues 7 30 p m 1515 Sloat Blvd 2 San Francisco CA Call Robert Dudley Ackerman 415 626 6295 Nova Group Chapter Contact Mr Francis Saint 2218 Lulu Witchita KS 67211 316 261 6280 days MMSFORTH Users Chapter Monthly 3rd Wed 7 p m Cochituate MA Dick Miller 617 653 6136 FORTH INTEREST GROUP MAIL ORDER FOREIGN USA AR O Membership in FORTH INTEREST GROUP and Volume IV of 15 27 FORTH DIMENSIONS 6 issues O Volume HI of FORTH DIMENSIONS 6 issues 15 18 O Volume II of FORTH DIMENSIONS 6 issues 15 18 O Volume I of FORTH DIMENSIONS 6 issues 15 18 O fig FORTH Installation Manual containing the language model of 15 18 fig F ORTH a complete glossary memory map and installation instructions O Assembly Language Source Listing of fig FORTH for specific CPU s and machines The above manual is required for installation Check appropriate boxes Price per each O 1802 D 6502 D 6800 D 6809 O 8080 O 8086 8088 0 9900 O APPLE II O PACE O NOVA O PDP 11 O ALPHA MICRO 15 18 O Starting FORTH by Brodie BEST book on FORTH Paperback 16 20 O Starting FORTH by Brodie Hard Cover 20 25 O PROCEEDINGS 1980 FORML FORTH Modification Lab Conference 25 35 O PROCEEDINGS 1981 FORTH University of Rochester Conference 25 35 0 PROCEEDINGS 1981 FORML Conference Both Volumes 40 55 O Volume I Language Structure 25 35 O Volume II Systems and Applications 25 35
37. I Printed 8080 Assembly listing cccccccssreeSld 18 TOTAL Price includes postage No purchase orders without check Arizona residents add sales tax Make check or money order in US Funds on US bank payable to FORTH Dimensions Dennis Wilson c o Aristotelian Logicians 2631 East Pinchot Avenue Phoenix AZ 85016 602 956 7678 gm l e 22 Volume IV No 2 Source Screen Documentation Tool Kim Harris Laxen amp Harris Inc This article describes a simple but powerful program which extracts and prints information from FORTH source screens This tool will print lines of a screen which start with a non blank in the first column It also prints the screen number and line 0 If source screens are entered according to a simple natural FORTH style then this tool extracts most of their useful information Two words are defined for the tool JOUTLINE screen Print outline of one block Display the screen line zero and any lines containing a non blank in the first column 1st screen last screen Print lines as described in 1OUTLINE above for the range of screens from 1st screen through last screen It is used like INDEX An example of using this tool on its own source screen is shown below The first line of the compressed listing shows the screen number and line 0 The next four lines are indented and are copies of lines 2 3 11 and 12 of the source screen These lines have a non bl
38. IG line editor an 8080 assembler and graphics interface Only 12 includes cassette and documentation of differences from fig FORTH Russell Schnapp 8062 Gold Coast Drive e San Diego CA 92126 fig FORTH ON PET CBM fig FORTH version for CBM disk systems allows up to eight units 16 drives treated as single mass storage Employs CBM s screen editor Also includes FIG editor 6502 assembler string package data base demo calendar program case statement and decompiler 45 includes two disks and very minimal documentation Assumes familiarity with fig FORTH Include description of your hardware Juergen Pfeifer e Oranjerring 28 4150 Krefeld e West Germany 32 Volume iV No 2 Book Review Discover FORTH Learning and Programming the FORTH Language Thom Hogan Osborne McGraw Hill 1982 Reviewed by Glenn S Tenney Fantasia Systems Inc In his introduction the author states that the book will discuss developing work habits that suit the FORTH environment This goal however has not been fully achieved due to many technical errors omis sions and misconceptions In describing manipulations of the stack which is strangely referred to as a poor man s array the author unfortunately places the top of the stack to the left This notation is especially confusing when showing the operation of comparison words In the chapter about memory manipulations the description of CONSTANT is evidently based on t
39. In some cases it is not time effective and acceptable to make bit level deci sions by using 16 bit arithmetic Look for example to hand shake procedures at ports in high speed communication applications The problem that lan guages inherently show a time penalty compared to assembler programming leads typically to the smart definition of clever language elements Such a smart word I have found in Charles Moore may forgive me some Micro soft BASICs it s the WAIT command This is a word which expects an address a mask and an optional select the later two are bytes It fetches the address contents XOR s it with the select and makes a AND with the mask if result equals zero then repeat Select byte default value is zero I will suggest the following definition as a exact copy of this construct as follows 6800 code count WAI T 80 link WAIT 2 TSX LDX 2 X get addr LDAB 0 X get adr TSX EORB 0 X bit polarity ANDB 1 x bit select BEQ WAIT 2 PULA PULA PULA PULA JMP NEXT data stack I think that it is not good if FORTH isn t able to do a smart thing that BASIC can although of course FORTH is able to include special assembler defined words Volume IV No 2 Engineering for FORTH software of professional quality ready to run FORTH development systems application programs in FORTH Consulting services including custom program development Our latest product
40. LOK YELL GW Lass TEXTURE TEXTURE HARD TEXTURE SMOOTH TEXTURE SOFT T YELLOW SOLER MEMBER BLUE COLOR MEMBER 7 HARD COLOR MEMBER 1 ROUGH TEXTURE MEMBER Li WHITE TEXTURE MEMBER 2 HARD WHITE iZ GREEN BLUE i SOFT SOFT COLOR BLUE ized to ZERO and is followed in the next cell by the class number of this class Thus the parameter field address allows us to uniquely identify the CLASS of COLOR as opposed to some other class Now then let s look at what happens when COLOR is executed We start with the pfa of COLOR on the stack Next we encounter a CREATE That means we are executing a defining word It looks like we ll have to apply rules 1 3 one more time but this time they describe the behavior of COLOR not of CLASS 1 The word CREATE is executed and it gets the next word in the input stream and adds it to the dictionary Thus we expect COLOR to be followed by another word say RED Note the pfa of COLOR is still on the parameter stack 2 The words between the CREATE and the DOES gt are executed and deter mine the compile time behavior of the word COLOR The first thing they do is LINK up the pfa of the member word RED to the pfa of the defining word COLOR Next the Item number is stored and incremented That is all that hap pens at the compile time of COLOR since the next word we see is DOES gt Continued on next page od UNG ZHHL CULUPR GREEN TEXTURE RO
41. No 2 Handling Interrupts in FORTH Stephen Melvin When FORTH is used in a process control application it is often desirable to have a high level FORTH word execute in response to an exter nally generated interrupt This article stemmed from a motor controller pro ject and the desire to use FORTH for everything including the interrupt service routine The implementation shown in Figure 1 was used for the pulse width modulation control of a DC motor An 8253 interval timer was the central element in the system An interrupt occurred every 250 ms and the interrupting word updated the speed and provided feedback informa tion to the main routine through a shared variable FORTH was extreme ly helpful in debugging the system and undoubtedly saved much time Fur thermore all of the software fit in three screens Although an interrupt processing scheme must by definition be hard ware dependent the ideas presented here are very general and can be ap plied to most FORTH systems Theory of Operation In the discussion that follows the definitions below are used HIGH LEVEL DEFINITION A list of addresses of words to be executed Each address actually points to the cfa of the word to be executed Each cfa in turn is a pointer to executable code IP The interpreter pointer Points to an element inside a high level defini tion thus a pointer to a pointer to a pointer to executable code yes three levels of indirection
42. TH Several kinds of recursion are possible in FORTH so long as stack limits are recognized Whether to use recursion at all may be questioned by some it has the distinction of being much more interesting and slower than branching and iteration with conventional control structures To begin two words are needed MYSELF which calls the word as a whole in which it is used and RETURN which is simply RETURN R gt DROP Editor s note The 79 Standard word EXIT has the same func tion RETURN is used in a stoprule which stops and returns execution to the calling level Remember when RETURNing FORTH lets you decide whether to DROP local variables associated with that instance of the procedure The following procedure COUNTUPTO illustrates this COUNTUPTO ievel DUP 0 IF DROP RETURN THEN stopruie DUP 1 _ put 1 param on stack MYSELF level CR LEVEL remove 1 stack param The procedure as a whole destroys the parameter it starts with so MYSELF must behave the same way If there is a risk of exceeding data stack capacity 93 in the FORTH I use an alternative to piling up so many local variables is to have the procedure reverse the parameter change it makes PROCEDURE IN amp OUT decrements by 3 before calling itself and increments by 3 upon RETURNing Also it draws a diagram of its own action 0 VARIABLE LIMIT PROCEDURE IN amp OUT size size 6 DUP LIMIT l
43. To avoid this little inconvenience I propose to have the recursive word push its own PFA on the return stack with a variant of MYSELF called TAILMYSELF TAILMYSELF LATEST PFA COMPILE LITERAL COMPILE gt R IMMEDIATE I show its use here in a division by subtraction opera tion that ACCUMULATES the quotient in a variable of the same name You don t have to tell me that MOD is available to do the same thing at a saving of 30 seconds Note the recursive call is the last word in the procedure 0 VARIABLE QUOTIENT ACCUMULATE divdnd divsr remndr 2DUP lt IF DROP RETURN THEN 1 QUOTIENT 2DUP ROT DROP SWAP TAILMYSELF divdnd divsr remndr 9 stoprute FORTH Dimensions 25 DIVISION dividend divisor 0 QUOTIENT ACCUMULATE CR QUOTIENT IS QUOTIENT REMAINDER IS Returning to depth recursion that RETURNs in order to branch this next procedure draws a branching tree PENDOWN or PENUP determine whether the moving turtle draws or not BI TREE includes two recursive calls one for each side of the V The Y shaped element spans two levels Comparing with IN amp OUT above this procedure returns with the parameter still on the stack for use on the other branch In stepping thru trust that the procedure as a whole is transparent and ignore the MYSELFs In fact the Zen of reading or writing recursive procedur
44. UF SPACE 2 ELSE DUF 2 CLIT IF 2 DUP C SPACE it ELSE DUP 2 IF 2 DUF COUNT TYPE IUP C it ELSE 2 THEN THEN THEN THEN 2 GIN 5 COMPILE ID 2 LIT OR OR OR O CO o Ch Obra te OS O ONO CA GI I Ft KEY DUP 81 p GOESINTO FIND IF DROP O GIN GOESINTO ELSE NOT FOUND THEN 3 pa C HANDLE SPECIAL CASES Robert Dudley Ackerman Editor s Note A FORTH decompiler is a tool that scans through a compiled dictionary entry and tells you what has been compiled In the case of a colon definition it prints the names of the words that are pointed to inside the definition In an ideal programming environment in which you have the source for your system right on your disk you may not need a decompiler But otherwise it beats all the hit and miss ticking and dumping you would have to do Decompilers can also be useful learning tools A very thorough decompiler was writ ten by Ray Duncan of Laboratory Microsystems and published in Doctor Dobbs September 1981 The following decompiler while not as complete as Ray s and not as elegantly written beware of long definitions introduces a clever feature recursive descent In this version pressing the space bar steps you through each name used in a colon defintion but pressing carriage return instead causes the word whose name was just printed to be itself
45. UGH FORTH Dimensions 21 Volume IV No 2 Defining Words I continued from page 21 3 When the word defined by COLOR say RED is executed we push the parameter field address of RED on the stack and execute the code between the DOES gt and the on line 10 It simply increments this pfa by 2 and fetches the contents of that location In Step 2 just above we saw that we stored the item number corresponding to RED in that location Thus the run time behavior of an element of a class is to push its item number on the stack We have succeeded in creating a defining word called CLASS which in turn defines more defining words Look at Block 25 to see how it can be used We use CLASS to define the classes of COLOR and TEXTURE Next we use the word COLOR to define some members of its class such as RED WHITE and BLUE Furthermore we use the word TEXTURE to define some members of its class such as HARD and SOFT Now we want to be able to ask questions like is YELLOW a member of the class COLOR or is WHITE a member of the class TEXTURE To answer this question we define a word called MEMBER on lines 11 thru 13 of Block 24 It expects an item number and a pointer to a CLASS on the stack It returns a flag indicating whether the item number is a member of the class We can get an item number by simply executing the name of an item such as RED or SMOOTH It s a little trickier to get a pointer to a class since w
46. a f 0 ROT BEGIN DUP WHILE F 2DROF DROP 1 1 NULL gt MEMBERS 5 pta BEGIN DUP WHILE 0 ITEN SWAP LINK CLASSE 2 ITEM DUP NFA ID FORTH Dimensions i CLASSE 1 ITEMS 2DUP 2 THEN REPEAT REPEAT input stream and makes a dictionary entry for it The word thus created is called a member word 2 The words between GREATE and DOES gt which specify the compile time behavior of the defining word These execute when the word containing the CREATE and the DOES gt executes 3 The words between DOES gt and which specify the run time behavior of the member words These execute when the word defined by the CREATE DOES gt pair is executed As a bonus before the words between the DOES gt and the are executed the parameter field address pfa of the member word is pushed onto the parameter stack Remember these three facts and apply them whenever you see a defin ing word They completely describe the compile and run time behavior of the FORTH machine If the above aren t clear to you I suggest you reread the defining words article printed in the last issue of FORTH Dimensions and apply the rules to the examples presented We will now apply them to a new example The problem we want to solve is to be able to create classes of items and ask questions about whether an item belongs to a given class or not We would also like to know whether or not two items are the
47. actual mailing the renter never actually gets any list Second the material has to be approved as being appropriate Of course anyone on the list who does not wish to receive such material can make a written request to be excluded from the rental list our data base has this capability built in As for the incident you described Roy Martens does not remember renting any list to a head hunter It s possible that someone could get a list of local members from the local chapter This would depend on the local chapter s policy Editor VAX And Ye Shall Receive Dear FIG We are interested in implementing FORTH on our VAX 11 780 computer I ve noticed that among the FORTH vendors there is no reference to the VAX There is of course the package distributed by John James for the PDP 11 We would be able to run this version in compatibility mode but a version that runs in native mode would have obvious advantages I would appreciate your help in locating such a vendor James H Rapp C 010 Computer Center UCSD La Jolla California Nice Work Chuck Dear FIG I was very impressed with the last issue of FORTH Dimensions especi ally Michael Perry s article on Charles Moore s BASIC compiler It took me quite a while to figure it out but when I did was I ever impressed It s one of the slickest pieces of software I ve ever seen When people ask me What makes FORTH so damn good I ask them what la
48. also produce the appropriate signals to the motor but need the computer to send the driver two signals a step signal that turns the motor one step and a direc tion signal that tells the driver which way to turn the motor One such driver chip is the SAA1027 by AIR PAX North American Phillips and Signetics A FORTH system which communicates with this driver has been described in Stepper Motor Control a FORTH Approach by Mark Bernstein in MICRO The 6502 6809 Journal Software Driver Our approach in this example will be to control the stepper motor lines directly In effect we will build a driver chip in software The only interface between our com puter s output ports and the motor itself will be an inexpensive transistor circuit designed to boost the milliamp of driving power at the port to handle the four amp load required to drive a single motor pole The circuit is called a Darlington Array see Fig 1 Eliminating an integrated circuit driver and taking direct control of the motor has certain advantages For one _ thing of course we eliminate the cost of the chip without making the cir cuitry any more complicated Also we can if needed step the motor in half step increments for finer resolution although we won t provide this capa bility in our example Perhaps the most important advan tage is our ability to control accelera tion or deceleration which the chips do not provide For heav
49. am and exhibitor displays are all ose Ks scheduled at the Red Lion Inn San Jose making it the most conve TOTAL nu nient hotel for attending the convention Name s Telephone Return to FORTH Interest Group P O Box 1105 San Carlos CA 94070 proFORTH COMPILER 8080 8085 Z80 VERSIONS e SUPPORTS DEVELOPMENT FOR DEDICATED APPLICATIONS INTERACTIVELY TEST HEADERLESS CODE IN PLACE COMPILATION OF ROMABLE TARGET CODE MULTIPLE PURGABLE DICTIONARIES FORTH 79 SUPERSET AVAILABLE NOW FOR TEKTRONIX DEVELOPMENT SYSTEMS 2250 MICROPROCESSOR BASED PRODUCT DESIGN SOFTWARE ENGINEERING DESIGN STUDIES COST ANALYSIS ELECTRONICS AND PRINTED CIRCUIT DESIGN PROTOTYPE FABRICATION AND TEST REAL TIME ASSEMBLY LANGUAGE proFORTH MULTITASKING DIVERSIFIED STAFF MICROSYSTEMS INC 213 577 1471 2500 E FOOTHILL BLVD SUITE 102 PASADENA CALIFORNIA 91107 FORTH Dimensions 15 Volume IV No 2 The FORTH Step continued from page 14 tion variables X COUNT Y COUNT X DIR and Y DIR to plug the correct values into X PTR and Y PTR The word XY STEPPER Block 8 defines a DO LOOP that will run as many times as the greater of X COUNT or Y COUNT to step the motors the right number of times Inside the loop X STEP and Y STEP check to see if the x or y count has gone to zero and if so stop the appro priate motor refer back to Fig 2 The final three blocks put it all together to create a word calle
50. ank in the first column Lines with a blank in the first column are ignored This tool works best if a particular style for the layout of a source screen is used The style is simple to remember OUTLINE Screen 155 LOUTLIWE screen non blankK in column i CR CR GUF BLOCK 3 SPACES 0 1 3 4 6 7 8 9 DROP OUTLINE Source screen documentation too Print Screen a I DUP Ce BL NOT ist screen last screen Print and fits well with normal Forth programming The goal is to permit OUTLINE to find the words defined in a screen and selected comments 1 Overall format a Line 0 should be used for a comment only b Line 15 should be left blank c Any line may have text from the first column UP TO the last column The last column of each line should be blank to avoid running into the start of the next line 2 Start each definition in the first column of a new line This applies to colon definitions and all other classes e g CONSTANTs VARIABLEs etc 3 Follow each defined name by a stack comment similar to that of a glossary entry 4 Follow each stack comment by a purpose comment i e WHAT the word does not HOW it does it If the comment is continued to the next line put an open parenthesis in the first column of the second line Although this is not required for FORTH it allows OUTLINE to pick up this comment line The documentation tool is compati
51. ate failure or accident But hardware redundancy is virtually useless unless software design provides consistent support If the address of parallel port A appears explicitly in dozens of lines of program code backup ports B and C will not help the unhappy researcher who finds that port A is not working properly Faced with the task of loca ting every reference to port A s physi cal address users may find it easier to wait for repairs than to use backup equipment which the software cannot easily support FORTH s modular structure helps accommodate necessary repairs with out demanding extensive program changes Last winter our laser s We build programs to run experiments often on the spur of the moment using existing FORTH and assem bly language procedures grounding system started to fail A blizzard made repair impossible and left us with large fast noise spikes everywhere Normally we invoke 7FIRED to detect laser pulses FIRED gt f FIRED waits for the laser to fire and returns a logical flag to indicate whether the laser fired successfully or failed Laser firing is detected by the photodiode interface bit Because of the grounding problem FIRED started to respond to noise spikes as well as to valid laser shots Since the offending noise pulses were very short we thought the com puter might be able to adapt to the noise by ignoring anamolously short trigger signals A 500 microsecond
52. ble with the following dialects except as noted below 79 STANDARD Starting FORTH fig FORTH and polyFORTH The implementation assumes 1024 byte disk buffers and 64 byte lines for screens On a single user FORTH system TYPE may be used instead of gt TYPE On a multi user system gt TYPE is needed to avoid conflicts between shared disk buffers and interrupt controlled Input Output opera tions gt TYPE copies its string to PAD before typing it WEFZ25 2ArPra2 KRH line O amp lines with 1024 0 DO OR IF ELSE THEN 64 LOOF DUR I Q TRAILING TYPE CR DROP line O amp lines with non blank in column 1 for range of screens 1 SWAP pO I LOUTLINE LOOP Above is the source for this documentation tool Saying 155 10UTLINE produces the listing below Screen 155 LOUTLINE screen non blank ir column 1 OUTLINE Source screen documentation tool Print 1ist screen hast screen Print WF25 2AePr82 KRH line O amp lines with line O amp lines with non blank in column 1 for ranse of screens FORTH Dimensions Volume IV No 2 The Art of Recursion graphics where lines are drawn as though they were tracks left on the screen by a cursor called the turtle The com Bob Gotsch Inspired by the interesting Roundtable on Recursion in Vol III No 6 FORTH Dimensions I would like to offer some models for recursive style in FOR
53. cent report of the Association of Electronic Industry the popularity of various languages in Japan for application software devel opment is changing as follows Ever experienced Wish to use or using in future work Assembler 41 7 2 0 BASIC 23 1 6 5 PL M 18 6 14 1 FORTRAN 10 1 6 5 G 1 5 21 6 COBOL 1 0 FORTH 1 0 10 6 PASCAL 0 5 32 2 ADA 5 0 The figure for FORTH seems surpris ing considering the lack of integrate publication about this language in Japan Toshio Inoue Professor of Mineral Processing University of Tokyo China News Dear FIG It has been almost six months since I last reported on our FORTH discus sion group at Taipei It is alive and well We are now meeting at the EE Department in the National Taiwan University every fourth Saturday from 2 to 5 p m Participants vary from 20 to 50 An encouraging sign of the strength of this group is that people are bringing programs to be distri buted in the meetings I am also teaching a course on FORTH to the EE seniors in the EE Department of Chung Yuan Christian University Its head Dr Lo imple mented a ROMmable FORTH on his ZDS system which was used to develop an intensive care unit for local hospitals It was a success I just learned At this moment we have about 10 FORTH programmers at the profes sional level and about 100 enthusiasts FORTH literatures have been spread to more than 1 000 people About 20 FIG FORTH systems are in regu
54. d GOTO XY which uses the current position and the desired position to calculate the appropriate number of steps to move for each motor then calls XY STEPPER For example GOTO XY could be given the coor dinates for the position of a hole to be drilled in the circuit board The step per software will do all the rest Martin Petri is a consultant specializ ing in application software hardware design manufacturing and marketing His most recent product is the Con trolex CS 105 which he deomonstrated at the June 26 1982 fig FORTH meeting in Palo Alto Leo Brodie is Editor of FORTH Dimensions D THE FORTH CAVALRY IS HERE personalFORTH for the IBM PC by FORTH Inc Multi tasking full screen editor floating point support DOS file handler color monitor support turnkey compiler Screen 9 Oo The FORTH Step 8 of 10 OZJUNG2MEP 300 i 2 2X STEPS X pos 3 X POSITION get old count 4 new pos old pos gt ke DUP amp oO lt see if negative number MULTI TASKING 7 IF MINUS get compliment 8 X COUNT set the count FORTH 9 O X DIR set direction reverse 8 CP M Northstar amp Micropolis A FORTH by Shaw Labs Ltd can make your micro operate like a mainframe You can be printing sorting and inter actively inputing data all at the same time Hardware permitting you can even have multi users operating 395 ELSE X COUNT set the count 1 X DIR
55. d 6 5 tax C FORTH 79 STANDARD specify system 150 Foreign air shipments add 15 O Manual alone credit toward program purchase 25 O Send more information TRANSLATOR This program provides a one to O Master Charge O Visa Account Number Exp Date Name Indicate disk format O 8 ss sd fig FORTH screens Company e aaa O 8 ss sd CP M 2 2 file O Apple 3 3 Street a O PC FORTH Ciy_ State pC i SS the Send to Curry Associates e PO Box 11324 e Palo Alto CA 94306 e 415 322 1463 or 408 378 2811 a E EE E eee a a I Sree een eT FORTH Dimensions 27 Volume IV No 2 A Recursive Decompiler SCR 54 O GOES INTO vas GOES INTO gt MYSELF LATEST PFA CFA REGULAR FIG PFA amp LFA VARIABLE GIN TO INDENT GIN CR GIN 2 DUP GIN SPACES 5 DIN CR CIN SPACES 35 IMMEDIATE C PFA CFA t GOESINTO gt DUP CFA lt amp OVER ERROR O AND IF COLON DEF amp NOT ERROR BEGIN DUP DUP 5S CFA OVER CODE CFA OR O WHILE HIGH LEVEL amp NOT END OF COLON DEFINITION 2 DUP GIN NFA IB IF Q SP QUIT ELSE 13 RETURN IF GO DOWN ONE LEVEL MYSELF ELSE DROP THEN THEN GCHK REPEAT SHOW LAST WORD gt 2 DIN NFA ID THEN DROP 5 GCHK TUP 2 IF 2 DUF 2 NFA ELSE DUP 2 DUP OVER BRANCH OVER OBRANCH OVER LOOF SWAF LOOP OR IF 2 D
56. d from reading Brodie I haven t figured this out yet but I will eventually hopefully e In the installation manual the user variables IN and HLD are not identified with the U identifying them as such In general User variables are not well enough described When do they get changed Under what conditions The variable CURRENT is not des cribed It s a user variable e The parameters C L characters per line 64 B BUF bytes per disk sector and B SCR buffers per screen 8 are not defined anywhere that I could see The assembler code defines them however On another subject I plan to build some FORTH words which allow you access to CP M 86 files as an alter native to the use of FORTH screens and no directories If you know of anyone already doing this work or if you are interested in adding it to your repetoire of products please let me know Derek Vair Weston Ontario The situation you re describing is both real and unfortunate The FIG model was created in 1978 and generously placed in the public domain by its implementors to spread the popularity of the language The model was not however the only version of FORTH around and the 79 Standard was later adopted to resolve the many differences between these versions Starting FORTH was written more in accordance with the 79 Standard than with the FIG model The book took some exceptions to the 79 Stan dard and
57. e that this version is better as FLUSH can be defined as FLUSH FL EMPTY BUFFERS but FL cannot be made out of FLUSH Naturally this definition is valid only for Fig model FORTHs FL FIRST LIMIT FIRST B BUF 4 0D0 DUP 0 lt IF DUP 32767 AND OVER DUP 2 OVER 0 R W THEN B BUF 4 LOOP DROP All true The current FLUSH combines two logically distinct functions writing changed buffers to disk and marking the buffers as empty The second func tion sometimes called a mount com mand allows you to change disks after a FLUSH Michael Perry Volume IV No 2 RANDOM BUGS Donald P Madson Minneapolis MN While using the random number generator that has appeared in FORTH Dimensions III 5 pg 152 I noticed a problem If the seed is 3954 the scaling ratio becomes one and the result is equal to the range instead of the range 1 Depending on the pro gram this could cause anything from minor irritations to program self destruction Thanks Don I d like to point out that a different high level random number generator appears on p 265 of Starting FORTH The code for this version was provided by Dean Sanderson of FORTH Inc and I doubt if there are any problems with it Editor 6800 CONTEMPLATIONS Ronald Zech West Germany Now that I ve worked with FORTH about two years I would like to share some observations regarding the FORTH kernel and especially the 8080 and 6800 lis
58. efined at the keyboard or in scratch screens Pulse gated generator integrator photodiode trigger shaper energy meters computer toolbox delay stage motor contro Figure 1 This block diagram represents a typical configuration for our computer toolbox Note the relative complexity of the computer node toolbox design encourages the computer to get involved with many aspects of the experiment The detailed configuration tends to change every few weeks as instruments and experimental needs change Continued on page 7 FORTH Dimensions Volume IV No 2 Computer Toolbox continued from page 5 s EAS gt power 100 0 DO POWER 100 LOOP Listing 2 AVERAGE POWER measures the mean laser power measured by a device driver called POWER by averaging 100 shots Loops like this take only a few seconds to write and can provide answers to many unanticipated questions work areas for writing temporary tools Particularly useful sequences can be stored permanently to be called up whenever needed Disk resi dence is ideal for plotting procedures data reformatters and analysis pro grams that are used intermittently and are not especially useful in building new tools FORTH s compactness also allows us to retain a variety of tool components in memory at all times so that device drivers and tool building aids are always online and available In fifteen months of ac
59. eloped by an independent software supplier to run on HP computer systems tis eligible for HP PLUS as determined by references from satisfied end users Support services are available only through the software supplier Hewlett Packara s responsibilities are described in the Responsibilities Statement below Responsibilities Statement HP PLUS software was developed by an independent software supplier for operation on HP computer systems The supplier is solely responsible for its software and support services HP is not the manufacturer or developer of such software or support HP disclaims any and all liabilities for and makes no warranties expressed or implied with respect to this software Distribution of this product or information concerning this product does not constitute endorsement of the product the supplier or support services The customer is responsible for selection of the software it purchases For more information please write Marvel Ross Hewlett Packard Company 3404 East Harmony Road Ft Collins CO 80525 FORTH Dimensions Volume IV No 2 FORTH in the Computer Toolbox Mark Bernstein Department of Chemistry Harvard University A prominent but misguided goal of lab computer design has become the program free instrument one that can plug into an experiment and collect data without explicit program ming To retain some degree of flex ibility a limited programmability is achieved throu
60. epper motors OUTP 7 PORT i Our approach will be heya to control the stepper motor lines directly In effect we will build a Suni aaga 085 driver chip in software Be ae SI O 42 Holid Torque gain Nn SHAFT RolaTiow can be controlled with exacting resolu mole Le i i CONTROLEX ERYITELE STEPPER Tam ol CE tion on some motors the resolution is 005 degrees of rotation or less Their speed is also directly con trollable and stepper motors can stop on a dime or a micrometer Operation Most stepper motors are controlled by either four or eight lines In our exam ple we ll assume a four pole motor A Figure 2 step is a one quarter revolution of the internal shaft of the motor the smallest amount we can cause the motor to turn Each step corresponds to a certain combination of the motor s four input poles being turned on Most stepper motors including the 400 400 o e 400 900 one in our example contain a gear e 400 900 mechanism The motor in our exam ple is geared such that one complete cycle produces 7 2 degrees of rotation 100 100 Interfacing Techniques 109190 Oven There are several ways to control the stepper motor One is to buy a stepper motor driver IC The most advanced of these driver chips allows the com Producing a direct diagonal Fig 2a between the two points above requires puter to simply output the desired the Y motor to run a sub optima
61. es FP FORTH PROGRAMMING AIDS is a software the word to disk editing and recompiling package containing high level FORTH routines l l which allow the FORTH programmer to write Build on previous work by transferring more efficient programs more quickly and they debugged FORTH routines including _ are especially useful for those who are using constants and variables from one appli a metacompiler or cross compiler cation to another FORTH PROGRAMMING AIDS allow the pro e Speed program loops by finding all words grammer to called from the loop for possible merging e Minimize memory requirements for target or recoding to assembler systems by finding only those words used in the target application e Patch changes into compiled words in seconds e Tailor existing words including nucleus words to specific needs by decompiling FORTH PROGRAMMING AIDS comes with complete source code and a 40 page manual FPA contains the following modules DECOMPILER This is a true decompiler which a ee converts the FORTH words in RAM into compilable OOO BEGIN FIND structured FORTH source code including program IF STATE lt control words such as IF ELSE THEN BEGIN etc IF CFA If you ask FPA to DECOMPILE the nucleus word Seere eae A INTERPRET you get the following output displayed ELSE HERE NUMBER DPL 1 on your terminal within 3 seconds IF CCOMFILEJ DLITERAL ELSE DROP CCOMPILE LITERAL THEN STACK THEN AGAIN 3 You may DE
62. es is to be NOT distracted to other levels by the MYSELF Just be in this instance 0 VARIABLE LEVEL BI TREE size size LEVEL 1 lt IF RETURN THEN stoprule PENDOWN DUP FORWARD 1 LEVEL 45 LEFT DUP 6 9 RANGERAND 11 branchsiz MYSELF size size 90 RIGHT MYSELF size size DROP branchsiz 45 LEFT 1 LEVEL PENUP DUP BACKWARD SETUP BI TREE size Jevel 2 ENUF LEVEL GRAPHINIT FULLSCREEN PENUP 95 BACKWARD SBI TREE DROP Continued on next page Volume IV No 2 a a SS SSS The Art of Recursion continued from page 25 In one last example that parallels the first parameters are piled on the stack to be used for drawing on the way back up the levels after the stoprule has been encountered The pattern was drawn with starting size of 180 so it s somewhat possible to see why there are six sizes of triangles Excuse the mixing of iteration and recursion It just seemed more readable that way HALVE 2 TIMES 0 PROC NESTED TRI size DUP 5 lt _ iF DROP RETURN THEN stoprule 3 TIMES DO DUP HALVE MYSELF size DUP FORWARD 120 RIGHT LOOP DROP Bob Gotsch is a graphics programmer for Time Arts Inc and a teacher of graphic arts at California College of Arts and Crafts He s interested in exploring the use of computers as aids to artists oO OmniFORTH is a high level computer language and operating
63. ext and the previous ele ment For extra credit figure out how to create a double linked list using only a single cell for the pointer Now then let s continue on with our CLASS example We will apply our three rules to the definition of CLASS 1 We see a CREATE so we know that CLASS is a defining word Thus when CLASS is used we expect it to be followed by a yet undefined word which it will define such as COLOR COLOR would be called a member word of the defining word CLASS 2 When CLASS is executed the words between CREATE and DOES gt are execu ted determining the compile time behavior of the word GLASS They do the following First the ZERO is ex ecuted which initializes the linked list to empty Next the class number is stored and incremented That is all that happens at compile time 15000 LINK CR contents 0 10000 17000 12000 Location 15000 Location 17000 12000 2777 12000 2277 12000 2277 12000 22727 12000 12000 12000 12000 17000 12000 3 When the word defined by CLASS such as COLOR is executed the para meter field address of COLOR is pushed onto the parameter stack and then the words between the DOES gt on line 8 and the on line 10 are executed Question What is the significance of the parameter field address of COLOR Answer It contains the pointer to the head of the item list which was initial JE 3 3 flafine come classes 1 CLASS CHLOR COLOR FEB COLOR WHITE DA
64. gh some form of menu selection using either conventional menu trees or special purpose dedi cated keyboards to select the actions which may be performed In practice keystroke function selection is completely equivalent to programming in a small very high level language Indeed in some com mercial systems the computer trans lates each key stroke into a FORTH word for immediate execution To comfort timid users the control language is made to be very simple and very rigid Despite its superficial appeal this approach ignores the real needs and abilities of scientific users Research is unpredictable indeed often chaotic Scientists need flexibility even at the cost of complexity since the labora tory environment changes constantly as new results demand new methods and techniques Lab computers ought to promote creative research Too often though rigid pre programmed instruments actively inhibit creativity freezing experimental procedures into a fixed unchangeable mold Rather than attempt to provide a program free facility we have tried to build a computer toolbox for our laser spectroscopy work The toolbox concept embraces hardware and software design with the goal of providing a powerful and flexible array of tools to knowledgeable capable users We don t avoid programming On the contrary we make program writ WIGGLE MOVE 1 MM FORWARD MOVE 1 MM BACK BEEP Listing
65. h processing fast hi res graphics and text turtle graphics print formating two text editors unlimited data types and incredible FORTH extensibility all at speeds up to 100 times faster than Basic USER FRIENDLY EASY TO LEARN Starting with simple commands that are comfortable even for non programmers MicroSPEED extends and builds allowing you to create your own tailored application languages The capability of your computer will grow exponentially as you work in an active part nership with the machine exploring and develop ing new problem solving facilities creating cor recting refining your increasingly powerful system DEMANDING JOBS AT LOW COST Developed by a team of standout computer professionals MicroSPEED has been put to the test in fields as diverse as medicine the stock market oceanography and the arts In even the most challenging appli cations MicroSPEED users have been unanimous in their praise of the System and manual Typical comments are Very bigh marks Thomas Tosch Ph D Tosch Information Management The more I use MicroSPEED the more I love it Prof James L Hockenhull University of Washington Great A joy to use Henry Harris Mission Designer Cal Tech s Jet Propulsion Lab If you plan to use the Apple or IBM Personal Computer for any demanding task then we built MicroSPEED for you Sam Cottrell President of Applied Analytics MicroSPEED requires
66. he misconception that some FORTH implementations do not initialize the constant with a value from the stack when defined The chapter on control structures never explicitly states that LOOP adds one to the increment UNTIL is described backwards with loops continuing while true Booleans are described as further mathematical possibilities The chapter con cludes with a half page discussion of the virtues of having a CASE state ment while never mentioning the word LEAVE A later chapter states that the variable BLK contains the number of the last block accessed Discover FORTH concludes with six appendices a coding sheet a 79 Standard glossary a table of ASCII characters suggested alter natives to the FORTH system typical error messages and some FORTH extensions Because the 79 Standard glossary has been rewritten incorrectly in places that appendix must be ignored If all of these errors and misconceptions were corrected this book could be a good introduction to FORTH In its current condition it cannot be recommended In the meantime Starting FORTH is a much better alternative FORTH Dimensions Course Review Laxen amp Harris By Brian Donovan Editor s note The reviewer attended a general FORTH course taught by Laxen amp Harris in February 1982 This course is fantastic I went from code I couldn t read myself to imple menting multitasking in two days Kim Harris and Henry Laxen are t
67. he vocabulary for the instruction book STARTING FORTH by Brodie editor assembler many useful routines and utilities MVP FORTH PRODUCTS O MVP FORTH Programmer s Kit including disk with documentation ALL ABOUT FORTH and STARTING FORTH Assembly source listing versions 100 O MVP FORTH Disk with documentation Assembly source listing version 75 O MVP FORTH Cross Compiler with MVP FORTH source in FORTH 300 C MVP FORTH Programming Aids for decompiling callfinding and transiating 150 O MVP FORTH Assembly Source Printed listing 20 1 ALL ABOUT FORTH by Haydon 20 ORDER TODAY x MVP FORTH operates under a variety of CPU s computers and operating systems Specify your computer and operating system x x FORTH MANUALS GUIDES amp DOCUMENTS O FORTH Encyclopedia b O Starting FORTH by Derick amp i poca Dy Brodie Best instructional plete programmer s manual available soft MORE FORTH DISKS fig FORTH Model and Source with printed Installation Manual and Source Listing O APPLE Il 51 8080 Z80 C 8086 88 8 ee H89 Z89 ae manual to fig FORTH with cover 16 i FORTH 79 references O Starting FORTH hard re Flow charted cover FORTH with editor assembler and manual Source provided O 1980 FORML Proc 25 O METAFORTH by Cassady Specify disk size O 1981 FORML Proc Cross compiler with 8080 OU APPLE MII by U PET by FSS 90 2 Vol 40 code 30 MicroMotion 100 TRS 80 1 by Nautilus O 198
68. hen we execute a class name we define a new word and we don t get a pointer We solve this problem by using tick to get a pointer to a class Thus to determine if YELLOW is a member of COLOR we would have to type YELLOW COLOR MEMBER CR MEMBER is defined to run through the linked list and see if the item numbers match If they do it returns true otherwise it returns false Notice the use of the NULL variable to ter minate the search in the event of a match The search continues until the zero link is found however if we get a match we want to terminate imme diately We arrange this by throwing away the pointer we have been chas ing and replacing it with a pointer to a zero which is exactly what NULL provides Finally on lines 14 15 of Block 24 we define the word MEMBERS which lists all of the members of a particular class It too expects a pointer to a class on the stack which must be provided by Next time we ll finish up our series on defining words by generalizing the concept of CLASS to an arbitrary number of levels and by combining it with recursion to create n way trees and other linked structures Stay tuned to this station for all the details That s all for now good luck and may the FORTH be with you Henry Laxen is part of Laxen amp Harris Inc a FORTH teaching and consulting company based in Hayward California o 50 saves debugging them only The first disk is
69. ier loads the stepper motor must be accelerated gradually if it is to supply the neces sary torque to get the load moving Also the motor can run at higher speeds Trying to start a motor at too great a speed can cause it to stall Our example will use an acceleration technique The Example Our example controls two separate stepper motors Together they control the x and y coordinates of some posi Continued on next page Volume IV No 2 A The FORTH Step continued from page 13 Screen 5 The FORTH Step 4 af 19 C2JIUNG2MBP 1 z XY RUN 3 ACCELERATOR want to ramp up the speed gt 4 Y PTR PHASES y addr 5 X PTR PHASES y addr x addr 6 40 4 phases 1 full step 7 DO 8 2DUP I SWAP I get x y offsets 9 XY MOTORS x addr y addr 10 LOOP ii 2DROP or DROP DROP if you don t have it 4 12 13 XY RUN calculates the table address then calls XY MOTOR 14 15 S Screen amp O The FORTH Step Sof 10 OZJUNB2MBP gt i 2 X STEP 3 X COUNT 4 IF 1 X COUNT X DIR 3 5 IF 0 X PTR 1 X POSITION amp ELSE 4 X PTR 1 X POSITION 7 ENDIF 8 ELSE 8 X PTR 9 ENDIF 10 11 X STEP sets the forward or reverse bit pointer if there is 12 more steps to do and adjusts the position variable else 13 it sets the stop pointer 14 3 S iS Screen 7 O The FORTH Step amp of 10 OZJUNS2MBP gt 1 23 Y STEP
70. ies in the final document Perhaps the future standardization efforts should be split into separate functions somewhat like that of the COBOL or MUMPS standardization committees At the lowest level a language development committee meets regularly to make changes to the language Their output is published as a journal for consideration and testing by implementers and users A separate Standards committee generates an actual Proposed Standard document on the time scale of five years They freeze the output of the language development committee who con tinue to work independently After a suitable voting process this document becomes the new Standard Thus the community of users has an adequate chance to make their views known Additional steps in the process involve approval by an ANSI committee then perhaps other governmental or quasi governmental committees Vocabularies The area of greatest concern for the next Standard is that of vocabularies FORTH 79 has a very weak vocabu lary structure It was chosen as the minimum subset of most FORTH implementations The only weaker structure is the complete lack of vocabularies in older versions of FORTH such as DECUS or OVRO Cal Tech FORTH In FORTH 79 the search order at a given time is through two vocabularies the one specified by CONTEXT and then the FORTH vocabulary Some other FORTH systems like fig FORTH have vocab ularies linked together in a tree struc ture dete
71. in the 6800 definition Here it is defined in high level by saving 4 four bytes but missing a conditional branch and its literal Including this missing link lead to a completely exact perfor mance of the signed divide But this latter bug leads to a more fundamental question regarding the high level low level balance especially regarding the 6800 version but with not as great extent also regarding 8080 of FORTH Especially the 6800 version seems to show the attempt of a rigorous byte saving In the special case of the bug above the byte saving compared to an appropriate primative definition disappeared completely after debugging the 6800 high level definition Compare with the defini tion below which I m using for myself instead count S gt D 80 2 TSX LDAB 255 LDAA 0 X BM STOD1 INCB STOD1 TBA JMP PUSHBA Look also at the word TOGGLE in the 6800 listing I have found this word worthwhile not only as a system word but in aplications Therefore its time penalty as a high level word for only toggling a single byte with a pattern is not at all acceptable I ll close the 6800 Fig FORTH con templations with a little remark regarding the loop run time proce dure following label XLOOP in that listing you will find the instruction BRA XPLOP2 which can become replaced by BRA XPLOF resulting STOD 31 in a little speed up of looping and branching with no memory space penalty
72. lar use FORTH is still far from being a household name here but it is known to most micro hobbyists Dr C H Ting Taipai Taiwan 6809 Gift Dear FIG I am herewith releasing my copyright on the 6809 fig FORTH source code listing and placing it in the public domain to be distributed by the FORTH INTEREST GROUP You are hereby authorized to alter the listing to give the standard FIG nota tion that the listing may be copied pro vided that due credit always be given the source Raymond J Talbot Jr Talbot Microsystems Redondo Beach CA Hunting Figheads Dear FIG Enclosed is my check for member ship renewal I would like to compli ment you on the quality and economy of your work and publications I have been contacted by a local head hunter employment agency who mentioned that he got my name and telephone listing from a FIG membership list I do not know whether it was a local or global list I feel neutral about such a practice presently provided the head hunter does not persist in an obnoxious man ner after being told to cease and desist If other FIG members have had similar experiences and found them objec tionable some guiding policy on dis tributing member lists to head hunters vs to vendors should be discussed Larry Pfeffer San Diego California Here is FIG s policy on the utilization of our mailing list The list is available for rent but with two conditions first FIG itself will do the
73. ls of the motor directly we need to supply the proper sequence of pulses The table in Fig 1 shows the four step cycle of pulse patterns that will turn the motor one complete revolution 7 2 degrees After the fourth pattern is output the first pattern is sent again and the cycle repeats These bit patterns are stored as bytes in a table called PHASES Block 4 of the listing The bit sequence in the first four bytes produces one forward going cycle of the X motor The next four bytes contain the same sequence in reverse The final phase of both sequences is hex 6 which is phase 1 so that the motor will always stop at phase 1 The next four bytes in the table PHASES each contain the phase 1 pat tern Cycling through these four bytes will cause the motor to stay at its stop ping position The second half of the table contains the same bit patterns but stored in the high order nibble of the byte where they will be output to the Y motor The four byte sequence is cycled through by the 40 DO LOOP in Block 5 The appropriate sequence in the table is selected by the values in variables X PTR 0 for forward 4 for reverse and 8 for stop and in Y PTR 12 for forward 16 for reverse and 20 for stop These two variables are set up by the words X STEP and Y STEP respectively Blocks 6 and 7 These words refer to the count and direc Continued on page 16 nm eee eu Sar SSeS PP Pies lh SPP SSS SS y
74. many of these exceptions are being incorporated into the 83 Standard Starting FORTH was generously financed by FORTH Inc again with the goal to spread the popularity of the language The problem is neither with fig FORTH nor its documentation nor with Starting FORTH but simply with the fact that they were created at different times Many vendors are now selling versions of FORTH compatible with the 79 Standard Mountain View Press has even placed such an imple mentation in the public domain and Glen Haydon has published a book All About FORTH which describes this implementation carefully noting differences between it and other com mon versions For those who will continue to use the FIG model perhaps there is some other generous volunteer who will write and publish additional documentation to integrate the discrepancies Editor o Volume iV No 2 Now Available On HEWLETT PACKARD DESKTOP COMPUTERS HP 9826 36 Multi FORTH HARDWARE _ The HP 9826A and 9836A are two of Hewlett Packard s newest and most powerful desktop computers Each is based on the Motorola MC68000 microprocessor Both machines have full graphics capability and up to 2 full megabytes of user read write memory Both operate on 544 flexible disc drives the 9836A has two which feature 264K bytes of mass storage While the 9826A has an integral 7 178mm CRT which makes it useful for computer aided testing CAT and c
75. mitting implementors to overcome some annoying limitations of the fig and 79 STANDARD systems By relaxing the CPU s workload such enhancements will also help simplify laboratory programming since fewer FORTH Dimensions and fewer tasks will require critical programming to meet their timing restraints These developments hold great pro mise for lab computer design Greater CPU throughput will permit lab sys tems to dispense with some FORTH atavisms notably the strict reverse Polish grammar necessitated by FORTH s primitive parser and the absence of data typing and run time security features now omitted in the interest of increasing CPU throughput On the other hand greater CPU power could also be harnessed to the conven tional FORTH model permitting faster data acquisition But of greater importance the next five years should bring a general recognition of the im portance of true programmability to creative experimental work accom panied by further understanding of the role of software tools in small systems Acknowlegements The author expresses his sincere appreciation to Dr Kevin S Peters for continued support of this research 1 For example the Princeton Applied Research OMA controller a popular and suc cessful instrument operates in FORTH A number of functions have 1 letter names and so can be invoked by pressing a single key 2 M Bernstein The Computer Toolbox BYTE May 1982 p 456
76. n Unless the designer gets everything exactly right users will need simple features which the machine could obviously manage but which it cannot be told to do Menu and prompt driven systems are useful indeed invaluable in per forming and regulating repetitive and well defined tasks Both help protect system integrity But while a payroll program needs good protection from casual users or systematic abuse lab computers really ought not to protect themselves from their users at least not without good reason A decent command language is not difficult to learn Once learned it should not be difficult to use FORTH and its kin make command language interpreters very simple to write since such interpreters simply subset the language The payoff is substantial far from being a write only language as is sometimes claimed in control appli cations FORTH can be substantially more straightforward than BASIC or FORTRAN implementation The second generation microproces sors the 6502 8080 Z 80 and 6800 machines are frequently CPU bound in common lab operations Implemen tation efficiency is essential and FORTH s simple lexical analysis vestigial parser and threaded archi tecture match the limited computa tional power of these machines quite well E In the coming three to five years newer and more powerful machines should relax the CPU constraints under which lab computers now labor per
77. n produce ROMable code 79 Standard FORTH Price 450 FORTH Advanced FORTH Advanced FORTH Fundamentals Applications Systems e Program Design e FORTH Tools e FORTH Internals e Program Documentation e Engineering Applications e Assemblers and Editors e FORTH Architecture e Floating Point e Other Compilers e FORTH Arithmetic e Communications e Cross Compilation Theory e Control Structures e Sorting amp Searching e Romability Multitasking e Input Output e Project Accounting System Timesharing e The Vocabulary Mechanism e Process Control e File Systems e Meta Defining Words e Simulations Database Systems OCT 4 8 NOV 8 12 NOV 15 19 OCT 11 15 JAN 3 7 FEB 7 11 FEB 14 18 JAN 10 14 395 Incl Text 495 Incl Text 495 Incl Text Instructors LEO BRODIE GARY FEIERBACH and PAUL THOMAS For further information please send for our complete FORTH Workshop Catalog Inner Access Corporation P O BOX 888 BELMONT CALIFORNIA 94002 415 591 8295 FORTH Dimensions 9 Volume IV No 2 MVP FORTH A Public Domain Product in keeping with the public domain release of FORTH by its inventor Charles Moore and the promotion of the language by the FORTH Interest Group MVP FORTH for Mountain View Press and the companion book ALL ABOUT FORTH are also placed in the public domain and may be used freely without restriction MVP FORTH contains a kernal for transportability the FORTH 79 Standard Required Word Set t
78. n the vocabulary stack Otherwise the stack would be truncated back to its first appearance on the stack There are other designs for vocab ulary mechanisms Almost any of them would be an improvement over FORTH 79 In my opinion it is impor tant that the next Standard have a significant improvement in vocabu lary structures If you have any strong opinions on this matter please com municate them in writing to the FORTH Standards Team FORTH Standards Team Upcoming Working Meeting A working session in the develop ment of the FORTH language 1983 standard FORTH 83 has been scheduled this October 3rd through 5th in Carmel Valley California Space will be limited with priority for existing standards team members Accommodations will cost US 150 based on double occupancy including meals Room reserva tions require a deposit of US 50 and should be received by July 31 This working session will attempt to resolve the FORTH 83 Standard working draft in anticipation of an accepted standard near the begin ning of 1983 This working draft will be available for US 15 beginning August 1 Comments on this work ing draft are encouraged Stan dards team sponsors additionally receive all mailings to team members prior to the October meeting including copies of sub mitted proposals and comments Standards team sponsorship is available for US 50 Please send orders deposits or inquiries directly to the FORTH Standards Team P O
79. n the system on the other hand R W may view the disk very differently here R W addresses three distinct abstract devices The abstract devices in turn access the disk drive indirectly through device drivers thus shielding R W and BLOCK from future hardward changes FORTH Dimensions 8 Volume IV No 2 DEVELOPMENT TOOLS No downloading No trial PROM burning This port addressed RAM on your S 100 host is the ROM of your target system Develop FORTH code for any target 8080 Z80 system on your current 8080 Z80 or Cromemco CDOS based system WORD BYTE WIDE ROM SIMULATOR Simulates 16K bytes of memory 8K bytes for 2708 and 2758 Simulates 2708 2758 2516 2716 2532 2732 2564 and 2764 PROMS The simulated memory may be either byte or 16 bit word organized No S 100 memory is needed to hold ROM data Driver program verifies simulated PROM contents Price 495 each CONSULTING SERVICES Inner Access provides you with Custom Software Design We have supplied many clients with both Systems and Application Software tailored to their specific needs Contact us for your special programming requirements FORTH WORKSHOPS ONE WEEK WORKSHOPS ENROLLMENT LIMITED TO 8 STUDENTS 8080 Z80 METAFORTH CROSS COMPILER Produces code that may be downloaded to any Z80 or 8080 processor includes 8080 and Z80 assemblers Can produce code without headers and link words for up to 30 space savings Ca
80. nd and 79 Standard Vendor package available for 450 00 Perkel Software Systems 1636 N Sherman Springfield MO 65803 417 862 9830 FORTH LANGUAGE CARD FOR APPLE Il Plug this Language Card into Slot 0 and run FORTH without a disk drive Minimum 16K required however it prefers 48K of RAM because you will then have a 24K byte pseudo disk The entire pseudo disk can be dumped back to cassette for storage This Card is com patible with the Apple Integer BASIC Card with the 8K FORTH dictionary replacing the Integer BASIC Implemented by Dr C H Ting Price is 100 00 OFFETE Enterprises 1306 S B Street San Mateo CA 94402 DUAL TASKING FORTH Dual Tasking FORTH by Timin Engineering is the first microcomputer language to per mit simultaneous execution of two programs No interrupts or real time clocks are required although they may be used if desired Less than 10 of processor time is devoted to the Dual Tasking function Two demonstration programs are included Requires Z 80 hardware systems with at least 32K RAM and any verison of CP M or CDOS 285 Timin Engineering Company 6044 Erlanger St San Diego CA 92122 e 714 455 9008 Editor s Note This product is not the first microcomputer language to permit simultaneous execution of two programs Several FORTH vendors offer multi tasking systems fig FORTH FOR INTERACT HOME COMPUTER Modified for use with cassette Auto adjusts to use 16K 32K or 48K Includes F
81. nguages have they work ed with that you can write a BASIC compiler in just 8 screens Keep up the good work Marc Perkel Springfield Missouri Letters continued on next page FORTH Dimensions Published by FORTH Interest Group Volume IV No 2 July August 1982 Editorial Production Leo Brodie Publisher Roy C Martens FORTH Dimensions solicits editorial material comments and letters No responsibility is assumed for accuracy of material submitted Unless noted otherwise material published by the FORTH interest Group is in the public domain Such material may be reproduced with credit given to the author and the FORTH Interest Group Subscription to FORTH Dimensions is free with membership in the FORTH Interest Group at 15 00 per year 27 00 foreign air For membership change of address and or to submit material the address is FORTH interest Group P O Box 1105 San Carlos CA 94070 FORTH Dimensions Volume IV No 2 Letters continued Minor Errors Dear FIG I have a few notes on F D III 6 In regard to J T Currie Jr s letter good FORTH code looking neat improves readability and brings out structure Since my own code doesn t always live up to this standard I best not be too preachy keen In Henry Laxen s article the stack diagram for ASSIGN should read pfa I am completely confused by Marc Perkel s article on control structures Where are BRANCH and OBRANCH
82. not for profit corporation to support and promote a Forth and its applications e Programs im ie lt The Institute will sponsor Forth related conferences such as the 1981 and 1982 conferences at the lt University of Rochester Other institutions using Forth may conser hosting conferences or seminars with EE z administrative backing from the Institute We will address specific topics in Forth through seminars i O workshops and lectures like those held this past May in Rochester au We are starting a program of summer student fellowships at universities working with Forth in which the projects will be chosen so as to further a student s expertise in Forth while doing work of interest to the internships within companies applying Forth Combination academic industrial internships are also possible and would facilitate the transfer of new techniques between the academic and industrial sectors We welcome suggestions for this program as well as inquiries from companies and institutions interested in sponsoring students Finally we are establishing a library or archive of Forth related materials to serve as a resource for the community 1 Publications BE A We plan to publish a refereed professional journal whose primary subjects will be Forth based tools and their applications in industry and research Referees are being chosen based on their experience and ne interest from universities research laboratories
83. ons change to except in line 5 change the phrase COMPILE to Change to EXIT Stephen Melvin is a graduating senior in Electrical Engineering at the Univer sity of California at Berkeley oO Figure 2 1 LOAD OK STAR 12 EMIT OK STARS 10 0 DO STAR LOOP OK PUT STAR OK TEST OK PUT STARS OK PUT CR OK TEST OK Volume iV No 2 FORTH Standards Corner Towards a New Standard Robert L Smith The Standardization Effort The FORTH Standards Team met in May at the National 4 H Center Washington D C The team decided to work towards a new FORTH Stan dard tentatively called FORTH 83 The mechanism of producing a FORTH Standard seems to be evolv ing Previously the team members met discussed and then voted on a variety of topics during a three day session Ambiguities and smooth wording were worked out by a smaller group of referees The resulting document was then offered for acceptance as a whole by at least two thirds of the voting members One of the problems with this method is that the time for deliberation is far too short for the pro posals and implications to be thor oughly understood The next Standard will evolve through various working drafts It is intended that there be opportunities for public examination and input By having more than one meeting prior to acceptance of the next Standard changes and corrections can be made which should reduce the inconsisten c
84. ontrol the 9836A has a full 12 2 310mm CRT which makes it ideal for computer aided engineering CAE applications Each model features the following Seven levels of prioritized interrupt Memory mapped 1 0 Built in HP IB interface Standard ASCII keyboard with numeric keypad and international language options Ten 20 with shift user definable soft keys with soft labels Rotary control knob for cursor control interrupt generation and analog simulations System clock and three timers Powerfail recovery option for protection against power lapses Seven additional interface cards DMA controller up to 2 4 mb sec 8 16 bit bi directional parallel Additional HPIB interface Serial RS232 449 BCD Color video RGB 3 planes 512 x 512 8 color Unbeatable Combination SOFTWARE HP 9826 36 Muilti FORTH HP PRODUCT 97030JA Multi FORTH was developed in 1979 by Creative Solutions Inc The standard product has been substantially modified to take full advantage of the 9826 36 hardware features Multi FORTH features 79 standard programming environment Multitasking Full screen editor In line structured assembler IZO and graphics extensions Loadable H P floating point IEEE format Extensive user manuals and documentation Optional Features e Meta compiler e Multi user e Data access methods library This product is part of HP PLUS a program for locating user software It has been dev
85. p SP EE e A a e A FORTH Dimensions 14 Volume IV No 2 FIG NATIONAL CONVENTION SPECIAL HOTEL RATES October 9 1982 for Convention Attendees RED LION INN SAN JOSE 2050 Gateway Place San Jose CA 95110 Sarge ar patho 9 00 a m 6 30 p m Conference and Exhibits e 7 30 p m Dinner and Speakers interest Group National Conven FORTH APPLICATIONS tion at the newly opened Red Lion Learn about the latest FORTH applications and how to develop your own application programs Inn San Jose The special room SPS aaa rates may be obtained by telling feregist aon FOTN the Red Lion Inn reservation desk that you will be attending the Con vention A room with two queen Company m beds is 60 00 for one person or Adarei 70 00 for two persons Alternately a room with one king bed may be City ___ n ip __ ____ reserved at the same rates Write to the Red Lion Inn San Jose 2050 e eee Ne ee Gateway Place San Jose CA _ am interested in presenting a paper on 95110 or telephone directly by call ing 408 279 0600 Tiieasioada s ve The Red Lion Inn San Jose is nclosed isa cheek ior located near the San Jose Airport 5 00 registration s and has courtesy car service Notification of your flight number a S eee e carrier and time of arrival will help with scheduling airport pick up Penny errs nesta The FORTH Interest Group Na 135 00 FORTH Vendor 8 x10 Feed eee ee tional Convention conference pro exhibit booth s with draped gr
86. plementation of Multiple Interrupts Consider the problem of handling multiple interrupts in FORTH The most direct way would simply be to define a new INT INTSRV PUT TEST AND SETINT for each interrupt only one RETURN would be required This approach would be quite reasonable for a small number of interrupts since INT and INTSRV are relatively short and the other three words would probably only be needed for debugging In fact any other kind of multiple interrupt processing scheme would cost addi tional speed However if space is scarce and speed isn t too important another method could be adopted The type of method used would depend heavily on the hardware but the general idea would be to be able to have only one interrupt service routine One such method which used a look up table was implemented on an 8080 based system but it was not found to be very useful If any readers have come up with multiple interrupt routines that they like please send them in This article has attempted to provide a basis for interrupt handling in FORTH which can be applied to most systems with some basic knowledge of the particular configuration However if there were considerations which were neglected then please let us know Also there must be many other interesting applications of interrupts in FORTH so send them in Editor s Note This code was written for fig FORTH To run the code on 79 Standard or Starting FORTH imple mentati
87. pt of the interrupt Steps 1 2 6 and 7 are relatively simple and most microprocessors provide for handling them quite easily Note however that the state of the processor may in clude external variables as well as in ternal registers Generally the saved information is pushed onto the system stack in step 2 and popped off the stack in step 6 the CPU s stack may correspond to FORTH s data stack its return stack or neither The main problem comes with steps 17 3 and 5 There are several different ways to handle them as there are many potential entry points into FORTH All methods however must sooner or later load the IP and they can be classified according to how it is done There are three categories of methods as follows 1 those which initialize the IP directly i e from assembly language 2 those which depend on DOCOL to initialize the IP and 3 those which depend on to initialize the IP Note that a particular method may fall into one of these categories indirectly for example if EXECUTE is jumped to without first initializing the IP then the method would fall into category 2 since it would have to jump to DOCOL to work Those methods falling into category 2 have the disadvantage of having to clean up the garbage on the top of the return stack and may have to deal with passing the PFA to DOCOL The methods of category 3 are sometimes even more involved since some assemblers don
88. rmined when the vocabu laries are created The search order is determined by the vocabulary last activated and its predecessors in the tree structure down to the trunk of the tree which is usually FORTH In poly FORTH systems the search order when a given vocabulary name is invoked is determined by a four nybble in one word parameter given when the vocabulary name is created Typically this limits the total number of separate vocabularies to 7 or possibly 15 A dynamic method for determining search order uses the vocabulary stack This is a concept taken from STOIC Each wordset is sealed i e not linked to any other A wordset is pushed onto the vocabulary stack from say the value in CONTEXT by using a word such as VPUSH my favorite name for this function is ALSO Another word is used to drop the top member of the vocabulary stack or perhaps to clear it out entirely Bill Ragsdale uses the word ONLY for the latter purpose By first searching CONTEXT and then the vocabulary stack we can maintain a reasonable amount of upward com patibility This is an idea advanced by George Shaw at the last FORML Conference There are many other possibilities Don Colburn has suggested a defining word like SEARCH ORDER which would name a word which specifies the search order John James has sug gested that the invocation of a vocabulary or wordset name would push itself onto the vocabulary stack if it was not currently o
89. ro for finishing a linked search Add a link to a linked list chain Addr is the head CLASS NENBER 2DROP MEMBERS DROP 20 A defining word that creates defining words class number is assigned to a class be used to create itees belonging to the class nueber is assigned ta each member Sn pfa f J Takes an item number and a pointer to a class and returns True if the itea is a aesber of the class S pfa Takes a pointer to a class and lists its seebers A unique The class nase cas An item Meabers are linked Else False Volume IV No 2 item by a unique item number The word LINK is used to add a new item to a linked list The address it expects on the stack contains the address of the head of the list Let s look at LINK in detail Suppose that HERE is at 17000 then addresses contents 10000 0 12000 10000 15000 12000 17000 2277 15000 LINK HERE OVER SWAP Thus after the execution of LINK location 15000 now points to the new head of the linked list namely 17000 which now points to the previous head of the linked list namely 12000 Also after LINK has executed HERE would be at 17002 due to the that was execu ted as part of LINK We have just created what is called a singly linked list that is a list where the pointers only run in one direction As an exer cise you might try to create a doubly linked list that is a list where pointers point to the n
90. s Inexpensive upgrades to jatest version Programming staff can provide advice modifications and custom programs to fit YOUR needs MMSFORTH UTILITIES DISKETTE includes FLOATING POINT MATH BASIC ROM routines pius Complex numbers Rectan guiar Polar coordinate conversions Degrees mode more TRS 80 a full Forth styie 280 ASSEMBLER plus a powerful CROSS REFERENCEAR to list Forth words by block and line plus ali on one diskette requires MMSFORTH V2 0 1 drive amp 32K RAM a ee 39 95 FORTHCOM communications package provides RS 232 driver dumb terminal mode transfer of FORTH biocks and host mode to operate a remote TRS 80 requires MMSFORTH V2 0 1 drive amp 32K RAM 0 0 0 ee eee 39 95 THE DATAHANDLER a very sophisticated database manage ment system operable by non programmers requires MMSFORTH V2 0 1 drive amp 32K RAM we 59 95 FORTHWRITE fast powerful Word Processor wieasy keystrokes Help screens manual amp demo files Full propor tional witabs outdenting include other blocks documents keyboard inputs ideal for form letters requires MMSFORTH V2 0 2 drives amp 4BK RAM ee 175 00 MMSFORTH GAMES DISKETTE real time graphics amp board games wisource code Inciudes BREAKFORTH CRASH FORTH CRYPTOQUOTE FREEWAY TAS 80 OTHELLO amp TICTACFORTH requires MMSFORTH V2 0 1 drive amp 32K RAM eae eh Nes site shan gaan conte the SUED 228 tient EA ope B Os 39 95 Other
91. system offering e FORTH 79 Standard with Programming Aids Utilities Double Number Standard and Examples Illustrated with Extensions Listings and Source on Disk Full 31 Character Unique e Full Screen Video EDITOR Names based on fig FORTH for 16x64 and 24x80 Displays e ASSEMBLER for the 8080 Z80 Complete with 150 pages of Processors easy to understand manual EXPLORE THE FORTH FRONTIER OmniFORTH 3 0 OmniFORTH 3 0 WITH for the TRS 80 Model III for the North Star DOS 8080 8085 and Z80 Compatible 0 m ni FO R l Requires 1 Drive amp 32K 130 Requires 1 Drive amp 32k 130 OmniEDIT l OmniC ROSS full en Video EDITOR fo Prints a cross reference of your FASTER cursor addressable displays FORTH application Identifies each word that you use 30 FLEXIBLE Included in OmniFORTH 3 0 30 EFFICIENT OmniEDIT and OmniCROSS both require o COMING SOON o fig FORTH or FORTH 79 Packages OmniFORTH 3 0 for the North Star come with documentation and ADVANTAGE INTERACTIVE SI M PLE TO USE NOTE Please specify your system and T L ORATORIES GIVES YOU CONTROL NAND GATE AB FL 33688 0426 Florida residents add sales tax A PROD U S Funds only Foreign orders UCT OF add postage for tkg package INTERACTIVE COMPUTER SYSTEMS INC source on disk Ee a SS SS FORTH Dimensions 26 Volume IV FORTH PROGRAMMING AIDS by Curry Associat
92. t IF 135 RIGHT 4 FORWARD 135 LEFT 6 RETURN THEN stoprule DUP FORWARD 90 LEFT 3 change stack for next level MYSELF size size 6 3 reverse change upon return 90 RIGHT DUP BACKWARD If you will accept as self evident the relative turning and displacement commands FORWARD BACKWARD RIGHT and LEFT each consuming one parameter here is the figure it draws Editor s note The author is using the syntax of turtle FORTH Dimensions mands used to move the cursor are these n FORWARD Moves the cursor n units forward in the direction it is already pointing n BACKWARD Negates n then calls FORWARD n RIGHT Changes direction by adding n in degrees to the current heading n LEFT Negates n then calls RIGHT ie feel RUUNA Sie eel iM g EE EE Fs BE fife E eS 3 g 3 F Ss 5 33 FEF ES 8 ae PEFFE F 3 cee A minor disadvantage is that as MYSELF had to leave a value on the stack for each next level coming back up so does the procedure as a whole leave a value A named variable could have been used instead or in this example a setup word could also do stack cleanup IN amp OUT startsize limit LIMIT GRAPHINIT POSITION ARROWHEAD PROCEDURE IN amp OUT DROP This variation minimizes use of data stack but could reach return stack limits 112 in the FORTH I use Some practical applications of recursion with branching have more lateral acti
93. t up the user s application Unit price is 2995 including FORTH software and full user documentation Controlex Corporation 16005 Sherman Way Van Nuys CA 91406 213 780 8877 FORTH 79 VERSION 2 FOR APPLE AND Z 80 CP M FORTH 79 Version 2 for APPLE II I Z 80 CP M 2 x and NorthStar DOS users Floating Point and HIRES Graphics are also available HIRES on APPLE amp NorthStar ADVAN TAGE only Base system price is 99 95 With enhancements 139 95 NorthStar Advantage users add 49 95 to include HIRES MicroMotion 12077 Wilshire Blvd 506 Los Angeles CA 90025 213 821 4340 pns FORTH FOR ATARI 400 800 fig FORTH includes full screen editor Atari CIO interface and graphics commands debug ging tools 6502 assembler string package tiny multi tasking kernal player missile graphics sound and manual controller interface Requires 32K min 1 disk drive 250 page manual covers all features and includes brief FORTH tutorial 90 includes shipping manual diskette and four newsletters Order from Mountain View Press or directly from Pink Noise Studios P O Box 785 Crockette CA 94525 SOURCE FOR MARX FORTH Complete source code for Marx FORTH only 30 sold as an ideas package and tutorial Includes Z 80 assembler and metacompiler Features links first all math in machine code 1 byte relative branching arguments results unique compiler security techniques headerless code printer control fast fi
94. tings I have implemented the FIG ver sions of both the 8080 and the 6800 FORTH into several machines and I think that the 8080 version is fairly bug free But the 6800 version isn t At first the word M is not included in 6800 FORTH but copying it from the 8080 version not in accordance to the FIG model screen 57 leads to a work ing completion But this also requires the inclusion of a DDUP word into the 6800 dictionary doing the job of the 8080 fig word 2DUP which is named not following the usual name conven tion with Dxxx for double length operators please watch this danger ous practice Editor s Note The choice of the prefix 2 was not accidental It was chosen because this class of words handles two 16 bit cells regardless of whether or not they comprise a double length number The worst bug in the 6800 FORTH occurs at signed division and is based at the fact that in the word MOD a call FORTH Dimensions of the word U occurs instead of calling the appropriate word M Furthermore the word M doesn t exist in the 6800 version Look also for the words and D When I included M and replaced it with the U in the word then the behavior of the slash operator was not yet okay That lead to the detection of a fur ther bug in 6800 FORTH the word S gt Dis defined in the 8080 Listing as a primative similar to screen 56 in the installation manual but not so
95. tive experimen tal work we have yet to run short of dictionary space in our 24K 6502 system FORTH s stack architecture pro vides a convenient mechanism with which to pipeline data from one instrument to another Figure 2 The stack is also a good place to average data accumulated over many runs given POWER a routine which fetches a reading from the laser power meter we can readily write AVERAGE POWER Listing 2 which provides the averaged power over 100 laser shots It is more pleasing to work with the computer rather than against it to build a procedure out of simpler tools and device drivers than to try to subvert a powerful but rigid procedure which doesn t quite do the job Planning For Disaster The laboratory can be a difficult envir onment for a computer especially one which is connected to many indepen dent alien devices Cables come un stuck or short circuit power supplies malfunction ICs fail Unpredictable minor failures crop up constantly the computer must be able to cope gracefully with unexpected mishaps Figure 2 The FORTH stack provides a useful channel for the simplest and most common lab computing function moving data from one instrument to another Since PLOT and PRINT are functionally equivalent they can be interchanged freely as experimental needs alter The FORTH stack is also useful for format coversion and scaling required by many instruments Extra hardware helps accommod
96. ve goal 2 the ability to reassign the interrupting word Since we have to reserve a location in memory for the word s CFA the obvious approach would be to allow the CFA of another word to be stored there Specific Implementation Details This section provides an example of the method described above for an 8080 based FORTH system with sug gestions for systems based on other processors As illustrated in Figure 1 the complete implementation is fairly short and has little assembly language The first question is what informa tion is saved by the processor when an interrupt occurs Some CPUs e g 8080 Z80 and 2650 push just the pro gram counter PC onto the stack others e g 6502 and Z8 save the PC and a status register while others still e g 6800 6809 save the PC and all registers The code on line three of Figure 1 is what is necessary to save the information which has not already been saved Note that if the IP and the so called W registers do not reside in the processor then they must be retrieved from memory and saved FORTH Dimensions Also note that stack pushes need not be used For example a Z80 user might want to perform EX AF AF and EXX to switch register banks or a Z8 user might want to simply reload the register pointer register The next task is to load the IP in this example the IP is stored in register pair BC of the 8080 The IP is loaded with the PFA of INT which is a pointer to the
97. vity rather than going to such depth I will RETURN to branching with examples a little later But another way to avoid return stack limits is to write a procedure that does its work as it goes rather than as it comes back up the levels If it invokes itself repeatedly as the last instruction without coming back it is called tail recursion or sometimes not true recursion Some folks even claim that the job can be done more efficiently with iterative structures such as DO LOOP and BEGIN AGAIN Probably such practical people will not see any point in this article as a whole Here is a simple example that draws a diagram of tail recursion jumping out of the cycle when a limit condi tion is reached Volume IV No 2 gt CYCLEUNTIL startsize DUP 5 lt IF 90 RIGHT 95 FORWARD ARROWHEAD RETURN THEN stop rule 6 LEFT DUP FORWARD 1 R gt DROP MYSELF Ei t pt pr 3s gate pri pm et p p att p a2 F oS t r wt wo tr wt p p m sA at Notice the same form a stoprule at the beginning of the procedure R gt DROP prevents useless build up on the return stack allowing unbounded repetition But if CYCLEUNTIL were called from within another word the R gt DROP first removes from the return stack the address of the next action in the calling word jumping over instead to the level that called the calling word
98. wo incredible programmers and great people to learn from FORTH Is much much more than a language It is the implementation of an incredibly powerful philosophy for solving complex problems in a way that is not only effective but fun Now all this was not apparent to me before this course In ten sessions twice weekly three hours per night the class went from simple stack operations to metacompilation More than just an understanding of how to use FORTH s various tools I learned the difference between good FORTH and bad FORTH and why there can be such a difference Kim Harris and Henry Laxen have been so intimately involved in the building of what FORTH really is that you can t help but get a feeling for the philosophy the style and the com munity of FORTH The Laxen amp Harris course is a great way to get up to speed fast You d better hurry though the price of the course limits it to professionals and very serious amateurs Upcoming Issues Here s the planned schedule of themes for the remaining issues of Volume IV including the deadline for theme articles 3 Operating Systems 4 Coding for ROM 9 01 10 15 12 15 5 Business Applications 6 Teaching FORTH The projected themes for Volume V are Project Management FORTH in the Arts Serial Communications Laboratory Workstations The FORTH Environment and Looking Back FORTH History 33 FOR TRS 80 MODEL OR ili
Download Pdf Manuals
Related Search
Related Contents
入出力モジュール - ジョンソンコントロールズ Manual de Operaciones B-SA4TP SERIES Adaptateur allume-cigare avec capteur de vibration Mode d`emploi バイオメトリクスによる簡易認証システムの調査・開発報告書 2 - Olympus America CATC Traffic Generator Flexible USB Host Emulator User`s Manual Compact 3010 - Campingcar Newsletter Droit bancaire et financier n° 3 - MAI 2013 Copyright © All rights reserved.
Failed to retrieve file