Home

5 - Forth

image

Contents

1. 157 A VIDEO VERSION OF MASTER MIND SCR 18 David Butler Master Mind in Forth by David Butler DAB 17nov amp 8O Dorado Systems 1 2 Butler The writing of this program served as 3 33300 Mission Blvd my introduction to FORTH Using the fig 4 Art 126 FORTH Installation Manual I stumbled my 5 Union City 245387 way through the basic concepts of FORTH amp 415 487 6039 and eventually arrived at this video 7 Master Mind game The game is derived completely from the original board version 9 x39 A note about style If there it is an accident of Master Mind therefore all credit for 10 This was first application in Forth so it may lack the game itself goes to the Invicta Game 11 some elesance 12 13 Requirements video display 20 x 24 characters The program contains many of the 14 cursor addressing and clear screen functions found in video editors including 15 functions cursor management and character col SCR 19 lection The sequence of this computer version of the game as follows After sates Mind notes displaying the di i This is implementation of Master Mind by Invicta Then a secret code is generated with the 3 The game is very Popular because it is easy to learn and a help of the player tapping the space bar 4 challenge to play There is a
2. to bring the S 3 use RP to address the lowest byte of the return stack Offset the value to address higher bytes Address mode is automatically set to X 4 Restore X from XSAVE As an example this definition non destructively tests that the second item on the return stack also the machine stack is zero CODE IS IT zero XSAVE STX TSX return stack 2 LDA RP 3 ORA or 2nd item s two bytes setup for together O IF INY THEN if zero bump Y to one TYA PHA XSAVE LDX save low byte rstore data stack PUSH JMP END CODE push boolean Return Stack second PR 0101 X gt item bottom item 5 gt free byte _ FORTH REGISTERS Several Ferth registers are available only at the assembly level and have been given names that return their memory ad dresses These are IP address of the Interpretive Pointer specifying the next Forth address which will be interpreted by NEXT W address of the pointer to the code field of the dictionary definition just interpreted by NEXT 1 contains 6C the op code for in direct jump Therefore jumping to W l will indirectly jump via W to the machine code for the def inition UP User Pointer containing ad dress of the base of the user area N utility area in z page from N 1 thru N 7 CPU Registers When Forth
3. 3 1 Screen Transfer 2322 C Noe M 1 2 4 5 CINPUT 2321 C SOUT SOUTPUT CINPUT SEND SCREEN 9 SOUT DUF 10 10 0 DO I SOUT P 11 WAIT CINPUT TERMIMAL SEND FIRST 13 SWAP DO I 14 SOUT CR WATT SOUT 15 DECIMAL a sending COUTFUT LIST If that is inconvenient a variable contain ing an offset or starting receiver screen number could be added The proof that it works is before you the different screen formats and distant screen numbers reflect the fact that screen 58 was written on my OSI and sent to my APPLE to be printed I have used these definitions to send a 6502 assembler database manager and several hundred data entries between my machines with no trouble GTG 7 02 81 SEND QUTPUT SERIAL CONSOLE SEND OUTPUT ONLY TO CONSOLE GET INPUT FROM SERIAL GET INPUT FROM CONSOLE SIN COUTFUT SINPUT WAIT SIN QUERY SCRS gt nothing left SOUTPUT CR WAIT OVER LINE CR LEAVE THEN LOOP s SCR LAST SCRH gt nothing left SEND SCREEN TERMINAL IF FINISHED CR LEAVE THEN LOOP COUTPUT SCR CUNSOLE SERIAL 1 0 1 FORTH DEFINITIONS HEA 2 UNLINK FDFO 36 FDiB 38 3 C200 36 4 s COUTPUT FDFO 36 5 SINFUT C200 38 CINFUT FDIB 38 8 EDITOR DEFINITIONS 10 s FINISHED CINPUT COUTPUT FLUSH 11 COUTPUT SOUTPUT 3 RECEIVE COUTPUT SINFUT iS FORTH DEFINITIO
4. 415 961 4103 Supersoft Associates P O Box 1628 Champaign IL 61820 217 359 2112 Consuitants Creative Solutions Inc 4801 Randolph Rd Rockville MD 20852 Dave Boulton 581 Oakridge Dr Redwood City CA 94062 415 368 3257 Go FORTH 504 Lakemead Way Redwood City CA 94062 415 366 6124 Inner Access 517K Marine View Belmont CA 94002 415 591 8295 John S James P Box 348 Berkeley CA 94701 Laxen amp Harris Inc 24301 Southland Drive 303 Hayward CA 94545 415 887 2894 Microsystems Inc 2500 E Foothill Blvd 102 Pasadena CA 91107 213 577 1471 FORTH DIMENSIONS 11 5 FORTH INTEREST GROUP MAIL ORDER FOREIGN USA AIR 1 Membership in FORTH INTEREST GROUP and Volume 6 issues of 15 27 FORTH DIMENSIONS Volume Il of FORTH DIMENSIONS 6 issues 15 18 O Volume of FORTH DIMENSIONS 6 issues 15 18 fig FORTH Installation Manual containing the language model of 15 18 fig FORTH a complete glossary memory map and installation instructions Assembly Language Source Listings of fig FORTH for specific CPU s and machines The above manual is required for installation Check appropriate box es Price per each 1802 O 6502 6800 6809 8080 8086 8088 L1 9900 APPLE II L1 ALPHA MICRO O PDP 11 NOVA 15 18 Starting FORTH by Brodie BEST book on FORTH Paperback NEW 16 20 O Starting FORTH by Brodie Hard Cove
5. CARD 1 67 IF UPDATEDECKSUM SWAF HOME YOUR CARD WAS A DUP i 15 CAFD IN THE DECK IF DROP FLAG BAD PLAY CR CR CARD NOT IN DECK SHOWDECKSUM THEN ELSE DROP DROP BADPLAY THEN ELSE DROP DROP DROP BADPLAY THEN SOURS 7 MAINLINE WORDS CONT 33 BY TONY LEWIS my CARL CR iF CHECK 157 PILAY SWITCH KI RANDOM 1 DUP LPDATEDECKSUN DROP ELSE DUP CARDSUM Ca K2 MOD DUP UPDATEDECK SUM 1 FLAG ON VALID CHOICE DROP 1 DUP UPDATEDECKSUM LF ELSE DROP 2 UFDATENDECKSUM THEN SO NO DROF THEN THEN MY PLAY I3 SAGWLECHR SUM MAINLINE WORDS CONT St TUNY 916 2 YOUROARL BEGIN PLAVERMUOVE LEGAL PLAY LEAVES v ON STALK UNTIL SHOwDECE SUM 0 PLAYER MADE LAST PLAY s YOUWIN Ck OR OH YOu WiN Se TNORFI GAME Ca at GAMESWON 6C YOULOSE CR CR SETING YOU LUSE BETTER LUCK NEXT 5 SORT MAINLINE WORDS CONT 71 BY TONY LEWIS NORMAL 51 HUME 7 V DO YOU WANT FIRST PLAY TYPE OR n OR kY 78h N IF i 1597 MOVE MYCARD ELSE YOLRCARD THEN O SWAP x SET UF LOOP BEGIN TRUE FLAS SET ON CAROSUM C IF je SET Ex1I LSE 71 CAROSUM IF YOULMSE i EL YOURCARD HHEN LSE FROM i le YUU ELSE G1 CARDSUM te FLSE o0 THEN N T 157 WOVE futt b
6. The foregoing is not a commercial for prof ORTH but rather is intended to illus trate that the scope of usage to which FORTH can be applied is very broad In a situation where you have multiple diction aries and are fighting for every byte of memory available thinking in terms of storing unbounded tokens at HERE and floating PADs of arbitrary length becomes very incongruous Admittedly des cribed a somewhat extreme situation but it is not as rare as you may think Micro processor applications are getting more ambitious every day and sooner or later you wil have a crowded memory condition I think FORTH should be able to handie these situations gracefully without having to deviate from the Standard When defining WORD then one ob jective should be to enable users to extract arbitrarily long tokens from the text stream but not force the implementor to provide an arbitrarily long memory buffer to accomplish it While this may sound a little like trying to have your cake and eat it too a rather simple factoring of WORD can easily accomplish it To illustrate my point suppose we devise a more basic WORD called WORD and define it as follows WORD BLK d DUP YF BLOCK FLSE TIB amp THEN gt IN SWAP ENCLOSE gt IN 1 OVER ROT SWAP where ENCLOSE is defined as in the FIG glossary and ROT is equivalent to ROT ROT This new WORD extracts the next token from the text stream delimit
7. lt FUSE THEN 13 2 58 CURSOR TAB between colors 14 13 68 CURSOR RETURN te get clues 15 gt SCR 25 Master Mind board larout mask 17 1 2 BAR i 3 i DASH 3 BOSRO SYMBLLS TITLE 21 5 5 4 MASTER MIND 3 S DASHER 2 21 CURSOR BAR 32 0 DO LOOP BAR CR 6 CLINE DUP 21 CURSOR BAR 24 CURSOR BAR 7 S 2 SPACER 22 CURSOR 5 Pen oe eee CBLOCK DUP CLINE 1 SPACER 10 HIDDEN 3 Z3 CURSOR 2 XXXXXX XxXX X XX 5 11 12 DISPLAY BOARD 13 CLEAR TITLE DASHER HIDDEN 24 3 DO I CRLOCK 2 L OF 14 SHOW COLORS 3 15 gt FORTH DIMENSIONS 1175 Page 159 SCR 24 Master Mind curser tracking definitions 17 80 1 23 X Y e 4 XBUMP X 52 5 IF 22 DUP CUR COL 6 ELSE 1 X CUR C OL 2 7 IF X CUR COL THEN THEN 3 9 10 WNBUMPX X 23 IF 52 XLOC ELSE 1 XLOC THEN 3 11 12 TAB CUR COL 47 13 23 CUR COL 14 ELSE 8 CUR COL 15 THEN CUR COL xLGC DROP Y X CURSOR s gt SCR 27 Master Mind character collection editins DAB 17nov amp O 1 BACKSFACE X CUR COL z IF DROP 3 ELSE UNELIMPX Y X CURSOR SPACE Y X CURSOR DROP 4 32 COLORS X 23 C 5 THEN 7 PROCESS 2 12 PROCESSES CHAR MANAGES CURSOR 2 DUP EMIT COLORS X 23 C Y X CURSOR
8. piler which produces a Z8002 79 Standard FORTH compiler interpreter for the Zilog 28000 Development Module Package includes 28002 assembler Tektronix download program and a number of utilities Released on two 5 1 4 diskettes or on FORTH DIMENSIONS 111 5 one 8 diskette Price 1 450 00 5 Zilog 28002 Development Module fiq FORTH ROM set Contains 79 Stand ard FORTH with 28002 assembler and editor in 4 2716 PROMS Price 280 00 CODE9 Arthur M Gorski 2240 S Fvanston Avenue Tulsa OK 74114 918 745 0115 CODE is a M6809 Assembler for use with any fig FORTH system It features all M6809 addressing modes except long relative branch instructions It performs syntax error checking at assembly time Memory requirements 4 75K bytes free RAM above FORTH CODE is distribut as commented source listing and manual Price 20 00 PET FORTH by Datatronic AB Box 42094 5 126 12 Stockholm Sweden 0 8 744 59 20 Peter Bengtson Product Description Extended fig FORTH for the Commodore CBM PET computer series Screen editor utilizing the special CBM screen editing possibilities for compact ness and ease of use macro assembler double precision extensions CRT hand ling random numbers real time clock a very complete string package FEE con trol words integer trig functions An expansion disk coming soon will con tain floating point arithmetic including complex numbers transparent
9. 52 Seventh Avenue San Francisco CA 94118 Really slick But the algorithm would be hard to explain to most people ed FORTH DIMENSIONS III 5 FUNCTIONAL PROGRAMMING AND FORTH Harvey Glass University of South Florida College of Engineering Department of Computer Science Tampa FL 33620 The distinguished computer scientist John Backus in his 1977 Turing Award lecture 1 describes the shortcomings of conventional programming lanquages and suggests a new approach to programming in a style described as functional pro gramming FP We will summarize the faults that Backus finds in conventional languages briefly describe the functional programming style and lastly show that FORTH meets the spirit of this style of programming Conventional Languages An underlying problem of conventional programming languages is that they tend to be high level descriptions of the Von Neumann computer The assignment statement is the principal construct of these languages A program becomes a series of these assignment statements each of which requires the modification of a single cell We may think of the Von Neumann computer as a set of storage cells a separate processor and a channel connecting the two If assignment state ments imitate the store operation then branch statements imitate jump and test while variables imitate storage cells The high level languages provide sophisticated constructs to directly model the under lyin
10. but I just had to write to say that the speed of FORTH is not necessarily just a function of pro cessor speed as you have often claimed Everett Carter Harvard University Division of Applied Sciences Cambridge MA 02138 Thank you for your well thought out con tribution ed Dear F ig A comment about your publication FORTH DIMENSIONS The information is certainly useful especially the ap plications however much of the material assumes a complete understanding of FORTH S inner workings 1 don t really understand how the compiler works and what all those cryptic words CFA PFA SMUDGE IMMEDIATE etc do but I would like to learn I am sure there are others out there like me so how about some tutorial articles on some of these FORTH unique features Thomas Kastner 7918 207th St SE Snohomish WA 98290 Entry level tutorial articles are an area 1 have been exploring for the past year Check this issue and you will find the first in a series of articles contributed by Henry Laxen of LAXEN AND HARRIS INC a firm that specializes in FORTH instruction ed Dear F ig I don t doubt FORTH would be more useful if my machine had all of the fea tures described in An Open Response Volume II 6 but consider what 1 have gained without them 1 An understanding of how FORTH works 2 A demonstration that a workable sub set of FORTH can be implemented on a very small system 3 Hours of enjoyment an
11. cending ASCII sequence is used for A and above Next we add to the original definition of number as follows number A number is represented in the input stream as a word composed of a sequence of one or more digits with a leading ASCII minus if the number is negative and a trailing ASCII dot if the value is to be considered double precision I recommend that implementers allow the above format and that authors of transportable programs adhere to the same format In any case when the Stan dards Team meets again they should cer tainly clarify this area Under the Spreading FIG TREE As many of you are aware there is a Computer Conference Tree now nick named the FIG TREE which contains items of interest to the FORTH com munity I would like to encourage all persons interested in the 79 Standard to read and contribute to the branch of the FIG TREE called 79 STANDARD you need is a terminal 110 or 300 baud a modem and a telephone The number is 415 538 3580 See back issues of FORTH DIMENSIONS for further information or just call up and send a few carriage returns until the system responds CORRECTIONS Add to FD pg 102 the following REFERENCES 1 Forsley Lawrence Laser Control System A talk given at the Laboratory for Laser Energet ics on March 9 1977 and on July 16 1977 at the Wilson Synchrotron Cornell University 2 Lawrence P Forth Multi tasking
12. will occur if the processor status bit given by cc is false otherwise BOT CODE CPU CS ELSE execution continues ahead At assembly time BEGIN leaves the dictionary pointer address addr and the value 1 for ater testing of conditionary pairing by UNTIL n assembling Used during code assembly in the form BOT LDA or BOT 1 X STA Addresses the bottom of the data stack containing the low byte by selecting the X mode and leaving n 0 at assembly time This value of n may be modified to another byte offset into the data stack Must be followed by a multi mode mnemonic A defining word used in the form CODE lt name gt END CODE to create a dictionary entry for lt name gt in the CURRENT vocabu lary Name s code field contains the address of its parameter field When lt name gt is later executed the machine code in this parameter field will execute The CONTEXT vocabulary is made ASEMBLER to make available the op code mnemonics n compiling assembler An assembler defining word used to crate assembler mnemonics that have only one addressing mode EA CPU NOP CPU creates the work NOP with its op code EA as a parameter When NOP later executes it assembles EA as a one byte op code cc assembling Specify that the immediately fol lowing conditional will branch based on the processor carry is set C 1 The flag cc is left at as sembly time
13. word order partly to distinguish these often unrelated words A few examples are in order Consider the possible function of these FORTH words both with respect to their current use some are nouns while others are verbs but also in their opposite hypothet ical use BUFFER FENCE KEY LIMIT LOOP SPACE TYPE etc Others which a programmer might wish to use developing applications might include OFFSET SPAN INSERT FILE CATALOG OUTPUT Since the action of these words is not known from the word itself but only from either pre vious agreement or syntax and since syn tax sensitivity is not a common part of FORTH ie where a syntactical form does not alter the way in which a word is compiled some degree of confusion can result Furthermore use of a word in only one form rules out its use in another form ex cept where it can reside in a different vo cabulary Thus words like KEY LOOP BLANK and TYPE all FORTH verbs cannot function as nouns despite our temptation to use them that way for their inherent English language based clarity The same is true of some of the FORTH nouns like BLOCK BUFFER STATE LIMIT and BASE Thus it is not possible to know the nature of the word from its name alone Would prefixes for verbs unnecessarily clutter the language Would some prefix or suffix to differentiate constants from variables be useful Or should we leave it alone The TO and FROM wo
14. 3 9 10 GET CHAR KEY DUF 127 11 IF BACKSPACE ELSE 7 2 TAE ELSE DUF 13 13 IF 1 DONE DROP 14 ELSE PROCESS THEN THEN THEN 5 19 SCR 28 Master Mind Suess row section DAR 17nov820 NOUS NI INITIAL 2 3 DUP YLOC CUR ROW CUR COL Y X CURSOR 22 I COLORS C 5 So GET COLORS INITIAL DONE 10 PARSE GUESS 40 DO I amp COLORS 11 I 9 COLORS 1 iz 1 8 COLORS 2 ce 13 I GUESS C LOOP 3 14 gt 15 SCR 29 Master Mind Clue generation 1 2 CLUE CHECK 2 BLACKER O WHITER INITIAL 4 40 HO 5 SECRET I GUESS J IF 1 BLACKER oO I GUESS 7 THEN LOOP D GUESS I ce gt IF 4 pi 10 GUESS I SECRET J 11 IF 1 WHITER 1 I GUESS 12 THEN 13 LOOF THEN 14 LS gt Page 160 23 23 XLOC BEGIN GET CHABR DONE UNTIL DABR 17novzO COUNTS gt CHECK FOR DIRECT HIT IF NO HIT CHECK FUR WHITE gt LEAVE FORTH DIMENSIONS 11 5 o a C 20 MO nmn PON DON e Thy 4 1 30 Master Mind Present clues DAB 17naveo GIVE CLUES Y 1 CURSOR PARSE GUESS BLACKER WHITER 23 CURSOR SCODE Ce COLOR FIND 1 ELSE THEN LOOP CLUE CHECK BLACK WHITE H UNMASK
15. 40 3 1 3 23 1 CURSOR 2 PAGAIN 20 52 CURSOR TYPE MASTER PLAY AGAIN UNMASK 1 CURSOR 3 LOSER 16 58 CURSOR NICE TRY BUT NO CIGAR TAGAIN 3 1 WINNER 16 58 CURSOR PRECISELY TRYS PAGAIN 3 gt 31 Master Mind 21 SS CURSOR 23 17 SS CURSOR ATTEMETS gt Directions to elaver Li B 17noveO DIRECTIONS CLEAR CR CR CR CR 10 DO LOOP Welcome to MASTER MIND CR CR The object of Master Mind is to break the secret cade The computer will Pick the secret code and vou must CR figure it out Two kinds of clues are diventi CK CR 1 BLACK means that vou have pess correct OR a in both color and Position CR CK 2 WHITE means that veu have reds of the R a correct color that are CR Placed CK CR Be sure te spell the calors correctlw You may tab amoung CR the 4 Positions until vou ve make vour best suess UR CR RETURN to receive clues CR CR Gond iuck CR gt 32 Master Mind FINAL 17 MASTER DIRECTIONS OO ATTEMPTS ASK FOR LEVEL ASK FUR RANDOM DISPLAY BOARD FRANSLATE CULE lt eut UNMASK te debus 10 DO 1 ATTEMPTS FARSE GLUESS 1 GET COLORS GIVE CLUES BLACKER 4 IF WINNER LEAVE ELSE THEN 1 LOUF BLACKER 4 lt IF L SER ELSE THEN MASTER ese are hidden during play YELLOW REG BLACK GREEN W
16. BEGIN CR Reverse how many PAD 80 EXPECT PAD 48 DUP O OVER 9 gt OR DUP IF CR Only through 9 is allowed THEN UNTIL CR gt 232 The Game of Reverse ARRAY operations cont 100781 AREVERSE Reverse a subset of ARRAY 2 47 1 Loop limits are 1 to n 21 1 DO DUP I 1 t Calculate index n I 1 DUP A SWAP Get ARRAYIn I 1 1 I ARRAYII SWAP Store ARRAYII 1 1 I A Store ARRAY n I 1 in LOOP DROP ACHECK Check for ascending seq flag 1 10 1 DO I DUP A8 AND LOOP gt 233 The Game of Reverse REVERSE definition 101281 MPB REVERSE Play the game INSTRUCT AINIT BEGIN ASCRAMBLE MOVES BEGIN A GETIN DUP IF 1 ELSE AREVERSE 1 MOVES ACHECK THEN UNTIL CR You made MOVES 6 reversals CR CR Care to play again Y N Ox UNTIL CR Thanks for playing REVERSE CR CR 38 case Y If a Y is present the flag returned is true For any other char acter the flag is false INSTRUCT Prints the name of the game and then asks if instructions are required yes instructions are displayed ARRAY A ten word array that contains the number list that REVERSE works on Element zero of the list is not used index array value Fetches the index array value of ARRAY and leaves it on the data stack array value index Stores array value int
17. DROP NEWGAME SEIFLASH BIG BET GAME Z THE FINALE CR CR SETNORM BIGRE WELL DID YOU HAVE THE CORRECT ANALYSIS iF 50 THEN SEE IF YOU CAN FIGURE OUT Ck WHO WINS WITH 157 CARD OF ONE OR TWO 11 5 TOUGH COMBINATORIAL PROBLEM 1 FINAL EXIT IN MAINZI SCRHE4 PLAY THE GAME OF 21 BY TONY LEWIS 1 MAINZI LOGIC SHELL GAMESWON BEGIN CR CK TYPE OR CR OR KEY DUF FALSE LEAVES 78 ON STACK FOR UNTIL gt NEW GAME OR B BIG CHECK FOR N IF NEWGAME 66 IF GAMESWUN 2 IF BIGBET ELSE HOME YOU HAVE WON GAMESWON Ca DUF GANE 1 IF a ELSE S THEN YOU MUST WIN 3 GAMES TO PLAY BIG BET THEN ELSE NORNALSI THEN THEN UNTIL HOWiOSI1 CODECONS MAINS1 CODECONSA MAINSI NEW GAME TYPE Y OR N OR B BIG HET DO YOU WANT FIRST PLAY TYPE Y OR N PLAY IS 2 THE DECK NOW CONTAINS 1 L3 5555 6666 THE RUNNING TOTAL 15 2 CARD 1 YOUR CARD WAS 2 1 i DECK NOW CONTAINS 1 FHE RUNNING TOTAL 15 5 PLAY IS 5 THE 1 2 gt DECK NOW CONTAINS E d 2 44 5 5 6 THE RUNNING TOTAL 15 ic TYPE IN CARD 1 amp YOUR CARD WAS A THE i 4 5 5 e DECK i CONTAINS pues THE RUNNING TOTAL IS 15 my
18. EEEEEEEEEEEECEEE FORTH OES FORTH INTEREST GROUP Volume III P O Box 1105 Number 5 San Carlos CA 94070 Price 2 50 Functional Programming and Forth Harvey Glass Forth and Artificial Linguistics Raymond Weisling Technotes A Forth Assembler for The 6502 William F Ragsdale A Technical Tutorial Table Lookup Examples Henry Laxen The Game of Reverse M Burton The 31 Game Tony Lewis Simulated Tektronics 4010 Graphics with Forth Timothy Huang A Video Version of Master Mind David Butler Transfer of Forth Screens by Modem Guy T Grotke Published by Forth Interest Group Volume III No 5 January February 1982 Publisher Editor Roy C Martens J Street Editorial Review Board Bill Ragsdale Dave Boulton Kim Harris John James Dave Kilbridge Henry Laxen George Maverick Bob Smith John Bumgarner FORTH DIMENSIONS solicits editorial material comments and letters No responsibility is assumed for accuracy of material submitted ALL MATERIAL PUBLISHED BY THE FORTH INTEREST GROUP IS IN THE PUBLIC DOMAIN Information in FORTH DIMENSIONS may be reproduced with credit given to the author and the Forth Interest Group Subscription to FORTH DIMENSIONS is free with membership in the Forth Interest Group at 15 00 per year 27 00 foreign air For membership change of address and or to submit material the address is Forth Interest Group P O Box 1105
19. PLAY IS 1 eU buen me whe Hi DECK NOW CONTAINS THE RUNNING TOTAL IS 17 TYPE IN CARD 1 YOUR CARD WAS A 5 4 D BON URON DECK NOW CONTAINS 1 2 44 5 6 THE RUNNING TOTAL 15 20 PLAY i5 4 DECK NOW CONTAINS 1 1 22 in 3 555 amp 56 THE RUNNING TUTAL i 24 im CARD 1 CARD WAS A S THE NOW CONTAINS DECH t 1 44 d THE RUNNING TOTAL IS 2 e PLAY 152 THE DECK NOW CONTAINS IX X 44 44 55 THE RUNNING TOTAL 15 51 YOU LOSE LUCK NEXT TIME NEw GAME N OR BET YOu HAVE WON GAMES YOU MUST WIN 2 GAMES TO PLAY BIG GAME TYPE Y GR N OR B BIS BET t FORTH CLASSES LAXEN AND HARRIS INC 24501 Southland Drive Hayward CA 94545 415 887 2894 Introductory classes Process control Applications programming Systems leve programming GREG STEVENSON Anaheim CA 714 523 4202 Introductory classes KNOWARE NOLOGY Box 8222 Stanford CA 94305 408 338 2720 Introductory classes Graphics classes INSTITUTE OF INNER ACCESS CORPORATION Belmont CA 415 591 8295 Introductory classes FORTH INC 2509 Pacific Coast Highway Hermosa Beach CA 90254 213 372 8495 Introductory classes Advanced classes FORTH DIMENSIONS 5 Page 155 SIMULATED TEKTRONICS 4010 GRAPHICS WITH FORTH i Scree
20. San Carlos CA 94070 HISTORICAL PERSPECTIVE FORTH was created by Mr Charles H Moore in 1969 at the National Radio Astronomy Observatory Charlottesville VA It was created out of dissatisfaction with available programming tools especially for observatory automation Mr Moore and several associates formed FORTH Inc in 1975 fo the purpose of licensing and support of the FORTH Operating System and Programming Language and to supply application programming to meet customers unique requirements The Forth Interest Group is centered in Northern California Our membership is over 2 400 worldwide It was formed in 1978 by FORTH programmers to encourage use of the language by the interchange of ideas through seminars and publications Page 134 EDITOR S COLUMN 1981 is behind us and as I look back I am pleased to see how much has been accomplished for FORTH FIG and FORTH DIMENSIONS I really appreciate all the help and support I have received from our readers I have not done everything right and some of the best help has been your disagreement Intelligent construc tive criticism is as welcome as earned praise 1982 will be a year of continued growth You can look forward to continuing responsiveness is my plan to contact FIG chapter by telephone at least quarterly to get feedback and encourage reader contributions FORTH DIMENSIONS wiil also be awarding AUTHOR S CERTIFICATES for outstanding articles that co
21. addr assembling Used in a code definition in the form N1 ADC STA N 2 constant which leaves the ad dress of a 9 byte workspace in z page Within a single code defini tion free use may be made over the range 1 thru N 7 See SETUP addr assembling A constant which leaves the machine address of the Forth ad dress interpreter code defini tions must return execution to NEXT or code that returns to NEXT i e PUSH PUT POPTWO ccl ccl assembly time When assembling reverse the con dition code for the following con ditional For example 0 NOT IF true part THEN will branch based on not equal to zero addr n assembling run time A constant which leaves during assembly the machine address of the return point which at run time will pop a 16 bit value from the data stack and continue inter pretation POPTWO PUSH PUT RP THEN addr assembling nln2 run time A constant which leaves during assembly the machine address of the return point which at run time will pop two 16 bit values from the data stack and continue interpretation addr assembling n run time A constant which leaves during assembly the machine address of the return point which at run time will add the accumulator as high byte and the bottom machine stack byte as low byte to the data stack addr assembl
22. be discovered usually by trial and error FORTH s big gest virtue in my opinion is that it makes the trial and error process extremely ef ficient and therefore allows people to experiment and discover the best solution for themselves HELP WANTED Programmers needeed to produce new polyFORTH systems and applications Two to three years extensive FORTH experience working with mini micro computers and peripherals Contact Patricia Jones FORTH INC 2309 Pacific Coast Highway Hermosa Beach CA 90254 213 372 8495 fig FORTH NOVA GROUP Mr Francis Saint 2218 Lulu Wichita KS 67211 316 261 6280 days has formed a FIG Group to trade information and assistance between fig FORTH NOVA users Pub Comment Hope to see a new clean listing about some other specific groups FORTH DIMENSIONS 5 Page 151 THE GAME OF REVERSE M Burton REVERSE is a number game written in FORTH primarily as an exercise in array manipulation The object of REVERSE is to arrange a list of numbers 1 through 9 in ascending numerical order from left to right Moves are made by reversing a sub set of the list from the left For example if the current list is 234516789 and four numbers are reversed the list will be 543216789 then if five numbers are reversed the game is won 123456789 To leave a game that is in progress simply reverse zero numbers REVERSE Glossary SEED The number seed for
23. bit of luck to 1 but it is The screen is cleared nd 6 dr of the 5 mainly an exercise in lodical deduction A secret code is mI Master Mind playing board is displayed generated and it is cracked by analyzing set of clues T he cursor lands at the location where the 8 Those familiar with the original board game will have player is to begin entering his guess The program retains control of the cursor re sponding to the player s key strokes Backspacing and tabbing are allowed en difficulty adjusting to the computer version newcomers 10 follow the directions carefully and vou will have it in 11 time The Forth version is functionally identical to the 12 board version It is written in fis Forth and has been run 13 successfully on 6502 2030 220 and 68000 processors re 14 is good demonstration Program as well as an enjoyable 15 SCR 20 Master Mind set up some variables DAB 17naveo 1 2 TASK 3 FORGETTABLE MARKER 4 VARIABLE COLORS 25 ALLOT COLORS 30 BLANKS 5 6 VARIABLE SCODE 2 ALLOT VARIABLE GUESS 2 ALLOT 7 VARIABLE SECRET 2 ALLOT O VARIABLE BLACKER VARIABLE WHITER 9 amp VARIABLE COLORS 10 11 3 VARIABLE CUR ROW 23 VARIABLE COL 12 1 VARIABLE XLoc 1 VARIABLE VARIABLE DONE 13 gt 14 15 SCR 21 Master Mind set cant DAB 17neveo 2 C CONSTANT YELLOWRED BLACK GREEN WHITE BLUE a VAR
24. execution leaves NEXT to execute a CODE definition the following conventions applv 1 Y index register is zero It may be freely used 2 The X index register defines the low byte of the bottom data stack item relative to machine address 0000 3 The CPU stack pointer S points one byte below the low byte of the bottom return stack item Exe cuting PLA will pull this byte to the accumulator 4 accumulator may be freely used 5 The processor is in the binary mode and must be returned in that mode XSAVE 5 is a byte buffer in z page for temporary storage of the X register Typical usage with a call which will change X is CODE DEMO XSAVE STX USER S JSR which will change X XSAVE LDX NEXT JMP END CODE N Area When absolute memory registers are required use the N Area in the base page These registers may be used as pointers for indexed indirect addressing or for temporary values As an example of use see CMOVE in the system source code The assembier word N returns the base address usually 0001 The N Area spans 9 bytes from N thru N 7 Con ventionaily 1 holds one byte and 2 N 4 N 6 are pairs which may hold 16 bit values See SETUP for help on moving values to the N Area It is very important to note that many Forth procedures use N Thus N may only be used within a single code definition Never expect that a value will remain there outsi
25. fullFORTH is worth a mention if not a comprehensive review Francis T Chambers ROCK HOUSE Ballyoroy Westport Co Mayo Ireland Thank you for your interest This was reviewed in Vol 3 Dear Fig This is our response to Chuck s Moore s cute letter Arthur Goldberg Spencer SooHoo CEDARS SINAI MEDICAL CTR 9700 Beverly Bivd Los Angeles CA 90048 FORTH DIMENSIONS 5 DEA CHU YOU TO CON CON OF THI CON LET WE CLA THA THE CON OF A WOR IN COM ENG CON CONS TO OUR TO DEC IT FRO THR LET AND THE LEN HOW IN COM PRO THE CON IS LES CON WOR CAN BE SWA WIT CHA THE SEM IT CON cates CON LES HEL IN IDE THE DEF OF A WOR IN FAC AS THI LET DEM THR LET AND LEN CAN LET EVE A CAR REA OF COM ENG SIN YOU ART GOL SPE SOO TRANSLATION Dear Chuck WE CHALLENGE YOU TO CONSIDER THE CONTENTS OF THIS CONFUSING LETTER WE CLAIM THAT THE CONTEXT OF A WORD IN COMMON ENGLISH CONTRIBUTES CONSIDER ABLY TO OUR ABILITY TO DECIPHER IT FROM THREE LETTERS AND THE LENGTH HOWEVER IN COMPUTER PRO GRAMS THE CONTEXT IS LESS CONFINING COMMONLY WORDS CAN BE SWAPPED WITHOUT CHANGING THE SEMANTICS CONSEQUENTLY IT CONTRIBUTES CONSIDERABLY LESS HELP IN IDENTIF YING THE DE
26. overlay control words for date and program segments a file system and more METAFORTH compiler will shortly be available Runs on CBM 8032 plus an 8050 dual disk drive Other configurations coming 4032 4040 VIC and MicroMainF rame 8032 version runs in 32K only 4032 versions will run in either 16 or 32K Manual Description all source code 322 pages including Complete introduction to FORTH Special chapters cover the asembler lt BUILDS and DOES gt IEEE handling strings etc Manual is available separately Separate purchase price is 40 00 This is not creditable towards later purchase Product Ordering Data Shipped as disk ette and an accompanying security ROM holding part of the Kernel Currently there are approximately 75 in stallations after 2 months on the market Price 290 00 Includes diskette ROM manual shipping and taxes PET FORTH as all other Datatronic soft ware carries a life time guarantee All future versions will be distributed to the soever Delivery is immediate US dealers are invited UK sole distrib utor is Petalect Electronic Services Ltd 33 35 Portuga Road Woking Surrey You may also order directly from us Diskette of FORTH Application Modules from Timin Engineering Company 9575 Genessee Avenue Ste E 2 San Diego CA 92121 714 455 9008 The diskette of FORTH application modules a new product by Timin Engin eering is a variety package of FORTH
27. single density diskette only Reference Manual for PDP 11 fig FORTH above Price 20 00 2 Fig FORTH compiler interpreter for CP M or CROMEMCO CDOS system comes complete with source code writ ten in native assembler Included in this package are an assembler and editor written in FORTH and instal lation documentation Price 80 00 All diskettes are single density with 5 1 4 diskettes in 128 byte 18 sector track format and 8 diskettes in 128 byte 26 sector track IBM format Released on two 5 1 4 diskettes with source in 8089 assembler Released on one 8 diskette with source in 8080 assembler Released on two 5 1 4 diskettes with source in Z80 assembler Released on one 8 diskette with source in Z80 assembler Manual for CP M or Cromemco fig FORTH above Price 20 00 3 Cross compiler for CP M or Cromemco CDOS to produce 79 Standard FORTH on a target machine The target can include an application without dictionary heads and link words It is available on single density diskettes with 128 byte 26 sector track format Target compiles may be readily produced for any of the following machines CROMEMCO all models TRS80 Model Il under CP M Northstar Horizon Prolog Z80 Released on two 5 1 4 diskettes or on one 8 diskette Price 450 00 4 Complete Zilog AMD 28002 develop ment system that can be run under CP M or Cromemco C System includes a METAFORTH cross com
28. the immediately preceding IF BEGIN lt code always executed CS IF lt code if carry set gt ELSE code if carry clear THEN 0 NOT UNTIL loop till condition flag is non zero lt code that continues onward gt Next is an error that the assembler security will reveal BEGIN PORT LDA 0 BOT INC 0 UNTIL ENDIF The UNTIL will not complete the pending BEGIN since the immediately preceding IF 15 not completed error trap will occur at UNTIL saying condi tionals not paired Page 146 RETURN OF CONTROL revisited When concluding a code definition several common stack manipulations often are needed These functions are already in the nucleus so we may share their use just by knowing their return points Each of these returns control to NEXT POP POPTWO remove one 16 bit stack values POPTWO remove two 16 bit stack values PUSH add two bytes to the data stack PUT write two bytes to the data stack over the present bottom of the stack Our next example complements a byte in memory The bytes address is on the stack when INVERT is executed CODE INVERT memory byte HEX BOT X LDA fetch byte addressed by stack FF EOR complement accumu lator BOT X STA replace in memory POP JMP END CODE discard pointer from stack return to NEXT A new stack value may result from a code definition We could program placing it on the stack by CODE ONE put 1 o
29. the pseudorandom number generator SEED is initialized as the REVERSE words are compiled by hitting any key on the console MOVES Keeps track of the number of moves made in a REVERSE game If more than fifteen moves are made to win you haven t got the hang of the game RND range random number The pseudorandom number generator courtesy of FORTH DIMENSIONS RND generates random number in the range 0 through 1 RND is used to scramble the number list DIM n A defining word used in the form n DIM xxxx Produces an n l length word array named xxxx with elements 0 through n For the REVERSE application element 0 is not used Y N flag Solicits an input string from the con sole then checks the first character of the string for an uppercase or lower i52 SCR 228 The Game of Reverse SEED MOVES RND DIM Y N 101281 MPB 1 2 0 VARIABLE SEED Seed for random number generator 30 VARIABLE MOVES Number of reverses so far 4 CR Please depress key Fertilize the seed 5 KEY SEED 6 7 RND Random number generator range rnd 8 SEED e 259 3 32767 AND DUP SEED 32767 9 10 DIM Reserve an integer word array n 11 BUILDS 1 2 12 DOES gt 13 14 Y N Get a or N response flag 15 PAD 80 EXPECT PAD Ce CR CR 95 AND 89 gt SCR 229 O The Game of Reverse Game instructions 101281 MPB 1 2 INSTRUCT CR CR 18 SPACES Th
30. this that requires less typing and is also more general We will first define a word called TABLE which will aid us in the cre ation of tables like the one above What we will do is first place the initial values of the TABLE on the stack together with the number of the initial values Then we will define TABLE te copy these into the dictionary Here is how it works TABLE Nn 1 NI n DO LOOP CREATE DAYS MONTH 31 50 31 50 31 51 30 31 30 51 28 31 12 TABLE DAYS MONTH INDEX VALUE l 2 DAYS MONTH 8 Now this is considerably iess typing than the first way of doing it but notice that I had to reverse the order of the days per month since that is the way stacks be have I used CREATE instead of VARI ABLE because it does not allocate any space for the initial value but otherwise behaves just like VARIABLE The access word DAYS MONTH is identical to before I am still not satisfied however so let s try it yet another way Instead of defining TABLE to add values to the dic tionary with comma why not just use directly CREATE DAYS MONTH 31 28 31 30 31 30 31 51 30 51 30 31 DAYS MONTH INDEX VALUE 1 2 DAYS MONTH Now we are getting somewhere If we simply use the FORTH word comma to add the value to the dictionary see how simple and readable it becomes The values are just typed in and separated by commas Is it possible to improve even on this Funn
31. vari able Because the width number of char acters saved is also allowed to be less than the actual number of characters in the name one cannot rely on the count to provide the address of the link field given the address of the name field This is why the fig FORTH compiler automatically sets the most significant bit of the first character and the last character in every name By this device one can scan a name forward or backward by looking for this bit In a dictionary search the address in the link field is followed to the beginning of the name field of the previous word If it is not a match to the key you are look ing for we scan forward in memory until the most significant bit tells us we have found the link field to the next word When dictionary link is broken by clob bering RAM an erroneous address is fol lowed and the system is said to crash However in fig FORTH the system does not always die In many cases it is merely wounded displaying a strange kind of amnesia in which it has no recol lection of recent definitions but remem bers with clarity its childhood What happens is this the broken link sends the dictionary search off to a totally random part of memory if you do not have 64K it may address RAM where there are no boards Since it is not likely to find a match at this address it scans forward for the most significant bit that marks the end of the name The odds are that it wi
32. words have the fig FORTH definitions Philip Wasson FOR TH DIMENSIONS III 5 MORE WORDS ABOUT WORD Robert D Villwock Microsystems Inc In analyzing or proposing changes to any Standard definition it is very impor tant to concentrate on the details of the needed function and to avoid any precon ceived notion of internal implementation details unless of course the two are in separable If this is not done we can severely and unnecessarily constrain future implementors frem doing their best possible job or worse yet find them a voiding the Standard entirely A good case in point is the word WORD Since most FORTH implementors have favored using the free space above the dictionary to store tokens extracted by WORD and further since their exper ience seems to be centered around small to medium sized application programs it is tacitly assumed that this free space is arbitrarily Jarge In addition to storing tokens at HERE PAD is usually also de fined to float above the dictionary in this unbounded free space Therefore whether WORD handles tokens of length 128 256 or even 1024 bytes is innocently discussed with the idea that the only issue involved is the length descriptor preceding the string However whether this token buffer and PAD float above HERE or are fixed location buffers or some different scheme is devised they consume real memory and are not really free space To illustrate suppose w
33. 2 90 CONSTANT gt ASSEMBLE TEST FOR GREATER OR EQUAL ZERO 13 gt IS ONLY CORRECT AFTER SUB OR CMP 14 15 SCR 86 0 USE OF ASSEMBLER WFR 79APR28 1 END CODE END OF CODE DEFINITION 2 CURRENT CONTEXT EXEC CSP SMUDGE IMMEDIATE 3 4 FORTH DEFINITIONS DECIMAL 5 CODE CREATE WORD AT ASSEMBLY CODE LEVEL 6 CREATE COMPILE ASSEMBLER 7 ASSEMBLER MEM 1 5 IMMEDIATE 8 9 LOCK ASSEMBLER INTO SYSTEM 10 ASSEMBLER CFA CODE 8 OVER WRITE SMUDGE 11 LATEST 12 ORIGIN TOP NFA 12 HERE 28 ORIGIN FENCE 13 HERE 30 ORIGIN 14 ASSEMBLER 6 32 ORIGIN VOC LINK 15 HERE FENCE Paged50 7T 0 IU Mpu pO x FORTH DIMENSIONS 5 APPLICATIONS A TECHNICAL TUTORIAL TABLE LOOKUP EXAMPLES Henry Laxen Laxen and Harris inc One of the problems with FORTH as with every rich language is that given an idea there are many ways of expressing it Some are more eloquent than others but it takes practice and experience to create the poetry and avoid the mundane This article is written to illustrate 4 different ways of implementing simple Table Lookup operation The goal is the following we want to create a FORTH word named OAYS MONTH which be haves as follows Given an index on the stack which is the month number such as l for January and 12 for December we want to return the number of days in that month in a norma year Thus if we exe c
34. 8 CPU SEI AA CPU TAX 12 A8 CPU TAY BA CPU TSX 8A CPU TXA 9A CPU TXS 13 98 CPU TYA 14 15 FORTH DIMENSIONS 11 5 Page 149 SCR 84 0 M CPU MULTI MODE OP CODES WFR 79MAR26 1 M CPU BUILDS C DOES 2 DUP 1 8 80 AND 10 MODE THEN OVER 3 FF00 AND UPMODE UPMODE IF MEM CR LATEST ID 4 3 ERROR THEN C MODE 5 INDEX C MODE C 7 AND IF MODE CQ 6 OF AND 7 lt IF C ELSE THEN THEN MEM 7 8 1C6E 60 M CPU ADC 1 6 20 M CPU AND 1 6 CO M CPU CMP 9 1C6E 40 M CPU EOR 1 6 AO M CPU LDA 1C6E 00 M CPU ORA 10 1C6E EO M CPU SBC 1C6C 80 M CPU STA ODOD Ol M CPU ASL 11 OCOC Cl M CPU DEC OCOC El M CPU INC ODOD 41 M CPU LSR 12 21 M CPU ROL ODOD 61 M CPU ROR 0414 81 M CPU STX 13 0486 EO M CPU CPX 0486 CO M CPU CPY 1496 A2 M CPU LDX 14 M CPU LDY 0480 80 M CPU STY 0480 14 M CPU JSR 15 8480 40 M CPU JMP 0484 20 M CPU BIT SCR 85 0 ASSEMBLER CONDITIONALS WFR 79MAR26 1 BEGIN HERE 1 IMMEDIATE 2 UNTIL EXEC gt R 1 PAIRS R gt C HERE 1 C IMMEDIATE 3 IF C HERE 0 C 2 IMMEDIATE 4 THEN 2 PAIRS HERE OVER 5 IF SWAP ELSE OVER l SWAP C THEN IMMEDIATE 6 ELSE 2 PAIRS HERE 1 1 JMP 7 SWAP HERE OVER 1 SWAP C 2 IMMEDIATE 8 NOT 20 REVERSE ASSEMBLY TEST 9 90 CONSTANT CS ASSEMBLE TEST FOR CARRY SET 10 DO CONSTANT 0 ASSEMBLER TEST FOR EQUAL ZERO 11 10 CONSTANT 0 lt ASSEMBLE TEST FOR LESS THAN ZERO 1
35. ELSE or THEN Conditionals may be nested addr assembling An array used within the assem bler which holds bit patterns of allowable addressing modes addr assembling Used in a code definition in the form STA LDA A constant which leaves at as sembly time the address of the pointer to the next FORTH exe cution address in a colon defini tion to be interpreted At run time NEXT moves IP ahead within a colon definition Therefore IP points just after the execution address being inter preted If an in line data struc ture has been compiled i e a character strinc indexing ahead by IP can access this data IP STA or IP Y LDA FORTH DIMENSIONS 5 Page 147 MODE NEXT NOT POP Page 148 loads the third byte ahead in the colon definition being interpreted nl n2 compiling assembler An assembler defining word used to create assembler mnemonics that have multiple address modes 1C6E 60 M CU ADC M CPU creates the word ADC with two parameters When ADC later executes it uses these parameters along with stack values and the contents of MODE to calculate and assemble the correct op code and operand Used within the assembler to set MODE to the default value for direct memory addressing z page addr A variable used within the assembler which holds a flag indicating the addressing mode of the op code being generated
36. FINITION OF A WORD IN FACT AS THIS LETTER DEMONSTRATES THREE LETTERS AND A LENGTH CAN LETDOWN EVEN A CAREFUL READER OF COMMON ENGLISH SINCERELY YOURS ARTHUR GOLDBERG SPENCER SOOHOO Your letter and its translation certainly make the pointi ed Dear Fig Right now I am trying to put together a loca Danish FIG and I would therefore like you to update me with the names and addresses of the Danish FIG members and possible make a note in FORTH DIMENSIONS about my intentions As the communication lines are rather long and since our magazine is only bi monthly please inform me on your next deadline as soon as possible Niels Oesten Brostykkeveh 189 2650 Hvidovre Denmark Thanks Niels Good iuck on esiablishing a local Danish FIG Group Anyone inter ested please contact Niels as listed above Regarding deadiines Copy must be in our hands 6 weeks prior to pubi ication i e 4 15 is the deadline for May June edition etc ed Dear f ia I just wanted to write to tell you how much I enjoy FORTH DIMENSIONS Every issue has several things of interest to me and 1 appreciate your work in seeing that it gets done often a thankless task Here in New Hampshire Rob Moore of SNAC Southern New Hampshire Apple Corps is doing most of the work in implementing and refining a version of fiq FORTH for the Apple Il We have takeri as much as possible from page zero so that we can use the many subroutines available
37. FOR THE 6502 by William F Ragsdale INTRODUCTION This article should further polarize the attitudes of those outside the growing community of FORTH users Some will be fascinated by label less macro assembler whose source code is only 96 lines long Others will be repelled by reverse Polish syntax and the absence of labels The author immodestly claims that this is the best FORTH assembler ever distri buted It is the only such assembler that detects all errors in op code generation and conditional structuring It is released to the public domain as a defense mechan ism Three good 6502 assemblers were submitted to the FORTH Interest Group but each had some lack Rather than merge and edit for publication I chose to publish mine with all the submitted fea tures plus several more Imagine having an assembler in 1300 bytes of object code with 1 User macros like IF UNTIL finable at any time 2 Literal values expressed any numeric base alterable at any time 3 Expressions using resident computation capability 4 Nested control structures without labels with error control 5 Assembler source itself in a port able high level language OVERVIEW Forth is provided with a machine lang uage assembler to create execution pro cedures that would be time inefficient if written as colon definitions It is intended that code be written similarly to high level for clarity of expressi
38. HITE BLUE BLACK WHITE BLACK 3 WHITE BLACK 4 WHITE 77 PRECISELY 14 TRIES BLACK 1 WHITE Snapshot of board after lavins Master Mind ANNOUNCEMENTS NEW JERSEY FIG CHAPTER BEING FORMED Interested parties should contact George B Lyons 280 Henderson St 212 696 7606 days 201 451 2905 eves BOSTON SEEKING MEMBERS FIG CHAPTER Interested parties should contact R I Demrow P Box 158 Blv Sta Andover MA 01810 617 389 6400 x 198 work 617 664 5796 home FIG CHAPTER MOUNTAIN WEST ORGANIZING Interested parties in the greater Salt Lake City area should contact Bill Haywood 801 942 8000 TECHNICAL PRODUCTS CO MOVES New address P O Box 2358 Boone NC 28607 2358 FIG NEW YORK CITY MEETING CONTACT James Basile 40 Circle Drive Westbury NY 115900 516 333 1298 DALLAS FT WORTH METROPLEX FIG MEETING CHANGE Meetings now being held at Software Automation Inc 1005 Business Parkway Richardson TX contact Marvin Elder 214 231 9142 Bill Drissel 214 264 9680 FORTH DIMENSIONS 1175 Page 161 TRANSFER FORTH SCREENS BY MODEM Guy T Grotke Forth Gear San Diego CA Here is a simple but hopefully useful set of definitions for serial transfer of FORTH screens between machines Several of us in the San Diego FIG are in terested in sharing software but we have been unable to do so because of all the different disk formats in use Wh
39. I stand in good company Roy C Martens FORTH DIMENSIONS 11 5 LETTERS THE EDITORS Dear Fig I have developed a process simulation program that occupies very little memory space and yet has many of the capabilities of commercial simulation packages I have been heavily involved in model ing and simulation of automated manufac turing systems for over six years My ultimate objective for this work is to develop a microprocessor based simulation capability which incorporates process control structures far beyond those of currently available languages However the relatively extensive modeling power of the current code would seem to offer in teresting market potential in its own right If you can provide information on marketing such a product please contact me by mail or by phone home 317 447 9206 office 317 749 2946 Joseph Talavage Ph D 3907 Prange Dr Lafayette IN 47905 Hope printing your letter helps ed Dear Fig I am puzzled as to why I have not seen mention in your New Products announce ments of fullFORTH for PET available also I believe for Apple It is published by IDPC Co PO Box 11594 Bethlehem Pike Colmar PA 18915 at 65 It is advertised as A full featured FORTH with extensions conforming to Forth Interest Group standards Includes as sembler string processing capabilities disk virtual memory multiple dimensioned arrays floating point and integer pro cessing Surely
40. IABLE COLOR KEY ALLOT colors table 5 7 6 Use the sum of the ASCII code of the first 2 letters i e BLUE B L U 66 76 85 227 COLOR KEY COLOR KEY 2 C 2 COLOR KEY 4 COLOR KEY amp C 219 COLOR KEY 1 222 GULOR KEY 3 C COLOR KEY 5 C 14 VARIAELE ATTEMFTS used to keeP score 159 2 158 FORTH DIMENSIONS IiI 5 SCR 22 O Master Mind Promet and randomize 17 20 abling the player to keep changing his 1 These definitions det the random values for the game quess until he is satisfied that it is consis 2 tent with the clues he has thus far receiv 3 NEWCOUNT COLORS J DUP COLORS c ed correct guess is the result of the 4 IF ELSE DROP 1 THEN player s logical deduction or very good luck based his previous clues The 1 RAND 1 BEGIN NEWCOUNT YTERMINAL UNTIL KEY DROF 5 directions on screen 31 explain the mean gt ing of the two types of clues ASK FOR RANDOM To randomize tap space bar 4 times 4 0 DO RAND I SCODE C LOOP CR When the player signals he is ready the program compares the player s quess to the secret code which was stored away 2 1 11 ASK FOR LEVEL 1 1 2 CR Level 1 ar 2 KEY DUP EMIT KEY EMIT earlier Clues are generated and dis 3 50 IF 7 C0L0RS ELSE amp C0LURS THEN played indicating to the player how close 14 he is to the solutio
41. IENDS AND FAMILY WITH IT OF COURSE WHEN PLAYING AT BAR YOU MUST USE A REAL DECK OF CARDS AS IT WOULD PROBABLY TEND TO DISCOURAGE WAGERING IF YOU SHOULD BRING YOUR MICKO WITH YOU SCRHSS ENCODED CONSTANTS 31 TONY LEWIS 6 NOTE THESE CONSTANTS ARE USED ONLY TO CONCEAL THE SOLUTION OF THE GAME NOT TO MAKE THE CODING HARD TO FOLLOW CONSTANT CONSTANT K2 CONSTANT KS CONSTANT BC amp 41098 KL 1 CB ASC7 Ka t BD KS DB 1FD K4 s DEC IMAL scras4 SETUP AND UTILITY WORDS 31 TOMY LEWIS CREATE DECK 0 84 84 4 4 4 4 0 VARLABLE CARDSUM VARIABLE GAMESWON 2 NEWGAME FIRST NEW DECK 7 1 DO I 24 DECK 4 SWAP LOOF CARDSUM HOME 4 CV SHOWDECH SUM CR CR THE DECK NOW CONTAINS 7 1 DG I t NOT J gt 2 DECK C9 DUCK DO DUP IF 1 1 CR DOG ELSE DROP THEN 12 CH THE RUNNING TOTAL IS CARDSUM tubi FLAG BAD PLAY BAD SHOWDECE SLM 3 SCR SS UTILITY WORDS CONT 21 BY TONY LEWIS UPDATEDECKSUM i 1 TO NOW GN STACK DUP 2 DUP DECK C DUP ANY LEFT IF 1 4 UPDATE DECK SWAP DECK C CARDSUM CARDSUM C NEW SUM 2 CARD IN DECK FLAG ELSE DROP DROP DROP THEN 3 MAINLINE WORDS PLAYERMOVE OR CR IN CARD 1 6 KEY FROM ASCII DUP DUP DUF CHECK VALID ENTRY 7 31 TONY LEWIS IF 0
42. NS EDITOR 14 DECIMAL 26 HELP WANTED Part time New York New Jersey Area Assist internationally known sound artist Max Neuhaus develop additional software for micro computer controlled sound synthesis system FORTH con trolling 32 synthesizers from CRT Light Pen Terminal Moderate fees travel possibilities hardware experience preferred Send information or resume to Max Neuhaus 210 Sth Avenue New York NY 10010 Independent FORTH programmers to im plement Marx FORTH for TRS 80 Apple CP M and other systems Royalties paid for best implementation with most en hancements Great opportunity for the competitive programmer who like me would like to make a living at home and not have to move to California to do it Contact Mare Perkel Perkel Software Systems 1636 N Sherman Springfield MO 65803 417 862 9830 FORTH DIMENSIONS 5 PRODUCTS REVIEW SORCERER FORTH by Quality Software For about a year I have been using an excellent version of fig FORTH tailored for the Exidy Sorcerer It is a product of Quality Software 6660 Reseda Bivd Suite 105 Reseda CA 91335 FORTH for the Sorcerer implements Release 1 1 of 8080 It in cludes a full screen editor and input output routines for the keyboard screen and both serial and Centronics printers The Sorcerer s excellent graphics are also available Disc storage is simulated in RAM A 32 Sorcerer can hold 14 scr
43. Orders shipped out within 3 days of receipt usually next day HEATH H89 FORTH MCA 8 Newfield Lane Newtown Conn 06470 MCA announces the availability of FORTH for the Heath H89 computer MCA FORTH is 8080 fig FORTH V1 1 configured to run on a single disk H89 with 32K or more of memory utilizing HDOS 1 6 or later MCA FORTH provides the standard FORTH facilities plus the following special features HDOS file manipulation capability a control character to restart FORTH recover from loops on line tailoring of FORTH facilities e g num ber of disk buffers ability to hook to sep arately assembled routines and use of Heath DBUG Items supplied with FORTH include the fig Editor an 8080 structured assembler and two games provided as examples of FORTH programming The documentation supplied with MCA FORTH is suitable for experienced FORTH programmers however a bibli ography of documentation for beginners is provided MCA FORTH is available from MCA on a 5 1 4 disk for 25 including docu mentation Documentation is available for 4 00 Conn residents please add sales tax FORTH DIMENSIONS 5 NEW PRODUCTS FROM INNER ACCESS CORPORATION 1 Fig FORTH compiler interpreter for 11 for RT11 RSX11M or stand alone with source code in native as sembler Included in this package are an assembler and editor written in FORTH and installation documenta tion Price 80 00 This is available on a one 8
44. RTH vocabulary Let me know how it works for you If you would like a machine produced listing I could run one for you from my current version Edgar H Fey Jr 18 Calendar Court La Grange IL 60525 A HELPFUL UTILITY Here s a short FORTH word of great utility that I use heavily in my screens I hope you like it Its name is CVD which stands for convert to decimal DECIMAL CVD BASE SWAP OVER MOD ROT MOD 10 10 I like to work in hexidecimal but often make mistakes when using the words LOAD LIST and many of the FORTH screen editor words because I m thinking in decimal when the system s in hex If I do the following LIST CVO LIST then 130 LIST lists screen 150 whether I m in decimal or hex also works for any other base as long as that base accepts the number As to how it works a little work will show that CVD splits a three digit number into its respective digits IE 130 becomes 1 5 and 0 and reassembles the digits into the number that is in decimal the same as the keys pressed by the user Gregg Williams BYTE Publications PO Box 372 Hancock NH 05449 CALL FOR PAPERS 1982 Rochester FORTH Conference on Data Bases and Process Control May 17 through May 21 1982 University of Rochester Rochester New York The second annual Rochester FORTH Conference will be held in May and will be hosted by the University of Rochester s Laboratory for Laser Energetics T
45. S probably could be added but apparently the implementor doesn t know how or chooses to deprive his customers of this powerful struc ture Arrays are definitely not equiva lent technically or philosophically In conclusion it appears that TransFORTH is a reverse POLISH BASIC with names rather than labels A small amount of additional effort would have built upon FORTH rather than strip out major attributes 163 NEW PRODUCTS FLEX FORTH Complete compiler interpreter bler editor operating system for assem 25 00 21 00 APPLE II computers KIM computers FLEX FORTH is a complete structured language with compiler interpreter editor assembler and operating system for any APPLE II or APPLE computer with 48K and disk or KIM with 16K of mem ory Most application programs run in less than 16K starting at 1000 HEX and often as little as 12K including the FLEX FORTH system itself This is a full featured FORTH follow ing the F I G standard and contains a 6502 assembler for encoding machine language algorithms if desired The assembler permits macros BEGIN UNTIL BEGIN AGAIN BEGIN WHILE REPEAT IF ENDIF IF ELSE ENDIF Editor and virtual memory files are linked to the Apple DOS 3 2 An ap plication note for upgrading to DOS 3 3 is included Object code on disk with user manual sells for 25 00 APPLE or on cassette with user manual for 21 00 KIM A compl
46. S1 HOW QZ21 HOME 51 GAME TONY LEWIS 31 GAME BY TONY LEWIS 31 IS PLAYED WITH DECK 24 CARDS CONTAININING ONLY THE ACES THRU SIXES EACH OF TWO PLAYERS ALTERNATELY DRAWS CARDS FROM THE DECK ONE CARD AT TIME A RUNNING TOTAL IS KEPT OF THE COMBINED SUM OF THE CARDS DRAWN THE PLAYER WHO ARRIVES AT THE SUM OF 31 EXACTLY WINS IF NEITHER PLAYER CAN MAKE 31 EXACTLY THEN THE PLAYER WHO MUST GO OVER 21 LOSES THE GAME MAY APPEAR TOO EASY BUT iT IS DECEPTIVE WHEN COR IF 3 YOU HAVE WON THREE GAMES TRY TO BEAT THE PROGRAM FOR THE BIG BY TYPING IN B RATHER THAN OR N WHEN NEW GAME COMES UP THE BIG BET IS A TWO GAME SERIES YOU GO FIRST IN GAME 1 AND SECUND IN GAME 2 YOU MAY BE SURPRISED CR CR CR HIT ANY KEY TO BEGIN KEY DROP HOME 5 na SCR S2 WORDS OF WISDOM 31 BY TONY LEWIS THE ANSWER PAGE IS NEXT IT DOESN T REQUIRE ANY SKILL TO FIGURE OUT WHAT THE CONSTANTS REALLY ARE THEY ARE ENCODED SO THAT YOU CAN ENTER AND COMPILE THE GAME WITHOUT DISCOVERING ITS PRINCIPLE REMEMBER THE PURPOSE OF THIS PROJECT WAS TG GET YOU TO FIRST EXAMINE THE GAME PLAYING IT THEN FIGURE OUT HOW TO APPROACH THE PROBLEM OF PROGRAMMING IT AND FINALLY GO BACK AND COMPARE YOUR METHODS TO MINE THE GAME 15 AMUSING AND 18 A LITTLE KNOWN CINCH BAR BET IF YOU TAKE THE TIME TO ENTER IT ONTO YOUR FORTH DISC YOU SHOULD HAVE FUN BOTH ANALYZING IT AND THEN ENTERTAINING COR HUSTLING FR
47. SNDRAW 4 SUIT 2 i a y DUP Y SWAr DUE X SWAP ERE OUT 19 1 GMOVE i a y Page 156 FORTH DIMENSIONS 5 Screen 14 0 Graphic Package 4 12 0 80 H RDRAW Relative DRAW 3 SWAP X amp SWAP DRAW 4 5 RMOVE Relative MOVE 6 65 RDRAW 7 8 ACURSOR 5 alphocursot 4 y 55 DRAW us 10 11 SCROLL CAN CR press FUNC 5 keys 12 i3 LINE ERASE 14 BLACK x 5 Screen 15 9 Graphic Package 2 NITO 3 INIT ROT a SQUARE 6 i 3 6 7 1 8 Xs 10 ERASESGU 1 INITO 32 ie 13 14 7 creen i G i Graphic Tackage 2 1 advance 5 1216 xi 4 cise 2025 5 amp 122 799 iNIT2 2 9 X 9 2 10 MANYSQUARES i a 11 IMITI SGUARS T 12 13 DELAYCS ce DELAY 9 DIMENSIONS 5 tox lt 1 PRE CUT 5 nu i2 vv isl DUP 7 SWAP DU X SWAP GHCVE y i OUT X Y 9 PRAW t Y DRAW e DUP X DRAW i DU DRAW SOWN Y 6 47 Sis 9 X LINE ERAZE e t LING TRASE SWK moa 7 9 Do SGUARE 424 DC igor miilseiinis DO DELAYES 29007 D milisec we at least knew that the graphic part simulates Tektronics 4010 he spent a whole week just trying to draw one mere square along the edges ef the CRT Seem ingly it would be an easy job but even so it never came near to wha
48. TransFORTH is fast It is not as fast an integer versions of FORTH because it handles 5 bytes with every stack manipu lation instead of two TransFORTH pro grams wil run faster than similar Apple soft programs and show a great increase in speed when longer programs are com pared While TransFORTH works much like Fig FORTH the differences between the two become readily apparent under closer examination FORTH programmers will pick up TransFORTH with little trouble but nearly all FORTH programs will re quire translation into TransFORTH to take advantage of its powerful features These features are accessible with a min imum of work from the user bringing a FORTH like environment into the realm of practical scientific and business pro gramming for the first time EDITOR S RESPONSE TO TRANSF ORTH The above material is extracted from explanatory sales material from the pro gram vendor Commentary we have indi cated from Trans ORTH users can be summarized l This implementation should be named as one of the CONVERS group of languages as it compiles to as sembly language rather than threaded code 2 It is easier to add floating point math to FORTH than to alter Trans FORTH to use integers for execution speed improvements Why not both 3 If the implementor had done his DOS 3 3 interface using the standard FORTH word BLOCK an immense gain in value would result Direct access and DOS compatibility 4 BUILDS DOE
49. WFR 79JUNO3 1 HEX 2 VOCABULARY ASSEMBLER IMMEDIATE ASSEMBLER DEFINITIONS 3 4 REGISTER ASSIGNMENT SPECIFIC TO IMPLEMENTATION 5 EO CONSTANT 5 DC CONSTANT W DE CONSTANT UP 6 D9 CONSTANT IP D1 CONSTANT N 7 8 NUCLEUS LOCATIONS ARE IMPLEMENTATION SPECIFIC 9 DO OE CONSTANT POP 10 OC CONSTANT POPTWO 11 LIT 13 CONSTANT PUT 12 LIT 11 CONSTANT PUSH 13 LIT 18 CONSTANT NEXT 147 EXECUTE NFA 11 CONSTANT SETUP 15 SCR 82 ASSEMBLER CONT WFR 780CTO3 0 VARIABLE INDEX 2 ALLOT 0909 1505 0115 8011 8009 1DOD 8019 8080 0080 1404 8014 8080 8080 1 0 801C 2C80 2 0 MODE 1 MODE 2 MODE X 3 MODE i wt 4 MODE X 5 MODE 2X 6 MODE 3 F MODE 1 2 3 5 2 VARIABLE MODE 6 7 8 9 10 BOT X 0 ADDRESS THE BOTTOM OF THE STACK 11 SEC 25 9 ADDRESS SECOND ITEM ON STACK I gt r RP 101 5 ADDRESS BOTTOM OF RETURN STACK 13 14 15 SCR 83 0 UPMODE CPU WFR 780CT23 1 2 UPMODE IF MODE 8 8 AND 0 IF 8 MODE THEN THEN 3 1 MODE OF AND DUP IF 0 DO DUP LOOP THEN 4 OVER 1 8 AND 0 5 6 CPU BUILDS C DOES C MEM 7 00 CPU BRK 18 CPU CLC D8 CPU CLD 58 CPU CLI 8 B8 CPU CLV CA CPU DEX 88 CPU DEY 8 CPU INX 9 C8 CPU INY EA CPU NOP 48 CPU PHA 08 CPU PHP 10 68 CPU PLA 28 CPU PLP 40 CPU RTI 60 CPU RTS 11 38 CPU SEC F8 CPU SED 7
50. after exe cuting PORT DEC 6 times execution continues ahead after UNTIL Note that FORTH DIMENSIONS 1175 Page 145 BEGIN generates no machine code but is only an assembly time locator CONDITIONAL EXECUTION Paths of execution may be chosen at assembly in a similar fashion and done in colon definitions In this case the branch is chosen based on a processor status con dition code PORT LDA O for zero set THEN continuing code In this example the accumulator is loaded from PORT The zero status is tested if set Z 1 If so the code for zero set is executed Whether the zero status is set or not execution will resume at The conditional branching also allows a specific action for the false case Here we see the addition of the ELSE part PORT LDA 0 lt for zero set ELSE lt for zero clear gt THEN lt continuing code gt The test of PORT will select one of two execution paths before resuming execution after The next example increments N based on bit D7 of port PORT LDA fetch one byte KIF DEC if 07 1 decrement N ELSE INC if D7 0 increment N THEN continue ahead CONDITIONAL NESTING Conditionals may be nested according to the conventions of structured pro gramming That is each conditional se quence begun IF BEGIN must be ter minated THEN UNTIL before the next earlier conditional is terminated An ELSE must pair with
51. andard and the problem goes away 2 A clarification could be added to the Standard indicating either that the string will always be at HERE or that it may be at 3 The problem could be forced upon users by requiring that the char acters from WORD be stored in a user defined area prior to their movement to the final destination Let Me Number the Ways In many areas the 79 Standard defines limits and formats in painful detail There is an important area in which very little is said namely the format for single and double precision numbers in the input stream In the section interpreter text it is clear that numbers are allowed in the input text stream and may either be compiled or placed on the parameter stack A definition of the format of a number should include at a minimum the distinction between double and single pre cision the sign of the number and the set of allowed characters from which the number is constructed In keeping with the spirit of the rest of the Standard I would like to propose a few definitions which should be fairly easy to implement and which appear to be compatible with most current implementations including FORTH DIMENSIONS 5 fig FORTH First we define a digit digit A digit is any one of a set of ASCII characters which represent numeric values in the range from 0 to base l For bases greater than decimal 10 the set of char acters is 0 9 A B where the as
52. c is false exe cution returns to BEGIN other wise execution continues ahead At assembly time UNTIL as sembles conditional relative branch to addr based on the condi tion code cc The number 1 is used for error checking addr assembling Used in a code definition in the form UP LDA or UP Y STA A constant leaving at assembly time the address of the pointer to the base of the user area i e HEX 12 LOY UP Y LDA load the low byte of the sixth user variable DP addr assembling Used in a code definition in the form W 1 STA or W1 JMP or W Y ADC A constant which leaves at as sembly time the address of the pointer to the code field exe cution address of the Forth dic tionary word being executed In dexing relative to W can yield any byte in the definition s parameter field i e 2 5607 W Y LDA fetches the first byte of the parameter field ad op Specify indexed indirect X dressing mode for the next code generated addr assembling Used in a code definition in form the XSAVE STX XSAVE LDX A constant which leaves the ad dress at assembly time of a tem porary buffer for saving the X register Since the X register in dexes to the data stack in z page it must be saved and restored when used for other purposes i FORTH DIMENSIONS III 5 FORTH Assembler for 6502 by W F Ragsdale July 1 1980 SCR 81 0 FORTH 65 ASSEMBLER
53. ch based on the processor status bit being negative 27 1 less than zero The flag cc is left at assembly time there is no run time effect on the stack cc assembling Specify that the immediately fol lowing conditional will branch based on the processor status bit being equal to zero 27 1 The flag cc is left at assembly time there is no run time effect on the stack Used to conclude a colon defini tion in the form lt name gt 3CODE assembly code END CODE Stop compilation and terminate a new defining word lt name gt Set the CONTEXT vocabulary to AS SEMBLER assembling to machine code the following nmenonics An existing defining word must exist in name prior to CODE When lt name gt later executes in the form lt name gt lt namex gt the definition lt namex gt will be created with its execution proced ure given by the machine code fol lowing lt name gt That is when lt namex gt is executed the address interpreter jumps to the code fol lowing CODE in lt name gt in FORTH Make ASSEMBLER the CON TEXT vocabulary It will be searched first when the input stream in interpreted addr 1 assembling run time Occurs in a CODE definition in the form BEGIN cc UNTIL At run time BEGIN marks the start of an assembly sequence re peatedly executed It serves as the return point for the corres ponding UNTIL When reaching UNTIL a branch to BEGIN
54. d appreciation of FORTH s virtues 4 A useable language faster and better than Tiny Basic and more convenient than machine language 5 The ability to install and interactively test a larger version of FORTH when I expand my machine I feel the article does users of small systems a disservice Instead of discouraging users of small systems FIG should encourage development of standardized subsets for use on small machines Roger L Cole 395 Elm Park Avenue Elmhurst IL 60126 FORTH DIMENSIONS publishes articles to encourage communications thought and growth of the FORTH world far from discouraging users of small systems the FIG leadership is composed almost exclu sively of members with small systems FIG has been a leader in encouraging the development and use of FORTH on small systems In fact it is probably safe to say that if there were no FIG there would be no FORTH for small users today Most of the vendors and systems now in use have been derived from FIG listings provided at cost The source data for these listings FORML research standards ete which so many take for granted have been de rived from the labor and cash contribu FORTH DIMENSIONS III 5 tions of volunteers serving without reim bursement The FORTH DIMENSIONS editorial staff supports FIG efforts to keep FORTH intact and resist the temp tation to obtain mere popularity and in the process fail in their mission to provide and support the fi
55. de a single definition CODE DEMO HEX 6 LDA N 1 STA setup a counter BEGIN 8001 BIT tickle a port N 1 DEC decrement the counter G UNTIL NEXT JMP END CODE loop till negative SETUP Often we wish to move stack values to the N area The sub routine SETUP has been provided for this purpose Upon en tering SETUP the accumulator specifies the quantity of 16 bit stack values to be moved to the N area That is A may be 1 2 5 or 4 only 3 LDA SETUP JSR stack before after stack after H high H G low bot gt G_ F F E E D D sec gt C Cc B B bot A N gt CONTROL FLOW Forth discards the usual convention of assembler labels Instead two ments are used First each Forth defini tion name is permanently included in the dictionary This allows procedures to be located and executed by name at any time as well as be compiled within other defini tions Secondly within a code definition execution flow is controlled by label less branching according to structured pro gramming This method is identical to the form used in colon definitions Branch calculations are done at assembly time by temporary stack values placed by the con trol words BEGIN THEN UNTIL IF ELSE Here again the assembler words end with a comma to indicate that code is being produced and to clearly differen tiate from the high leve form One major difference occurs High leve
56. e Game of REVERSE 3 CR CR Would you like instructions Y N 4 IF The object of the game is to arrange a random list 5 CR of nine numbers into ascending numerical order in 6 CR as few moves as possible by reversing a subset of 7 CR the list For example given the random list CR 8 5 2 4 8 7 3 9 1 6 CR 9 CR reversing a subset of 4 would yield the list CR 10 CR 8B 4 2 5 7T 3 9 1 6 R 11 CR To quit the game simply reverse O CR CR 12 THEN 13 14 gt 15 SCR 230 O The Game of Reverse ARRAY operations 101281 MPB l 29 DIM ARRAY Reserve a ten word array 3 4 Ae Fetch array word index array value 5 2 ARRAY i 6 7 A Store an array word array value index 8 2 ARRAY 9 10 AINIT Initialize ARRAY 11 10 1 DO I DUP A LOOP 12 13 A Print ARRAY 14 CR The list is now 15 CR 6 SPACES 10 1 DO I Ae 3 R LOOP gt fig FORTH Version 1 15 M Burton 7 FORTH DIMENSIONS 5 SCR 231 10 11 12 13 14 15 fig FORTH Version 1 15 ok M Burton The Game of Reverse ARRAY operations cont 100781 ASCRAMBLE Mix up the array values 1 9 DO I RND 1 Calculate I Ae i Get ARRAYI I value OVER Ae Get ARRAYIK value I Al Store ARRAYI K in ARRAY I SWAP 1 Store ARRAYII in ARRAY K LOOP GETIN Get amount to reverse nu
57. e assume the traditional imple mentation for a moment and use HERE as the start of the token buffer used by WORD The PAD is then usually floated at a location equal to HERE plus some constant If WORD must handle tokens as long as 255 bytes then PAD must be floated at least 256 bytes above HERE to prevent token extraction from corrupting the contents of PAD The 79 STANDARD requires that PAD be able to hold at least 64 bytes so now we re at HERE 320 bytes If one is compiling a large application program the dictionary will grow until eventually HERE 320 hits the whether it is a fixed boundary or the PSTACK bottom or whatever When it does no more compilation can take place even though there is at least 320 bytes of unused dictionary left without violating the Standard If you permit further com pilation the size of PAD begins to drop below the minimum 64 which is not al lowed Even if you start automatically reducing the PAD offset so that it remains fixed in size the token buffer begins shrinking and can no longer satisfy the 256 byte string requirement I m trying to illustrate that free space is only free as long as all of memory isn t needed When memory fills these free space buffers prevent code from being compiled into their space The floating buffer concept seems to obscure this fact more than if the token buffer and the PAD were given fixed dedicated areas of memory If the token buffer
58. e first chip set in hand Page 156 Martin Schaaf P O Box 1001 Daly City CA 94017 Thanks for the update Martin This points up why we have our policy of not announc ing unreleased products ed Dear F ig In the packet of materials I got when I joined FIG was a copy of FORTH DIMEN SIONS Volume III 1 with a product re view of Timin FORTH The review inter ested me in two respects One was the benchmark tests that it contained the other were the comments on the alleged lack of superiority of the 2 80 compared to the 8080 Those benchmarks gave me a chance to compare my machine with my version of FORTH the results of which surprised me since my machine only runs at 2 mhz and the machine used in the review runs at 6 mhz expected my machine would take three times longer but in all tests it ran comparable or even faster It would seem my implementation is faster for involved arithmetic operations The editors of FORTH DIMENSIONS are right I believe in being wary of timing benchmarks for it is easy to draw invalid conclusions from them In fact the editors themselves drew the wrong conclusions The tests do not show the Z 80 runs benchmarks slower than the 8080 the Z 80 was used for both tests The correct conclusion is that some FORTH implemen tations are more efficient than others and that some versions on the market are ter ribly slow I am sure you get a flood of letters fol lowing a benchmark
59. ed by c and leaves its address and length on the stack Actually the token is merely left in the input buffer keyboard or disk and a pointer to it is given Thus no additional or temporary buffer is needed The user may now do anything he she wants with the string including moving it to HERE if desired and if it will fit For example if you want to compile the token as a dot quote string defini tion such as WORD can be used WORD WORD HERE OVER 1 SWAP OVER C COUNT CMOVE If you want a blank filled line put in PAD the following could be used TEXT PAD C L 2 BLANKS WORD C L MIN PAD C PAD COUNT CMOVF For the routine compiler interpreter job of extracting small 31 characters or less tokens from the text stream the fol lowing could be used NORD a WORD WDSZ MIN WBFR C CMOVE WBFR WBFR COUNT 1 where WBFR is a small word buffer limited to WDSZ 2 Note that except possibly for the self imposed size limi tation the last definition satisfies the 79 STANDARD definition of WORD If you will carefully examine these constructs you can quickly discover that given WORD as the elementary form the user can extract tokens of any size put them wherever he wants and format them with or without the trailing delimiter or for that matter the leading count byte or 16 bit word if you prefer In other words the user ought to be able to do es
60. een denotes composition The notation fif denotes construction where f f applied to an argument x yields the sequence lt f x The notation p gt f g applied to an argument x indicates that the value p x is to be examined and if p x is true the ex pression yields f x else it yields g x Other definitions used in the above are eq0 applied to x yields a value true if x is 0 and yields false otherwise l is the literal value 1 and yields the Page 137 value 1 regardless of the argument is the multiplication operator and applied to a sequence lt x y gt yields x y id is the identity operator id applied to x yields x subl applied to an argument x yields x Following the logic of the above func tion we see that applied to an argument n yields 1 if n is zero If n is not zero we generate 1 Clearly then for this is a definition of the factorial function In FORTH if the language were recursive we would write DUP 0 IF 1 ELSE DUP 1 THEN The syntaxes of the two examples are different The composition rule is applied right to left in the first example and left to right in FORTH The rules for dropping arguments are different Construction is not used in FORTH That the rules of syntax are different should not be sur prising The operations were defined by different people at different times What is most important is that on close exami nation it is apparen
61. eens with 48 K up to 30 screens Tape handling routines are provided to move data to and from the simulated disk space The CP M disk interface routines are present but not implemented One of the nicest features of Quality Software s FORTH is its documentation The 126 page manual is well written and relatively complete includes sufficient information for a FORTH neophyte though it does not delve too deeply into system operations Quality Software permits even en courages users to market application programs incorporating Sorcerer FORTH They do ask that written permission be obtained frist but promise that permission will normally be granted after review of a sample of the program I highly recommend this excellent pro duct and ask that you include it in your periodic listing of available software C Kevin McCabe 1560 N Sandburg Terr 4105 Chicago IL 60610 312 664 1632 A COMPARISON OF TRANSFORTH WITH FORTH Insoft Medford OR A question we ve been hearing a lot lately is How does TransF ORTH compare with fig FORTH In structure Trans FORTH is similar to most version of FORTH but is is not a FORTH 79 Stand ard System The major differences are outlined in this paper Floating point numbers In TransF ORTH the stack itself con tains floating point numbers with 9 digits of accuracy No special sequences are required to retrieve floating point values Words are available for storing or
62. emblers plus a little COBOL of the late 60 s vintage Any constructive suggestions on general style and technique are welcome but I am not really interested in being told that I could have shaved 100 microseconds from my run time or saved fifteen bytes of memory In fact there are indeed extran eous Cr s which were included to get good hard copy also This program was written in micro motion c FORTH 79 Version 1 2 to be run on a 48K Apple II Therefore the following words are non standard but included in the micro motion FORTH Home position the cursor to the upper left corner of the CRT and clear the CRT to blanks CV and CH are used to position the input cursor anywhwere on the text win dow per Ex 4 CV 10 CH moves the cursor to the 4th pun row 10th column of screen SETINV SETFLASH and SETNORM set flags in the Apple output subroutines which respectively cause all subsequent characters to be displayed on the text screen inverse flashing and norma mode without affecting charcters already dis played In closing I wish to thank Bill Ragsdale for his gracious support and I especially acknowledge the incredibly patient treat ment 1 received from Phil Wasson of Micromotion as he neatly led me through my FORTH initiation Tony Lewis 100 Mariner Green Dr Corte Madera CA 94925 415 924 1481 415 924 4216 late hours Apple is a registered trademark of Apple Computer Inc Page 154 SCRS
63. en unt it D LUO BACK EN MAINSI 5 FORTH DIMENSIONS III 5 MAINLINE WORDS CONT 21 BY TONY LEWIS MYBIGBET CR CK DUP Ca kK DUP UPDATEDECK SUM SCKHSO t MOD IF DROP K3 Due THEN MY PLAY IS UPDATEDECKSUM DROP SHOWDECKSUM 3 s MYBIGOBET2 CR IF DUP UPFDATEDECKSUm ELSE CARDSUM Ca k2 MOD LPDAITEDECKSUM o IF DROP DUP UPDATEDECKSUM DROF THEN HEN MY PLAY IS SHOWDECKSUM 3 SER 61 MAINLINE BIGBETI YOURCARD BEGIN IF TRUE FROM 31 CARDSUN C IF OUNIN 1 5 SET ELSE 31 if YOULOSE 1 ELSE YOURLARD THEN THEN i RETURN FROM 1 CARDSUM v IF i ELSE Si S RDSUM C YGUWIN 1 ELSE MY IGBETI TREN THEN WORDS CONT Si BY LEWIS nmYbfcpr 19 LOOP EXII OURCARD MAINLINE WORDS BIGHETY 3 BEGIN IF Si GARDSUM C3 IF YOULOSE 1 ELSE YOURCARD CONT 51 BY TONY LEWIS THEN ELSE 31 ChRUSUM C3 YOULOSE 1 ELSE 157 MYBRIGBET2 THEN THEN UNTIL 3 SCk eS t MAINLINE WORDS CONT 21 BY TONY LEWIS 5 HOME 57 WELCOME TO RIG THE FINAL PHASE OF THE 51 GAME TWO GAMES WILL BE PLAYED CR YOU WILL FIRST IN GAME ONE AND 1 WILL GO FIRST IN GAME TWO GOOD LUCK CR ANY FEY AND I WILL BEGIN GAME 2 FEY
64. ete source listing is available to purchasers of FLEX FORTH for 20 00 The source is valuable in both showing how FORTH works and in giving examples of FORTH code and integrated assembly code Order from GEOTEC 1920 N W Milford Way Seattle WA 98177 Be sure to specify machine MARX FORTH V1 1 Perkel Software Systems 1636 N Sherman Springfield MO 65805 417 862 9830 Enhanced Z80 fig F ORTH implemented for Northstar System enhancements in clude link fields in front of name for fast compile speed dynamic vocabulary relink ing case arguments results with to vari ables and more 79 Standard package in cludes easy to use screen editor Price 75 00 Smart assembler meta compiler and source code in FORTH sold separately Call for information TWO NEW PRODUCTS FROM LAXEN AND HARRIS INC Laxen and Harris Inc 24301 Southland Drive Hayward CA 94545 415 887 2894 1 Working FORTH Release 2 1 Page 164 Starting FORTH compatible FORTH software for 8080 280 computer system with the CP M TM operating system Copyright C 1981 by Laxen and Harris Inc rights reserved This FORTH implementation is com patible with the popular book Starting FORTH by Leo Brodie It is intended to be a companion to the book to aid learning FORTH It is also a complete environ ment for developing and executing FORTH programs It contains Compilers Disk operating system Full names stored
65. from the Applesoft ROM I have been working with our version for some time now and am doing a high resolution graphics game using FORTH and Applesoft hi res routines Gregg Williams BYTE Publications PO Box 372 Hancock NH 05449 Thanks Gregg Glad you enjoy and appreciate our efforts ed Dear F ig Regarding the 8080 Renovation Pro ject s requests for bug fixes 1 would like to counter with a request that they pro vide a status report in FORTH DIMEN SIONS that includes those bugs already reported along with any solutions proposed or implemented It would also be of inter est to find out what the goals are for the 8080 Renovation Project and how local FIG chapters can help There is what I consider a bug in that the message routine uses an absolute value of screen 4 and 5 for getting error mes sage information This is fine where offset is zero but when an offset other than zero is used and the disk has other information on absolute screens 4 and 5 things don t look too good Robert I Demrow P O Box 158 BluSta Andover MA 01810 Thanks for the input Your request has Page 135 been forwarded to the 8080 Renovation Project people as well as printed here Dear Fig After receiving my installation quide I spent a week keying in the requisite sev enty five pages of 6502 assembler code Now I am a confirmed figger I have written my own 6502 FORTH assembler a small wordprocessor with w
66. g Von Neumann design Conventional languages in the word at a time flow described above require large data trans fers through this small channel connecting main storage and the CPU Backus calls this the Von Neumann bottleneck is not merely a physical bottleneck but more importantly it is a bottleneck to our thinking about computer languages Backus refers to it as an intellectual bottleneck characterizes conven tional languages as both fat and weak since increases in the size and complexity of these languages have provided only small increases in power The typical pro gramming language requires a large fixed set of constructs is inflexible and is not extensible The problem has been eased by approaches such as top down design and structured programming but these have not provided a solution to the underlying difficulty Backus suggests that we need a new way of thinking about computing He describes a new style which he calls func tional programming Functional Programming This new style of programming has the following characteristics A function program is constructed from a set of previously defined functions using a set of functional forms that combine these existing functions to form new ones The most fundamental functional form is called composition If the composition operator is denoted by then in Backus notation fog is the function where g is first applied and then f The fu
67. ges which have attri butes similar to FORTH begin to appear in academic circles The author has recently implemented such an operator in FORTH The way that literals are handled can be viewed as merely a question of im plementation and efficiency References 1 2 Backus Can Programming be Liberated from the Von Neumann Style CACM Vol 21 No 8 August 1978 p 613 FORTH AND ARTIFICIAL LINGUISTICS Raymond Weisling Surakarta Jawa Tengah Republik Indonesia There has not been much said about the linguistic mature of computer languages principally because so few of them permit the development of syntax structures that apporach human language and hence foster linguistic observation FORTH and its other threaded code rela tives allow for such structures to be developed principally because of the larger body of words that arise from its extensibility and hierarchal function of operators The point I wish to address here is the syntactical limitations of the language we are building an artificial language based in part on a human language English that is widely used wherever technology has developed But there is a fundamental weakness in this English which I think we must be aware of since it runs counter to the philosophy of FORTH This is the syn tax sensitivity of word forms especially nouns and verbs which in English are commonly spelled and pronounced exactly the same We rely on the structure
68. he processor status bit referenced The digit 1 or 2 is tested for conditional pairing The general method of security control is to drop off the check digit and manipu late the addresses at assembly time The security against errors is less but the pro grammer is usually paying intense atten tion to detail during this effort To generate the equivalent of the high level BEGIN lt a gt WHILE lt b gt REPEAT we write in assembly BEGIN DROP the check digit 1 leaving addrB lt a gt leaves addr and digit 2 CS IF lt b gt ROT bring addrB to bottom JMP to addrB of BEGIN ENDIF complete false for ward branch from IF It is essential to write the assembly time stack on paper and run through the assembly steps to be sure that the check digits are dropped and re inserted at the correct points and addresses are correctly available ASSEMBLER GLOSSARY Specify immediate addressing mode for the next op code gener ated Specify indirect indexed dressing mode for the next op code generated FORTH DIMENSIONS 11 5 0 lt ASSEMBLER BEGIN Specify indexed X addressing mode for the next op code gener ated Specify indexed Y addressing mode for the next op code gener ated Specify accumulator addressing mode for the next op code gener ated cc assembling Specify that the immediately fol lowing conditional will bran
69. hich I am writing this letter and an APPLE II graphics utility resembling LOGO I like FORTH Bob Wiseman 118 St Andrews Drive Cincinnati OH 45245 Your last name says it all How about some articles for F D publication ed Dear Fig I am spreading the FORTH gospel here in Taiwan I have written about 20 lec tures and numerous demonstrations to var ious universities and institutions in this area and have generated quite a bit of local interest From ground zero can now count about 10 FORTH systems installed al ready Many of them from the FIG In stallation Manual and source listing I brought with me An informal FORTH discussion group has already been formed and our last meeting on October 25th attracted 20 en thusiasts I having fun too My home phone in Taipei is 393 1554 If any of you happen to be heading this way be sure to let me know Dr Chen hanson Ting National Yang Ming Medical College Taipei Taiwan 112 R O C 02 831 2301 Glad to hear you are doing so well We all miss you Dear Fig I want to extend my apologies to you your readers and the FORTH Interest Group sent an announcement about FORTH ROMS for the TRS 80 MOD I sev eral months ago Unfortunately cir cumstances beyond my control now force me to revise their avabilability schedule I will spare everyone further embarrass ment by waiting to send in another an nouncement until I have th
70. his year s topics complement and extend the work described at the 1981 FORML Con ference and the previous Rochester Con ference We believe that the areas of data bases and process control can be uniquely dealt with using FORTH There is a call for papers on the fol lowing topics l Data Bases including but not lim ited to hierarchical network and relational models scientific use process control and commercial systems 2 Process Control including but not limited to multitasking meta compilation data acquisition and real time systems video games 3 Related concepts of implementation speed space tradeoffs user interactions de signer tools and graphics Papers will be handled in either oral sessions or poster sessions although oral papers will be refereed in accordance with conference direction paper quality and topic Please submit a 200 word abstract by March 15 1982 The oral papers dead line is April 15 1982 and the poster papers deadline is May 1 1982 Send ab stracts and papers to the conference chairman Lawrence Forsley by those dates Please keep papers to a maximum of 10 printed pages If this restriction causes a serious problem contact us For more information please contact the conference chairman at Lawrence P Forsley Laboratory for Laser Energetics University of Rochester 250 East River Road Rochester New York 14625 FORTH DIMENSIONS 5 FORTH ASSEMBLER
71. ile only a few had access to similar machines we took a poli and found that more than 9096 had RS 232 ports The following two screens permit unidirectional transfer with a modem over telephone lines at 300 baud or hardwired at 19 200 baud The definitions are not particularly sophisti cated There is no error checking or ack nack with retry Since it is source code which is being transferred some editing will probably be necessary anyway so such safeguards aren t worth the effort to write them There are four definitions which are entirely system dependent in each screen These are SOUTPUT COUTPUT SINPUT and CINPUT Respectively they direct output to the serial port output to the console input from the serial port and input from the console If your sys tem doesn t use I O flags or vectors you may have to write serial port drivers and point KEY and EMIT to them for SOUTPUT and SINPUT screen 80 these four words are defined for an APPLE running a serial interface in slot two driver at C200 In screen 58 they are defined for an Ohio Scientific with the normal serial port found in the personal models These are examples of vectored and flagged 1 redirection The remaining definitions should be quite universa among fig and other systems Screen 80 contains all that is necessary to receive screens under the control of the sender FINISHED and RECEIVE simply redirect input and out put The word P redef
72. in URTH The Best of the Computer Faires Volume IV San Francisco 1979 3 Boles J A Pessel D and L P Forsley Omega Automated Laser The Beta And Computing Monthly Control and Data Acquisition IEEE Journal of Quantum Electronics Vol QE 17 No 9 New York New York IEEE September 1981 Towards More Usable REUS E Report Large Systems Requirements for Application Development Chicago Share Inc 1979 IEEE Standard 583 1975 New York IEEE 1975 1977 Laboratory for Laser Energetics Annual Report Rochester NY Laboratory for Laser Energetics 1978 7 Moore Charles Forth New Way to Program Minicoimputers Journal of Astronomy and Astro physics Supplement 15 New York AAAS September 1974 8 Moore Charles Forth The Past Ten Years and the Next Two Weeks Forth Dimensions Vol 16 San Carlos CA Forth Interest Group 1979 Elizabeth and Charles The FORTH Approach to ACM 176 Pro ACM 9 Rather Moore Operating Systems ceedings New York October 1976 10 Ritchie D M and K Thompson The UNIX Time Sharing System The Bell System Technical Journal Vol 57 No 6 Part 2 New Provi dence NJ A T and T July August 1978 ll Ritchie D M et al The C Pro gramming Language The Bell Sys tem Technical Journal Vol 57 No 6 Part 2 New Providence NJ A T and T July August 1978 Change pg 118 para 3 to The TO conce
73. ines the fig editor word P to do the same thing except with 1 O redirection Note that these three definitions simple fool proof enough that they could be sent to another computer if that computer was first told to accept all input from the serial transfer line Once these definitions were com piled by the receiving system screen transfer could begin In screen 58 the word WAIT waits for anything to be sent back from the receiver with a carriage return on the end The word OK is defined just in case the receiver sends one or more OK s back to the sender during transfers SEND SCREEN will send a screen to the receiver one line at a time by emulating user entering lines with the receiver s line editor First SEND SCREEN asks the receiver to list the screen being sent Page 162 This insures that the proper disk blocks are resident After the LIST the receiver will reply followed by a carriage re turn WAIT makes the transmitter wait for this carriage return This is the only handshaking needed Each line s text is sent preceded with the letter P and a space and followed by a carriage return WAIT causes the transmitter to wait for the receiver to reply OK after each line is sent SEND is a multi screen transmit ter Note that the range of screens re ceived and recorded on disk will corres pond exactly to the screen numbers sent SCR 58 Serial HEX SOUTPLUT COUTPUT 2522 C SINPUT 521
74. ing nl n2 run time A constant which leaves during assembly the machine address of the return point which at run time will write the accumulator as high byte and the bottom machine stack byte as low byte over the existing data stack 16 bit value n1 assembly time Used in a code definition in the form RP LDA or RP 3 STA Address the bottom byte of the return stack containing the low byte by selecting the X mode and leaving n 101 n may be modi fied to another byte offset Be fore operating on the return stack the X register must be saved in XSAVE and TSX be executed be fore returning to NEXT the X register must be restored n assembling Identical to BOT except that 2 Addresses the low byte of the second 16 bit data stack value third byte on the data stack run time addr 2 assembly time Occurs in a code definition in the form cc IF true part ELSE lt false par THEN At run time THEN marks the conclusion of a conditional struc ture Execution of either the true part or false part resumes fol lowing THEN When assembling addr and 2 are used to resolve the pending forward branch to UNTIL UP x XSAVE run time addr 1 cc assembling Occurs in a CODE definition in the form BEGIN cc UNTIL At run time UNTIL controls the conditional branching back to BEGIN If the processor status bit specified by c
75. l flow is controlled by run time boolean values on the data stack As sembly flow is instead controlled by pro cessor status bits The programmer must indicate which status bit to test just be fore a conditional branching word IF and UNTIL Examples are PORT LDA 0 IF 4a THEN read port if equal to zero do lt a PORT LDA 0 NOT IF a THEN read port if not equal to zero do lt a gt The conditional specifiers for 6502 are CS test carry set 1 in processor status 0 lt byte less than zero 1 0 0 2 1 CS NOT test carry clear C 0 O lt NOT test positive N 0 0 NOT test not equal zero Z The overflow status bit is so rarely used that it is not included If it is desired compile ASSEMBLER DEFINITIONS HEX 50 CONSTANT VS test overflow set CONDITIONAL LOOPING A conditional loop is formed at as sembler level by placing the portion to be repeated between BEGIN and UNTIL 6 LDA N STA define loop counter in N BEGIN PORT DEC repeated action N DEC 0 UNTIL N reaches zero First the byte at address N is loaded with the value 6 The beginning of the loop is marked at assembly time by BEGIN Memory at PORT is decrement ed then the loop counter in N is decre mented Of course the CPU updates its status register as N is decremented Finally a test for Z 1 is made if N hasn t reached zero execution returns to BEGIN When N reaches zero
76. ll eventually find one mistake the next two bytes for a link and follow another wild address somewhere else Now depending on how much of your memory is filled with dictionary and de pending on what is in your unused RAM the odds are not bad that after bouncing aimlessly around for awhile the search may land in the middle of a valid name One does not expect a match to compare with the middle of a name but the search then scans for the most significant bit finds a valid link and gets back into the dictionary What the amnesia has ac tually forgotten then is everything be tween the broken link and the point where the search re enters the dictionary If your used RAM is large in compar ison to FORTH you are likely to find most of FORTH still available as a kind of crip pled monitor to help you find out what went wrong without re booting the system which destroys the damage Further more since you now know the cause of this illness you can exploit it to your ad vantage Simply modify your boot up RAM check routine so that it leaves a pattern in your unused RAM such that no matter how it is viewed it will appear to be an address somewhere in the middle of a name field somewhere near the top of your basic FORTH and utilities You will now find to your delight that when you crash you usually have your most powerful tools still at your disposal Users of FORTH Inc Micro FORTH are not likely to observe this
77. moves execution from one definition to the next At the end of your code defini tion you must return control to NEXT or else to code which returns to NEXT RETURN OF CONTROL Most 6502 systems can resume execu tion after a break since the monitor saves the CPU register contents Therefore we must return control to Forth after a return from the monitor NEXT is a con stant that specifies the machine address of Forth s address interpreter say 0242 Here it is the operand for JMP As JMP executes it assembles a machine code jump to the address of NEXT from the assembly time stack value SECURITY Numerous tests are made within the assembler for user errors 1 parameters used in CODE definitions must be removed 2 Conditionals must nested and paired properly 3 Address modes and operands must be allowable for the op codes These tests are accomplished by checking the stack position in CSP at the creation of the definition name comparing it with the position at END CODE Legality of address modes and operands is insured by means of a hit mask associated with each operand Remember that if an error occurs during assembly END CODE never exe cutes The result is that the smudged condition of the definition name remains in the smudged condition and will not be found during dictionary searches The user should be aware that one error not trapped is referencing a defini tion in the wro
78. must handle 1024 byte strings the situation is even worse We then have to stop compiling when the dictionary has over bytes of space left Since most of the time the tokens extracted by WORD are very short 31 characters or less we pay a dear price to be able to handle the occasional long string given that WORD must handle it and WORD is defined as at present If you discard the notion that a more or less unbounded free space exists somewhere in memory the approach to WORD s definition takes on a new facet At Microsystems we have developed several large applications using FORTH which resulted in target compiled code in the range of 32K to 48K bytes exclusive of the dictionary headers and the FORTH operating sysem software When appli cations become that large there isn t even room to hold all the names in memory at one time even if constrained to 5 char acters and length let alone room to burn for large free space buffers Our im plementation which is called proF ORTH handles this problem by means of multiple dictionaries ROM RAM segment contro with selective symbol purging Names are classified as to their needed lifetimes during com pilation When the names are no longer needed they are purged and their memory space is reclaimed This allows much of the mernory devoted to dictionary headers to be reused many times during com pilation thereby enabling very large ap plications to be compiled
79. n 10 ee Pang 2 Videc controis ior Colenois M264 12192151 FORTH DEFINITIONS DECIMAL In this article I am going to tell a true 3 M S WAT AS SWAP story For those people wh think FORTH 3 S NES 93 MIN 55 SURE is a religion they might just consider this 5 0 Sa to be my testimony Ve EMIT Last November I had access to a very 6 HOME 25 TENIS 2 eee M a TT little known but well built microcomputer 82 CLR CLR VIDEO HOME 2 CLEARSCREEN CLR MX 964 2 by Columbia Data Products ANN g5 i SAYS mad Inc of Maryland This little machine has 20 DW C 10 EMIT i ibo ect TOMUS EM two 2 CPUs One is for the Host and lA p TOW the other for terminal There 64 K of 12 gt 4 DES RAM in the Host and 32 K of the Ter 18 CLRROS 25 ENIT minal RAM is dedicated to the 512 x 256 14 CLRLINE 21 bit mapped graphics It also includes 9 us CRT 2 double density drives keyboard 4 Screen 4 11 serial ports and 4 parallel ports Its all in Graphic Package TIK 1210940 one piece It boots up with whatever i Pu operating system is on the disk after 2 0 VARIABELE 4 0 VARIAELZz Y 3 VARIABLE L 2 VARIABLE 7 powered up and the carriage return key 3 0 VARIABLE XI 0 VARIABLE Y has been pressed Beautiful isn t it 4 ESC 27 EMIT ST i2 EMIT 092 29 vector 2 However there is a big problem as US 3i EMIT i al
80. n The player has ten 15 gt chances to deduce the secret code SCR 23 Master Mind transiate color to numeric UAR i 7nevad There are many improvements which 1 could be made to this program to take ad 2 LCOLOR 11 TYPES COLOR FROM vantage of more of FORTH S built in 53 1 4 C CUNSTANT 3 TYPE vocabulary most notably PAD and re 4 lated words For those short of memory 1 TRANSLATE CODE note that the directions could be short amp converts calor fram SCODE to COLCR KEY ened left out or read from disk with no 7 numeric value in array SECRET change to the overall logic of the pro 40 DO SCODE I 1 COLOR KEY Ce SECRET gram 9 i Dr LOOP s 10 Further notes and comments may be 11 found in the source screens 12 13 14 Pod gt gt R gt LCOMPILEJ R SWAF gt R SWAF gt R SWAF 3 15 gt R 24 Master Mind cursor motion 1 Qf course dependent Here is Heath start CRT dependent words Wes 2 CURSOR 1 EX1 L23 ABSOLUTE CURSOR POSITION gt 31 SWAP 21 87 27 EMIT EMIT EMI CLEAR CLEAR CRT SCREEN 27 EMI 69 EMIT HOME PUT CURSOR AT HUME POSITION O CURSOR 3 HRH end ot derendert words 1 4 5 4 7 9 10 SHOW COLORS DISPLAY COLOR CHOICES 11 7100 I 2 58 CURSOR I Looe 12 COLORS 7 IF 9 57 CURSOR
81. n the stack DEX DEX make room on the data stack 1 LDA BOT STA store low byte BOT 1 STY hi byte stored from Y since zero NEXT JMP END CODE A simpler version could use PUSH CODE ONE 1 LDA PHA push low byte to machine stack TYA PUSH JMP high byte to accumulator push to data stack END CODE The convention for PUSH and PUT is l push the low byte onto the machine stack 2 leave the high byte accumulator 3 jump to PUSH or PUT the PUSH will place the two bytes as the new bottom of the data stack PUT will Over write the present bottom of the stack with the two bytes Failure to push exactly one byte on the machine stack will disrupt execution upon usage FOOLING SECURITY Occasionally we wish to generate unstructured code To accomplish this we can control the assembly time security checks to our purpose First we must note the parameters utilized by the control structures at assembly time The notation below is taken from the as sembler glossary The indicates as sembly time execution and separate input stack values from the output stack values of the words execution BEGIN gt addrB 1 UNTIL gt addrB 1 cc IF gt cc 2 ELSE gt addrI 2 addrE 2 THEN gt addrI 2 addrE 2 The address values indicate the machine location of the corresponding B EGIN TF or E LSE cc represents the condition code to select t
82. ncludes a straightfor ward line based text editor The editor is not added to the dictionary as a list of de fined words but is included as a separate module callable from TransF ORTH DOS text files are used for saving source files This means that any text editor that uses DOS text files may be used for edit ing TransFORTH programs In addition TransF ORTH program data may be shared with other programs and languages Grahics Two graphics utilities along with a couple of graphics demo programs in cluded on the system diskette One utility contains high resolution graphics and Turtlegraphics commands and the other has low resolution graphics commands The graphics capabilities are added to the system by compiling these utilities into the dictionary The hi res package in cludes a call to a module which ailows text and graphics to appear together any where on the screen Vocabulary TransFORTH is single vocabulary system Related programs can be grouped together in disk files rather than in sep arate vocabularies Multiple vocabularies find their most usage in multi user sys tems Compilation and speed All entries in TransFORTH are com piled directly into 6502 machine language for greater speed No address interpreter is used Even immediate keyboard entries are compiled before being executed This means that routines can be tested at the keyboard for speed before being added as colon definitions
83. nctions incorporate no data and do not name their conventions nor substitution rules A function is hierarchical i e built from simpler functions Backus points out that FP Functional Programming systems are so minimal that some readers may find it difficult to view them as programming languages We have a set of predefined functions in a library dictionary and may define new functions in terms of these predefined functions Functional forms are constructs de noting functions which take functions as parameters For example the construct if else then and the construct while are functional forms As indicated above composition is also a functional form FORTH of course has predefined con structs which serve as the functional forms of FP systems In fact FORTH provides facilities for adding new func tional forms An example would be a case construct to provide a more flex ible and clear decision structure than that of a set of nested if else then s capability of language to add new func tional forms is not inherent in FP systems Backus defines a language with this capability as a formal functional pro gramming FFP language An Example of Functional Programming The Factorial Function An example of a program written in the style of functional programming is as follows def 0 1 id subl where the notation and 1 denote func tional forms As we have s
84. nest software concepts and tools available today This has not been an easy task and all too often a thankless one but it is hoped that if others will least try to understand the efforts and contributions of these volun teers will continue to benefit us all ed Dear F ig Congratulations to all the people who produce FORTH DIMENSIONS on its qual ity and improvement Please send me a writer s kit so 1 can make some of my ap plications presentable for publication Bob Royce Box 57 Michiana New Buffalo MI 49117 Your kit is on the way Anyone else ed Dear F ig Glen Haydon s nice article in FORTH DIMENSIONS 2 page 47 talks about an algorithm he would like to have to determine the Julian day With the background that FORTH has in astronomy I m sure there must be several but this is the nicest I know It comes from the U S Naval Observatory via an article in the Astrophysical Journal Supplement Series Vol 41 No 5 Nov 1979 pp 591 2 0 JULIAN DATE 1 JD SWAP 2 DUP 9 12 R 7 4 MINUS 3 OVER9 7 R 100 1 3 4 4 SWAP 2759 5 5 gt D 1 721029 D 6 367 R gt M D Example 3 20 1982 JD D 2445049 OK If you are only concerned with dates between 3 1 1900 and 2 28 2000 then you can omit line 3 entirely On another subject there is another correction I noticed in the dump of the fig FORTH 6502 Assembly Source at location OC32 80 1A should be 07 OB Peter B Dunckel
85. ng vocabulary O of ASSEMBLER when you want 0 of FORTH FORTH DIMENSIONS III 5 Page 143 Editor s note the listing assumes that the figFORTH error messages are already available in the system as follows CSP issues the error message DEFI NITION NOT FINISHED if the stack position differs from the value saved in the user variable CSP which is set at the creation of teh definition name PAIRS issues the error message CONDITIONALS NOT IMPAIRED if its two arguments do not match 3 ERROR prints the error message HAS INCORRECT ADDRESS MODE SUMMARY The object code of our example is 305 983 4D CE CODE MON 305D 4D 30 link field 305F 61 30 code field 3061 00 BRK 3062 4C 42 02 NEXT OP CODES revisited The bulk of the assembler consists of dictionary entries for each op code The 6502 one mode op codes are BRK CLC CLD CLI CLV DEX DEY INX INY NOP PHA PHP PLA PLP RTI RTS SEC SED SEI TAX TAY TSX TXS TXA TYA When any of these are executed the corresponding op code byte is assembled into the dictionary The multi mode op codes ADC AND CMP EOR LDA ORA SBC STA ASL DEC INC LSR ROL ROR STX CPX CPY LDX LDY STY JSR JMP BIT These usually take an operand which must already be on the stack An address mode may also be specified If none is given the op code uses z page or absolute addressing The address modes are deter mined by S
86. ntribute to the growth and understanding of the language While we are not yet in a position to give you cash for your contributions we at least will give you credit Starting in this issue will be a policy of putting in tutorial articles designed to help our entry level readers This however will not be done at the expense of our more seasoned FIGGERS who will find an expanded base of challenging articles and applications In closing I want to say that the writer s kits have finally come off the presses and I will be glad to send one to anyone who wants to contribute Please send in applications and utilities philosophy questions and problems in the final analysis FORTH DIMENSIONS is what you make it C J Street PUBLISHER S COLUMN 1981 has been a great year for FORTH the FORTH Interest Group and for me personally FORTH has spread around the world and is being used on thousands of computer and microprocessor based products It is being taught extensively in schools companies and by FORTH programmers FIG has just completed its most successful national convention with almost 500 attendees over 20 exhibitors and multiple sessions Thanks to Bob Reiling Conference Chairman and Gary Feterbach Program Chairman The FORML conference was well attended and the Proceedings are now available see order form My deepest thanks to the FORTH community for THE FIGGY Man of Year Award It was a fantastic thrill and a surprise
87. o the index ele ment of ARRAY AINIT Initializes ARRAY with the numbers 1 through nine in game winning order A Displays ARRAY in an understandable format ASCRAMBLE Using RND scrambles the numbers in ARRAY for a new REVERSE game GETIN Solicits the number of elements of the list to reverse If any character other than 0 through 9 is entered GETIN prints Only 0 through 9 is allowed and solicits another number AREVERSE n Reverses the nth length subset of ARRAY starting from element 1 ACHECK flag Checks ARRAY for proper ascending numerical order If ARRAY is in the proper order returns a true flag REVERSE The game definition Uses all pre viously defined words to play the game of REVERSE FORTH DIMENSIONS III 5 Page 153 THE 31 GAME Written by Tony Lewis 11 81 The 31 Game is an attempt to use FORTH fundamentals to produce enter taining result The object is to entice you into anlyzing both the game itslef and the methods used to produce it The game buffs might wish to know that I have been an avid player not gambler for over 30 years and have made extensive practica studies of various games Any phone communication is welcome I am two years behind in written corres pondence so sending me letters which require replies will prove futile The pro gram is my first effort in FORTH How ever I have had extensive experience with six different main frame ass
88. ofessional Management Services 724 Arastradero Rd 109 Palo Alto CA 94506 415 858 2218 Sierra Computer Co 617 Mark NE Albuquerque NM 87123 APPLE IDPC Company P O Box 11594 Philadelphia PA 19116 215 676 3235 IUS Cap n Software 281 Arlington Avenue Berkeley CA 94704 415 525 9452 George Lyons 280 Henderson St Jersey City NJ 07302 201 451 2905 MicroMotion 12077 Wilshire Blvd 506 Los Angeles CA 90025 213 821 4340 CROSS COMPILERS Nautilus Systems P O Box 1098 Santa Cruz CA 95061 608 475 7461 polyFOR TH FOR TH Inc 2309 Pacific Coast Hwy Hermosa Beach CA 90254 213 372 8493 LYNX 3301 Ocean Park 301 Santa Monica CA 90405 213 450 2466 M amp B Design 820 Sweetbay Drive Sunnyvale CA 94086 Micropolis Shaw Labs Ltd P O Box 3471 Hayward CA 94540 415 276 6050 North Star The Software Works Inc P O Box 4386 Mountain View CA 94040 408 736 4938 11 Laboratory Software Systems Inc 3634 Mandeville Canyon Rd Los Angeles CA 90049 213 472 6995 051 Consumer Computers 8907 LaMesa Blvd LaMesa CA 92041 714 698 8088 FORTH VENDORS Software Federation 44 University Arlington Heights IL 60004 312 259 1355 Technical Products Co Box 12983 Gainsville FL 32604 904 372 8439 Tom Zimmer 292 Falcato Dr Milpitas CA 95035 1802 FSS 0 Box 8403 Austin TX 78712 512 477 2207 6800 amp 6809 Kenyon Micro
89. on Functions may be written first in high level tested and then re coded into assembly with a minimum of restructuring THE ASSEMBL Y PROCESS Code assembly just consists of inter preting with the ASSEMBLER vocabulary as CONTEXT Thus each word in the in put stream will be matched according the Forth practice of searching CONTEXT first then CURRENT ASSEMBLER now CONTEXT FORTH chained to ASSEMBLER user s CURRENT if one exits FORTH chained to user s vocab try for literal number else do error abort The above sequence is the usual action of Forth s text interpreter which remains in control during assembly During assembly of CODE definitions Forth continues interpretation of each word encountered in the input stream not in the compile mode These assembler words specify operands address modes and op codes At the conclusion of the CODE definition a final error check veri fies correct completion by unsmudging the definition s name to make it available for dictionary searches RUN TIME ASSEMBLY TIME One must be careful to understand at what time a particular word definition executes During assembly each as sembler word interpreted executes Its function at that instant is called assemb ling or assembly time This function may involve op code generation address calculation mode selection etc The later execution of the generated code is called run time This distinction is particular
90. pha CAN 21 EMIT non Qieliv with most microcomputer companies the 7 LM 25 EMIT clear video mewory instruction manuals are terrible And I WHITE ESC 97 EMIT BLACK ESS 127 SNIT mean terrible Let me just give you one examle For this information please see 10 figure only to find there was no such ii figure and no page number 12 Graphics are one of the most impor ie tant features with this machine 512 x 15 256 bit mapped graphic is the best that Screen 22 can be expected under the price al S Geaphic Package 2 2 69 80 lowance There are quite a few well known 1 microcomputers on the market claiming F vecronr Lo Hi High Resolution Graphics But those High 1022 AND 32 400 Resolution ones are just like a big blob 4 compared with the individual pixel that bit s 4oX max gt mapped So I have a nice machine with 4 32 4 EMIT 64 all the fancy graphic capabilities but YSEN 4 HY lacking the key to open it Anxiety 3 32 2 EMIT 06 EMIT mounts up quickly 9 I have a friend who s an excellent P TE Hec dad zCiN 8080 780 assembly programmer im 12 plemented UCSD Pascal for microcom 13 PAGE enter alpha irom vector puter Naturally since he was the first 4 ESC rr one it seemed logical to seek his help 15 With a poorly written computer manual 43 24 Graphic Package 2 7DH 12 09 80 2 2 PAGE 65 32 76 EMIT 32 2X 46 OMIT 4
91. phenomenon Because names are always exactly four characters long the link field does not have to be scanned for instead it is found by simple arithmetic In order to re enter the dictionary one must land by chance on the exact beginning of name field Much more likely than this is that the search will enter a loop in which it goes again to an address it has already visited and get caught forever Remember that the addresses found are by no means ran dom All you have to do is cover the most common ones Steve Munson 8071 E 7th Street 14 Buena Park CA 90621 TRANSIENT DEFINITIONS These utiliites allow you to have tem porary definition such as compiler words CASE OF ENDOF ENDCASE GODO etc in the dictionary during compilation and then remove them after compilation The word TRANSIENT moves the dictionary pointer to the transient area which must be above the end of the current dictionary The tem porary definitions are then compiled into this area Next the word PERMANENT restores the dictionary to its normal location Now the application program is compiled and the temporary definitions are removed with the word DISPOSE DISPOSE will take a few seconds because it goes through every link including vo cabulary links and patches them to bypass all words above the dictionary pointer NOTE These words written in MicroMotion s FORTH 79 but some non 79 Standard words are used The non Standard
92. pt yas developed by Dr Paul Bartholdi as an alternative to constants and variables EDITOR S NOTE Peter Bengtson of DATATRONIC AB in Stockholm Sweden sent us a copy of the September 1981 edition of Electronics Feature article was FORTH The Language of the Eight ies in which FIG is mentioned prominent ly More confirmation we are all riding the crest Page 139 TECHNOTES BUGS AND FIXES I have three questions about FORTH Q I know of two CP M FORTHs that have their own way of dealing with the BIOS and BDOS and as a result cannot read each other s screens What I m leading to is this CP M and fig FORTH are both sup posed to be machine independent systems but cannot read each other s source code files CP M figgers ought to get together on this one A Differences between disk organizations are sector skewing and location It is easy to add definitions to a FORTH which uses BIOS so it can read other organizations it is not possible the other direction 2 When selecting a new drive you need to do COLD start or you ll remain on the last drive this is only true if you are accessing the same screen number If you leave an empty line between two defini tions on the screen a LOAD will stop loading at the empty line Are these FORTH conventions I haven t heard about yet or are they peculiar to my Timin FORTH A Both of these are bugs demand fixes from Timin 3 Somehow I ve been leaving a lot of cont
93. r E 20 25 PROCEEDINGS 1980 FORML FORTH Modification Lab Conference 25 35 O PROCEEDINGS 1981 FORTH Univ of Rochester Conference 25 35 PROCEEDINGS 1981 FORML Conference Both Volumes NEW 40 55 O Volume Language Structure 25 35 O Volume ll Systems and Applications 25 35 O FORTH 79 Standard a publication of the FORTH Standards Team 15 18 1 Kitt Peak Primer by Stevens An indepth self study primer 25 35 BYTE Magazine Reprints of FORTH articles 8 80 to 4 81 5 10 D FIG T shirts 1 Small O Medium O Large O X Large 10 12 Poster Aug 1980 BYTE cover 16 x 22 3 5 1 FORTH Programmer s Reference Card If ordered separately send a FREE stamped addressed envelope TOTAL NAME Bu MAL ORGANIZATION CIF company address ADDRESS a STATE NW ZIP GOUNTRY ________ MASTER CHARGE 4 c Lo ExpirationData Minimum of 10 00 on charge cards Make check or money order in US Funds on US bank payable to FIG All prices include postage No purchase orders without check ORDER PHONE NUMBER 415 962 8653 FORTH INTEREST GROUP BOX 1105 SAN CARLOS CA 94070 BULK RATE U S POSTAGE PAID Permit No 261 Min View CA Support Your Local FIG P O Box 1105 San Carlos CA 94070 Chapter Address Correction Requested
94. rds help clar ify things but are not without problems whereas and are perfectly uniform in function Could a FORTH like language be built that allows the word type to be come part of the header with the com piler choosing which form of the same named word to use based on its syntactical position like nouns variables constants arrays being objects of TO and FROM Or does this push us back into the horrible mess of artificial syntax forms such as algebraic notation something we are per haps proud to have departed from I offer no solution per se I only wish to point out a weakness that we all should be sensitive to when we assign names to our words Since FORTH is still in evo lution this is yet another aspect to con sider when standards are defined I wish to disclaim any implication that 1 am a linguist of any sort other than Armchair Linguist My sensitivity to this is a result of living in a different culture where I am learning a human language that permits far greater fluidity of structure due to the inherent differences in nouns and verbs shown by a well codified system of pre fixes and suffixes morphemological dif ferentiators Those here who learn English struggle with the structural dif ferentiation of all the parts of speech while our differentiators are used for relatively useless things like verb conjugation plurality cases and tenses which are all essentially absent in this par
95. retrieving single bytes and two byte cells but all values are stored on the stack in FORTH DIMENSIONS 111 5 floating point format Numbers can be as large as 1 38 and as small as 1 38 Transcendental functions The floating point format mentioned above makes TransFORTH a natura lang uage for transcendental functions Func tions included in the system which are not found most versions of FORTH include sine cosine tangent arctangent natural logarithm exponential square root and powers Data structures TransFORTH contains words that will store fetch 5 byte floating point values 2 byte cells and single bytes from any location in memory Trans ORTH does not have the fig FORTH lt BUILDS DOES gt construction but instead uses a powerful built in array declaration Arrays can either fill space in the diction ary or be located absolutely in memory Arrays with any number of dimensions mav be declared and each dimension can have any length within the limits of available memory Strings Strings are merely arrays of any di mension and size with an element length of one Each character occupies one byte one element of the array Built in string functions included Disk access and the editor TransF ORTH does not use the virtual memory arrangement found in most ver sions of FORTH Instead a standard DOS 3 3 format is used and files are called from the disk by name TransFORTH i
96. rol characters behind when using the editor They don t show up on a screen list but they sure ruin any attempt at loading the screen am not sure if this is a common problem but I have enclosed a short routine to replace control charaters with spaces for anyone else who has this probiem SCREEN 95 HUNT FOR CONTROL CHARACTERS HUNT SCREEN BLOCK 1024 0 DO DUP DUP 32 lt IF CR 64 EMIT DUP U ELSE DROP ENDIF 1 LOOP DROP FIXSCREEN SCREEN BLOCK 1024 0 DO DUP 32 IF DUP 32 SWAP C ENDIF 1 LOOP DROP ACTUALLY HUNT AND FIXSCREEN ARE QUITE SIMILAR HUNT JUST SHOWS UP ANY GUILTY CHARACTERS AND FIXSCREEN REPLACES THEM A Don t know May be an editor bug or the way you are using it If you add a line with followed immediately by a car riage return in the fig editor a null is introduced into the line which stops com piling editor fix should be supplied Page 140 THAT MYSTERIOUS fig F ORTH AMNESIA Many fig FORTH users have probably noticed the curious phenomenon I refer to as amnesia in their computers and those who understand the method of the fig FORTH dictionary search no doubt under stand it as well It is an amusing often perplexing but usually useful property peculiar to fig FORTH dictionaries Because names in fig FORTH may have variable length the distance between the start of the name and the link to the next name in the dictionary is also
97. sentially anything that he may desire but the im plementor need not provide any special temporary buffers or arbitrary size just to FORTH DIMENSIONS 111 5 Page 141 satisfy the Standard Using WORD as the fundamental token extractor allows implementors to compile dot quote strings for example without the need for any transitional buf fers see WORD On the other hand if dot quote strings are acquired by the present form of WORD in the Standard then the token buffer must be at least as large as the longest dot quote string which is presently specified to be 127 characters One might argue that if the buffer is at HERE there is no penalty since that is where the string must go anyway and if it won t fit it can t be compiled However this line of reasoning is again limited by a parochial view that all FORTH implemen tations must be alike If a system like proF ORTH is being used the target defin ition body can optionally be compiled in place separate from the dictionary header There may be room for the string in the target segment of memory but not enough in the dictionary In conclusion let me say that if there is sufficient memory the user declare all the buffers he wants but we should not require that these buffers be preallocated by the implementor in order to satisfy the Standard Therefore I sub mit that my definition of WORD is a more fundamentally valuable function than WORD as currentl
98. source code It contains hundreds of FORTH definitions not previously pub lished Included on the diskette are data structures software development aids string manipulators an expanded 32 bit vocabulary a screen calculator a typing practice program and a menu ation selection program In addition the diskette provides examples of recursion lt BUILDS DOES gt usage output number formatting assembler definitions and conversational programs hundred screens of software and hundred screens of instructional dacumentation are supplied on the diskette Every screen is in exemplary FORTH programming style The FORTH screens written by Scott Pickett may be used with Timin FORTH or other fig FORTH The price for the diskette of FORTH application modules is 75 00 if other than 8 standard disk add 15 00 To order the FORTH modules write Timin Engineering Company 9575 Genesee Avenue Suite E 2 San Diego CA 92121 or cail 714 455 9008 AUDIO TAPES OF 1980 FORML CONFERENCE AND 1980 FIG CONVENTION 1 FORTH 79 Discussion 200 min Price 35 00 2 Purpose of FIG 37 min Price 10 00 3 Charles Moore 63 min Price 15 00 4 FORTH Alan Taylor 47 min Price 15 00 Complete set 65 00 edu FORTH 1442 A Walnut Street 332 Berkeley CA 94709 Page 165 The following vendors have versions of FORTH available or are consultants FIG makes no judgment on any products ALPHA MICRO Pr
99. systems 1927 Curtis Avenue Redondo Beach CA 90278 213 376 9941 TRS 80 The Micro Works P O Box 1110 Del Mar CA 92014 714 942 2400 Miller Microcomputer Services 61 Lake Shore Rd Natick MA 01760 617 653 6136 The Software Farm P O Box 2304 Reston VA 22090 Sirius Systems 7528 Oak Ridge Hwy Knoxville TN 37921 615 693 6583 6502 Eric Rehnke 540 S Ranch View Circle 61 Anaheim Hills CA 92087 Saturn Software Ltd P Box 397 New Westminister BC V3L 477 CANADA 8080 780 CP M Laboratory Microsystems 4147 Beethoven St Los Angeles CA 90066 213 390 9292 Timin Engineering 9575 Genesse Ave E 2 San Diego CA 92121 714 455 9608 Application Packages InnoSys 2150 Shattuck Avenue Berkeley CA 94704 415 843 8114 Decision Resources Corp 28203 Ridgefern Ct Rancho Palo Verde CA 90274 213 377 3533 Page 166 68000 Emperical Res Grp 0 Box 1176 Milton WA 98354 206 631 4855 Firmware Boards and Machines Datricon 7911 NE 33rd Dr Portland OR 97211 503 284 8277 Forward Technology 2595 Martin Avenue Santa Clara CA 95050 408 293 8993 Rockwell International Microelectronics Devices P O Box 3669 Anaheim CA 92803 714 632 2862 Zendex Corp 6398 Dougherty Rd Dublin CA 94566 Variety of FORTH Products Interactive Computer Systems Inc 6405 Di Marco Rd Tampa FL 33614 Mountain View Press P O Box 4656 Mountain View CA 94040
100. t he would have liked Later on I spent a couple of weeks twiddling with Microsoft BASIC compiler and it also produced lousy results At the same time I received my 8080 fig FORTH listing So I typed the whole 60 of assembly listing with the lousiest text editor i e ED COM It was a mon umental job Nevertheless I had the fig FORTH up and running By now I was very desperate to get it going Equipped with the FORTH power and the poor manual I set forth to try the graphics again Again I sought help from a friend who works for Tektronics and is experienced with FORTH With FORTH the whole task turned into a very simple job compared to the previous attempts we had with the assembly and BASIC Thus now I am steadfast in my belief FORTH Screen 10 and 11 sets up the variables and the Columbia Mx964 hardware depen dent words The X coordinate starts at the lower left corner as 0 far right as 1023 while 0 starts at the lower left corner to the top as 779 Screen 12 to 14 defines the basic words which draw the line move the cursor relative draw and move Screen 15 defines the words to draw a square and the erasing of it Screen 16 lets me draw many squares I know that there are still a lot of nice words that can be written such as to draw triangles curve lines etc But from this small exercise I am totally convinced the FORTH is the one I will use from now on A ZEN BANANAS
101. t of the world As technology spreads an artificial lanquage for man machine manipulation a two way street should be more universally based at least with re spect to linguistic modeling As FORTH is already in use in many parts of the world the channel for feedback is already open FORTH DIMENSIONS 5 FORTH STANDARDS CORNER Robert L Smith More Words on WORD In my last column I discussed WORD I neglected to mention an important topic relating to the implementations of WORD which may influence transportability Prior to the 79 Standard the execution of WORD caused the string from the input medium to be moved to the dictionary area starting at HERE with the character count Some implementers would be tempted to define the 79 Standard WORD from the older WORD in a manner some what like this WORD WORD Other implementers would probably put the string elsewhere suppose that the user wished to reverse the character string and emplace the modified string in the dictionary The result from the for mer implementer s system will not be as expected and will not result in equiva lent execution on the later implementer s system similar but much less serious problem occurs with PAD PAD is conventionally offset from HERE by a fixed amount 68 bytes in fig FORTH There are at least three different solu tions 1 Implementations which place the string at HERE could be con sidered non st
102. t that the style is es sentially the same We have words which denote functions which are eval uated following very similar rules FORTH as a Language with Charac teristics of Functional Programming Consider the FORTH outer inter preter Literally all that the interpreter recognizes are functions or to be precise words that denote functions The fund amental combining form is composition where in F ORTH fog would be expressed as g f Functions need not incorporate data do not name their arguments and require no substitution rules for parameter passing There are no assignment state ments and a new function is built from simpler previously defined functions It is this style of programming in F ORTH so different than that of conventional lang uages that provides a power and flex ibility that has sparked the enthusiasm of so many of us Summary This very short summary of the article by John Backus does not begin to do justice to either the scope or depth of the paper The new type of programming has generated considerable interest within the computing community and most particu 138 larly among those interested in innovative approaches to computer architectures It is this author s contention that FORTH is a functional programming language which closely resembles the approach suggested by John Backus in his definitive paper It will be interesting to see if as a result of this paper langua
103. there is no run time effect on the stack run time addr2 2 assembling Occurs within a code definition in the form cc IF true part ELSE lt false THEN At run time if the condition code specified by cc is false execu tion will skip to the machine code following ELSE At assembly time ELSE assembles a forward jump to just after THEN and re addrl 2 solves a pending forward branch from IF The values 2 are used for error checking of conditional pair ing END CODE IF INDEX IP An error check word marking the end of a CODE definition Suc cessful execution to and including END CODE will unsmudge the most recent CURRENT vocabu lary definition making it available for execution END CODE also exits the ASSEMBLER making CONTEXT the same as CURRENT This word previously was named addr 2 assembly time time addr 2 assembly Occurs within a code definition in the form cc IF true part ELSE false part THEN At run time IF branches based on the condition code cc 06 0 or CS If the specified processor status is true execution continues ahead otherwise branching occurs to just after ELSE THEN when ELSE is not present At ELSE execution resumes at the corresponding THEN When assembling IF creates an unresolved forward branch based on the condition code cc and leaves addr and 2 for resolution of the branch by the corresponding
104. up to 31 characters String handling Enhanced error checking 16 bit and 32 bit integer arithmetic and input output This is a single user single task sys tem which is not ROM able as supplied Floating point arithmetic and CP M file access are not supported This system as supplied runs comfort ably in a 8080 or Z80 computer system with at least 32K bytes of RAM memory at least one floppy disk drive 8 single density single sided soft sectored format is assumed and the BIOS part of the CP M operating system The use of a printer is supported but not required This software may be easily modified to use other memory sizes or disk formats It requires 14K bytes of memory which in cludes 4K bytes of disk buffers This FORTH system was adapted from the fig FORTH model but is not fully compatible with that language dialect It is also not fully compatible with the FORTH 79 Standard The three dialects are similar but the Starting F ORTH ver sion has advantages over the other two Price 55 00 plus 2 00 Postage and Handling CP M is a registered trademark of Digital Research Inc 2 Learning FORTH Learning FORTH is a computer aided instruction package that interactively teaches the student the fundamentals of the FORTH programming language and philosophy It consists of a set of FORTH screens that contain program source code and instruction text It is based on the book Starting FORTH by Leo Brodie
105. ute 6 DAYS MONTH it should return 70 which is the number of days in the month June I will use the Starting FORTH dia lect in this paper not fig FORTH so if you try to type in the examples they probably won t work unless you are running a system that behaves as described in Starting FORTH or the 79 Standard Our first attempt at solving this prob lem uses the FORTH word VARIABLE The code is as follows VARIABLE DAYS MONTH 22 ALLOT 31 DAYS MONTH 28 DAYS MONTH 2 31 DAYS MONTH 4 30 DAYS MONTH 6 31 DAYS MONTH 30 DAYS MONTH 10 31 DAYS MONTH 12 31 DAYS MONTH 14 30 DAYS MONTH 16 31 DAYS MONTH 18 30 DAYS MONTH 20 31 DAYS MONTH 22 DAYS MONTH INDEX VALUE 1 2 DAYS MONTH Sarde Sasa E RIT There is nothing significant about the apostrophe I only prefaced the VARI ABLE name with it because I want to use the word DAYS MONTH later Now what happened is that VARIABLE allocated 2 bytes in the dictionary for the value of DAYS MONTH The 22 ALLOT then allo cated another 22 bytes for a total of 24 bytes or 2 12 celis We next proceeded to initialize the values that were allocated by explicitly calculating the offsets and storing in the appropriate location Finally we defined DAYS MONTH as a colon definition which performs arith metic on the index adds it to the start of the table and fetches the result Now let s look at another way of doing
106. w byte is at low memory with the high byte following This allows indexed indirect X directly off a stack value The bottom and second stack values are referenced often enough that the sup port words BOT and SEC are included Using BOT LDA assembles LDA 0 and SEC ADC assembles ADC 2 X BOT leaves 0 on the stack and sets the address mode to X SEC leaves 2 on the stack also setting the address mode to X Here is a pictorial representation of the stack in z page sec high sec low bot high bot low lt X offset above 0000 Here is an examples of code to to the accumulator four bytes on the stack BOT LDA 10 0 1 ORA 1 X SEC ORA 2 SEC 1 ORA 3 X To obtain the 14 th byte on the stack BOT 13 LDA RETURN STACK The Forth Return Stack is located in the 6502 machine stack in Page 1 It starts at 01FE and builds downward No lower bound is set or checked as Page 1 has sufficient capacity for all non recursive applications By 6502 convention the CPU s register points to the next free byte below the bot tom of the Return Stack The byte order follows the convention of low significance byte at the lower address Return stack values may be obtained by PLA PLA which will pull the low byte then the high byte from the return stack To operate on aribitrary bytes the method is 1 save X XSAVE 2 execute TSX register to X
107. will run with any Starting FORTH compatible system as well as fig FORTH system The manual is only one page ong and describes how to load the system After that everything is self explanatory It is supplied on 8 single density diskettes in IBM 3740 format The price is 33 00 if ordered together with the Working FORTH Disk Please add 2 00 for shipping and handling and allow at least 3 weeks for delivery Note Buy both for 55 00 plus 2 00 postage and handling POLYMORPHIC FORTH Abstract Systems etc 1686 West Main Road Portsmouth RI 02871 401 683 0845 Ralph E Kenyon Jr Product Description FORTH Poly Morphic fig FORTH 1 1 0 8080 fig FORTH 1 1 without asmb or Editor uses PolyMorphic resident editor A demo application which computes a table of values for a general quadratic equation is included PolyMorphic Systems 8815 8810 needs only 16K Documentation on FORTH not included Manual documentation covers parti cular implementation details for fig FORTH to interface to the PolyMorphic Systems Microcomputer Sorted VLIST included Implementation document available separately Separate document available for cost of postage Product data avail able on PolyMorphic SSSD 5 diskette format 4 copies sold to date Price 40 00 includes shipping diskette R I residents add 696 sales tax Warranty limited to replacement of a diskette damaged in shipment We ll try to fix any bugs discovered
108. y defined in the 79 STANDARD from which all others can be built without burning sometimes precious memory space There are al ready enough buffers and such required directly or indirectly by the Standard Let s not arbitrarily insist on more by ac cidently defining words in such a way as to force an implementor to provide them 1 emphasize possibly because fortun ately the Standard is not explicit as to the length of tokens that must be handled by WORD CORRECTION TO FEDIT Sorry you had trouble with FEDIT The listing was retyped at FIG and several typos creeped in They are 1 SCR 64 Line 10 compile should be COMPILE 2 SCR 65 Line 23 1 MOD should be 1 16 MOD 3 SCR 67 Line 48 B BUD should be B BUF SCR 67 Line 49 e should be SCR 67 Line 50 ALIN should be ALIN wp You are perfectly right that source text should be loadable I talked to some Page 142 of the people at FIG about this and they were acutely aware of the problem but they are simply not set up to directly reproduce listings into FD at the present time They do the best job they can with the resources available to them and they work darn hard at it can t fault them REPL is a pseudonym for the Fig FORTH line editor definition R I used the pseudonym because FEDIT was the first program I wrote in FORTH and I really wasn t familiar enough with Vocab ularies to comfortably use a word that was already used in the FO
109. y important with the condi tionals At assembly time each such word i e IF UNTIL BEGIN etc itself runs to produce machine code which will later execute at what is labeled run time when its named code definition is used AN EXAMPLE As a practical example here s a simple call to the system monitor via the NMI address vector using the BRK opcode CODE MON exit to monitor BRK NEXT JMP END CODE The word CODE is first encountered and executed by Forth CODE builds the following narne MON into a dictionary header and calls ASSEMBLER as the CONTEXT vocabularly The is next found in FORTH and executed to skip til This method skips over comments Note that the name after CODE and the after must be on the same text line OP CODES BRK is next found in the assembler as the op code When BRK executes it as sembles the byte value 00 into the dic tionary as the op code for break to moni tor via NMI Many assembler words names end in The significance of this is l comma shows the conclusion of a logical grouping that would be one line of classical assembly source code 2 compiles into the dictionary thus a comma implies the point at which code is generated 3 The distinguishes from possible hex numbers ADC and ADD NEXT Forth executes your word definitions under contro of the address interpreter named NEXT This short code routine
110. y you should ask There is a quality that can be abstracted from the definition of DAYS MONTH namely that of table lookup Wouldn t it be nice if we didn t need to create that extra name DAYS MONTH simply so we could access it later in our definition Well that is where our friend CREATE DOES gt comes in Instead of defining a particular in stance of a TABLE we will create a new Defining Word called TABLE which acts as follows creates a new entry in the dictionary which when executed uses the value that was placed on the stack as an index into itself and returns the contents of that location It would be coded as fol lows TABLE CREATE DOES gt INDEX VALUE SWAP 1 2 TABLE DAYS MONTH 31 28 31 30 31 30 31 31 36 31 30 31 Now we have truly generalized the problem and solve it in an elegant way We have defined a new data type called TABLE which is capable of defining new words Part of the definition of TABLE was specifying the run time behavior of the word being defined This is the code following the DOES We then use the comma technique discovered above to initialize the table Note that DAYS MONTH is now just a special case of TABLE and is in fact defined by the new defining word TABLE The above examples illustrate the im mense diversity available in FORTH There is no obvious right or wrong and the simplest and usually most genera solution to a given problem must
111. ymbol Mode Operand A accumulator none immediate 8 bits only X indexed X z page or absolute indexed Y z page or absolute X indexed indirect X z page only Y indirect indexed Y indirect none memory z page only absolute oniy z page or absolute Page 144 EXAMPLES Here are examples of Forth vs con ventional assembler Note that the oper and comes first followed by any mode modifier and then the op code mnemonic This makes best use of the stack at assembly time Also each as sembler word is set off by blanks as is required for all Forth source text AROL ROLA 1 10 LDY 1 DATA X STA STA DATA X DATA Y CMP CMP DATA Y 6 X ADC ADC 06 POINT STA STA POINT Y VECTOR JMP JMP VECTOR A distinguishes from hex number 0A The words DATA and VECTOR specify machine addresses In the case of 6 X ADC the operand memory address 0006 was given directly This is occasionally done if the usage of a value doesn t justify devoting the dictionary space to a symbol ic value 6502 CONVENTIONS Stack Addressing The data stack is located in z page usually addressed by Z PAGE X The stack starts near 009E and grows down ward The X index register is the data stack pointer Thus incrementing X by two removes a data stack value decre menting X twice makes room for one new data stack value Sixteen bit values are placed on the stack according to the 6502 convention the lo

Download Pdf Manuals

image

Related Search

Related Contents

Philips Spiral 929689431601  取扱説明書 ご使用前に必ず、ご確認ください  Téléchargez les textes des invités.  USO DE ADOBE CONNECT Requisitos de uso Reserva de salas  Gamber-Johnson Lind Low Profile Shut Down  Interphase Tech Echo 220 User's Manual  

Copyright © All rights reserved.
DMCA: DMCA_mwitty#outlook.com.