Home
1 - Forth
Contents
1. Start Gl integer character CZ J This shows one of the basic syntax elements the colon declaration which in Forth only declares words According to one of my favorite guidelines simplification by generali zation the colon is used in OOF as the general method of the system in order to create objects or instances of this class If you wantto declare more than one object ofthe same class the names of the objects separated by commas form a list of objects to be declared terminated by a semicolon Forth Dimensions declaration It can be applied to any class that is known in Figure One Defining an instance method im size image i integer 3 integer i gt xdim i gt ydim pixels i gt bits pixel pixels s am Figure Two Using individua instance methods perum subclass state define default reaction define states for state machine state iim keypressed state A key was pressed print state idle input idle iim keypressed state s Idle state S key print er ee Actually the comma is exactly the same method as the colon Insome cases the colon method needs some more parameters e g when defining a string you want to give the maximum number of charactes in the string
2. Name OFFICE USE ONLY Company By Date Street Shipped by City State Prov Zip Country Daytime a MEMBERSHIP SEE BELOW em NEN Lond ine w ren sen Nan wu quim Led pee m MANN qan uses CHECK ENCLOSED Payable to Forth Interest Group Sub Total 10 Member Discount O VISA MasterCard Member Sub Total Card Number Te Sales Tax CA only Expiration Date Mail Order Handling Fee Membership in the Forth Interest Group New Renewal 40 46 52 Enclosed is 40 46 52 for 1 full year s dues This includes 34 40 46 for Forth Dimensions Signature 15 00 minimum on all VISA MasterCard orders PAYMENT MUST ACCOMPANY ALL ORDERS MAIL ORDERS PHONE ORDERS PRICES POSTAGE amp SHIPPING TIME CALIFORNIA SALES TAX BY COUNTY Send to Cail 408 277 0668 All orders must be prepaid Prices are HANDLING Books in stock are shipped 7 5 Sonoma 7 75 Fresno Imperial Inyo Forth interest Group toplacecreditcard subject to change without notice Credit Prices include within seven days of receipt of Madera Monterey Orange Riverside Sacra P O Box B231 orders or for cust card orders will be sent and billed at cur shipping The the order Please allow 4 6 mento San Benito Santa Barbara San Bernar San Jose CA 95155 omer service rent prices 15 minimum on charge or 3 00 handling weeks for out of stock books dino and San Joaquin 8 25 Alameda Contra U S A Hours
3. 1985 Extending Forth s Control Structures into the Language Requirements of the 90 s David W Harralson 1986 Charting Escaping Hacking Leaping Forth Wil Baden 1986 Extended Forth Control Structures for the Languages Re quirements of the 1990 s David W Harralson 1987 Loops and Conditionals in LaForth Robert L Smith 1987 Interpreting Control Structures the Right Way Mitch Bra dley 1987 Forth Control Structures for the Language Requirements of the 1990 s David Harralson 1988 GOTO A Proposal C H Ting 1989 Have Dot if Dot else Dot then Klaus Schleisiek Kern 1989 Control Flow Words from Basis 9 Wil Baden 1989 Pattern Matching in Forth Brad Rodriguez interaction between control structures and pattern matching Kocbester Fortb Conference Proceedings 1981 Transportable Control Structures Kim Harris 1982 The Importance of the Routine QUIT Hans Nieuwenhuijzen 1982 Techniques Working Group Rieks Joosten 1984 Hello a Reptil AM Israel Urieli 1985 REvised REcursive AND REPTIL IS Israel Urieli 1985 Exception Handling in Forth Clifton Guy and Terry Rayburn 1986 Do Loop Exit Address in Return Stack and leave 1988 89 not available to author 1990 Non Local Exits and Stacks Implemented as Trees RJ Brown abstract 1990 Cryptic Constructs Rob Spruit Dr Dobb s Journal 9 83 Non deterministic Control Words in Forth Louis L Odette 1 84 Non det
4. M n Advantage TDS When you have developed your product using the TDS2020 or TDS9092 and are now manufacturing it that is not the end of the story for Forth It can be used for repair and maintenance because the language is on board A connector can be built into the product which gives serial access to the TDS board in your instrument With a PC or hand held terminal you can now gain access to the system The command ctrl C allows you to break out of your program and individually exercise all the procedures that make up the software For instance you can drive the Ee J 20MHz Forth Controller 16 bit uP 8ch 10 bit A D 3ch 8 bit D A IDS2020 CONTROLLER AND DATA LOGGER 4 x 3 board uses Hitachi 16 bit H8 532 CMOS uP Screams along at 3MIPS but runs on 30ma On board FORTH and assembler no need for in circuit emulalion Up to 512K NVRAM 45K PROM Attach keyboard lcd l2C peripherals Built in interrupts multi tasking watchdog timer editor and assembler 33 I O lines two RS 232 ports 6 16 volts 300uA data logging on chip 8 ch 10 bit A D 5 ch D A Date time clock low power mode lasts over a year on 9v battery ots of ready made software solutions free Program with PC Many in use world wide for machine control data logging inspection factory automation robotics remote monitoring etc Specials 40 85 C or 1 MHz full functions 4ma STARTER PACK 49
5. word move long move The assembler chooses always best form for instruction That means that add may compile addg add general addq add quick addi add immediate and move may compile moveg move general moveq move quick to data reg or movei move immediate For address registers size is ininfluent so a long immediate move may be compiled as word immediate move and a long adda add to address register may be compiled as word immediate adda if the immediate value is small enough FU um uM arum ue uw um ur ur CodeAddrOf name InputStream Pfa cfa compile literal immediate Observe figure 5 to understand to what make reference the above words CSF I means in forth pseudocode CSF macro I macro I macro I macro macro CSbegining macro OldCSF macro releaser macros Index ir aui cadit ad I macro Step and counter are used by the I macro loop structure macro Step macro Counter HR SBS macro Old rrorCSF macro OldSP I macro OldErrorCSF and OldSP are used I macro by the recoverably structure 44 Ug BEER Sm variable lastErrorCSF lastErrorCSF off Contains the value of the CSF of the last RECOVERABLY structure macro IPtoBegining Set the instruction pointer to point to the CSbegining IP 1 CSF RP 1 begining of the control structure while reseting the return stack to be as when the control structure was entered
6. Elliott Chapin ELLIOTT C BIX Byte Information eXchange For Information call 800 227 2983 Forth Conference Access BIX via TymNet then type j forth Type FORTH at the prompt SysOp Phil Wasson CompuServe For Information call 800 848 8990 Creative Solutions Conf Type Go FORTH SysOps Don Colbum Zach Zacharia Ward McFarland Greg Guerin John Baxter John Jeppson Computer Language Magazine Type Go CLM SysOps Jim Kyle Jeff Brenton Chip Rabinowitz Regina Star Ridley The WELL Unix BBS with PicoSpan frontend Forth conference Access WELL via CPN CompuServe Packet Net orvia SprintNet node casfa or 415 332 6106 Forth Fairwitness Jack Woehr jax Type j forth Citadel Network two sites Undermind UseNet Citadel bridge Atlanta GA 404 521 0445 GEnie is the repository of the Forth Interest Group s official Forib Library perte Dimensions SEE Interface formerly Nite Owl SysOp Bob Lee Napa CA 707 823 3052 Non Forth specific BBS s with extensive Forth libraries DataBit Alexandria VA 703 719 9648 SprintNet node dcwas Programmer s Comer Baltimore Columbia MD 301 596 1180 or 301 995 3744 SprintNet node dcwas e PDS SIG San Jose CA 408 270 0250 oprintNet node casjo International Forth BBS s See Melbourne Australia in ForthNet node list above Serveur Forth Paris France Fr
7. LAL BREAK CASE ISLAH OF LAH BREAK NOCASE BREAK Get a hexadecimal number from the keyboard NUMIN n 0 NUMBUF Clear receiving buffer NUMBUF BYTE 10 EXPECT User inputs number here BASE HEX Set base to hexadecimal NUMBUF BYTE 1 NUMBER Convert 2DROP SWAP BASE Restore base Exit to forth from debugger TOFORTH TO FORTH CR INTERPRET BACK TO DEBUG CR Return to the debugger RESUME R DROP Get user input at each debugger step USERIN BEGIN 0 KEY SELECT CASE ASCII F OF Shell out to Forth TOFORTH BREAK CASE ASCII Q OF Abort 1 ABORT ABORTED BREAK CASE ASCII I OF Display current instruction BASE 8 IFETCH HEX BASE CR BREAK CASE ASCII D OF Dump ADDR NUMIN Address LEN NUMIN Number of bytes SDUMP BREAK NOCASE DROP 1 BREAK Anything else continues UNTIL Main debugger loop T i Qe that returns the user to the debugger where he left off Currently these words make no attempt Lo save and restore the parameter and return stacks It s up to you to make sure the stacks are in the same state wnen you execute RESUME as when you left the debugger I Displays in hexadeci mal the instruction the debugger is about to execute I found this handy for ALU
8. Mail a hard copy and a diskette Macintosh 800K or PC preferred to the Forth Interest Group P O Box 8231 San Jose California 95155 May 1992 June supports the programmerby local parameters to the ad Forth Dimensions FIG MAIL ORDER FORM HOW TO USE THIS FORM Please enter your order on the back page of this form and send with your payment to the Forth Interest Group Most items list three different price categories USA Canada and Mexico Other countries via surface mail Other countries via air mail Note Where only two prices are listed surface mail is not available Were Sure You Wanted To Know Forth Dimensions Article Reference 151 4 5 An index of Forth articles by kcy word from Forth Dimensions Volumes 1 12 1978 91 FORML Article Reference 152 4 5 An index of Forth articles by keyword author and date from the FORML Conference Proceedings 1980 89 FORTH DIMENSIONS BACK VOLUMES A volume consists of the six issues from the volume year May April Volume1 Forth Dimensions 1979 80 101 15 16 18 Introduction to FIG threaded code TO variables fig Forth Volume2 Forth Dimensions 1980 81 102 15 16 18 Recursion file naming Towers of Hanoi CASE contest input number wordset 2nd FORML report FORGET VIEW Volume3 Forth Dimensions 1981 82 103 15 16 18 Forth 79 Standard Stacks HEX database music memory man agement high level interru
9. The CASE SEL and COND Structures Peter H Helmers 3 No 1 Compiler Security George W Shaw 3 No 3 Multiple WHILE Solution Julian Hayden letter Vol 3 No 6 Cases Continued John J Cassady Vol 3 No 6 Eaker s CASE for 8080 John J Cassady Vol 3 No 6 Generalized CASE Structure in Forth Edgar H Jr Fey Vol 3 No 6 CASE as a Defining Word Dan Lerner Vol 3 No 6 Faker s CASE Augmented Alfred J Monroe Vol 3 No 6 Transportable Control Structures with Compiler Security Marc Perkel LEAVE discussion Vol 4 No 3 Forth 83 DO LOOP Robert L Smith Vol 4 No 3 Forth 79 compatible LEAVE for Forth 83 DO LOOPs Klaxon Suralis 5 No 3 Yet Ancther Case Statement Marc Perkel letter 5 No 3 RPN Blues Revisited Horst G Kroker 5 No 3 Forth 83 Standard Robert L Smith 5 No 3 Forth 83 a Minority View 5 No 4 Forth 83 Loop Structure Bill Stoddard 5 No 5 Within WITHIN Gary Nemeth 5 No 5 A More General CASE Martin Schaaf letter 5 No 5 Just One Exit in Case Ed Schmauch letter Vol 5 No 6 Do When Loop Construct R W Gray Vol 5 No 6 DO LOOP 83 Caution Nicholas Pappas Vol 6 No 1 Parnas it ti Structure Kurt W Luoto subcases COR CAND 6 No 1 More on WITHIN Rich Leggit letter 6 No 2 Forth Control Structures David W Harralson 6 No 4 ANDIF and ANDWHILE Wendall C Gates
10. VARIABLE HERELOC IFETCH HERELOC Put the instruction in line HERE HERELOC Set HERELOC 0 4d Make room in the dictionary a m The word IFETCH re uieves the instruction pointed to by HISIP The debugger stores that instruction at the address stored in HERELOC As you can see by the code between and HERELOC is set to point to an initially empty cell within the debug ger s stream of execution Simply put the debugger patches itself on the fly the patch being the instruction fetched from the location given by HISIP Finally after the in line instruction has executed the debugger uses the GFLAG word mentioned earlier to save the state of the FL bit User Input While you re in the debugger the system gives you the option of entering a variety of single character commands at each execution step These commands are F Allows the user to tem porarily suspend the debug ger and go to Forth This command simply calls the SC Forth32 word INTER PRET The debugger defines an additional word RESUME May 1992 June SWAP 16 SWAP REPEAT 2DROP Debugger kx Fetch his next instruction IFETCH n HISIP Mask out jump address for calls and branches JADDR n IFETCH 1FFFFFFF AND F Mask out instruction type ITYPE N IFETCH E0000000 AND DECIMAL Safely print the stack Given the byte address of a name fi
11. num M index d 1 gt CodeAddrOf rawIN bsr di tst lt gt Yenter end code To use IN IN ecc consider to define and They may be defined as Svariable OldDepth NV depth OidDepth push sog Abo E depth OldDepth pop or if you aren t familiar with Stack Variables as described in FD XII number 1 you may use this alternative definition that allows for nested and VARIABLE OLDDEPTH NV x OldDepth depth oldDepth X x ni nZ see nM nl n2 aes nM N depth olddepth dup i roll OldDepth 1 ROLL means SWAP code I IndexValue index push next end code code TO 1 newvalue index pop next end code code STEP valueToAdd STEP or TO I dO pop d index add next end code add to the index a value code J IndexValue oldCSF a 1 gt reference the old Control structure frame oa a I push Attention no information localisation next Value A is that of the index macro Better but unefficient definition is CSF a 1 OldCSF CSF 1 index push a CSF 1 next end code Full compile time error checking is provided An easy syntax is provided to construct new control structures structure BegStructure cell gt BegToken the words begToken BegStarter cell BegStarter cell gt BegEnder gt BegEnder are equivalent to cell gt Beg pointers cell gt BegApplica
12. 2 Fall 91 908 6 7 9 Postscript Issue What is Postscript Forth in Postscript Review PS Tutor 1989 SIGForth Workshop Proceedings 931 20 21 26 ware engineering multitasking intcrrupt driven systems object oriented Forth error recovery and control virtual memory support signal processing MEMBERSHIP IN THE FORTH INTEREST GROUP The Forth Interest Group FIG is a world wide non profit member supported organization with over 1 500 members and 40 chapters Your membership includes a subscription to the bi monthly magazine Forth Dimensions FIG also offers its members an on line data base a large selection of Forth literature and other services When you join your first issue will arrive in four to six weeks subsequent issues will be mailed to you every other month as they are published six issues in all You will also receive a membership card and number which entitles you to a 10 discount on publications from FIG Your member number will be required to receive the discount so keep it handy Dues are not deductible as a charitable contribution for U S federal income Cost is 40 00 per year for U S A amp Canada surface mail 46 00 Canada tax purposes but may be deductibic as a business expense where applicable air mail all other countries 52 00 per year No sales tax handling fee or discount on membership FORTH INTEREST GROUP P O BOX 8231 SAN JOSE CALIFORNIA 95155 408 277 0668 408 286 8988 FAX
13. Go TETRA Life Source IBM A Forth Spreadsheet V2 Craig Lindley C003 1 This model spreadshect first in Forth Dimensions VII 1 2 Those issues contain docs amp sourcc IBM Automatic Structure Charts V3 Kim Harris C004 1 Tools for analysis of large Forth programs first presented at FORML conference Full source docs incl in 1985 FORML Proceedings IBM A Simple Inference Engine V4 Martin Tracy C005 1 ased on inf engine in Winston amp Hom s book on LISP takes you from pattern variables to complete unification algorithm with ap on Forth philosophy amp style Incl source IB The Math Box V6 Nathanicl Grossman C006 1 Routines by foremost math authorin Forth Extended double precision arithmetic complete 32 bit fixed point math amp auto ranging text Incl graphics Utilities for rapid ynomuial evaluation continued fractions amp Monte Carlo actorization Incl source amp docs IBM AstroForth amp AstroOKO Demos LR Agumirsian C007 1 AstroForth is the 83 Std Russian version of Forth Incl window interface full screen editor dynamic assembler amp a great demo AstroOKO an astronavigation system in AstroForth calculates sky position of several objects from different earth positions Demos only IBM Forth List Handler V1 Martin Tracy C008 1 List primitives extend Forth to provide a flexible high s environment for AI Incl ELISA and Winston amp Hom s micro LISP as examples
14. Incl source amp docs IBM 8051 Embedded Forth William Payne C050 4 8051 ROMmable Forth operating system 8086 to 8051 target compiler Incl source Docs are in the book Embedded Controller Forth for the 8051 Family IBM F83 V2 01 Mike Perry amp Henry Laxen C100 1 The newest version to a variety of machines Editor assembler decompiler metacompiler Source and shadow screens Manual available separately items 217 amp 235 Base for other F83 applications IBM 83 ACM SIGFORTH The ACM SIGForth Newsletter is published ey by the Association of Computing Machinery Inc SIGForth s focus is on the development and refinement of concepts methods and techniques needed by Forth professionals Volume 1 Spring 1989 900 6 7 9 F PC glossary utility Euroforth SIGForth 89 Workshop summary real time software engineering Intel 80x8x Volume 1 Summer 1989 901 6 7 9 Metacompiler in cmForth Forth exception handler string case statement for UF Forth Volume 1 43 Fall 1989 902 6 7 9 1802 simulator tutorial on multiple threaded vocabularies Volume 1 4 Winter 1989 903 S6 7 9 Stack frames duals an alternative to variables PocketForth Volume 2 2 December 1990 904 6 7 9 BNF Parser abstracts 1990 Rochester conf F PC Teach ee F PC V3 53 Tom Zimmer C200 5 A full Forth system with pull down menus sequential files editor forward assembler mctacompiler floating
15. Is midPointerOffset midender IS name create midFreeMask 8 dup 2 midFreeMask Z cells immediate does addr comp check compilation state dup midmask begaddr Bega pplicableMids and is it applicable to this CS Q abort midEnderBeginer isn t applicable to that control structure dup gt midPointerOffset ofsPoints abort mid already applied ender 6 token dup midpointer ffset here ofsPoints set the pointer point here dup midender ender set new ender drop Forth Dimensions 33 May 1992 June 6 midpointerOffset LEAVE midender mid Is COMPLETED 6 midpointer ffset ERRORPROPAGATE midender midj Is ONERROR Midst 0 Mids ni n2 nN 1 0 Sspointers at least one applicableMask BEGINol1d rot dup WHILEold body gt midMask G or swap i swap REPEATold drop Mids Mids is used to construct the mask of the control structure applicable 4 midpointerOffset LEAVE midender mid Is JLEAVING Clause words I create CONTROL CONTROL SIMPLE C LEAVE Midst jLEAMVINGC Mids BegIs CONTROLL Enderis CONTROL create REPEAT REPEAT SIMPLE AGAIN Mids LEAVING Mids Begis REPEAT EnderIs REPEAT create CASE CASE INDEXED LEAVE Mids LEAVING Mids BegIs CASEL EnderIs CASE create FOR FOR INDEXED AGAIN Midst LEAVINGL Mids BegIs FOR En
16. Note If you are unable to access SIMTEL20 via Internet FTP or through one of the BITNET EARN file servers most SIMTEL20 MS DOS files including the PC network at 313 885 3956 DDC has multiple lines which support 300 1200 2400 9600 14400 bps HST V 32 V 42 V 42bis MNP5 This isa subscription system with an average hourly cost of 17 cents It is also accessible on Telenet via PC Pursuit and on Tymnet via StarLink outdial New files uploaded to SIMTEL20 are usually available on DDC within 24 hours rr Information provided by Keith Petersen Maintainer of SIMTEL20 s MSDOS MISC amp CP M archives IP address 26 2 0 74 w8sdz WSMR SIMTEL20 Army Mil or w amp sdz vela acs oakiand edu Uucp uunet wsmr simtel20 army mil w8sdz BITNET w8sdz OAKLAND Internet This list was compiled 20 February 1992 While every attempt was made to produce an accurate list errors are always possible Sites are also subject to mechanical problems or SysOp burnout Please report any discrepancies additions or deletions to the following Gary Smith uunet doi 1 lirark gisrk gars P O Drawer 7680 nuucp ddi 1 uunet UU NET Little Rock AR 72217 GEnie Forth RT amp Unix RT SysOp U S A ph 501 227 7817 fax 501 228 9374 8 5 Central M F Forth Dimensions 40 F Mail For those with e mail only access there is not much For now posts from ForthNet ported into comp lang forth sometimes adver tise files
17. RCFB Real Time Control Forth Board SysOp Jack Woehr Location Denver Colorado USA ACFB Australia Connection Forth Board 03 809 1787 in Australia SysOp Lance Collins 61 3 809 1787 International Location Melbourne Victoria AUSTRALIA 213 306 3530 sprintNet node calan LMI BBS Laboratory Microsystems Inc SysOp Ray Duncan Location Marina del Ray California USA 501 753 8121 t register 501 753 6859 thereafter Grapevine Grapevine RIME hub SysOp Jim Wenzel Location Little Rock Arkansas USA GEnie General Electric Network for Information Service SysOps Dennis Ruffer D RUFFER Leonard Morgenstem NMORGENSTERN Gary Smith GARY S Location Forth RoundTable type M710 or FORTH Forth Libraries There are several repositories of Forth programs sources executables and so on These various repositories are notidentical copies of the same things Material is available on an as is basis due to the charity of the people involved in maintaining the libraries There are several ways to access Forth libraries 800 638 9636 for info D 9inz 3 E FIP Note You can only use FTP if you are on an Internet site which supports FTP some sites may restrict certain classes of users If you have any questions about this contact your system administrator aU May 1992 June I NUN EL for information Your system administrator should always be you
18. This is necessary to allow an AGAIN beeing executed by a secondary called within the control structure without filling the RetStack with unnecessary addresses macro IPbeg end 2 IP I IP w add macro Assuming the Instruction Pointer IP points to the begining of the control structure make it point after the end of the control structure figure 3 macros ph ge ae a wur ut a macro unframe Hof extra cells onRS cells A RP add while freeing from the return stack the space macro used for the control structure OldCSF CSF 1 gt Restore the old contents of the CSF register create releasers code unfr ame unframe rts end code Unframe a return stack frame code lunframe 1 unframe rts end code where the space occupied by code 3Sunframe 3 unframe rts end code extra values index step ecc is of i or 3 cells code RECOVERABLYrelease More elaborate behaviour to LastErrorCSF APCI a lea unframe a recoverably control oldErrorCSF a 1 structure frame 3 unframe rts end code code otherReleasers end code macro frame releaserAddr Sextra cells onRS 8of compiled pointers gt r extra cells onRS cells RP w sub Reserve space on RetStack for Extra cells releaserAddr releasers w rpush push offset of unframing routine r gt 4of compiled pointers 2k IP w add Make the IP point to the first word after tbe control structu
19. Whenever it sees a set bit it would mask the bit out transfer the top of the return stack into HISIP and execute the modified instruction May 1992 June gt m ELSE ITYPE ISBRAN IF SSTACK USERIN JADDR HISIP ELSE ITYPE IS BRAN IF SSTACK USERIN HISFLAG IF 1 HISIP ELSE JADDR HISIP THEN ELSE SSTACK USERIN IFETCH HERELOC HERE HERELOC GFLAG HISFLAG l HISIP THEN THEN THEN CR AGAIN The outermost word simply enter DEBUG BL WORD CELL FIND NOT LE NOT FOUND CR QUIT ELSE HISIP WORD AT HISIP HEX DECIMAL CR DLOOP THEN Listing Two Execution trace TRACE R 1 HISNAME CR gt gt TRACE TRACE COMPILE ast em uu m uam me ua ma ad me Gm a Ga r To unleash the DEBUG lt wordname gt UNCOND BRANCH Show the stack Get user input Get jump address New instr pointer COND BRANCH j Show the stack Get user input Get his FL bit Branch not taken Branch taken Show the stack Get user input Put instr aem amm Bail out if not am m n Re n m am Enter the loop Back up to code field Display name Compile TRACE into dictionary Make colon happy TRACEON gt gt TRACE cy 3 8 Address where was Overwrite it TRACEOFF Kk S B T s Put back where he was 10 Forth Dimension
20. 16 bit object numbers sometimes called handles An object number can be converted into a memory address via the Object Table an array that holds the memory address of every object that exists in the system The address of an object is determined by using the object number as an index into the Object Table Thus it is possible to vocabulary source file relocate an object without having to change every reference to this object only the entry in the Object Table must be updated This is very important in an object oriented system where objects are constantly created and deleted at run time causing the need for garbage collection and relocation of objects Every object has a unique object number The corre sponding address from the Object Table points to the header of the object and the nature and state of the object can now be deduced However since the body of the object can be stored anywhere else in memory we need more information in the object s description a further object number gives the address of the memory block where the body is located An offset within the block must be added to this address to arrive at the complete body address of the object This process is shown in Figure Eight Thus a complete description of an object consists of a reference to the header and a reference to the body of the object This concept has great impact on the format of stack entries It makes sense to push onto the par
21. Mon Fri ders Checks must be in U S dollars fee is required deliveries in most cases willbe Costa Los Angeles San Diego San Mateo 9a m 5p m PST drawnonaU S bank A iOchargewillbe with all orders much sooner San Francisco Santa Clara and Santa Cruz added for returned checks 7 25 other counties XIV 1 Panr Two or Two Kourtis Giorgio Genoa Italy Continued from the previous issue Create avery large table The available memory could consist of a non integer part of cells Nevertheless the definitions work correcily and do not corrupl unavailable memory this depends on the choice times diff step MaxAvailableChunk addr size constant LogosSize constant Logos gt LogosInit Logos LogosSize Cell SIZE LOOP I off LOOP LogoBackSearch logo false addr true Logos LogosSize cell SIZE BACK LOOP dup I WHEN drop I true WHEN COMPLETED drop false LOOP Simple examples 10 19 3 End LOOP I LOOP types 19 10 3 three numbers These are 10 13 16 19 10 3 End LOOP I LOOP types 10 19 3 three numbers These are 19 16 13 10 20 3 LOOP I LOOP types 20 10 3 three numbers These are 10 13 16 20 10 3 LOOP I LOOP types 10 20 3 three numbers These are 20 17 14 Subtle exercise What gets typed by this phrase 10 20 3 END BACK LOOP I LOOP GSolu on the same numbers but in reverse
22. Software Inc has written a number of software applications for a variety of clients including General Motors Saturn plant HVAC cluster interlink pro tocol Eastman Kodak T88 Densitometer McDonnell Douglas Electrophoresis Operation in Space Ground Data Systems Lockheed ITT Power Systems SUPERVISOR and Federal Express X PC protocol and Astra Label System for the Super Tracker The company s founder is James Dewey He has implemented X PC SECS II DDCMP and a variety of other protocols primarily for applications involving single chip microcomputers He has programmed in PL1 PLC7 ASYST polyFORTH and Fortran as well as various assembly languages Before founding Paladin Software Inc he worked as an Elecuical Engineer and was a senior pro grammer with Forth Inc He holds degrees in Electrical Engineering and Psychology from Cornell University M M J l J M M I L SSE Forth Dimensions Produoe Wateh May 1991 Orion Instruments revealed a trade up program for converting from the UniLab UDL microprocessor emulator analyzer to a more powerful UniLab 8620 microprocessor emulator analyzer The discount offer ended September 30 1991 July 1991 BDS Software announced CF83 a 1983 Standard Forth for the Radio Shack Color Computer running RS DOS september 1991 Paladin Software announced DataScope
23. Version 2 0 a serial line monitor and protocol analyzer sporting a windowed GUI and requiring MS DOS 2 1 or higher running on a PC September 1991 Forth Inc announced the chipFORTH 68332 Software Development System which includes one year telephone suppont uses an MS DOS PC host and includes a 68332 board set known as the Motorola Evaluation Kit EVK October 1991 Forth Inc announced a new release of EXPRESS Event Management and Control System a process control software package Companies Mentioned BDS Software P O Box 485 Glenview Illinois 60025 0485 Phone 708 998 1656 Forth Inc 111 N Sepulveda Blvd Manhattan Beach California 90266 6847 Phone 310 372 8493 Fax 310 318 7310 Orion Instruments 180 Independence Dr Menlo Park California 94025 Phone 415 327 8800 Fax 415 327 9881 Se ee Paladin Software Inc 3945 Kenosha Avenue San Diego California 92117 Phone 619 490 0368 Fax 619 490 0177 M A a LG 88 AAAALUGGZIULLLuLI DIES LLL L tGuoGiiiE VLIiAA LCLGLLLUUCQ 4 51 GPL 39 May 1992 June e On Line Resources ForthNet ForthNet is a virtual Forth network that links designated message bases of several bulletin boards and information services in an attempt to provide greater distribution of Forth related info ForthNet is provided courtesy ofthe SysOps of its various links who shunt appropriate messages in a man
24. Wanted Some things bear repeat ing like the basics of CRE ATE DOES Leonard Morgenstern s article in this issue tackles that perennial nighunare of Forth neo phytes If someone once helped you by explaining a particularly thorny topic why not return that favor for the up and coming generation of Forth programmers Irecently got a phone call from a gentleman in the Midwest he appreciates Forth over other languages but hasn t yet achieved the degree of proficiency re quired to benefit from many of FD s intermediate and advanced articles Would we ever he asked be publish ing more tutorials I told him the truth we d love to but they are too rarely seen crossing the editor s desk Please consider this a call for tutorials Perhaps a topic springs to your mind even now chances are some of our readers need to hear about it And a FIG Chapter looking for a group project should consider putting its collective genius to work developing a list of such likely topics and jointly developing a series of short written tu torials with succinct coded examples As many of you have noted over the years there is a deanh of Forth learning resources Won t you help to relieve this need After all Forth s success will ultimately depend on new people learning to use it And if you know of any Forth classes and workshops let us know so we can add them to our reSource Listings
25. accompanying advertisement so I won t list them here If you are interested in JForth or HMSL give us a call and we can direct you to a discount retailer Hierarchical Music Specification Language HMSL is an extension to Forth that provides MIDI support and object oriented compositional tools The object classes include Shapes which are a general purpose array of N dimensional points The data can represent a melody a tuning a trajectory or any user defined parameter Another class called P ayers schedules the conversion of Shape data into musical or other forms of output obs Hierarchical Language Experimental music for Macintosh and Amiga HMSL is an object oriented extension to Forth with extensive MIDI toolbox MIDI File support tools for building your own user interfaces Markov chains 1 F noise graphical shape editor hierarchical scheduler for playing abstract data tools for complex algorithmic composition support for Amiga local sound and samples complete source code provided with manual If your music is too unusual to create using traditional music applications write your own using the tools HMSL provides HMSL is being used in hundreds of studios and colleges worldwide by some of the today s most creative composers HMSL was developed by Frog Peak Music complete Amiga DOS 2 0 toolbox support simple IFF ILBM and ANIM tools source level debugger with breakpoints object oriented dialec
26. instance variables In order to achieve the desired security and consistency the instance variables of any object may only be modified by the methods that have been declared for 4 X X Q Forth Dimensions pixels CR DE ee L V c SK C define class state 13 define individual reaction its class the instance methods abbreviated as im No method defined for any other class may alter or even read these instance variables One method for the class image might forexample compute the size of an image in bits You can define this method as in Figure One So size is defined as an object of class im What is known as the stack comment in Forth has evolved to a full declaration of input and output parameters as well as local variables in OOF The parameters are defined in the same way as any object by the colon declaration The method size can refer to the object that was passed to it on TOS as i the object that is to be passed as the result can be referred to as s and pixels is a local object It goes without saying that you can define as many of these temporary objects here s i and pixels as you like Their scope is only within the definition of this method they cannot be accessed from outside the method They
27. introduced this year require simple easy to use low memory methods of pro gramming Sounds like Forth to me So let s get started I ve been playing around with ways to do what I ve proposed and I m eager to take it further Remember the Future starts tomorrow Regards Mark Martino 170 11th Avenue Seattle Washington 98112 tet ial Printers a rd UN ae T F stri eger Ht Sent yet a Ta R is or PURA 7 ret De THIRTY DAY FREE OFFER Free MMSFORTH PETES ett MES DISK worth 39 95 with purchase of MMSFORTH 4 ML Se CRYPTOQUOTE HELPER OTHELLO BREAK FORTH and others May 1992 June Debugger A Single Step and Other Tools for the SC32 Processor Rick Grehan Peterborough New Hampshire The SC32 is a 32 bit stack based processor designed specifically for executing high level Forth like languages It can directly execute two gigabytes of code memory and 16 Gb of data memory Good descriptions of the SC32 can be found in the March April 1990 issue of Forth Dimensions SC32 A 32 Bit Forth Engine by John Hayes and in Philip J Koopman Jr s book Stack Computers The New Wave 1989 Ellish Horwood Ltd Chichester West Sussex England Silicon Composers SC FOX parallel coprocessing system PCS32 offers an SC32 on a PC XT AT compatible plug in card The PCS32 runs the SC32 at 10 MHz achieving execution speeds of 10 to 15 MIPS Thanks to the SC32 s pipelined design the system c
28. keeps correct time and date battery included with or without system power 24 bytes of keep alive CMOS RAM powered by wristwatch battery Source code driver software and test routines for SCSI parallel and serial ports DRAM timers CMOS RAM and wristwatch chip included Interrupts available for all I O devices No jumpers totally software configurable Hardware support for fast parallel to SCSI transfer Multiple boards may be stacked in one system Two 50 pin user application connectors Single 5 Volt low power operation Full power and ground planes Input for external 5 volt supply to keep DRAM data in case of loss of main power 6 layer Eurocard size 100mm x 160mm User manual and interface schematics included See application article in this issue For additional product and pricing information please contact us at SILICON COMPOSERS INC 208 California Avenue Palo Alto CA 94306 415 322 8763 May 1992 June 2 Forth Dimensions Contents Features S ES Cees Or MM 6 ASingle Step Debugger Rick Grehan amp Other tools for the SC32 The technical director of BYTE Labs produced a massive amount of code on Silicon Composers PCS32 system Here he shares the debugger he wrote to speed development 12 Designing Software Controlled Devices Carol Goldsmith The Sales Manager of The Saelig Company explains Forth s advantages when doing product developm
29. levels etc The concept of what is structured and what is not is cleaned up and some clarity is achieved Pascal C and standard Forth do not offer such possibili ties Besides although the code isn t actually provided it is possible to defined named control structures like LEAVE TO and AGAIN TO So the sequence ABORT CS AGAIN TO would mean ABORT while COLD CS AGAIN TO would mean COLD START Additionally OUTMOST CS LEAVE TO would mean BYE For efficiency purposes when programming in machine language for typical processors like 68xxx and 80x86 and using assembler control structures it may be necessary to use the usual xBRANCH words providing a less powerful set of control structures but probably more than enough for assembler needs Forth processors on the other hand are easily adaptable Lo variations of the more powerful solution sometimes with gains in efficiency In this article I provide two implementations One is a 68xxx implementation of the more powerful solution for Forth control structures Because the code presented must be readable by people using other processors pseudo assem bler code is given where appropriate So if you are interested May 1992 June in the precise implementation but do not know the 68xxx please don t panic I found I am able to read 80x86 assembler easily without knowing the processor Due to lack of time I have been unable to present code for the less powerful solution For a previe
30. of time they learn enough to program image processing algorithms So for various reasons the ease of understanding and getting access to a complex system is of high priority for us For this purpose our existing 32 bit Forth did not provide enough programming support and transparency So we conceived a new and object oriented Forth Within one half hour students learn enough Forth to program image processing algorithms The work was funded by the German Ministry for Research and Technology grant no BMFT AuT 01HK577 03 as part of the DIBA project Thanks to Maria Irene dos Reis Lourengo Kaierle for her work on the implementation An Object Oriented Forth The paradigm of object orientation has been around for quite a while but has recently received a lot of attention Apart from the hype it was even called the silver bullet to shoot all programming troubles itis a real advance for programmers in terms of structure clarity readability and thus useability of both the programming approach and the program code Forth s advantages are the interactivity of the interpreted language and the extensibility which allows the language to be fitted to a special application which make it suited for non expert users Moreover it enables you to test everything May 1992 June easily and directly via the keyboard which makes debugging easy Forth supports almost forces the method of factoring which greatly enhances the
31. ones I could have chosen as in other languages to write REPEAT or REPEAT begin end without using a REPEAT before the closing bracket While this is possible with very slight modifications to the presented code I found that readability and compile time error checking are greatly enhanced by specifying what is beginning and what is ending instead of asking the programmer to stack this in his brain If you try to program in C or Pascal you ll soon realize what I mean There isn tany real reason for selecting and foropening and closing symbols instead of and or and or and gt The motivations are mainly aesthetical or practical ones depending on the keyboard used American French Italian Swedish etc The choice to write xxxx xxxx instead of xxxx xxxx Or xxxx xxxx OF xxxx xxxx depends on the fact that the word xxxx could be written Forth Dimensions as xxxx CSbegin and that xxxx could be written as xxxx CSend In fact I am uncertain of which to select TIMES TIMES TIMES TIMES TIMES TIMES Actually the provided code allows TIMES TIMES butalso while discouraged TIMES and similarly WHEN WHEN as well as WHEN useable for very short WHENS So the and signs are read as begin and end while the spelling used is postfix When you indent vertically in my opinion TIMES TIMES reads better than
32. order as 10 20 3 END LOOP I LOOP That is 16 13 10 Implementation Preliminaries It s possible to implement the above set of control flow words in at least two different ways First is by using the usual Forth Dimensions I sms UI Q The Curly Control Structure Set words like BRANCH TBRANCH FBRANCH and similar tech niques Additionally an excellent idea appeared in the article LEAVEable DO LOOPs a return stack approach by George Lyons FORMI Proceedings 1952 page 132 It is a pity that sucha good idea hasn t been considered much in subsequent works Briefly that idea consists of compiling after the beginning of the control structure a pointer to the end of the control structure and to other relevant points like LEAVING etc Afterwards al run time when we enter a control structure we have to push the address of the beginning onto the return stack along with other things like the index and step values where applicable Then any word without need ee 23 of pointers compiled later can jump to the beginning of the control structure or by using the pointer compiled at the beginning can jump to the end or to other relevant points The above solution a little more refined is very powerful and provides really new possibilities likc the words AGAINS and LEAVES 1 LEAVES is like LEAVE 2 LEAVES leaves two levels of nested control structures 3 LEAVES leaves three
33. point Complete sourcc and help files Manual for V3 5 available separately iterns 350 amp 351 Base for other F PC applications Rou hard disk IBM 83 F PC TEACH V3 5 Lessons 0 7 Jack Brown C201a 2 Forth classroom on disk First seven lessons on leaming Forth from Jack Brown of B C Institute of Technology IBM F PC VP Planner Float for F PC V1 01 Jack Brown C202 1 Software floating point engine behind the VP Planner spreadsheet 80 bit rcp sem gp routines with transcendental functions number sopot vectors to support numeric co processor overlay amp user NAN checking IBM F PC F PC Graphics V4 2f Mark Smiley C203a 3 The latest versions of new graphics routines including CGA EGA and VGA suppport with numerous improvements over Der versions c or supported by Mark Smilcy IBM F PocketForth V 1 4 Chris Heilman C300 1 Smallest complete Forth for the Mac Access to all Mac functions files graphics floating pone macros create standalone applications and DAs Based on fig amp Starting Forth Incl source and manual MAC Yerkes Forth V3 6 C350 2 Complete object oriented Forth for the Mac Object access to all Mac functions files graphics floating point macros create standalone applications ncl source tutorial assembler amp manual MAC System 7 01 Compatable JLISP V1 0 Nick Didkovsky C401 1 LISP interpreter invoked from Amiga JForth The nucleus of the interpreter is the
34. program for example a finite state machine There are a number of states the machine can enter and a number of possible events that can occur This can be implemented by modelling each state as an object of class state where each object is supposed to react specifically to a message such as a key was pressed This behaviour could be achieved by means of a reaction table but there is a more elegant way which is an evolution of the concept of message passing OOF provides you with individual instance methods iim A default iim for all instances objects of the class is defined when the class is declared For every individual object a specific iim can now be declared which May 1992 June V creates the shallow state object active makes the shallow state object active act as if it were the state object idle Figure Four Using shallow objects in individual instance methods 7 Idle state key entering input state print now make input the active state end set limit and index variables V print the index value run will be the individual response to still the same message OOF code for this example might look like in Figure Two Shallow Objects In almost every language there is the notion of pointers A pointer is not an object itself but keeps only a reference to an object In Forth every address can be interpreted as a pointer to a data field The syntax for dealing with
35. pushes the OUT objects here s onto the stack restores the VM registers SFRAME SDELTA and OOFPC from the return stack and resumes where size was called Experiences with OOF and Future Work OOF was utilized to write a toolbox for graphical user interfaces for image workstations Since the OOF kernel will be finished real soon now we still have to gain experience about how the system behaves in terms of speed However early experiences about the impact on the style clarity and ease of writing programs in OOF are promising A very important lesson is that the way you tackle problems changes when using OOF You no longer think about some data structure in the beginning and then write lots of code manipulating it independently After having analysed your problem you try to build a hierarchy of classes that can represent the solution Here you use the well known techniques of factoring and decomposition which are May 1992 June Figure Eleven Parameter stack at entry of secondary size SBOTTOM bottom of stack not reachable by size Ee SFRAME stackframe stackentries of INPUT objects rr ee reserved space on stack Em domni TOS top of stack free stackspace already recognised good style in Forth and elsewhere Data structures and methods working on the data are tightly coupled now When you write a function in OOF first you have to consider to which object you wi
36. result of Martin Tracy s work Extended to allow the LISP interpreter to link to and execute JFonh words It can communicate with JForth s ODE Object Development Environment AMIGA 83 Pygmy V1 3 Frank Sergeant C500 1 lean fast Forth with full source code Incl full screen editor assembler and metacompiler Up to 15 files open at a time IBM KForth Guy Kelly C600 3 A full Forth system with windows mousc drawing and modem packages Incl source amp docs IBM 83 ForST John Redmond C700 1 Forth for the Atari ST Incl source amp docs Atari ST Mops V2 0 Michael Hore C710 1 Close cousinto Yerkes and Neon Very fast compiles subroutine threaded amp native code Object oriented Uses F P co processor if present Full access to Mac toolbox amp system Supports 6g 7 e g AppleEvents Incl assembler docs amp source MAC BBL amp Abundance Roedy Green C800 4 BBL public domain 32 bit Forth with extensive support of DOS mcticulously optimized for execution speed Abundance is a blic domain database language written in BBL Req hard disk cl source amp docs IBM HD hard disk reequired Volume 2 3 905 6 7 9 Tethered Forth model abstracts 1990 SIGForth conf Volume 2 4 906 6 7 9 Target meta cross an engineer s viewpoint single instruction computer Volume 3 1 Summer 91 907 6 7 9 Co routines and recursion for tree balancing convenient number handling Volume 3
37. shift instructions since the debugger simply announces them as ALU SH With the I command you can disas semble an instruction whose operation you are unsure of provided you have the manual of SC32 instruction formats handy D Provides quick access to a memory dump The de bugger will prompt you for the starting cell address and the number of cells to dump Q Executes an ABORT quitting the debugger and returning to Forth Entering any other charac ter at the execution steps will cause the debuggerto proceed with the next instruction Problems and Improvements Recognizing SC Forth Primitives Since the SC32 was de signed from the ground up to execute Forth and thanks to the optimization of the SC Forth32 compiler some of the more complex Forth primitives are compiled into DLOOP suem a series of obtuse SC32 in SHOTYPE Show instruction type structions For example if ITYPE Fetch it and select youencounterthe Forth word ISCALL z IE CALL DOinthe debugger you won t JADDR HISNAME Show word s name if possible see a call to the location of SSTACK Show the stack DO you ll see a series of SC32 USERIN Get user input instructions that load the re JADDR Get call s destination address turnstack with initial and ter Rs Execute the word minal loop index values ecu iota GUAE LIU LE ue VLL Actually the values loaded on Forth Dimensions 9 May 1992 June the retur
38. spending its time JForth also provides local variables that use the following style TYPE 2 addr cnt CNT 2 gt CNT ADDR CNT TYPE A new feature of JForth is support for IFF ANIM and ANIMBrush files This utility lets you load animation images from other programs to create animated displays The output of the Amiga can be plugged directly into a VCR for simple home video These and other features combine to create a powerful Forth based application development environment that offers a real alternative for commercial developers iz E HMSL schedule user written functions for repeated execution Collections can contain Players Jobs or other Collections and allow you to create a complex hierarchy of music objects HMSL supports standard MIDI files Thus you can use HMSL to algorithmically create sequences for use with other commercial music programs An event buffer provides low level scheduling of MIDI events and supports a text based Score Entry System Here is an example of a simple Score 1 4 C3 F 1 8 20 AAAA 1 2 _mf CHORD E4 G B CHORD HMSL provides a toolbox for building interactive screens out of control grid objects like check boxes and faders The Amiga version of HMSL uses JForth The Macintosh version has its own built in Forth HMSL pieces are generally portable between the Amiga and Macintosh versions A number of the other features of JForth and HMSL are mentioned in the
39. the stack they become the body DOES stops the action and sets the CFA of 3FOO to execute the Forth words that follow it at Point A These are not executed until phase three in which 3F00 is executed Line Four the address of its body is put on the stack and the Forth words at Point A are executed moving three Forth Dimensions 35 Forth words from the dictionary to the stack Using CODE Just as it is possible to substitute assembler for high level Forth by starting an ordinary definition with CODE instead of one can do the same for defining words by substituting CODE for DOES In the alternate definition on Screen One 3CONSTANT is rewritten in this way CODE is followed directly by the necessary assembler words and the definition is terminated by NEXT and END CODE with no semicolon Line Five As another example Screen Two we construct number machines The real ones look like rubber stamps but print sequence numbers Their Forth equivalent simply puts the next number on the stack Note that commands can precede CREATE We can specify that the machines reside in a vocabulary named MACHINES We could make all of them immediate by writing IMMEDIATE just before DOES What CREATE Does In the Forth 83 Standard CREATE will define a word that returns the address of the next available user memory location Hence if we write CREATE FOO and then ex ecute FOO an address is returned Most existing Forths fi
40. to a specific reference point code NegError error times is negative end code from assembly issue an error message macro MoNegativelimes lt CodeAddrOf NegError CCabranch macro if the condition code flags signal a negative value issue an error message macro OnlyPositive MoNegativeTimes if next then macro If the Cond Code flags signal a negative number issue an error If a they signal a number stop here without doing nothing else code LEAVES timesToLeave di pop OnlyPositive continue only if the times is positive di wtimes lt IPtoBegining IPbeg end RHesources amp HSrelease wtimes Unframe the return stack for timesToleave times next end code code AGAIN IPtoBegining next end code Continue from the begining of the control structure code AGAINS timesToAgain Resume execution from the begining of the dl pop OnlyPositive 1 di sub n th outer control structure di wtimes lt Hesources amp HSorelease wtimes So n 1 control structure frames IPtoBegining next must be unframed end code CodeAddrOf Qunframe releaser extra values 2 pointers frame next when we enter CONTROL or REPEAT we have only to make a control structure frame code SIMPLE It gets compiled by CONTROL or REPEAT end code n mcm SS a Forth Dimens
41. to the new control structure frame On the other side leaving the control structure involves the following actions 1 Using the CSF register recall the saved value of the IP pointing to the beginning of the control structure 2 Fetch the pointer compiled at the beginning of the control structure that points to the end 4 Set the IP register to point to the first word after the end of the control structure 4 Use the address pushed onto the return stack that points to the deallocating routine and jump to that routine Standard cases are handled by three very similar routines that deallocate the space used into the return stack along with the space occupied for extra data like the index step and backcounter Other control structures may have much more complicated un framing actions Ihe flex ibility provided by pushing an address of an un framing routine rather than a number of cells to deallocate is absolutely necessary for other control structures like RECOVERABLY TRACK and LOCALS Rationale for Name and Notation Choices The need to extend the set of control structures has been described in many previous articles What I ll describe here are the choices peculiar to the set of control structures proposed in this article The idea of using the same name at the beginning and end of a control structure simplifies both thc choicc of names when inventing control structures and their memorization by the user when learning new
42. 30 string textl If as a more elaborate example you want to handle images in your system you define the new class image You do not want to invent the methods anew for creation deletion or debugging methods of objects every time you define a new class So you let image inberit all these prop erties by declaring image a subclass of object the most basic class of all classes which already provides these properties object subclass image image is now defined as an object of the class subclass and at this moment has exactly the same properties as the class object The subclass image is now going to be extended in order to fulfill the purpose we defined it for For every image you need to know for example its dimension in x and y and how many bits are in a pixel These data are part of every object of the class image i e that is an instance of image Thus we have to define instance variables i e instance objects but instance variables in the typical nomenclature of object oriented languages in OOF it is abbreviated as IV of image i t image IV integer bits pixel image IV integer xdim ydim When you wantto declare two new images im1 and im2 you write image iml im2 using the general colon declaration Now you have two image objects each containing one set of the above defined
43. 340 18 19 25 Volume 1 814 5 15 16 18 KTX Pocket Scope eForth for muP20 ShBoom eForth for CP M amp 780 X MODEM for eFonh Volume 15 815 15 16 18 Moore New CAD System for Chip Design A portrait of the P20 Rible QS1 Forth Processor Q52 RISCing it all P20 eForth Software Simulator Debugger MISCELLANEOUS T SHIRT May the Forth Be With You 601 12 13 15 s ed size Small Medium Large Extra Large on orderform White design on a dark blue shirt POSTER BYTE cover _ 602 5 6 7 FORTH 83 HANDY REFERENCE CARD 683 free DISKS Contributions from the Forth Community The Contributions from the Forth Community disk library contains author submitted donations aee including source for a varicty of computers amp disk formats Each file is determined by the author as public domain shareware or use with some restrictions This library does not contain For Sale applications To submit your own contri butions send them to the FIG Publications Committee Prices Each item below comes on one or more disks indicated in parentheses after the item number The price of your order is 6 9 per disk or 25 37 for any five disks M o FLOAT4th BLK V1 4 Robert L Smith C001 1 Software floating point for fig poly 79 Std 83 Std Forths IEEE short 32 bit four standard functions square root and log IBM Games in Forth C002 1 Misc games
44. 6 No 6 Enhanced DO LOOP Michael Hore fallthrough 6 No 6 Techniques Tutorial YACS Henry Laxen 7 No 1 YACS part two Henry Laxen 7 No 1 Another Forth 83 LEAVE John Hayes 7 No 3 Improved Forth 83 DO LOOP Dennis Feucht 8 No 4 Second Take Multiple Leaves by Relay Richard Miller Cletter 8 No 5 Ultimate Case Statement Wil Baden Vol 12 No 2 Interactive Control Structures John R Hayes Vol Vol Vol Vol Vol Vol Vol Vol Vol Vol Vol Vol Vol Vol Vol Vol Vol Vol FORML Proceedings 1981 Unravel and Abort Improved Error Handling for Forth David Boulton 1981 A Generalized Forth Looping Structure Robert Berkey COUNTS RANGE Articles on Control Structures 1983 Error Trapping a Mechanism for Resuming Execution at a Higher Level Klaus Schleisiek 1982 Proposed Extensions to Standard Loop Structures Kim Harris and Michael McNeil 1983 User Specified Error Recovery in Forth Don Colburn 1984 Doubling the Speed of Indefinite Loops Michael McNeil 1984 An Improvement Proposal for DO LOOP Structure John Bowling 1984 Yet Another CASE John Rible 1984 Error Trapping and Local Variables Klaus Schleisiek 1985 Interpretive Logic Wil Baden 1985 Improvements in Error Handling Loring Cramer 1985 Error Handling Using Standard Compiler Directives Frans Cornelis definition of QUIT
45. 9 Sale or return CALL NOW FOR DETAILS Saelig Company European Technology tel 716 425 3753 fax 716 425 3835 Forth Dimensions many other routines Also available are string handling the application In the Forth environment any portion of 13 printer LCD keyboard or A D routine to determine fault conditions On board Forth is very useful during design and debugging but the ability to access individual software procedures in a finished product is invaluable This also saves writing lots of service routines often requested by servicing departments and frequently some options get forgotten requiring new routines to be written With on _ board Forth it s all there anyway Oe Thanks for the Memory The TDS2020CM is a useful module which sandwiches on top of the TDS2020 and allows storage of up to 8 Mbytes of non volatile data on industry standard JEIDA PCMCIA card memory including Flash types In an application this removable card can be brought back to base from field data collections and read in another TDS2020 or by a PC with a card memory drive Meanwhile the datalogger is storing information on a new card Datalogging for over a year on a single 9 volt battery is possible since the TD 2020 only draws 300 ha in standby mode A complete datalogging program is included with TDS2020 starter pack In addition to standard fig Forth 200 words are supplie
46. BUF C Line 5 DBUF CREATE DOES Line 6 0 DIRECTION NORTH Create game word NORTH and constant NORTH 3 DIRECTION EAST test forth north newstuff north forth SCREEN 5 Nested defining words ATTRIBUTE CREATE 0 DOES CREATE DUP DOES Gui ROT ATTRIBUTE COLOR COLOR RED SHAPE ROUND ATTRIBUTE SHAPE COLOR BLUE COLOR GREEN SHAPE SQUARE SHAPE OVAL 37 May 1992 June A Forum for Exploring Forth Issues and Promoting Forth Fast FORT UT ware In volume 13 of Forth Dimensions many FIG members requested more promotion of Forth Here and elsewhere we should tout the advantages of Forth Every cause has benefitted from promotion at times I think you ll agree that the promotion of Forth and FIG should extend to several areas One area is the promotion of trade or commerce For profit activity is ultimately what has kept us fed clothed and sheltered At some point in the development of an industry commerce also spawns trade magazines directed at fostering better informed trade amongst the producers and consumers in a particular industry Often user groups are born because of the widespread sale of one product Unfortunately for Forth the trade magazines do not serve Forth adequately although they seek an occasional Forth article Worse the number of people who are buying and selling Forth based goods and services is probably too few to fund a Forth dedicated trade magaz
47. CodeToInsert WHEN SomeCode2 WHILE CodeToInsert WHILE SomeCode3 WHEN SomeCode5 WHEN SomeCode4 WHILE SomeCode6 WHILE SomeCode7 xxxx WHILE SomeCode6 WHILE LEAVING CodeToInsert xxxx ma auium mn Does anyone have the ability to do benchmarks of various solutions Are modifications needed to achieve maximum performance How does this wordset compare to other solutions in Forth or more generally to the control structures of other languages Are there ideas to borrow from other languages If as is the case flexibility and freedom are the best characteristics of Forth let s use them to our best advantage And to conclude our story AUTHOR tired observing the reader Do you like all this READER thinking Hmm Have you got the code for this AUTHOR serious sure on the following pages Becoming impatient But tell me do you like it READER smiling Let me try my friend I ll try the code and tell you AUTHOR thinking silently Forthers are never satisfied very very strange people ADVERTISERS INDEX Delta Research ouoieensssiu exert ener 15 FOI DImensibs assisia 22 The Fon PSTD ou secco Miller Microcomputer Services 5 The Saelig Company 13 2 alo DOPmpOSBE Sus eise miren rares May 1992 June When the size is unspecified default is long B gt W gt L gt mean respectivelly byte move
48. D CTURI1 CTLRI get time till next image set hardware timer reg 1 NEXTIMG advance picture pointer ROCKET Turnkey task for launch INIT COLLECT Set pointers timer BEGIN MORE WHILE Outer Space loop POSITION CAMERA adjust camera if bob TIMEAPIC IF time for nth picture COLLECT IMAGE CCD image into SRAM COMPRESS IMAGE compress move to DRAM RELOAD TIMER wakeup call for next pic THEN REPEAT rest of images COLLECT REENTRY EARTH blocks DRAM 16384 SCSIWR more until reach earth Save data on SCSI drive 16K blocks 16MB 42 Forth Dimensions On THE BACK BURNER Demonstrating Competency Conducted by Russell L Harris Houston Texas Perhaps the most basic problem facing a Forth program mer is that of obtaining from a client unfamiliar with Forth authorization to use Forth on a particular contract The situation has been exacerbated in recent years by the unquestioning and near universal acceptance of C along with the methodology of object oriented programming A secondary problem is that of convincing the client that the programmer has the expertise to successfully complete the assignment The following paragraphs present one approach to surmounting these barriers Better vs Safe Programming assignments and contracts are not always won by the most talented programmer or by the one having the best tools and expert
49. DS was no longer needed but did not change the original action and spelling of DOES gt The action of defining words ranges from simple to complex Simplest are those that lack DOES At the opposite pole are highly specialized words for ex ample 1MI and 1AMI used by the F PC assembler to generate 80x86 commands Beginners carried away by a sense of power and free dom often create too many defining words Although there is little costin memory or execution speed doing this can result in hard to read source files Most pro grams need only the built in set of defining words and a few novelties Conclusion The easy formation of defining words is one of the features that makes Forth powerful and enjoyable At the basiclevel the technique is easy to learn and apply but programs are always better written when a pro grammer is aware of what is going on A deeper under standing is also required to creale specialized exten zm 2 sions which though not often needed can be very useful Leonard Morgenstem is a retired pa Ihologisl and computer hobbyist His interest in Forlh goes back over ten years Currently he is a sysop of the Forth RoundTable on GEnie His son David Morgenstern is also an author on compuler related subjects Forth Dimansions e H I MM s M M d
50. Defining words are based on the Forth construct CREATE DOES Beginners quickly learn to apply the method mechanically using two familiar steps 1 Start a colon definition write CREATE and follow by the actions that lay down data or allot RAM 2 Write DOES and follow by the action to be performed on the body of the word the address of which has been put on the stack by DOES Experienced programmers will please forgive certain oversimplifications Although the CREATE DOES pair is easy to use at this basic level understanding the details is hard because there are no fewer than three phases of action Words compiled in one are executed in another A simple example is 3CONSTANT which creates the six byte analog of CONSTANT Screen One It has two stack diagrams the first for creating an instance and the second for executing it The first phase is in effect when 3CON STANT is defined Line One It is a colon definition and works in the usual way that is sets up a header after which the CFA s of ordinary Forth words are compiled and immediate words such as DOES are executed The pro cess is ended by the semicolon In the second phase Line Three 3CONSTANT creates an instance named 3FOO The CFA s that were compiled in the first phase are now executed one at a me as follows CREATE picks up the next word in the input stream which is 3FOO and makes a header from it The commas lay down the top three words from
51. Forth Dimensions Type instruction Description Call 000 The SC32 places the return address on the return stack and jumps to the location given by the instruction s remaining 29 bits Branch 001 Same as a call instruction only the SC32 doesn t place anything on the return stack Conditional 010 If the SC32 s FL flag is zero this instruction performs branch a branch Otherwise the processor proceeds to the next instruction ALU shift 011 Executes a variety of arithmetic logical and shift operations depending on the remaining 29 bits Load 100 Adds an offset encoded in the lower 16 bits of the instruction to the contents of a designated source register The contents of the resulting address are loaded into a designated destination register Store 101 Adds an offset encoded in the lower 16 bits of the instruction to the contents of a designated source register The contents of a designated desunation register are stored at that address Load address 110 Adds an offset encoded in the lower 16 bits of the low instruction to the contents of a designated source register The result is placed in a designated destination register Load address 111 Adds an offset encoded in the lower 16 bits of the high instruction to the contents of a designated source register afler shifting that offset to the left 16 bits The result is placed in a designated destination register 11 into the dictionary Hence T
52. H J M P M ee SCREEN 1 JCONSTANT n3 n2 n1 n3 n2 n1 Line 1 CREATE DOES Point A DUP 4 SWAP 28 Line 2 12 3 3CONSTANT 3FOO Line 3 3FOO S Forth will display 1 2 3 Line 4 Alternate definition of 3CONSTANT using CODE 3CONSTANT n3 n2 nl n3 n2 nl CREATE CODE Point A POP BX PUSH 4 BX PUSH 2 BX PUSH 0 BX NEXT END CODE Line 5 SCREEN 2 NUMBER MACHINE CREATE 0 DOES DUP 1 ROT First alternate definition NUMBER MACHINE CREATE 0 CODE POP BK MOV AX 0 n uses CODE n BX INC 0 BX 1PUSH END CODE Second alternate definition puts all number machines in a special vocabulary VOCABULARY MACHINES NUMBER MACHINE n ALSO MACHINES DEFINITIONS CREATE 0 PREVIOUS DEFINITIONS DOES gt DUP 1 ROT SCREEN 3 MAKE 8 i a swap 8 CREATE INDEX1 1000 ALLOT MAKE B 125 B bit elements SCREEN 4 VOCABULARY GAME V Player s vocabulary CREATE DBUF 33 ALLOT X A buffer to hold the name MOVE DOES 8 Write game action here DIRECTION n BL WORD UPPERCASE COUNT DBUF PLACE Line 1 GAME DEFINITIONS DBUF CREATE DUP MOVE Line 2 FORTH DEFINITIONS Line 3 ASCII gt DBUF COUNT C Line 4 DBUF C 1 D
53. Have You Renewed Lately As a final note check to be sure you have renewed your FIG membership re cently This issue may have been sent as a courtesy even if your membership expired with the last issue We value your continued participation and are looking forward to an exciting year ahead So please don t let this issue be your last Marlin Ouverson Editor P S See our call for papers and contest announcement on page 22 Forth Dimensions Volume XIV Number 1 May June 1992 Published by the Forlh Interest Group Editor Marlin Ouverson Circulation Order Desk Anna Brereton Forth Dimensions welcomes editorial material letters to the editor and comments from its readers Mo responsibility is as sumed for accuracy of submissions Subscription to Forth Dimen sionsis included with membership in the Forth Interest Group at 40 per year 52 overseas air For membership change of address and to submit items for publication the address is Forth Interest Group P O Box 8231 San Jose California 95155 Administrative offices 408 277 0668 Fax 408 286 8988 Copyright 1992 by Forth In terest Group Inc The material contained in this periodical but na the code is copyrighted by the individual authors of the articles and by Forth Interest Group Inc respectively Any reproduction or use of this periodical as it is com piled or the articles except repro ductions for non commerc
54. IS BRAN Conditional branch 60000000 CONSTANT ISALUS ALU shift 80000000 CONSTANT ISLOAD Load A0000000 CONSTANT ISSTORE Store C0000000 CONSTANT ISLAL Load addr low E0000000 CONSTANT ISLAH Load addr high DECIMAL xk Improved dump rY Dump 16 bytes in hex starting at byte address baddr l6HEXBYTES baddr DUP 8 HEX R DECIMAL 16 0 DO I OVER C8 2 HEX R DECIMAL SPACE LOOP DROP Dump 16 bytes in ascii starting at byte address baddr 16ASCIIBYTES baddr 16 0 DO I OVER CR 127 AND DUP 32 Printable IF DROP THEN EMIT LOOP DROP ASCII Super byte dump from byte address baddr SDUMP baddr n CR BEGIN OVER 16HEXBYTES 4 SPACES OVER 16ASCIIBYTES CR M X d J aaa 16 DUP 0 WHILE orth Dimensions 7 uses the address stored in HISIP to determine the lo cation of the next instruc uon Consequently the portion of the debugger handling call instructions increments HISIP by one before exiting Unconditional Branch The debugger takes care of unconditional branch in structions by simply mask ing out the high three bits of t
55. LSE THEN Forth s main control structure hasn t been changed for several reasons Efficiency Code simplification if the IF THEN structure generated a return stack frame a LEAVE embedded in it would have the effect of leaving IF THEN instead of the outer control structure Presumed psychological resistance from individuals myself Forth Dimensions included to so radical a change The main reason for leaving IF THEN unchanged is the efficiency preserved Nevertheless many complaints have been raised about its counter intuitive syntax While any syntax becomes intuitive once it is learned the time needed Lo memorize a syntax depends on its relauonship to previous use usually spoken language New names for IF THEN that follow the presented syntax guidelines are THEN and THEN with the word IF acting like an optional comment word that doesn t compile anything So we could write IF 3 X gt THEN THEN which is equivalent to 3 X gt THEN THEN equivalent to the classic 3 xX gt IF THEN The syntax shown is probably more teachable than the old one But I resisted the temptation to rename it because my goal wasn t to offer new names for old words but to offer new possibilities in a coherent unitary frame Future Directions Ialready have some ideas of how to expand the presented control structure set but I am still experimenting with these extensions When they become more stable I will present them Me
56. May 1992 June 10 Volume XIV Number 1 e SILICON COMPOSERS INC Announcing the SC FOX DRAMIO32 Board e A e lle e 22a C ro C mh ee 70 e i ee 99 e eeeoeveeeeee cC Ul O C D ee D ai eeeeeoeoeoeoe eeeeeeeee eec ee eel ee ee ee ee ee et ee Jeo FI a s E e E e E E E lt E E g E B E E E E 6 Li Ule D24 e N 9 9 09 9 909 9 099 09 99 09 99099 9 9 0999909909999 U13 D8 U14 D16 H 97 9 09 9 09 099 9 9 9049 9 0909 99 9 90999 99990299 099 eeeoneoeee E EEEE EEEE E E E E E 099999 29 9 Ui6 DRAMCtI UIS DQ SC FOX DRAMIO32 Board actual size The DRAMIO32 is a plug on daughter board which attaches directly to either the SBC32 stand alone or PCS32 PC plug in single board computers Up to 16 MB on board DRAM 5 MB sec SCSI controller supports up to 7 SCSI devices 16 bit bidirectional parallel port may be configured as two 8 bit ports 4 Serial ports configurable as 4 RS232 or 2 RS232 and 2 RS422 Each serial port is separately programmable in 33 standard baud rates up to 230K baud 4 input handshaking and 6 output control lines 7 general purpose latched TTL level output lines 11 general purpose TTL level input lines with interrupts available on either transition 2 programmable counter timers may use internal or external event trigger and or time base Wristwatch chip
57. May 1992 June 20 Forth Dimensions Figure Ten Body ofa se con dary and paramete rstack d uring exec ution extractfrom I class self offset 0 EC CCE 0 d 20 bits pixel bis pixel pixels integer eee M BEC IN takes the offset parameter as an offset into the stack frame and copies the stack entry at that location to TOS effectively pushing the current input parameter im1 onto the parameter stack This is an example of the behaviour of shallow objects they do not appear on the stack themselves only the object they refer to BEC IV manipulates the stack entry on TOS as follows itaddsthe offsettothe of f set on TOS replaces class with integer and self with bits pixel The body object remains the same as explained above Now the instance object bits pixel of the input object is on TOS In order to push pixels onto the stack BEC LOCAL creates a new stack entry Then it takes the parameter offset as an offset into the stack frame subtracts it from the contents ofthe VM register SDELTA equal to the stack frame bottom of stack and places the result as the offset into the new stack entry The pseudo object SBOTTOM bottom of pa rameter stack becomes the new body class is set to integer and self is set to pixels The parameter of BEC IM is a token that rep
58. RACE becomes the first word executed by whatever word has just defined gt gt TRACE then executes so that the compiler enters the proper state at the end of A side effect is that words compiled after TRACEON are one cell longer than they would ordinarily be Now whenever the co lon defined word executes it immediately calls TRACE TRACE fetches the return address from the return stack and decrements that address by one cell The resulting cell address points to the body of the calling word and TRACE can unleash HISNAME described above to print the name field TRACEOFF simply un patches overwriting the call to 2 TRACE with a call to Thesource to the TRACE systemisshownin Listing Two May 1992 June Designing Software Controlled Devices Carol Goldsmith Victor New York When software is involved in product development the step of integrating hardwarc and softwarc is fraught with difficulty Sophisticated development systems emulators and logic analyzers exist to help the debugging process In the conventional approach to embedded system design a PC is used to write cross compile link and load code into emulation memory on the target system One iteration of the laborious and oft repeated edit compile link and load cycle can easily take ten or 15 minutes for a complex project This sequence must be enacted for one error in one line of code or many The agony really begins if the errors
59. SP SP L gt next end code M reset the stack to the level X it had when the error handler had been set May 1992 June 30 Forth Dimensions code WHEN flag d pop Uc if IPtoBegining fromBegMEXTto b eaving then next end code if the flag is true go to the LEAVING clause or if it doesn t exist LEAVE the C5 code WHILE flag d pop amp if IPtoBegining fromBegNEXTtoLeaving then next end code same as O WHEN macro Penter condition if 2 IP add next then 2 IP add compiles adda IP IP w add next macro a word pair beginner like WHEN has to decide if the code between X the word pair has to be executed or skipped If the condition is true we execute the code between the word pair code WHENT flag dO pop gt Penter end code code WHILE flag d pop Venter end code code OFC number to compare against index d pop index d cmp Yenter execute the pair code if the index end code equals the stack argument X Forth definition of WITHIN is WITHIN value lower upper over gt R R UC That means result Up low U lt value low If you design numbers on a circle in a counterclockwise manner X value is WITHIN lower and upper IF AND ONLY IF starting from lower and moving on the circle in a counterclockwise manner you find Value strictly before then Upper the starting position must
60. TIMES TIMES Furthermore locating the braces at the end of each word helps indicate that the beginning of the control structure is really outside the structure so that in a loop it is only executed once Likewise it helps indicate that the word compiled at the end of the control structure is inside the control structure so it is executed repeatedly About the name choices I haven t found anything better for CONTROL any ideas REPEAT and CASE are needed to maintain historical continuity FOR has been borrowed from the C language where it allows for the test of any condition and the execution of any operation The name FOR conflicts with the established use of FOR NEXT but I don t think that is clear either Wouldn t it be more appropriate as COUNT BACK or FOR PREVIOUS etc Nevertheless if someone has a better name to propose it is welcome TIMES is obvious and reads well WHILE has the same meaning as before and gains more flexibility WHEN is short and could be renamed as LEAVE for clarity but once used itis a good name In particular I think WHEN WHEN read very well COMPLETED is long and would be clearer if named JONCOMPLETION but I don t like typing so much JLEAVING means while leaving and sometimes but nol always could be named ELSE Name choices depend mainly on personal taste and the discussion could go on forever without being really construc live so here it ends IF E
61. XP plug on board A 64MB system can hold 1 024 gray Scale uncompressed 64KB images formatted as 256x256 8 bit pixels An application specific image compression routine can be used to increase storage capacity SC32 technology can also be used in the GSE station Data from the rocket telescope can be down linked to a PC based May 1992 June GSE system using the PCS32 Parallel Co processor System32 a PC plug in coprocessor board which uses the SC32 chip and supports the DRAMIO32 Data from the down link is routed through the DRAMIO32 parallel port and sent out the on board SCSI port to high speed SCSI devices such as optical disk tape or hard drive without going through the PC Once on the SCSI drive data can be accessed by any SCSI based system for analysis Software During project development the SBC32 DRAMIO32 flight hardware can serve as a development system by connecting it to a host terminal or PC for I O services When developing applications such as instrument control programming in Forth on 32 bit Forth hardware with high speed I O is a major advantage over other development methods Creating software in high level interactive Forth significantly speeds up development while running the application on a 32 bit Forth chip provides high resolution and performance High speed I O permits real time signal filtering data compression and encryption as data is acquired or transferred The code is tested and then placed in o
62. a variable Or we can use the predefined VARIABLE which is defined as VARIABLE CREATE 0 and write VARIABLE FOO The first method is preferred when only one instance is wanted as it avoids the overhead entailed in writing a defining word while the second is better when multiple instances are or might be needed What DOES gt Does DOES gt is immediate and is executed during phase one of a definition It lays down the word CODE and some assembler instructions Therefore if you decompile a Forth word that includes DOES gt you will see CODE fol lowed by the possibly undecompilable assembler in structions These will be followed by the address tokens of the Forth words that are to be executed in phase three CODE is actually executed in phase two It sets the CFA of the most recently created header to point to the assembler instructions At this point we can clarify the imprecise statements made in earlier paragraphs As a kind of shorthand it is convenient to attribute to DOES actions that are actually executed by CODE We also say that DOES gt makes the CFA of the word being defined point to the Forth words that follow DOES gt when it actually points to certain assembler instructions that precede them Don t confuse CODE and CODE The latter is a primitive laid down by both DOES gt and CODE It is conventional in Forth to name a primitive by enclosing in parentheses the name of the word th
63. ameter stack not only an address as in Forth but a complete object descriptor In order to speed up message passing the object number of the class of the object is added When primitive arithmetic or logical functions are executed it would cause an enormous overhead when a new object would have to be created each time a result is returned So in the stack entry there is a value field that can hold the result of operations on basic classes such as integer character or even float The com plete format of a stack entry on the parameter stack is shown in Figure Nine Because the description of an object is divided into a reference to the header and a reference to the body one Figure Seven Body of an image object offsets 0 4 body of instance object bits pixel 48 body of instance object xdim body of instance object ydim 19 aa _ _ May 1992 June Figure Eight Accessing the body of an object ree header can be used to de scribe many bodies This is the case for instance objects E g every time an image object is created its body contains the bodies of its object number of body three instance objects bits index in object table TT pixel xdim and ydim Figure Seven But a new header is created only forthe new image object there is no need to create a new header for each instance object The one header that was built during the d
64. an execute an instruction per clock cycle Furthermore since multiple Forth primitives can be combined into a single 5C32 instruction a PC532 oper ating with a 10 MHz clock can hit burst execution speeds of up to 50 MIPS On the software side the PCS32 is supported by Silicon Composers SC Forth32 a Forth 83 compliant system with 32 bit extensions added to harness the capabilities of the SC32 The PCS32 uses the host PC as an elaborate I O server the host PC gives the PC32 disk storage keyboard and video I O Working on a recent project I produced a massive amount of code on the PCS32 system As the number of words and their interactions grew it became obvious to me that some sort of debugger would speed the development process In spite of all my Forth coding abilities bugs inevitably crept into my work and the system would crash during a testing cycle A debugger would help me home in on the crash site more rapidly Unfortunately SC Forth32 included no debugger I had to build one The source code for the debugger is shown in Listing One Requirements My needs were not extravagant I didn t require breakpoints or multi step executions simply wanted a way to single step through a word s component instructions and watch the stack effects I also needed to be able to exit to Forth to check the states of variables I wanted the debugger to display at each instruction step the name of the word it was about
65. animation and 56000 based digital signal processing May 1992 June implemented a C like structure facility that automatically handles variously sized structure members Thus one can fetch a signed byte member or a 32 bit long member using the same S word Signed versus unsigned members and address relocation is also handled Here is an example structure definition plus some code to access it Define structure template STRUCT FOO LONG FOO SIZE APTR FOO BUFFER LONG FOO INDEX SHORT FOO SCRATCH STRUCT create a FOO structure FOO MY FOO TEST FOO index scratch MY FOO S FOO INDEX MY FOO S FOO SCRATCH If we use the JForth disassemblerto examine TEST FOO we will see that it built the following code BSR L MY FOO MOVE L 8 A4 D7 L D7 BSR L MY FOO MOVE W C A4 D7 1 D7 EXT L D7 sign extend RTS Notice that it used MOVE L for the ong member and MOVE W and a sign extension for the short member The top of the Forth data stack is cached in D7 so the results of the fetches are left there A4 is a register that points to the base of the Forth dictionary and allows us to build relocatable code JForth provides other tools including a Source Level Debugger with single step and multiple breakpoints The debugger also works with cloned images A code perfor Forth Dimensions mance analyzer in JForth will periodically interrupt an execuling program and gather statistics on where it is
66. anwhile here are some ideas to think about RECOVERABLY RECOVERABLY code to execute ONERROR error handler RECOVERABLY See provided code for more elucidations MULTILOOP Start stepQ startl stepl startN stepN times MULTILOOP MULT ILOOP Iterate a loop that takes a variable number of starts and steps and alany iteration moves all the indices together each with its own step The loop must be executed times IU IIl IZ etc IRACK Every word that allocates a resource e g files memory windows hardware etc must place into a stack variable or onto the stack an identifier forthe allocated object and for the deallocating routine Leaving the TRACK structure for any reason must have the effect of deallocating in addition to the return stack all the resources allotted within the above structure The LEAVE action may be executed as the result of a LEAVE WHEN WHILE or similar word or due to an error that happened inside a word called directly or indirectly within the TRACK structure Pay attention to the implementation of LEAVES and ERROR May 1992 June 1 No 3 D Charts Kim Harris 1 No 5 Case statement contest 1 No 5 Forth 85 Case Statement Richard B Main 2 No 2 Generalized LOOP Construct for Forth Bruce Komusin multiple WHILEs 2 No 3 Case contes 2 No 3 The Kitt Peak GODO Construct David Kilbridge 2 No 4 Case Statement Bob Giles letter 2 No 4
67. are interactive with the hardware the correction of one exposes another System debugging is often done via an in circuit emulator another expense that provides breakpoints and other software debugging support Ever wonder why project managers go gray at an early age Forth to the Rescue The solution familiar to most readers of this magazine but largely unknown to most designers is to include Forth Embedded control is a place where Forth can make a significant impact and become more widely known on the controller card giving users the ability to deal with code on a word by word or line by line basis interactively with the target system Forth s primary benefit for the developer is that it eliminates the middle man Both a language and a programming environment Forth can be developed and executed directly on the target system so there is no need for the traditional cross development system required by C or assembler Forth is interpretive and highly interactive giving developers the ability to proto type applications swiftly It offers the designer the unique opportunity to write test and run software in real time and avoid the time consuming steps of the edit compile test debug loop for each single modification On board Forth offers in one entity a real time programming language an operating system and a development environment The May 1992 June natural extensibility of Forth leads to application specifi
68. at compiles it Other examples include LIT etc Separating CREATE and DOES CREATE DOES are nearly always seen together but unlike the halves of a pair of scissors they can be useful when separated It is not well known that DOES can stand alone although it cannot be employed outside a colon definition When a word that contains DOES is executed regardless of whether it is part of a defining word or not the CFA of the last created header is set to execute the Forth words that follow DOES Screen Three shows how to define an indexed array with 125 eight bit elements by using an external DOES This trick is not often used because it is not often useful although Laxen and Perry did employ it in F83 It makes it possible to define words in groups for example pairs that vary slightly in spelling or words with the same name in May 1992 June different vocabularies This can be done in Forths for example F85 and F PC that factor CREATE into two parts one to get a string from the input stream and the other to create a new word from it In F83 for example CREATE is defined as follows CREATE BL WORD UPPERCASE CREATE BL WORD gets the string and places it at HERE leaving its address on the stack UPPERCASE converts it to capitals if the variable CAPS is set and CREATE a uses the result to form a new word Suppose that we are writing an adventure game in which we want compass directions t
69. aud the ANS standardization efforts that include these facilities One of the areas that Forth does not usually compare well with C is in the generation of small executable images We therefore added Clone which can generate standa lone images as small as 3K Clone starts at the top word in an application and disassembles its 68000 machine code then disassembles all the words called by that word and so on It then reconstructs an image without headers and with only the words and data needed by the application Eee We wanted JForth programmers to be able to call Amiga system libraries as easily as C programmers __ It also performs some optimizations made possible by the smaller image such as converting absolute subroutine calls to PC relative An executable image is then written to disk with an icon Clone able programs have a few restrictions related to storing addresses in variables at compile time These are easily handled however by using run time initialization or by using DEFER for vectored execution We wanted JForth programmers to be able to callAmiga system libraries as easily as C programmers To call Amiga system routines JForth uses a simple CALL by name syntax that automatically builds code to move parameters from the data stack to the appropriate 68000 registers Since the Amiga relies heavily on passing structures we Phil Burk is a co author of JForth and HMSL His current interests include electronic music
70. be checked first 50 lower value 10 upper zZ5 15 okay lower 23 value 23 upper 3 is okay X lower 10 value 34 upper 30 isn t okay lower 30 value 10 upper 1 is okay X lower 34 value 37 upper 30 is okay lower value 4 upper d isn t okay code WITHIN lower upper d lower dli index dZ upper index dl 1 d2 pop upper dO pop lower d dl sub d dz sub subtract lower from both index and upper di d2 Uc compare Yenter above line is equivalent to dl d2 cmp CC Fenter That means in forth pseudocode di d2 8 Uc Yenter end code The rawIM is used as subroutine the code is unneficient but doesn t matter code rawIN numi num numN N subject on d result on di di 1 d2 pop d2 contains the counter Loop on register dZ If at start dZ is the Loop isn t done d2 wtimes lt d2 times lt SP dO cmp SP edae 4 SP Q if 1 HH di L gt then if i di then wtimes times gt a jmp return from subroutine end code I a pop keep in a the return address code backIN numi num2 numN N subject flag group subject flag dO pop CodeAddrOf rawIN Absr di push next end code Forth Dimensions 31 May 1992 June IN subject numi num2 numN N flag subject group flag dup i pick backIN nip 3 Doing ROLL would have been unefficient code IN numi num
71. being available on GEnie Those messages also contain information on how to get UU encoded e mail copies of the same files There is an automated e mail service The entire FIG library on GEnie is available via e mail but no master index or catalog is yet available The file FILES ARC contains a fairly recent list of the files on GEnie and files added since then are only documented for comp lang forth readers by way of the Files On line messages ported through ForthNet If you have any questions about ForthNet comp lang forth or any information to add delete or correct in this message or any suggestions on formatting or presentation please contact either Doug Philips or Gary Smith preferably both but one is okay via the following addresses le Internet dwo willett pgh pa us or ddi1 irark gars uunet uu net Usenet uunet ddi1 lrark gars or uunet willett pgh pa us dwp eGEnie GARY S or D PHILIPS3 ForthNet Grapevine Gary Smith leave mail in Main Conference 0 To communicate with the following set your modem and commu nication software to 300 1200 2400 baud with eight bits no parity and one stop bit unless noted otherwise GEnie requires local echo half duplex GEnie For information call 800 638 9636 Forth RoundTable ForthNet Call GEnie local node then type M710 or FORTH SysOps Dennis Ruffer D RUFFER Leonard Morgenstern NMORGENSTERN Gary Smilh GARY S
72. bleMids CELLS 1 CELLS 2 CELLS ecc structure the above structure is tied to structure beginer words like CASE TIMES ecc the field gt BegToken contains the token of CASE or TIMES or what is the case the field gt BegStarter contains the token of the word to compile at the structure begining SIMPLE INDEXED TIMES See figures 3 and 4 The field gt BegEnder contains the token to compile at the control structure end words like LEAVE AGAIN TIMES LOOP The field gt Beg Pointers contains the of pointers to reference points to compile at the control structure begining The field gt BegApplicableMids is a bit Array that specifies wich clauses like LEAVING COMPLETED ONERROR ecc are applicable to the considered control structure gara ut m um uin ur FF un amp tructure midjtisStructure cell midMask cell gt midPointerOffset cell midEnder structure The above structure is related to the clause words like JLEAVING JCOMPLETED ecc the midMask field contains a bit array with the bit associated to the clause word on The field midPointerOffset specifies the offset 4 for LEAVING and for COMPLETED of the pointer at the begining of the control structure See figure 3 and 4 variable Beg variable CSbegining variable ender Tree variables to hold the token of the start word of the last control structure under construction the address of the begining of the control structure and the tok
73. c words that are self documenting as they are used Engineers using Forth can design words to suit their specific work Embedded control is definitely a place where Forth can make a significant impact and become more widely known Compilation occurs one word at a time on the target system itself Each Forth word can be tested as soon as it is entered if it does not produce the desired result you can quickly change the word and recompile This encourages thorough testing of each piece of code as it is written In contrast C and assembler have long edit compile or assemble link and load cycles that make it difficult to test fragments of code Debugging can t start until most of the framework is in place Incremental testing speeds project development because there is a higher probability that the design will work the first time Not at all Tedious Two economical and easy to use controllers which offer extensive on board Forth are the TDS2020 and the TD59092 from The Saelig Company Victor NY Well known in Europe and becoming recognized in the U S A and Canada these boards from Triangle Digital Services Ltd of London U K have been sold worldwide in their thousands Both of these nearly pin compatible 4 x 3 boards provide a complete Forth design environment the TD52020 operating at 20 MHz comes complete with eight channels of A D and the slower and cheaper TDS9092 runs at 1 MHz more suited to simpler control situati
74. ce Application of SC32 Forth Chip Silicon Composers for RIME network Forth access to appear soon He Departments x rait claudat GNI EE E ses Slee Se ane aa es 4 Editorial New in FD call for tutorials time of renewal Letters nerna No commerce no Forth ideal time for an end run ten Forth commandments 27 Advertisers Index 38 39 Fast Forthward Promoting trade product watch vendor spotlight 40 41 reSource Listings Revised and expanded On line Resources extensive listings 43 On the Back Burner Demonstrating competency Forth Dimensions d May 1992 June felit niic So What s New Welcome to a new vol ume year of Forth Dimen sions To commemorate this new beginning we have been preparing in con junction with our talented and dedicated contributors an infusion of fresh material On the Back Burner a new department is engincer Russell Harris forum for hardware software projects that readers can build and program Its intent apart from the enjoymentandeducation inherent in building pro grammable devices that work is to offer proof e g to prospective employers and project managers that Forth and the programmer can get the job done The clever gizmo from the World s Fastest Programmer contest several years ago is but one example of the genre Russell s first installment Demonstrating Compe te
75. certain number of cells here swap cells allot here cell DOold Iold cell OFold 3 X The use of the subsequent word is like X create CONTROL CONTROL SIMPLE LEAVE Mids LEAVING Mids Begls BegIs dataToFillBegStructure 5 cells immediate does gt comp Begloken 6 CSbegin compile the 5 structure parameters declare immediate the structure beginer previously created and declare it to DO the code after does e M E m M M M M B EA MH enderis correspondingBeg name IS create immediate does comp Beg lt gt 7 abort Ender doesn t maches Beg CSend declare a control structure ender word associated to the beginner 3 comp CSend immediate Generic ending word to be used with any control structure start or leaving pair Clause words as LEAVING and jCOPPLETED have a certain bit number associated When we define a CLAUSE word we must allot the next free bit number for the clause When executed a clause during compilation it must check that we are into compile state check that the CLAUSE is applicable to the actual control structure check that it hasn t been already used it must compile the ender token set by the control structure beginner it must set the associated pointer compiled at the control structure begining point to HERE and finally it must set it s own ender variable midFreeMask 1 midFreeMask mid
76. clarity of programs and thus the programmer s productivity and content Our main interest is to work with a programming language that supports fast and easy understanding and debugging and thus allows rapid prototyping of user interfaces by both engincers and on a higher level by psychologists OOF strives to achieve this by combining the best of both worlds by extending Forth following the paradigm of object orientation in a strict sense It provides all its amenities such as security inheritance and late binding This is achieved by strictly adhering to the concepts of data encapsulation strong typing and message passing rather than direct procedure calls The system still has a small kernel that performs everything from interpreting to compiling the source code in a simple but smart fashion The principles of OOF and their consequences are best explained by examples The use of OOF is therefore described step by step from simple definitions of objects to the creation and extension of classes and methods explaining T E AaS rr sss eee the nomenclature and buzzwords of object oriented lan guages en passant Here s How Everything in OOF is an object Every object is an object of some class e g integer or character it consists of a data field and a set of methods to manipulate the data For example when you want to create an integer object start or two character objects c1 and c2 you write
77. cts ask for input advise the Forth community or simply share a recent insight Code is also welcome but is optional Letters may boe edited for clarity and length We want to hear from you No Commerce No Forth Dear Fditor If there is no commercial Forth no commercial hype and no commercials there is no Forth I would like to hear about the activities of the firms who use Forth for their livelihood or who provide Forth development systems for a fee If such firms succeed Forth will also if FIG s aim is to promote Forth then it must promote those who use it Fortb Dimensions is a bit of a bore lots of articles on ideas that have little to do with commercial reality Charles Esson CVS 11 Park Street Bacchus Marsh Victoria 3340 Australia Ideal Time for an End Run Dear Marlin Forth does what no other language can do It allows the user to map his or her working environment to a computer in a direct and consistent fashion This allows the user to i not too often be invented 10 Forth Commandments by Tom Napier North Wales PA 0 1 These commandments are not carved in stone thou mayst change them if thine application demandeth 2 He who changeth these commandments shall not do so lightly and shall document the change in his program 3 Thoushalt put thine application into words and these words shall be thy program 4 The lord Moore has given thee many of the words of thy pro
78. d with the TDS2020 for simplifying tasks such as data logging key pad and LCD control stepper motor driving interrupt control etc The TDS2020 starter pack is 499 and the TD 9092 starter pack is 249 in stock from The Saelig Company 716 425 3753 fax 716 425 3835 Carol Goldsmith is the Sales Manager for The Saelig Company making a DATALOGGER CONTROLLER amp DATA LOGGER 8ch 10 bit 20 MHz 3 MIPS Store data on 4M JEIDA cards Easy use keyboard lcd 33 X I O 2 x RS 232 ports 300uA data logging Lots of ready made software solutions free Program with PC CALL FOR DETAILS 369 25 s Saelig Company tel 716 425 3753 fax 716 425 3835 May 1992 June JForth A 32 bit Subroutine Threaded Forth for the Amiga Phil Burk San Rafael California JForth falls into the category of big Forths We at Delta Research believe that Forth development systems should offer the same facilities that C programmers enjoy While minimal Forths are perfect for small embedded systems they are inappropriate on larger computer systems We feel that one of the reasons Forth has not sold as well on large systems is because many Forths adhere to a minimalist philosophy We feel that Forths for large systems should have all of the file I O routines memory allocation floating point complex data structures and other tools that are standard in competing languages We appl
79. derIs FOR create TIMES TIMES TIMES TIMES Mids jLERMVING SCOMPLETED Mids BegIs TIMES EnderIs TIMES create LOOP LOOP LOOP LOOP3 Mids JLEAVINGC jJCOMPLETEDC Mids BegIs LOOP EnderIs LOOP create RECOVERABLY RECOVERABLY RECDVEROBLY LEAVE create WHEN WHEN C WHEN LEAVE Mids Mids BegIs WHEN EnderIs WHEN create WHILE WHILE WHILE LEAVE Mids Mids Begis WHILE EnderiIs WHILE Mids LEAVING JONERROR Mids BegIs RECOVERABL Y EndercIs RECOVERABL Y create ON ONC ONC LEAVE Midsi Mids Begis ONC EnderIs ON create IN ING INC LEAVE Mids Mids Begis INL EnderIs IN create WITHIN WITHIN WITHING LEAVE Midst Mids Begls WITHIN EnderIs WITHIN May 1992 June 34 Forth Dimensions TUTORIAL Working with Create Does gt Leonard Morgenstern Moraga California It has been well said that programs are not written in Forth Rather Forth is extended to make a new language specifically designed for the application at hand An important part of this process is the defining word by which one can combine a dala structure with an action and create multiple instances that differ only in detail One thinks of M MQ M r 7 i EI Lln DOV n a cookie cutter all the cookies are the same shape but have different colored icing The Basics
80. dex starting value predecrement the backcounter value SN SS ee code LOOP IPtoBegining step d L gt d index add go to the control structure start 1 counter sub TCompleted Add the step to the index decrement end code the backCounter check it ecc code RECOVERABLY CodeAaddrOf RECOVERABLYRelease releaser 3 extra values 3 pointers frame lastErrorCSF ApcI amp lea Save the old value of the variable oldErrorCSF AD i oldError CSF 15 v on the return stack as an extra value SP oldSP 1 Save the Stack pointer position on the RetStack CSF AD 1 Set the new value of the oldErrorCSF point to the actual index clr next return stack frame Set the initial value of the index end code to The index counts the times an error occured until now code ERROR repeat lt lastErrorCSF Apcl CSF cmp lt gt while X Unwind the return stack to Resources amp RSrelease repeat gt reach the more recently 1 index add IPtoBegining fromBegNEXTtoOnerror set error handler and end code start executing the ONERROR clause code ERROR flag Do Error if the flag is dO pop CodeAddrOf ERROR CCabranch next true end code code ErrorPropagate BackPropagate the error to Resources amp 8RSrelease always CodeAddrOf ERROR CCaBranch the previous error handler end code code StackMark SP oldSP L gt next end code code StackRestore old
81. efinition of the class image for each instance object describes the nature of the instance objects completely OUT and LOCAL objects of a secondary are treated similarily every time a secondary is entered only space for the bodies of these objects is allocated on the b parameter stack no new header is created So in most cases L no new header is constructed for new objects This saves object numbers si n considerable amounts of both time and memory space Additionally it turns out access to the body of an object object descriptor is accelerated a great deal because there is only one u mechanism to arrive at the body address No testing of flags L3 di or considering of special circumstances at run tme which takes longer than it takes to actually access the Object Table are necessary The latter is especially important for the primitives which should be as fast and efficient as possible Once again the principle of simplification by generaliza tion proves useful Here it saves space and ume when crealing new objects and simplifies and therefore speeds up access to the body of an object The next paragraph describes how the appropriate stack entries are composed according to the special nature of each object 0 table array of memory addresses start of block E i body of e g an l instance object P have to test flags or search for its parameters somewhere else Since lots of kilobytes of memo
82. eld print it baddr Get count Anything there has undeflowed SSTACK DEPTH 0 IF Underflow ELSE 9 THEN SHONAME DUP C8 127 AND DUP IF 0 DO F This won t bomb if the stack 1 DUP C 127 AND EMIT LOOP SPACE THEN DROP S n er a uo ome a a 0 S Given the cell addr of a code field do your best to locate the associated name field and print it Works in most cases HISNAME addr BYTE Convert to byte address 0 Start a counter BEGIN SWAP 1 DUP C 127 AND Don t increment DUP 32 lt gt IF 32 x IF DUP CQ 127 AND 2PICK IF SWAP DROP SHONAME EXIT THEN THEN SWAP 1 ELSE DROP SWAP THEN DUP 33 UNTIL 8 Fetch a character Null Printable Fetch it again Equal to our count We got it Go home Increment counter Name can t be this big c d P S 2DROP tQ Forth Dimensions P MrP ee B Display the current instruction type SHOTYPE ITYPE SELECT CASE ISCALL OF CALL BREAK CASE ISBRAN OF BRANCH BREAK CASE IS BRAN OF BRANCH BREAK CASE ISALUS OF ALU SH BREAK CASE ISLOAD OF LOAD BREAK CASE ISSTORE OF STORE BREAK CASE ISLAL OF
83. en of the word to compile at the end of the control structure like LEAVE AGAIN TIMES ecc May 1992 June 32 Forth Dimensions BegAddr addr Beg body Give the address of the Begstructure associated with the last control structure Keep amp NewValue addr OldValue dup gt r r gt Store a new value into a variable holding the old one on the stack Ofspoints offset of pointer addr to point Set the pointer compiled at the start CSbegining swap CSbegining w of the control structure to point to the specified address LEI ofspoints offset of pointer flag Does the specified pointer point CSbegining we 1i already somewhere CSbegin Begloken given the token of the control structure beginner gt body gt r re BegToken G Beg KEEP amp set the Beg variable accordingly re gt BegStarter token compile the associated starting word r gt Beg pointers DOold 1 w LOOPold set to 1 the initial pointers here CSbegining KEEP amp set the Csbegining var to point here r gt BegEnder ender KEEP amp set the ender variable r gt drop CSend ender token Compile the ender token 2 end of structure here ofsPoints make the pointer to end point point to the end ender CS5begining Beg Restor the old values of the 3 variables cells values values cellsToCompile compile a
84. ent and describes the use of two on board Forth controllers offered by that firm 14 JForth 32 bit Forth for the Amiga Phil Burk The co author of JForth advocates big Forth for big microcomputer systems and his company s Forth offers such an alternative applications development environment Also discussed is HMSL the hierarchical music specification language extension 16 Object Oriented Forth Markus Dahm From a European group that develops workstations for medical imaging comes this description of their Forth The principles and benefits of its object oriented design are discussed including performance considerations Searching for a set of control structures with good performance ease of use generalization flexibility and teachability without sacrificing foo much historical continuity The code examples and text given here conclude the discussion begun in our last issue 35 Working with Create Does gt Leonard Morgenstern This word pair trips up many who are learning Forth The basics of writing a new defining word are demonstrated for the hesitant more advanced uses for the bold and a caution is 23 The Curly Control Structure Set Kourtis Giorgio given to the over confident Developing acquiring data from and controlling a suborbital solar telescope via a system configured around Silicon Composers C32 Forth RISC chip Using a single on board computer reduces complexity and development time 42 Spa
85. er from run end run do to to 1 end from integer run print loop Non object oriented languages such as Forth call methods directly they compile the address of the code to be executed OOF instead sends a message to the object on top of the stack CTOS In its essence a message is the name of a method to be called When a message is passed to the object O on TOS a method of that name is searched at run time in the list of all methods available for objects of O s class When it is found the method is executed if not an error method is called This ensures that only valid code meant for objects of the given class is run This mechanism also makes it possible to have the same message sent to objects of different classes where different methods of the same name are calied This property is called polypmorphism It saves inventing new names e g print_integer print_string etc for the same function print an object applied to objects of different classes In particular it enables you to send the same messages that can be sent to objects of class C to objects of all subclasses of C that in herited the methods from C Methods for Individuals Instance methods of a class have the same effect on every object of that class which is very desirable for consistency But sometimes you want to have different objects of the same class to react differently to the same message This is very useful when you want to
86. erminism Revisited Kurt W Luoto 1981 Comprehensible Conuol Structures Howard Jr Goodell new syntax 1982 Non Immediate Looping Words 1982 LEAVEable DO LOOPs a Return Stack Approach George Lyons 1983 Modern Control Logic Wil Baden May 1992 June 26 11 86 Extended Control Structures Wil Baden letter Miscellaneous Sources Adding GOSUB to Forth Michael Ham Computer Language 4 86 A Fas and Versatile Control System Using High Level Program ming 1 Ohel Motorcon 81 Conf Extensibility with Forth Kim R Harris Proceedings of the West Coast Computer l aire date n a Data Structures Issue James Basile Journal of Forth Application and Research Vol 2 No 1 Wm DURER Forth Dimensions Figure Seven XXXX SomeCodel WHEN SomeCode2 WHILE SomeCode3 WHEN SomeCode5 someCode4 someCode Figure Eight A as Such an error besides resuming execution at the level of the first error handler above the TRACK structure will also have the automatic effect of deallocating the resources allotted within that structure without leaving open files unused memory etc In addition if the TRACK word is reached resources still left intact will be deallocated auto matically LOCALS The locals solutions can be viewed at the internal of the control structure frame The syntax could be xlo Lt ABC COE L Conclusions I hope to have shown that
87. essor with plenty of horsepower and flexibility suitable for a wide variety of tasks ranging from real time control to high speed data compression The system software resides in 128KB of on board shadow EPROM which is loaded on power up into on board zero wait state SRAM maximum of 512KB The DRAMIO32 Board is designed for use in applications requiring high speed data acquisition or control capabilities The DRAMIO32 has up to 16 MB of DRAM a 16 bit bidirectional parallel port 4 serial ports SCSI port 2 timer counters wristwatch chip and CMOS RAM For the solar telescope application the DRAMIO32 s four serial ports are used to acquire control data from and send servo control commands to the telescope pointing optics filtering and control and mirror adjustment subsystems The observation light beam is reflected to the telescope s CCD camera via servo control using parallel handshake bits and a counter timer on the DRAMIO32 board Solar image snapshots are initiated at pre programmed times Solar image data is read from the 16 bit parallel port and written into 16 MB of on board battery backed DRAM Once the rocket telescope payload is recovered mission data can be transferred from the DRAM to a second SBC32 DRAMIO32 system or other system by way of the DRAMIO32 s ports Alternatively image data can be down linked from the DRAM to a GSE Ground Support Equipment station Up to 48 MB additional DRAM can be added with the DRAME
88. f applications in Forth Arepa are a compilation of the papers and abstracts presented at the annual conference FORML is part of the Forth Interest Group 1980 FORML PROCEEDINGS 310 30 31 40 Address binding dynamic memory allocation local variables concurrency binary absolute amp rclocatable loader LISP how to manage Forth projects n level file system documenting Forth Forth structures Forth strings 1981 FORML PROCEEDINGS 311 45 48 55 CODE less Forth machine quadruple precision arithmetic overlays executable vocabul stack data typing in Forth vectored data structures using Forth in a classroom pyramid files BASIC LOGO automatic cucing language for multimedia NEXOS a ROM based multitasking operating system 1982 FORML PROCEEDINGS 312 30 31 40 Rockwell Forth processor virtual execution 32 bit Forth ONLY for vocabularics non IMMEDIATE looping words number input wordset I O vectoring recursive data structures program mable logic compiler 1983 FORML PROCEEDINGS 313 30 32 40 Non Von Neuman machines Forth instruction set Chinese Forth F83 compiler amp interpreter co routines log amp exponential function rational arithmetic transcendental functions in variable precision Forth portable file system interface Forth coding conventions expert systems 1984 FORML PROCEEDINGS 314 30 33 40 Forth expert systems consequent reasoning inference engine Zen floating point portable graphics w
89. fore I propose that the Forth community do an end run around other programmers This maneuver would have two stages In the first stage using ANS Forth we build a graphic and possibly object based Forth Instead of using graphics to hide the machinery of Forth we use the graphic interface to make the simple Forth machinery visible accessible and understandable Users will be able to assemble small Forth pieces into their own applications and will learn to modify their environment as they get more comfortable This environment is ported to Macs DOS OS 2 and Unix machines allowing the user to operate in the same way and with the same environment on all of the operating systems The second stage builds on the first stage using the Forth chips now available to build expandable Forth computers that run this environment quickly and more efficiently than existing machines can run it Since Forth lends itself to multitasking and multiprocessing a basic unit with one Forth chip could be bumped to say four or eight chips as more power became necessary The additional chips would be have as coprocessors or as dedicated I O devices They could be both since they can be switched from one type of task to another by changing the software they run Now is an ideal time to pursue this approach The new wave of consumer clectronics provides a lot of opportunities to make inroads into the non programming world The multimedia devices that are being
90. g Forth is the important exception follow this rule as does the ANSI draft standard Differences derive from the fact that each implementation interprets the next available memory location in its own way For example in F83 the dictionary is confined to a 64K space and the address returned by FOO immediately follows the CFA In F PC header and body are in separate spaces called the head segment and the code segment respectively and FOO returns an address in the latter The ANSI draft standard adds specifications as to alignment The casual user need not be concerned with these details because words that allot memory such as comma C and ALLOT itself automatically do so in the proper place namely at the first available memory location It is worthwhile to comment here that one should not use 2 to go from the code field to the body of a word It will work in F83 but may not in other versions Porting from one Forth to another is never easy and a shortcut of May 1992 June this kind merely aggravates the problem The correct word is gt BODY CREATE can stand alone either inside or outside a colon definition without an associated DOES gt and is so used when the word to be created merely returns the address of its body for example variables and non indexed arrays Thus we can write CREATE FOO and follow it with 0 When FOO is executed the address of the zero will be returned so the action is the same as
91. gram and the re mainder shalt thou create 5 Thou shalt use no word in thy program before that word has been defined 6 Thy parameters shall precede thine op erations and thine operations shall remove their parameters from thestack 7 Thou shalt be sparing in thy use of the return stack and shall at all times keep it balanced lest thy program depart for the land of thy fathers 8 There shall be no goto foundin thy code Thy program shall use if else endif counted loops repeat while and re peat until 9 If thine application needeth a structure or adatatype which does not exist thou maystcreate anewstructure or datatype 10 Thou shalt tell thy fellow programmers what new structures and data types thou hast created that the wheel shall Moduli 4 n Forth Dimensions J ee te FAN cee ge ST 3 6 4 r 1 AR ag PEIS e 4 al OT OITO D t Bi B 2 hy a a PA T tM s Bis 3 4 A El A e s i IICRn On fov pow 95 e DIN ELS yn FA 3 Syste 00 gt 2 VA m 4 Pez at L AT MES TYAN ST S A solve problems using familiar models and terms This is of litle or no value to professional programmers They prefer C and C because they recognize this language no matter what the environment or problem That is why they do not and will not usc Forth However using familiar terms in a familiar environment is very valuable to everyone else There
92. greatly outweigh the expenditure for programming Likewise once a budget has been authorized and a schedule has been set the programmer may receive little ifany reward for early completion From the standpoint of the client the best insurance against a missed deadline is to select a programmer and a language both of which he personally knows to have produced serviceable code within reasonable time on a project of complexity comparable to that of the project at hand Shock Therapy or Back to Reality Something more than a resume listing past projects is required if the Forth programmer is to overcome the contemporary mind set of C and object oriented program ming and bring his client back into a state of objectivity regarding Forth He must convincingly demonstrate the capabilities of Forth the maintainability of programs written in Forth and his mastery of the art of programming and he must Forth Dimensions Os 43 the first place apparatus be it basically mechanical electri cal or virtual i e a screen image in nature almost always draws attention In the second place apparatus provides a concrete example of technique Finally Functioning appara tus proves capability Computerized apparatus programmed in Forth can attract and hold the attention of a client thereby affording the programmer opportunity to demonstrate his own effective ness and the effectiveness of Forth Source listings which ex
93. gular Forth Dimensions column serving as a Clearinghouse for the exchange of ideas and technical assistance regarding computerized apparatus for demonstration or other purposes The continuation of this undertaking will depend largely upon reader response What I as editor of this column hope to receive is a variety of submissions ranging from verbal descriptions and conceptual sketches to dimensioned draw ings schematics source code and photos of working devices together with suggestions criticism and feedback regarding specific devices and the column in general Material for publication may be sent directly to me at 8609 Cedardale Drive Houston Texas 77055 I can be contacted by phone at 713 461 1618 during normal business hours and on most evenings or on GEnie RUSSELL H Russell L Harris is a consulting engineer working will embedded systems im the fields of instrumentation and machine control He programs in polyForth types on a Dvorak keyboard and keeps his wristwatch set to Greenwich time May 1992 June 1992 Rochester Forth Conference on Biomedical Applications June 17 20th 1992 University of Rochester Call for Papers Invited Speakers The Conference There is a call for papers Dr C H Ting Applied Forth seminars on all aspects of Forth tech Biosystems Inc beginner through nology its application and Human Genome and advanced implementation but espe Automation FIG Demonstration of cially as relates to bi
94. he instruction thereby leaving only the jump s des tination address The un conditional branch handler then places this address in HISIP and passes back to the start of the loop Conditional Brancb On the SC32 a condi tional branch instruction will take the branch if the FL bit is set to zero This is a proces sor flag that can be modified by ALU shift instructions Consequently for the debugger to know whether a conditional branch should be taken or stepped over it has to simulate the setting of the processor s FL bit I accomplished this by creating a machine code in struction called GFLAG for get flag that places the contents of the FL bit on the parameter stack After the debugger executes any in struction in the target code that may affect FL it calls GFLAG and stores the pa rameter stack in the variable HISFLAG So when the debugger encounters a conditional branch it simply examines the contents of HISFLAG If HISFLAG is zero the debugger treats the instruc tion as an unconditional branch and the branch is taken Otherwise the debugger merely increments HISIP by one to skip to the next instruction May 1992 June Everytbing Else The debugger executes all other instructions arith metic logical shift and load store as is It does this by fetching the instruction pointed to by HISIP and placing that instruction in line The fol lowing is the SC Forth32 code fragment for doing this
95. hibit orderly arrangement functional grouping and intui tive names can dispel qualms regarding code maintainability The overall appearance of the demonstration is perhaps the best indication to a client of the programmer s ability to bring to completion on schedule the project under consideration Attention to detail is vital Confidence in the programmer s reliability can be severely eroded by poor workmanship by program bugs or quirks no matter how minor and by source code which is abstruse The apparatus need not relate to the project under consideration It should perform an obvious function of some complexity Ideally it should allow demonstration of the manner in which the interactiveness of Forth facilitates the development cycle Effective Yet Practical Mechanisms A demonstralion mechanism for maximum effective ness should be elegant functional and attractive yet practicality usually demands that it be both simple and economical to construct Ideally the complexity of the mechanism including the electronics should be no greater than necessary to support the programming demonstration so that the mechanism spotlights the code rather than overshadowing it Although demonstration apparatus frequently has no intrinsic usefulness it should be possible to devise a number of useful mechanisms which are simple cnough to be practical in this role A Clearinghouse This is the first appearance of what is intended to be a re
96. ial pur poses without the written per mission of Forth Interest Group Inc is a violation of the Copyright Laws Any code bearing a copyright notice however can be used only with permission of the copyright holder The Forth Interest Group The Fonh Interest Group is the association of programmers man agers and engineers who create practical Forth based solutions to real world needs Many research hardware and software designs that will advance the general state of the art FIG provides a climate of intellectual exchange and benefits intended to assist each of its mem bers Publications conferences seminars telecommunications and area chapter meetings are among its activities Forth Dimensions ISSN 0884 0822 is published bimonthly for 40 46 52 per year by the Forth Interest Group 1330 S Bascom Ave Suite D San Jose CA 95128 Second class postage paid at San Jose CA POSTMASTER Send ad dress changes to Forth Dimensions P O Box 8231 San Jose CA 95155 J HI H BBRE M p e M A i HP T H S M MM M D H E 1Q n a Bas M9 Forth Dimensions Lcx 9S Letters to the Editor and to your fellow readers are always welcome Hespond to articles describe your latest proje
97. ine Nevertheless FIG can help promote trade by making sure vendor names and product information somehow appear in the pages of Forth Dimensions hope we will be hearing from Forth vendors FIG can help promote trade by making sure vendor names and product information appear in the pages of Forth Dimensions in Fast FORTHward not as a means for them to provide product specific information but as a way for them to help promote Forth generally Beyond that the Board of Directors of the Forth Interest Group wants to try to maximize the advertising space sold up to postal limits for this type of journal FIG intends to play its part to promote trade I hope that other parts of the magazine may soon feature articles about various Forth products in hardware firmware or Software We have taken steps to help ensure that this takes place appropriately Such articles should serve the higher purpose of educating our readers about important programming techniques about practical ways to develop successful applications and so forth Professional societies and standards efforts can promote Forth in ways that would be difficult for individual vendors May 1992 June They can help ensure that consumers of a product or service are getting the best that can be made available The ACM and ANSI organizations are well known for their service in such areas Thanks to the dedicated efforts of Forth vendors and enterprising Forth ac
98. ions 29 May 1992 June code INDEXED value It gets compiled by FOR or CASE CodeAddrOf lunframe releaser 1 extra value 2 pointers frame index pop when we enter FOR and CASE besides making a control structure frame next reserving space for the index we have to set the initial index value end code macro Ylompleted lt if fromBegNEXTtoCompleted then next macro if the backcounter is negative the loop must go to the COPPLETED clause or if COMPLETED doesn t exist it must LEAVE the control structure code TIMES CodeAddrof lunframe releaser 1 extra value 3 pointers frame index pop NonegativeTimes issue error if negative times i index sub Completed predecrement the backCounter and if it is end code go to COMPLETED of leave if COMPLETED is absent code TIMES IPtoBegining set the IP to the begining of the control structure i HH index sub Completed decrement the backCouunter and if exausted go end code to COMPLETED or leave if COMPLETED doesn t exist code LDOP begining times step CodeAddrOf Sunframe releaser 3 extra values 3 pointers frame step pop counter pop NoNegativeTimes index pop 1 counter sub Completed end code make the control structure return stack frame reserving space for 3 extra values Set the step value set the backCounter value checking that it isn t negative set the in
99. ise The factors which typically weigh most heavily in the choice of a programmer are the m MR do so in a manner which will profoundly impress his client A demonstration may take any of several forms One could for example quote statistics studies or respected authorities regarding the matter in quesuon However one of the more effective means of demonstrating the efficacy of a product or a technique is through the use of apparatus In Ll o B I II PU language in which he programs and his previous perfor mance The factor typically of greatest import in the selection of a programming language is code maintainability Predict ability of completion date is a factor which influences selection of both language and programmer Clients tend to view code maintainability as a function of the language in which the program is written and the measure of maintainability as the relative abundance of programmers claiming proficiency with the language in quesuon They appear to give litte if any consideration to the relationship between programming technique and maintainability Clients frequently value predictability of completion date over minimization of programming time A program may be only one element in a complex system involving many components and the services of many vendors With the interdependency of schedules a missed deadline may have consequences which
100. l language interfaces OBJECT ORIENTED FORTH Dick Pountain 242 28 29 34 Implementation of data structures First book to make object oriented programming available to users of even very small home computers STACK COMPUTERS THE NEW WAVE Philip J Koopman Jr hardcover only Presents an altemative to Complex Instruction Set Tani ceris CISC and Reduced Instruction Set Computers RISC by showing the strengths and weaknesses of stack machines hard cover only STARTING FORTH 2nd ed Leo Brodie 245 29 30 38 In this edition of Starting Forth the most popular and complete introduction to Forth syntax has been expanded to include the Forth 83 Standard TOOLBOOK OF FORTH V1 267 23 25 35 Dr Dobb s Edited by Marlin Ouverson Expanded and revised versions of the best Forth articles collected in the pages of Dr Dobb s Journal TOOLBOOK V1 with DISK MS DOS 267a 40 42 50 268 30 32 40 TOOLBOOK OF FORTH V2 Dr Dobb s Complete anthology of FORTH programminmg techniques and developments picks up where V 1 left off Topics incl xm rog ramming windows extended control structures design of a Forth target compiler and more TOOLBOOK V2 with DISK MS DOS 268a 546 48 56 WRITE YOUR OWN PROGRAMMING LANGUAGE USING C orman Smith a 270 15 16 18 1s book 1s about an application language More penne i 1s about how to write your own custom application language The NEW book contains the too
101. listing of F83 including source and shadow screens Includes introduction on getting started FORTH A TEXT AND REFERENCE Mahlon G Kelly amp Nicholas Spies A textbook approach to Forth with comprehensive references to MMS FORTH and the 79 and 83 Forth standards THE FORTH COURSE Richard E Haskell 225 9325 26 35 This set of 11 lessons called the Forth Course is designed to make it easy for you to leam Forth The material was developed over several years of teaching Forth as part of a senior graduate course in design of embedded software computer systems at Oakland University in Rochester Michigan w disk 219 31 32 41 FORTH ENCYCLOPEDIA Mitch Derick amp Linda Baker 220 30 32 40 A detailed look at each fig Forth instruction FORTH NOTEBOOK Dr C H Ting 232 25 26 35 Good examples and applications Great leaming aid poly FORTH is the dialect used Some conversion advice is included Code 1s well documented FORTH NOTEBOOK 1I Dr C H Ting 232a 5325 26 35 Collection of research papers on various topics such as image processing parallel processing and miscellaneous applications INSIDE F 83 Dr C H Ting 235 25 26 35 Invaluable for those using F 83 LIBRARY OF FORTH ROUTINES AND UTILITIES James D Terry 237 5323 25 35 Comprehensive collection of professional quality computer code for Forth offers routines that can be put to use in almost any Forth application including expert systems and natura
102. ll unconditional branch conditional branch and everything else Although the debugger handles several different instruction types identically the system will nonetheless tell the user what the instruction type is Call To handle call instructions the debugger first fetches the instruction that would ordinarily execute It masks out the upper three bits leaving the destination address in that instruction s lower 29 bits This value is placed on the parameter stack and the debugger can simply use the Forth word EXECUTE to go where the call would have gone The debugger keeps track of where it is inside a word being debugged via the global variable HISIP short for his instruction pointer HISIP serves as a simulated insuuction pointer upon each loop through the debugger the system which pointed to the body of the M M Forth Dimensions Listing One Single step debugger Lam NA o e Storage VARIABLE HISIP VARIABLE HISFLAG VARIABLE HERELOC CREATE NUMBUF 4 ALLOT HEX 1991 6008242C uCODE GFLAG INSTRUCTION TYPES Single step debugger for SC Forth32 Copyright Rick Grehan Hancock NH His instruction pointer His FL bit Location for inline execution Buffer for number input Put FL on stack 00000000 CONSTANT ISCALL Call 20000000 CONSTANT ISBRAN Unconditional branch 40000000 CONSTANT
103. ll be sending a message to do the job Since OOF does a lot for you in terms of factoring or deciding what to do in special cases which is done by inheritance polymorphism and message passing code tends to be tighter and more to the point You have more control over what is going on in your program and you don t get lost in an unordered heap of data and words Last but not least it is more fun Some words concerning standards we have worked with more or less standard Forths and were less than happy with the environments and the support for non trivial programs written by more than one engineer OOF might not be suitable for tiny target applications or not fastenough for real time applications which is still to be decided there isenough tackle problems differently but still in the good ol Forth style of writing and testing small chunks of code incre mentally and interactively It St se SDELTA providing the integral order ing mechnisms of object ori ented languages and by adding security by means of strong type checking and nN o vantages of Forth Thus OOF could show a way towards a modernized extended sup portive Forth living side by side with the current standard minimalistic compact Forth The future will see an OOF system running all described features with optimized code for the kernel more classes ported versions on hosts such as PCs Macs and Unix machines and a full debugging envir
104. ls necessary to begin the process and a complete sample language implementation Guess what language Includes disk with complete source 244 62 65 72 REFERENCE FORTH 83 STANDARD 305 15 16 18 Authoritative description of Forth 83 Standard For reference not instruction SYSTEMS GUIDE TO fig FORTH 308 25 28 30 C H ng 2nd ed 1989 How s and why sof the fig Forth Model by Bill Ragsdale intemal structure of fig Porth system BIBLIOGRAPHY OF FORTH REFERENCES rd ed January 1987 er 1900 references to Forth articles throughout computer liter ature F PC USERS MANUAL 2nd ed V3 5 350 20 21 27 Users manual to the public domain Forth system optimized for IBM PC XT AT computers A fat fast system with many tools F PC TECHNICAL REFERENCE MANUAL 351 30 32 40 A must if you need to know the inner workings of F PC MORE ON FORTH ENGINES Volume 10 January 1989 810 3515 16 18 RTA reprints from 1988 Rochester Forth Conference object oriented cmForth lesser Forth engines Volume 11 July 1989 811 15 16 18 RTX supplement to Footsteps in an Empty Valley C32 32 bit Forth engine RTX interrupts uulity 812 15 16 18 Volume 12 April 1990 ShBoom Chip architecture and instructions Neural Computing 13232 pigForth binary radix sort on 80286 68010 Module N and R TX2000 Volume 13 October 1990 813 15 16 18 PALs of the RTX2000 Mini BEE EBForth AZForth RTX 2101 8086 eForth 8051 eForth
105. ly and if possible help me support our worthwhile cause by considering how you might contribute to this department If you received this issue as a complimentary gift I hope you will see that Forth Dimensions is becoming a more broadly informative magazine with more potential benefit for everyone involved Aike Elola P D Vendor Spotlight Paladin Software Inc Started in 1982 this software consulting firm wrote custom software for a wide variety of industries providing systems and applications software in projects ranging from HVAC to real time space telemetry and serial protocol implementations Recently the company released DataScope version 2 0 the latest in a family of PC based software products that lets PCs replace much more expensive communication debuggers and serial line monitors Version 1 0 of DataScope was brought out in 1991 Version 1 4 is available as shareware on CompuServe FIDONET EXEC PC and other bulletin boards as well as from the company itself see Product Watch Version 2 0 of DataScope features an SAA CUA compliant Systems Application Architecture and Common User Ac cess user interface option It includes user alterable multitasking window displays and a Windows like pull down menu interface It also provides search tools that can find data that is ordinarily an invisible part of a transmission Since 1982 Paladin
106. make possible clear and readable programming without stack juggling and they ensure that only the values declared are popped off the stack and only the values declared are pushed onto the stack as results This is performed auto matically when entering and exiting the method according to these declarations thus enhancing security The instance variables xdim ydim andbits pixel of the image object i are accessed by the method which may only be called inside an instance method for that particular class here image This is called data encapsu lation and ensures that these operations can only be performed on object data that you have explicitly allowed and defined to do so again enhancing program security p II ESSE NU Note that in order to push the value of for example pixels onto the stack there is no method involved and thus cannot be forgotten any more Every object lays itself onto the stack when invoked The low level difference between the object s value and its location is no longer visible there are only objects Making Passes The above defined method size for the class images can now be applied to the previously declared image object iml by May 1992 June Figure Three Using shallow objects state active idle active lt idle iim keypressed state s input active lt Figure Five Using the Do Loop im looptest integ
107. mbers arrays file query Batcher s sort screenless Forth classes in Forth Bresenham line drawing algorithm unsigned division DOS file IO Volume 9 Forth Dimensions 1987 88 109 320 22 25 Fractal landscapes stack error checking perpetual date routines headless compiler execution security ANS Forth meeting computer aided instruction local variables transcendental func tions education relocatable Forth for 68000 Volume 10 Forth Dimensions 1988 89 110 20 22 25 dBase file access string handling local variables data structures object oriented Forth lincar automata standalone applications 8250 drivers serial data compression Volume 11 Forth Dimensions 1989 90 111 20 22 25 Local variables graphic filling algorithms 80286 extended memory expert systems quatemnion rotation calculation multiprocessor Forth double entry bookkeeping binary table search phase angle differential analyzer sort contest Volume 12 Forth Dimensions 1990 91 112 20 22 25 Floored division stack variables embedded control Atan Forth optimizing compiler dynamic memory allocation smart RAM extended precision math interrupt handling neural nets Soviet Forth arrays metacompilation FORML CONFERENCE PROCEEDINGS FORML Forth Modification Laboratory is an educational forum for sharing and discussing new or unproven sals intended to benefit Forth and is an educational forum ibr diacus sion of the technical aspects o
108. n board EPROM for the space mission Sample Program The following code fragment shows how straightforward it is to use this board set UBW returns a flag showing that the next CCD data is available on the parallel port Direct manipulation of the hardware is possible such as PARRD to read memory mapped parallel port data CCD data is collected 16 bits at a time and placed in 32 bit wide 0 ws SRAM where it is processed at high speed before being stored in slower DRAM Access to drivers is shown in the call to SCSIWR which takes block number address number of blocks to write large chunks of data to a SCSI device COMPRESS IMAGE compresses and copies completed images to DRAM and updates pointers A list of snapshot times in an experiment sequence is loaded into EPROM or RAM before the rocket is launched After each image is collected RELOAD TIMER sets the time until the next picture After the solar imaging phase is complete additional data is collected until memory is fuil This data is then unloaded to a SCSI device after payload recovery Code example SBC32 ROCKET data collection CREATE PIC 32768 ALLOT allocate pic SRAM buffer HERE CONSTANT ENDPIC and mark end VARIABLE NEXTIMG pointer to image time array COLLECT IMAGE CCD parallel gt SRAM ENDPIC PIC DO FOR size of picture DO BEGIN UBW UNTIL wait for CCD word ready PARRD I LOOP copy parallel to SRAM RELOAD TIMER NEXTIMG 256 MO
109. ncy explains the ra son d etre for the department and invites ideas and sub missions from readers the success of this undertaking will rely greatly on the re sponse and participation of you the reader Fast Forthward is an other new feature to appear regularly It offers space for product news and an nouncements short profiles of Forth companies and es says about what makes a Forth business programmer successful and about the nature of Forth This synergy of Forth users vendors and developers should help us to to collaborate more closely to communicate about Forth more effectively with the rest May 1992 Juna of the world and to focus specialattention on the things Forth does well We are doing our best to encourage Forth vendors and developers to participate in FD in other ways too Add ing to the valued presence of our advertisers this issue welcomes editorial contri butions from three busi nesses A number of readers requested this kind of per spective in FD and the Forth business community has re sponded well We look for ward to hearing from other companies about their Forth products and their experi ences in the commercial world If your firm would like to participate get in touch with me soon to discuss the options And remember to send us your press releases about upgrades new prod ucts and your company s background Our readers want to hear from you Tutorials
110. nstack are nox the initial and final loop values Iheeffea is the same however Step Into In its Current incarnation the debugger handles call instructions using the SC Forth32 word EXECUTE Consequently there is no way to nest down a level and step into a word In order for the debugger to perform that feat you would have to add code that kept the variable HISIP properly tracking the instruction pointer of the debugged code The debugger would also have to take over the responsibility of managing the return stack Specifically whenever the debugger en countered a call instruction it would push the incremented value of HISIP onto the return stack extract the destination address from the instruction and store that address into HISIP Handling a return from subroutine is more diffi cult since the C432 actually embeds the return operation in ALU shift or load store instructions Bit 28 of such instructions is called the next bit If it is set it loads the top value on the return stack into the instruction pointer Bits 16 through 19 are called the stack bits They determine whether the parameter and return stacks are pushed or popped Ifthe next bit is set and the stack bits specify that the return Slack is to be popped the effect is a return operation So for the debugger to manage a return it would have to watch for a set next bit within ALU shift and load store instructions
111. o have two different actions In the GAME vocabulary NORTH will move the adventurer while in the FORTH vocabulary the same word with an appended will actas a constant and put a number on the stack With conventional methods each direction would need two defining words one for NORTH and the other for NORTH Screen Four shows how a single defining word DIRECTION can create the two at the same time The first step is to factor out the DOES action of all but one of the words to be created This is necessary because the run time action of CODE which is laid down by DOES is to exit from the word that it is in after setting the CFA in the most recently laid down header In our example the game word action is factored out into MOVE which fetches the direction number from the body and moves the adventurer The defining word DIRECTION gets a string from the input stream converts il to upper case and places itin the buffer DBUF Linc One In Line Two the resulting string is used to create NORTH in the GAME vocabulary DUP lays down its parameter field and MOVE executes DOES to set the action Lines Four and Five append a to the string in DBUF and Line Six uses the modified string to create NORTH and set its action with DOES Nested Defining Words Seasoned Forth programmers know that defining words can create defining words which in turn can create other defining words The nesting can in theory be continued indefinitel
112. ollers Prolog simulations and applications 1989 FORML PROCEEDINGS 319 40 43 50 Includes papers from 89 euroFORML Pascal to Forth extensible optimizerfor compiling 3D measurement with object oriented Forth CRC polynomials F PC Harris C cross compiler modular approach to robotic control RTX recompiler for on line maintenance modules trainable neural nets 1990 FORML PROCEEDINGS 320 40 43 50 Forth in industry communications monitor 6805 development 3 key keyboard documentation techniques object oriented programming simplest Forth decompiler error recovery stack operations process control event management control structure analysis systems design course group theory using Forth BOOKS ABOUT FORTH ALL ABOUT FORTH 3rd ed June 1990 Glen B Haydon 201 90 92 105 Annotated glossary of most Forth words in common usage including Forth 79 Forth 83 F PC MVP Forth Implementation examples in high level Forth and or 8086 88 assembler Useful commentary given for each entry THE COMPLETE FORTH Alan Winfield 210 314 15 19 A comprehensive introduction including problems with answers Forth 79 eFORTH IMPLEMENTATION GUIDE C H Ting 215 25 26 35 eForth is the name of a Forth model designed to be portable to a large number of the newer more powerful processors available now and becoming available in the near future w disk F83 SOURCE Henry Laxen amp Michael Perry 217 5220 21 30 A complete
113. om Germany add prefix 0033 From other countries add 33 1 4108 11 75 300 baud 8N1 or 1200 75 E71 or 1 4108 11 11 1200 to 9600 baud BN1 For details about high speed Minitel or alternate carrier contact SysOp Marc Petremann 17 rue de la Lancette Paris France F 75012 SweFIG Per Alm Sweden 46 8 71 35751 NEXUS Servicios de Informacion S L Travesera de Dalt 104 106 Entlo 4 5 08024 Barcelona Spain 34 32103355 voice 34 32147262 data e Max BBS ForthNet United Kingdom 0905 754157 SysOp Jon Brooks e Sky Port ForthNet United Kingdom 44 1 294 1006 SysOp Andy Brimson Art of Programming Mission British Columbia Canada 604 826 9663 sysOp Kenneth O Heskin The Forth Board Vancouver British Columbia Canada 604 681 3257 Forth BC Computer Society U NI net US The Monument Board U NI net RIME ForthNet bridge Monument CO Jerry Shifrin ForthNet charter founder 719 488 9470 May 1992 June A Space Application for the SC32 Forth Chip by Silicon Composers Inc Overvicw Applications requiring real time control and high speed data acquisition can take advantage of systems solutions that combine these features into one small package Fast and easy software development is especially important to generate control programs that can be easily tested with application hardware to shorten development schedules What follows is an example of a space application involving solar astronomy
114. om a secondary They are the counterparts of objects for the secondary SDELTA is calculated as SFRAME Forth s CFA primitives SBOTTOM bottom of stack and space for the bodies of the The inner interpreter works similar to most Forths inner oy7 and LOCAL objects is reserved on the stack by interpreters a register of the virtual machine called OOFPC decrementing TOS After OOFPC is set to the first entry in the points inside the body of a secondary where the next ntry body the innerinterpreteris ready to interpret the secondary shall be interpreted Each entry in a secondary consists of the Figure Eleven shows the contents of the parameter stack at object number of a BEC followed by parameters forthe BEC that time In order to speed up the interpretation OOF compiles To explain the functions of the BECs the evaluation of a references to the codes that evaluate the entries of the body sample part of the secondary that was called when the directly into the body rather than just storing a reference to message size was sent to the global image object im1 shall the object Everything that is known at compile time about now be traced Figure Ten shows both a sample of the body an object to be compiled is stored as the appropriate BEC and of the method size and the appropriate contents of the the necessary parameters so that at run time a BEC does not parameter stack after the execution of each BEC o SS ee re st e
115. omedical state of the art applications Other sessions Dr Steven Lewis commercial Forths include standards and em Aerospace Corporation eASYST seminar bedded languages including Rhinosoft Design of A sotack computers C Mumps ANS X3 J14 Forth Biomedical Product Forth in the post USSR and Open Boot esPoster sessions MR Mr Jack Woehr Vesta eWorking Groups Please submit 100 word Technology ANS Forth Standard abstracts by May 15th and papers by June 1st Limit of 5 pages 10 point size Call for ANS Forth as a Component Vendor Exhibits of Advanced Programming Forth vs C vs C Obj orient technology Environments longer papers Real time systems Registration For More Information 450 Attendees Lawrence P G Forsley 300 Full Time Students Conference Chairman 200 Spouse Forth Institute 70 Elmwood Avenue Hooms Rochester NY 14611 USA 150 Single 4 nights 716 235 0168 716 328 6426 fax 125 Double per person EMail Genie L Forsley Compuserve 72050 2111 Take advantage of lower registration internet 72050 2111 compuserve com fees this year Forth Interest Group P O Box 8231 SecondClass Postage Paid at San Jose CA San Jose CA 95155
116. onment to make life even casier We will run laboratory work for image processing and protoyping of medical image workstations using OOF Any comments annotations or additions are welcome Stay tuned We hope our work will not be misused for military purposes We will not take part in any military projects Markus Dahm received his Dipl Ing electrical engineering in 1987 at RWTH Aachen University of Technology Aachen Germany abd his M Sc Computer Science in 1988 at Imperial College London U K He has been a research assistant since 1989 al Lehrstuhl fuer Me technik RWTH Aachen DIBA project working on user interfaces for medical imaging workstations He can reached at the following Lehrstuhl fuer Messtechnik RWTH Aachen Templergraben 55 D 5100 Aachen Germany Phone 241 80 78 64 Fax 241 807871 room for optimization However OOF points out how to E mail SE DACTHS1 BITNET Contest Announcement Call for Papers Forth Dimensions is sponsoring a contest for articles about Forth on a Grand Scale Write about large scale Forth applications systems or This theme applies equally to projects requiring multiple programmers and to applications or systems consisting of large amounts of code and or of significant complexity Editorial FD XIII 6 Papers will be refereed Cash awards to authors 1st place 500 2nd place 250 3rd place 100 Deadline for contest entries is August 3 1992
117. ons The TDS2020 is a powerful CMOS controller card based on the Hitachi 16 bit H8 532 microprocessor and runs at about 3 MIPS It has 16 Kbytes of Forth as well as a full symbolic assembler eight channels of ten bit A D three channels of D A serial RS232 and 2c protocols too There is 45K for program storage and up to 512 K NVRAM space on board as well as timers interrupts and 33 I O lines Lite Programming Programming is accomplished by downloading suitable words from the PC software provided with the boards The TD 2020 starter pack includes lots of utility routines to Re Forth Dimensions make life easier for the designer Included are serial input output timer LCD keyboard driver memory test and routines trig functions graphics LCD display interrupt driven serial I O and round robin multitasking Embed the TDS2020 in a product talk to it from a PC compatible down an RS 232 sec line debugging each segment as you go and the final code can bc stored in NVRAM with no need for PROM burning You have very fast development time with no need for in circuitemulators or test stubs for developing fault free code The application also runs at full speed and the full resources of the developmentenvironment are available for use in debugging the code can be exercised at full speed and breakpoints can be introduced for snapshots or single stepping M MM Usee Y ssn
118. ontrol structure return stack frame is generated A processor register CSF control structure framer is reserved to point to the actual frame allowing access to index values from secondaries called within the control structure or more generally while using the return stack The control structure return stack frame is composed of both necessary and optional items the latter depending on the control structure See Figure Four for a description of the return stack frame in various cases The exact actions we have to take upon entering a control structure are 1 Depending on the number of extra values needed index step and backcounter or index only or nothing we have to adjust the return stack pointer to reserve space for them 2 We have to push onto the retum stack the address absolute or relative of the routine that will deallocate the return stack and or other resources related to the control Structure 3 We have to advance the instruction pointer to skip over the May 1992 June 24 pointers compiled after the beginning of the control structure and let it point to the first word after the beginning We have to push the old contents of the CSF register onto the return stack 5 We have to push the contents of the adjusted IP to mark the address of the beginning of the control structure 6 Having completed the control structure stack frame we have to store into CSF the contents of the RP register letting CSF point
119. ordset 32 bit Forth HP71B Forth NEON object onented programming decom piler design arrays and stack variables 1985 FORML PROCEEDINGS Threaded binary trees natural language parsing small lcarnin expert system LISP LOGO in Forth Prolog interpreter B parser In Forth formal rules for paak Forth coding conventions fast high level floating point Forth component library Forth amp artificial intelligence electrical network analysis event driven multitasking 1986 FORML PROCEEDINGS 316 30 32 40 Threading techniques Prolog VLSI Forth microprocessor natural language interface expert system shell inference engine multiple inhentance system automatic programming environ ment 315 30 32 40 1987 FORML PROCEEDINGS 317 540 43 50 Includes papers from 87 euroFORML Conference 32 bit Forth neural networks contro structures AI optimizing compilers hypertext field and record structures CAD command language object oriented lists trainable neural nets expert systems 1988 FORML PROCEEDINGS 318 24 25 34 sean nen impie rones ses cabe Forth anguage topics hardware Wil s workings amp Ting s philosophy Forth hardware applications ANS Forth session future of Fork in AI applications 1988 AUSTRALIAN PROCEEDINGS 380 24 25 34 Proceedings from the first Australian Forth Symposium held May 1988 at the University of Technology in Sydney Subjects include training parallel processing programmable contr
120. pointers can become very confusing Gust think of C pointer puzzles and error prone abandoned the idea of a class pointer for these reasons Instead Smalltalk inspired me to define shallow objects They are disguised as normal objects of a class but only bear a reference to another object They be have exactly as if they were the objects they keep the reference to you do not have to worry about their shallow nature An example is a shallow object of class state see above that represents the active state of the state machine It is created and handled as shown in Figure Three Now in order to send the message keypressed to the momentarily active state you write active keypressed which at this point sends the message keypressed to the state object idle Note that you need not perform some sort of pointer indirection operation the shallow object active automatically pushes the referenced state object idle onto the stack The iim keypressed of idle now can be ex tended as shown in Figure Four Looping The control structures are quite the same as in Forth The do leave Loop however was modified it still takes limit and index as parameters but they must be given in the form of local integer variables This offers you the opportunity to name the functions thal access the index and limit of the loop the former i and 3 the way you like and spares the implementation to clobber the return stack with looping For
121. pts string stack BASIC compiler recursion 8080 assembler Volume4 Forth Dimensions 1982 83 104 15 16 18 Fixed point trig fixed point square root fractional arithmetic CORDIC algorithm interrupts stepper motor control source screen documentation tools recursion recursive decompiler file systems quick text formatter ROMmable Forth indexer Forth 83 Standard teaching Forth algebraic expression evaluator Volume 5 Forth Dimensions 1983 84 105 15 16 18 Computer graphics 3D animation double precision math words overlays recursive sort a simple multi tasker metacompilation voice output number utility menu driven software vocabulary tutorial vectorerd execution data acquisition fixcd point logarithms Quicksort fixed point square root Volume 6 Forth Dimensions 1984 85 106 15 16 18 Interactive editors anonymous variables list handling integer solutions control structures debugging techniques recursion semiphores simple I O words Quicksort high level packet communications China FORML Volume 7 Forth Dimensions 1985 86 107 3220 22 25 Generic sort Forth spreadsheet control structures psuedo interrupts number editing Atari Forth pretty printing code modules universal stack word polynomial evaluation F83 strings Volume 8 Forth Dimensions 1986 87 108 20 22 25 Interrupt driven serial input data base functions TI 99 A XMODEM on line documentation dual CFAs random nu
122. r first resort if you have any difficulties or questions about using FTP For MS DOS related files there are currently two sites from which you can anonymously FTP Forth related materials WSMR SIMTEL20 ARMY MIL Simtel20 for short WUARCHIVE WUSTL EDU Wuarchive for short Wuarchive maintains a mirror of the material available on Simtel20 Simtel20 has a limited amount of material most of it binaries for MS DOS computers The Forth files on Simtel20 are in directory PD1 lt MSDOS PORTH gt The Forth files on Wuarchive are in directory mirror msdos forth For detailed information on how use FTP and the Simtel20 archive Cit is too much to include here see the text files in PD1 lt MSDOS STARTER gt SIMTEL20 INF or mirrors starter simtel20 inf An FTP site containing a mirror of the FIG library on GEnie is under construction and will be announced when it is ready FIGI L Gateway For those who have access to BITNET CSNet but not Usenet comp lang forth is echoed in FIGI L The maintainer of the Internet BITNET gateway since first quarter 1992 is as follows internet plglsi usp br PREFERRED uunet uunet yme131 pl hepnet psanchezQuspif 1 hepnet Pedro Luis Prospero Sanchez University of Sao Paulo Dept of Electronic Engineering phone 055 11 211 4574 home 055 11 914 9756 fax 055 11 815 4272 Modem For those desiring to use or stuck with modems the dial in systems listed above also have Forth libraries
123. re start CSF rpush IP rpush RP CSF 1 macro push old CSF push start IP addr set new CSF May 1992 June 28 Forth Dimensions macro Resources4RSrelease execute the unframing routine releasers ApcI AZ lea Load A with the base addr of unframing routines releaser AD w add Add the unframing routine offset to the base addr AM Jer Jump subroutine to the routine macro code LEAVE IPtoBegining IPbeg gt end Resources RSrelease next end code X move IP to begining Move it to end Execute unframing routine code fromBeginingLeave IPbeg end Hesources amp HSrelease next end code special case more efficient LEAVE Beeing at the begining of the control structure we want to jump to the LEAVING COMPLETED or similar points if they exist Other wise LEAVE the control structure directly macro TfromBegNEXTtoRefercencePoint offset_of pointer to ref point offset 2 4 6 IP I d w gt offset IP we d w lt CodeAddrOtf fromBeginingLeave CCabranch No code provided for LEAVING X or COPPLETED LEAVE out directly d IP w add move to the reference point d we IP next and continue execution macros macro fromBegNEXTtobeaving 4 TfTromBegNEXTtoHeferencePoint macro macro fromBegNEXTtoCompleted 6 fromBegNEXTtoReferencePoint macro macro tfromBegNEXTToOUnError 6 fromBegMEXTtoRHeferencePoint macro Beeing at the begining of a control structure go
124. resents the message The message is sent to the object on TOS which is now pixels In the list of instance methods of the class of the object on TOS here integer a method is searched that matches this token In order to speed up the search this list is 32 fold hashed When the method is found it is called if not an error message that is guaranteed to be understood by all objects since it is defined in the kernel is sent to the object The primitive for integer multiplication takes the two integer objects off the stack and pushes an integer object with Forth Dimensions the method size sent to the global object im1 Dire iud SBOTTOM SDELTA 32 product integer immediatd SBOTTOM SDELTA 32 SBOTTOM SDELTA 16 O body value offset bits pixel ims 4 T SBOTTOM SDELTA 20 21 the product in the value field of the stack entry Se1f is set to the pseudo object number immediate indicating that there is no valid header available for this object The OUT object s is pushed by BEC OUT the same way pixels was pushed The result of the multiplication is stored in s by the method that was found when BEC IM sent the message to s Finally the secondary size is exited by BEC EXIT which cleans the parameter stack by setting TOS to SFRAME ef fectively freeing the space of OUT and LOCAL bodies in the stack frame and taking the IN objects off the stack Then it
125. ry are no big deal anymore space is no problem in most development systems OOF makes incremental development and compilation possible so compilation speed is not critical The emphasis in the design of OOF s kermel is on execution speed which is always a critical issue in object oriented systems So in OOF compilation takes a bit longer and the code size grows but execution is sped up a great deal One by one each entry of a secondary is evaluated by calling the BEC that the OOFPC points to At the end of every BEC the OOFPC is set to the next entry the processor jumps The Virtual Machine back to the inner interpreter and the next entry in the body r mm SS The virtual machine VM of OOF consists of a number of the secondary is evaluated of Body Evaluation Codes BECs the inner interpreter the The execution of a secondary shall now be explained in primitives internal registers and the available RAM Itis the detail When a secondary is entered the VM registers machine dependent part of an OOF system SDELTA SFRAME and OOFPC and the object number of the A BEC is a piece of assembler code that performs a basic secondary are saved on the retum stack Then SFRAME is set function such as pushing an object descriptor onto the stack below the first input parameter within the parameter stack sending a message to the object on TOS and calling or now the stack frame starts with the stack entries of the input returning fr
126. s ALL OTHERS inline debugger on a word Save flag after operation Incr his address Is word in dictionary Set instr pointer if so Show word s body address Figure One SC32 instruction types Finally you would want to add an additional user input choice that would allow the userto select whether the debugger stepped into the called word or executed it as a whole as it does now Last Calls To Jumps SC Forth32 is an optimizing compiler Among otherthings this means that the compiler is intelligent enough to recog nize that if the last instruction in the definition of a word is a call instruction that call can be converted to an unconditional jump This saves return stack space as well as reducing some execution time that would ordinarily be unnecessarily consumed moving addresses between the retum stack and the instruction pointer From the debugger s point of view the jump instruction is just a jump there s no indication that this was a call optimized into a jump If you single step into this situation it will appear that you have nested down into a word and in some severe cases this nesting can go on for several levels as you repeatedly encounter the last instruction of each word Ultimately of course you will encounter a Forth primitive and pop out the end Trace As a final tool I built a simple execution trace facility I based the execution trace words on the
127. st all you need for the beginning is a C compiler for that machine In the following sections I will describe in detail the structure of objects the concept of object storage and the consequences concerning access by the virtual machine of objects the stack and the execution of secondaries Handle with Care Each object consists of a header and a body The structure of the header is shown in Figure Six It contains various information about the context and nature of an object as well of the object The body of the object that contains its data is located anywhere else in memory in a contiguous memory block The body ofa compound object that is built of instance objects consists of the bodies of its instance objects As an Forth Dimensions aa auaa rr en ni eee OO m name of object terminated by 0 followed by a count byte object number of next object in list e g vocabulary etc object number of next object in list of all objects object number of owner object e g owner of instance object e g shallow deep object private public allocated deleted object number of the class the object belongs to object number of the object that holds the object s body paradigm of object orientation As with any Forth the kernel as information for debugging and the source of the definition example the body of an image object is shown in Figure Seven Objects may not be ac cessed directly by an ad dress only via
128. t ODE hashed dictionary for fast compilation local variables for more readable code integrated file based text editor ARexx support for inter application I O FVG standard floating point support Profile code performance analyser global register based optimiser integrated assembler and disassembler numerous examples and tutorials in manuals Find out more about JForth or HMSL by calling or writing PO Box 151051 San Rafael CA 94915 1051 USA 415 461 1442 generates small royalty free applications Amiga is a registered trademark of Commodore Business Machines 15 May 1992 June Forth Dimensions Object Oriented Forth Markus Dahm Aachen Germany At the Institute for Measurement Techniques at the University of Technology RWTH Aachen we have used Forth since 1987 Our interdisciplinary workgroup has developed medical image workstauons We havc written a lot of software including memory management image processing algorithms fibre optics network coupling and a graphical user interface in our proprietary 32 bit Forth The psychologists in our workgroup conduct experiments con cerning the software and hardware ergonomical aspects of the design and functionality of the workstations using the prototype image workstation Some of the student laboratory work in image processing is done in Forth which is picked up by the students usually within half an hour Within this short amount
129. th Dimensions Se Figure Six Header of an object object number of moduie object offset in source file body size of object object number of the object itself offset within the body information The example in Figure Five shows how to use this feature Implementation OOF is not implemented by extending an existing Forth It is not based on clever use of vocabularies and create does gt constructs I did start defining it that way since it is the first and obvious way to any Forth programmer But it soon turned out that if I used a standard Forth as a basis to program OOF the underlying Forth would either not be in use any more when running OOF or it would induce intolerable speed penalties So the variety of new concepts forced an entirely new kernel for OOF In the process some wrinkles in Forth were ironed out by strictly adhering to the consists of some assembler primitives for arithmetic L O and special kernel functions comprising the virtual machine VM of OOF and the lion s share of the kernel is written in OOF itself This OOF source code is translated by a metacompiler into the kernel s threaded code To make porting as fast and easy as possible C source versions of all VM functions exist Existing programs e g image processing libraries written in C or other languages can easily be linked to OOF The metacompiler itself is written in C as well So in order to port OOF to another ho
130. that meets this profile Sun spots flares and granularity are solar phenomena of interest to scientists since a good theory of solar dynamics must take them into account The granularity of the sun is caused by convection cells which appear over the entire surface of the sun To some extent the sun s surface is similar to a pot of boiling Oatmeal with the bubbles of oatmeal paralleling the convection cells on the sun Although convection cells are about the size of the state of Texas high resolution visual imaging of individual cells from earth based solar telescopes is difficult to achieve because of the distortion due to the earth s atmosphere Solar telescopes operating from suborbital flights have the advantage of being above the atmosphere which allows them to acquire high resolution images that show more detail of convection cell dynamics For this type of mission using a single on board computer to control subsystems and data services can reduce system design complexity and development time This single embedded computer can perform tasks such as telescope pointing optics filter control and experiment sequencing as well as image acquisition data storage and down link communications Hardware A good embedded system for this type of application is the SBC32 single board computer using the SC32 Forth RISC chip and the DRAMIO32 board Together these provide a large solid state memory space high performance I O and a microproc
131. the presented control structure set is easy to use and learn powerful expandable uniform and unifying More work has to be done on the RECOVERABLY and TRACK structures and on the pattern matching problem that is related to control structures Is anybody willing to implement the above structure set for the 8086 processor on another system F PC for example and to present the developed code Does anybody have any new control structure Has anybody encountered inconsistencies in the above set of words I would be very glad to discuss the positive and negative issues of this wordset and any problems that remain unresolved Speculating on the structure of Forth engines I believe I have found ways to render these control structures pipeline able and as efficient or more so due to pipelines as normal branch words If fact variations of the above scheme are easily adaptable on some Forth engines to run as fast as their branch equivalents For structures like BEGIN WHILE RE PEAT in particular pushing the address of the beginning of the structure onto the return stack means that without compiling offsets the code is relocatable automatically while given the efficiency of subroutine return or better program counter load from the top of the return stack and we are able with slight processor modifications to execute an AGAIN concurrently with some other data stack manipulation Forth Dimensions WHEN XXXX SomeCodel WHEN
132. tivists Forth contingents have been installed in each of those organizations ACM SigFORTH and ANSI X3J14 I expect Fast FORTH ward to offer essays describing standards and open systems and how they should be able to benefit everyone in our industry consum ers as well as producers of Forth products One related activity that FIG has supported is the China Forth Examination project It helped China determine the level of competency of Forth programmers and it brought guaranteed employment to the top performers on the test Dr C H Ting will be translating portions of this test into English so that we are better able to appreciate it Publicity is another area of promotion that can help further a cause It also takes many forms For FIG purposes publicity should help create visibility for Forth in as much of the trade and general media as possible Another way FIG can help publicize Forth is to make sure educational materials arc readily available to anyone who is curious about Forth I promise to use Fast FORTHward as a forum to publish analytical essays regarding the nature of Forth Such explorations can help educate newcomers and they can hold the interest of the Forth pros too I will quote liberally or reprint where appropriate the materials from vendors standards committees Forth books articles and just about any source that can help shed light on this thing we call Forth If Forth is a philosophy besides a lang
133. to execute In some sense May 1992 June you could say that the SC32 supports subroutine threaded Forth the SC32 s call instruction which works much like any other CPU s subroutine call does the nesting job of the inner interpreter This meant the debugger had to extract the call s destination address word being called and back up to the name field address This is handled by the word HISNAME in Listing One Debugger Internals The main debugging loop is within the word DLOOP see Listing One DLOOP is simply a large BEGIN AGAIN structure that endlessly fetches instructions and executes them in a controlled fashion The only way out of DLOOP is when the debugger executes the final instruction of whatever word is being debugged Execution of the final instruction will inevitably cause the return stack to be popped which has the effect of exiting DLOOP and the debugger While I have some complaints about the C32 s cell based architecture it makes string handling a nightmare it became a real blessing as I struggled to build the debugger Unlike processors with instructions of varying length the SC32 s instructions are all 32 bits one cell long The SC32 instruction types fall into eight categories see Figure One on page 11 The top three bits of an instruction determine its type It turns out that it was sufficient to have the debugger treat instructions as though they fell into one of four categories ca
134. trace commands e a o Instruction Top 3 bits of found in old reliable interpreted BASIC To refresh your memory executing TRACEON in BASIC would cause the system to display the number of the current line BASIC was executing This was handy for locating exactly where the system either did a belly flop or hung in an infinite loop wanted a similar construct for my Forth work I wanted words to tell me when they were about to execute and I wanted to be able to turn this behavior on and off As in BASIC this would make it easier to pinpoint where the program died My solution was a pair of words TRACEON and TRACEOFF that you could use as brackets That is words compiled after TRACEON would display their names when execuled TRACEOFF would disable tracing subsequent words would act normally I was satisfied to have only colon words be affected by TRACEON and TRACEOFF I could have extended the trace word to cover defining words but I didn t need that particular feature Trace Operation TRACEON works by patching the colon word The last word in SC Forth32 s definition of is which puts Forth inthe compiling state The SC32 instruction that calls islocated eight cells into the definition of TRACEON overwrites that location with a call to the word TRACE So after you execute TRACEON whenever ex ecutes it calls TRACE as its last instruction gt gt TRACE will compile the word TRACE
135. uage then words must be found to express it adequately A valuable marketing exercise is to consider a market place without regard to existing products What does a market composed of software and hardware developers need Once that is known perhaps we can state how Forth uniquely meets those needs A market study should show how one s own product has a place among existing products serving the same customer base Along these lines Fast FORTHward invites the diverse customer base for Forth including laboratory researchers and mechanical engincers to write about their ideal Forth system The type of short articles letters or essays that I expect to appear here should help foster communication among the Forth user developer and vendor communities As your oo M 9 re Com M IB or HM o Forth Dimensions P UNI p M e n M E EE RR _ newly appointed FIG Publicity Director I also need review ers who can help me determine what Forth promotional messages should be offered to promote Forth and FIG If you have the interest and or background to help develop and review such materials please contact me in care of the FIG office If you wish to write material for this department send your ideas or finished work to me by way of Marlin Ouverson Fortb Interest Group P O Box 8231 San Jose California 95155 Please do your part to help Forth and FIG by renewing your membership immediate
136. ual or semi manual manner The current branches of ForthNet include UseNet s comp lang forth BitNet s FIGI L the bulletin board systems RCFB ACFB LMI BBS Grapevine and FIG s RoundTable on GEnie Information on modem accessible systems is included below The various branches of ForthNet do not have the same rules of appropriate postings or etiquette Many bulletin board posts are very chatty and contain some personal information and some also contain blatant commercial advertising Most comp lang forth posts are not like that ForthNet messages that are ported into comp lang forth from the rest of the ForthNet all originate on GEnie which is a kind of de facto ForthNet message hub All such messages are ported to comp lang forth with a from line of the form From ForthNet willett pgh pa us Most messages ported to comp lang forth also contain some trailer information as to where they actually originated if it was not on GEnie There is no e mail link between the various branches of ForthNet If you need to get a message through to someone on another branch please either make your message general enough to be of interest to the whole net or contact said person by phone U S Mail or some other means Thoughtful message authors place a few lines at the end of their messages describing how to contact them electronically or otherwise Phone information for the dial in services mentioned above 303 278 0364 SprintNet node coden
137. w please refer to the code provided in the article Stack Variables AD XII 1 Sorry Implementation Explanation The generic control structure has the following format xxxx MainCode ppppl someCodel pppp2 someCode2 ppppN someCodeN XXXX xxxx may be any one of CONTROL REPEAT CASE FOR TIMES LOOP and RECOVERABLY while pppp1 pppp2 etc can be any one of LEAVING COMPLETED ONERROR etc Not every PPPPX is applicable to every xxxx So only some combinations are valid Actually the maximum number of pppp s is two LEAVING and COM PLETED together or LEAVING and ONERROR together The position of reference points pppp s must be re corded at the beginning of the control structure along with the position of the end of the structure The control structures CONTROL REPEAT CASE and FOR can only use LEAVING while TIMES and LOOP can also use COMPLETED The RECOVERABLY structure can use LEAV ING and ONERROR So with CONTROL REPEAT CASE and FOR two pointers are necessary one for the optional LEAVING point Cf the LEAVING point doesn t exist a 1 is stored in the pointer and another for the end of the control structure See Figure Two to understand the compilation effects of CONTROL REPEAT CASE and FOR In TIMES and LOOP three pointers are necessary one for the leaving point one to the end of the control structure and one to the completed point see Figure Three Upon entering a control structure a c
138. y Suppose that we want to define colors as a series of arbitrary constants numbered 0 1 2 etc and that we also need shapes and other attributes defined in a similar way We proceed as on Screen Five Here ATTRIBUTE defines a word that contains the CREATE DOES sequence and is therefore another defining word This idea is not merely a clever trick itis the basis of most object 36 oriented Forth systems RED BLUE and GREEN are effectively constants with the values 0 1 and 2 and ROUND SQUARE and OVAL are constants with the same series of values I leave it to the reader to work out the detailed acuons of the various words Some Random Thoughts Why is there a right angle bracket in DOES It origi nated with certain early Forths where CREATE laid down HI P J E M e H Den M e _ 4542 0 RR a a ge Forth Dimensions a header whose code field contained a pointer to the next byte in memory instead of an execution token To set up a defining word it ea D J A d nmm i was necessary to follow CREATE by the pair BUILDS DOES The Forth 83 Standard changed the action of CREATE so that BUIL
Download Pdf Manuals
Related Search
Related Contents
Axis OfficeBasic Parallel User Manual - NeedInstructions.com EvoCam 4 User Guide Acerca de la función de reproducción del servicio de música digital User Manual here HP DesignJet 500 User's Manual Manual STEINEL 4000873248 AOC p2460Pxq Philips HX6032 Copyright © All rights reserved.
Failed to retrieve file