home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / love / lfintro.doc < prev    next >
Text File  |  1993-04-11  |  16KB  |  326 lines

  1.                         L.O.V.E FORTH
  2.  
  3.                         INTRODUCTION
  4.  
  5.  
  6.      It is our opinion that the FORTH computer language is without peer
  7. in the realm of computer languages. No other language has the BAND-WIDTH of
  8. FORTH.  Not only can a programmer write high level definitions, but without
  9. missing a beat, step down to the raw power of machine code.  This language
  10. can be used to control machines for real-time control applications, for
  11. writing games, systems applications, artificial intelligence (expert
  12. systems), robotics etc.  It can even be used to write other languages.
  13.  
  14.  
  15.  
  16. L.O.V.E. FORTH PARTICULARS:
  17. --------------------------
  18.  
  19.  
  20.      L.O.V.E. Forth  is as close to the full 83 Forth standard, as the 8088/86
  21. would allow.
  22.  
  23.      Full memory segmentation is employed by L.O.V.E.. This means that 
  24. code, variables, threads, heads and other FORTH constructs occupy separate 
  25. and individual memory segments inside the IBM's RAM memory space.  Thus 350 
  26. Kbytes of memory space is required to load and use L.O.V.E. Forth (DOS 
  27. excluded).  A full 640 Kbytes of memory is recommended.
  28.  
  29.      L.O.V.E. Forth supports all DOS functions (ver 3.xx and up), and 
  30. employs many of the  IBM DOS function calls for normal file chores.  
  31. However, it still retains the ability to work with individual screens.  As 
  32. a matter of fact, screens and text files can now be fully intermixed for 
  33. maximum flexibility and ease of programming.  ( We recommend using the text 
  34. editor supplied with L.O.V.E., or a similar product. See the chapter on 
  35. editing files.)
  36.  
  37.      As noted above, compiled word definition components are distributed
  38. among the four segments as they are input. The code part of the word goes to
  39. the CODE SEGMENT, the word threading goes to the DATA SEGMENT, data goes to
  40. the EXTRA SEGMENT. Both the parameter and the return stacks use the STACK
  41. SEGMENT.  The head part of the word goes to a segment calculated by the
  42. program during loading only, and is normally inactive. This segment we call
  43. the HEADS SEGMENT, but it is not an integral 8080 segment as such. A
  44. separate segment is devoted to local variables as well.
  45.  
  46.      We are currently supplying an assembler, a graphics package, a
  47. screens editor, an improved user interface, support for local variables, an
  48. online help system, an interactive L.O.V.E. Forth Menu ( which allows even 
  49. the most amateur programmer in Forth to begin learning how to use L.O.V.E.  
  50. FORTH), access to the complete DOS area, and the ability to use ASCII text 
  51. files generated by your favorite text editor.  We supply a text editor with 
  52. shareware versions only.  The extensive DOS interface lets you call your 
  53. own text editor from within L.O.V.E Forth (provided it leaves you with 
  54. enough memory in RAM) to enter code. As mentioned above, text code and 
  55. screens code can now be freely intermixed while loading your applications 
  56. from within L.O.V.E. Forth.
  57.  
  58.  
  59.      Currently we are working on giving L.O.V.E. Forth the capacity to
  60. handle object oriented programming structures, and this feature will be
  61. available with version two. Local variables, which form the preliminary part
  62. of object oriented programming, are already included.  The Metacompiler and
  63. L.O.V.E. Forth Programming Library are in the works and will become
  64. available in time as well.
  65.  
  66.  
  67. GETTING STARTED:
  68. ---------------
  69.  
  70. The files  needed  for  operation  are:
  71.  
  72. 1.   LOVES.EXE           Main Program with menu and demo attached
  73. 2.   MIN129.EXE          "Bare bones" minimum system
  74. 3.   VASMLINK.VTR        Virtual (pull down) assembler and linker
  75. 4.   VEDIT.VTR           Virtual (pull down) screens editor.
  76. 5.   VUTIL.VTR           Virtual (pull down) utilities.
  77. 6.   VSUTIL.VTR          Virtual (pull down) screens/blocks system.
  78. 7.   HM.EXE             }  Hyper-help system
  79. 8    LOVE.HTX           }
  80. 9.   DEMO-GS.DEM
  81. 10.  DEMO-LD.DEM
  82. 11.  DEMO-MU.DEM
  83. 12.  DEMO-VR.DEM
  84. 13.  DEMO.SCR
  85. 14.  2DEMO.TXT
  86.  
  87. ( Items 9 through 14 are needed only for the demo ).
  88.  
  89.      L.O.V.E Forth  contains a lot of its external tools in the form of 
  90. virtual memory pull-down overlays which are used as needed, and then 
  91. released from memory.  These are identified by the .VTR suffix.
  92.  
  93.      Along with the LOVES.EXE, these *.VTR files must also be present
  94. on the default drive and subdirectory, and are used as needed. For example,
  95. if you are editing screens or screens files, you will have opened a file
  96. with the OPEN" <fname.scr> command. Then you can edit screen "n" by typing
  97. "n" edit, and tapping the enter key. This will call the editor into memory
  98. and show that particular screen inside the screen editor on the CRT. A
  99. "screen" is 16 lines by 64 characters wide, and is used as an editing unit
  100. by the screens editor (archaic Forth usage).
  101.  
  102.      Typing HELP or help ( upper_case/lower_case ) will pull down the
  103. HELP system and start the hyper-help system. Typing HELP */MOD will get
  104. you help on */MOD. To get help on any other word that is currently
  105. used by L.O.V.E. Forth, type HELP <word_you_need_help_with>.
  106.  
  107.      To discover what words are available, type WORDS> FORTH <CR> and you
  108. will get an orderly display of all the words currently residing in the FORTH
  109. VOCABULARY (most recently defined word first). Should you forget the ">"
  110. character belonging to WORDS>, and type WORDS FORTH, you will get the words
  111. from the VOCABULARY which is at the top of the search order.  If at any time
  112. the search order becomes confused, type in the word DEVELOP, and then check
  113. the search order with the word ORDER.  DEVELOP places the VOCABULARY TOOLBOX
  114. at the head of the search order, followed by FORTH and ROOT.
  115.  
  116.      As you may have guessed by now all the "words" in Forth produce
  117. action results. Some desirable, some not desirable. To maintain compactness
  118. and speed, extremely little error checking is done in Forth. You may have to
  119. reboot (start again) your system if you execute words at random to see what
  120. they do. Consult the HELP utility or this manual to avoid problems.
  121.  
  122.      AGAIN, PLEASE REMEMBER THAT SOME OF THE WORDS SHOWN ARE INTERMEDIARY
  123. WORDS BELONGING TO HIGHER LEVEL DEFINITIONS AND MAY CRASH YOUR SYSTEM IF
  124. USED OUT OF THEIR PROPER CONTEXT. REFER TO A FORTH BOOK FOR THE MORE
  125. STANDARD WORDS AND USE OUR ONLINE HELP FACILITY. SIMPLY TYPE HELP
  126. <WORD_NAME>.
  127.  
  128.  
  129. FOR NOVICES:
  130. -----------
  131.  
  132.      This part is aimed at first users of FORTH including L.O.V.E. Forth, 
  133. but especially at newcomers to computers in general.
  134.  
  135.      Your diskettes were sent out with the write protect tab covering the
  136. notch of each disk. This is to prevent accidental write over of the
  137. diskettes and destroying the information on them. Using the DOS utility
  138. DISKCOPY, make TWO (2) copies of each diskette. Put the original and first
  139. copy in a safe place, and use only the second copy as your working copy.
  140.  
  141.      Consult your DOS manual, or a book on using MS/PC-DOS on the exact
  142. procedure.
  143.  
  144.      If you have a hard drive, simply make a directory by typing: MD
  145. LOVE4TH.  Switch to it with: CD\LOVE4TH.  Then copy the contents of 
  146. L.O.V.E. Forth by placing the L.O.V.E. Forth diskettes in drive A: 
  147. (or B: if necessary) closing the floppy drive door and typing: COPY  A:*.* .
  148.  
  149.      When the copying is finished, replace the diskette in drive A: with
  150. the other L.O.V.E. Forth diskette, re-type the COPY A:*.* instruction, and 
  151. hit ENTER.
  152.  
  153.      Once you have the back-up copies made, or the L.O.V.E. Forth files are 
  154. on your hard disk, you can safely begin to use L.O.V.E. Forth.
  155.  
  156.      To use L.O.V.E. Forth simply type LOVES at the command prompt, like
  157. this:  A>LOVES  (ENTER) (this is the floppy drive system) or, C> LOVES
  158. (ENTER) (this is a hard disk system, and your directory is LOVE4TH)
  159.  
  160.      A> B> C> etc simply indicate the current drive in use, while DOS is
  161. waiting to load some application or utility.
  162.  
  163.      When L.O.V.E. Forth finishes booting (loading) it will present the 
  164. L.O.V.E Forth logo on the screen, and below it the initial menu and general 
  165. instruction box.  Please read the contents of the box carefully. Hitting 
  166. any key brings up the interactive menu.
  167.  
  168.      The menu is there to help and assist you through the first
  169. rudimentary Forth activities only, and is NOT intended to act as an
  170. exhaustive tutorial or Forth shell.
  171.  
  172.      Still, if you are a beginner to Forth use and programming, it will
  173. give you an adequate feel and practice of the language. Use the left/right
  174. arrow keys to move the highlight bar along the main topics. Use the enter
  175. key to select a main topic. Then use the up/down arrow keys within a menu to
  176. select a Forth action. Use the enter key to carry out the action. The F1 key
  177. is the help key in all cases.
  178.  
  179.      When an action menu is pulled down, the ESC key will bring you back
  180. up to the main menu bar. To remove the main menu bar itself, and enter
  181. L.O.V.E. Forth in the native Forth mode, use the ESC key also. Typing the 
  182. word LOVE <CR>, brings the menu back in control.
  183.  
  184.      If you are perusing the demo part of the menu, the ESC key halts all
  185. action, and re-establishes the main menu bar.
  186.  
  187.      Whatever you do, remember to keep the stack clear of any unwanted
  188. numbers as these may cause trouble, if you continue to use L.O.V.E. Forth 
  189. in the native Forth mode.
  190.  
  191. L.O.V.E. Forth can be used in several modes:
  192.  
  193.      a.  INTERACTIVE: You enter numbers or word definitions directly at
  194. the keyboard and L.O.V.E. Forth will execute them.
  195.  
  196.      b.  COMPILE MODE: You define a colon word, and then type its name to
  197. execute. (See chapter on how to define Forth words).
  198.  
  199.      c.  EDIT MODE: You enter code into a text file, using any ASCII text
  200. editor, save it, and then load the definitions directly from disk to compile
  201. the code. Or you can use the Forth editor to edit either a screens file or
  202. disk screen and then load the screens for compilation.
  203.  
  204.      d.  RUN TIME MODE: You write and compile the code, create an
  205. executable file, and save it to disk for execution as a normal *.EXE file.  
  206. ( * = name of your choice )
  207.  
  208.      Because L.O.V.E. Forth, as most FORTHs, was designed for speed and
  209. efficiency it does NOT have a lot of internal error checking. Consequently,
  210. many words if not chosen with care as to their effect, will crash the
  211. system.
  212.  
  213.      To explain: FORTH in general and L.O.V.E. Forth in particular is a
  214. threaded code language, utilizing two or more "stacks" during operation. A
  215. "stack" is a reserved area of memory for handling numbers. These numbers can
  216. be ordinary literals, constants, variables etc.  Many of the L.O.V.E.
  217. definitions or just words as they are commonly called, use these stacks
  218. repeatedly as they are executed.
  219.  
  220.      Therefore, if a word requires some kind of a number to be available
  221. on the stack, and if such number is not there, then the system will crash,
  222. or at best give only a short terse message.
  223.  
  224.      A very good way of avoiding this happening, is to keep using the
  225. interactive help system that we have built in for you. Generally, avoid
  226. entering words at random. Rather, move to the end of this manual, and do the
  227. sample exercises present. Obtain some books on FORTH programming, and begin
  228. to really experience the power and joy of programming in FORTH.  Better
  229. still, join with us in the Fig (Forth Interest Group, P.O. Box 8231, San 
  230. Jose, California, USA, 95155), and become a part of the world of FORTH 
  231. programming.
  232.  
  233.      FORTH is a STACK oriented language. Most definitions require data on
  234. the stack before being called, put data on the stack after being called, or
  235. have no affect on the stack at all. A stack diagram makes this clear, and
  236. allows a programmer to determine the stack requirements of any word that he
  237. himself might be defining or coding. In most Forth source code, the stack
  238. diagram (comment) is placed right after the name of the word itself, ie:
  239.  
  240. : Hi ( -- )   ." Hi there" ;
  241.  
  242.      The two dashes -- represent execution of the word. The fact that
  243. there is nothing in front of the dashes means that the definition does not
  244. require an item to be placed on the stack. Likewise, the fact that there is
  245. nothing following the dashes, means that the word Hi does not leave anything
  246. on the stack.
  247.  
  248.  
  249.      NOTE: All L.O.V.E. Forth "words" must have a space following them to
  250. act as delimiters.  This does NOT apply to the end quote and right
  251. parenthesis, which serve merely to determine the end of a printable message
  252. or a non compiling remark statement.
  253.  
  254.  
  255. LEARNING TO L.O.V.E. FORTH
  256. --------------------------
  257.  
  258.      Now that we have given you the rudiments of L.O.V.E. Forth we should 
  259. give you some advice on how to study and learn it.
  260.  
  261.      There are two general approaches that can be taken. Each has its
  262. good and bad points.
  263.  
  264.      A. 
  265.     With L.O.V.E. Forth booted up and running, this manual and some 
  266. other Forth reference by your side, do as many consecutive exercises as 
  267. possible.
  268.  
  269.      If possible, get a printout of this manual, and attempt to memorize as 
  270. many definitions with their stack diagrams as possible. Use any kind of 
  271. memory method available to you, or simply copy the definitions by 
  272. long-hand. Do one definition from each alphabet group in turn, to maintain 
  273. motivation and variety ( one from A group, one from B etc ). After you have 
  274. done this, begin practicing as in A above.
  275.  
  276.      The second method may seem more arduous at first, but for learning
  277. L.O.V.E. Forth it has several advantages.
  278.  
  279.  
  280. We recommend it highly. Here's why !
  281. ------------------------------------
  282.      B.
  283.          As you may have noticed L.O.V.E. Forth and all other companion 
  284. FORTHs are word definition driven. Execution proceeds when one word calls 
  285. the next word in turn.  This makes the language very flexible, fast and 
  286. expandable in the direction of your application. But this means that, 
  287. except for the core or KERNEL words as they are commonly referred to, one 
  288. application will have differently named words from the next application.
  289.  
  290.      Navigating through all these word definitions becomes a burden,
  291. unless one has a fairly good cross-sectional sample of the kernel words
  292. committed to memory. This memory intensive study creates a very good map of
  293. L.O.V.E. Forth for you, and makes it much easier to associate word actions
  294. with their definitions, inside your or somebody else's application or
  295. program.
  296.  
  297.      Later, practice at the computer writing and debugging your own
  298. programs, will internalize your understanding of the connectivity and
  299. interaction of FORTH definitions and their uses. You will see that no matter
  300. what the code requirements are, you will write and debug faster than in any
  301. other language that is available today !
  302.  
  303.  
  304. -------------------------------------------------------------------------
  305.                             L.O.V.E. FUNDAMENTALS
  306. -------------------------------------------------------------------------
  307.  
  308.  
  309.      The Forth language architecture is built around the data stack.  While 
  310. Forth allows memory locations to be assigned for use as variables, 
  311. constants, and work areas, the data stack is used to hold and transfer most 
  312. values and parameters (data items) for use by the various sections of a 
  313. program. Thus the data stack allows very quick and convenient access to 
  314. data items. Since most data items needed by or produced within intermediate 
  315. portions of a program are temporary in nature, the data stack proves very 
  316. handy.
  317.  
  318.      The way the data stack works is similar to the way RPN type
  319. calculators, like the Hewlett-Packard, work. The following is another
  320. anology.
  321.  
  322.      We have all seen the in/out basket used by secretaries and business
  323. people to organize their work. They take the top item on the basket, work on
  324. it then place the finished work back on the top of another basket for
  325. disposal.  Similarly a restaurant has a dish holder to hold clean dishes.
  326. The first ones on the top are the first ones to be taken off.