home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / doc / chapter1.txt < prev    next >
Text File  |  1989-10-29  |  17KB  |  325 lines

  1. CHAPTER 1.  WHAT IS F-PC?
  2.  
  3.  
  4.  
  5.  
  6. 1.1.    HOW DID WE GET HERE?
  7.  
  8.  
  9. Over the past several years, the programming community for other
  10. languages has changed somewhat.  Several years ago, Forth had enormous
  11. advantages over Fortran, Pascal, and C in terms of development
  12. interactivity.  The Forth development cycle was very short, and new code
  13. modules could be put together for experimentation very quickly.  As the
  14. years went by, programmers for these other languages began to realize
  15. there had to be something better than their traditional debug cycle:
  16. EDIT-COMPILE-LINK-DEBUG and repeat.  This debugging loop could be
  17. measured in days, and each error correction session was normally at least
  18. 30 minutes long.
  19.  
  20. Forth did away with much of the above delays.  The editor was integrated
  21. into the Forth operating system environment, so the time to start up or
  22. leave the editor was zero.  The compiler was incremental, so programs
  23. could be debugged a piece at a time, and there was no linker at all.
  24. This naturally resulted in a productivity improvement and a significant
  25. reduction in programmer frustration.
  26.  
  27. As the years went by, other programmers noticed how much easier BASIC was
  28. to use than other compiled languages, since it had a built in editor, and
  29. didn't have to be compiled at all.  Of course it was so slow..., but then
  30. along came TURBO PASCAL.  It created fast compiled code, had an
  31. integrated SCREEN editor, and compiled like blazes.
  32.  
  33. We now start to see some similarities to Forth, a much superior
  34. development environment, where the development iteration cycle has been
  35. reduced to a very small number.  But Turbo Pascal still lacked the Forth
  36. interactivity, and the ability to incrementally debug programs as they
  37. were developed.
  38.  
  39. Finally along came the Macintosh and Light Speed Pascal (LSP).  It had
  40. evolved from Mac Pascal, an interactive and pseudo interpreted Pascal for
  41. the Mac.  LSP had windows, a built-in screen editor, compiled modules, a
  42. very fast compiler and a light speed linker, with the ability to test
  43. small segments of code, and two built-in debuggers: one for Pascal, and
  44. one for Assembly.  The only problem was that it was PASCAL, not Forth.
  45.  
  46. It is interesting to ask: "What is holding Forth back and preventing it
  47. from being more popular?" In spite of the strength Forth has in
  48. conciseness, interactiveness, and speed, there are weaknesses which
  49. hinders it's rapid spread in the general computing community.  The most
  50. important weaknesses are in its user interface and its interface to
  51. standard operating systems, which can be attributed directly to the use
  52. of blocks in storing source code.
  53.  
  54. In the early days of personal computing, programmers had their one and
  55. only choice of editor: the line editor ED and its clone EDLIN.  Comparing
  56. to this environment, the polyForth or figForth block editor was obviously
  57. superior.  However, after WordStar and its derivatives established a firm
  58. position in programmers' toolboxes, most people would reject the Forth
  59. block editor as too primitive a tool for substantial coding efforts.
  60. After IBM-PC's replaced CPM machines, the majority of programmers and
  61. users expect and demand source code and data being made available in
  62. sequential files on 5.25" DOS diskettes.  Blocked text files as used in
  63. F83 was only a half- hearted effort to come to term with reality.
  64.  
  65. Forth systems perform better if they can access the hardware resources
  66. directly, rather than through the arbitration of an inefficient operating
  67. system.  This was one reason why Chuck Moore invented Forth in the first
  68. place.  Ignoring the operating systems in the early days of main frames
  69. and minicomputers was advantageous because there were as many
  70. incompatible operating systems as there were brands of computers.  In
  71. personal computing, this advantage is rapidly diminishing as the species
  72. of operating systems disappeared rapidly due to natural selection.  It
  73. looks like we will end up with DOS, MAC, and UNIX (may be OS2).  In this
  74. situation, Forth systems must provide smooth and efficient interface to
  75. the operating systems, to be accessed conveniently by the users.
  76.  
  77. F-PC provides a much polished interface between a user and his
  78. IBM-PC/XT/AT or compatible computer.  Sequential files are adopted as the
  79. principal means of programming and documentation. The user is comforted
  80. by a very sophisticated and intuitive text editor to enter and modify his
  81. code and documentation, not constrained by the very limiting block
  82. structure.  The interface to the underlying DOS is seamless to allow the
  83. user full access to tools and services provided by DOS and other
  84. utilities.  In so doing, F-PC can be installed on all DOS compatible
  85. machines.
  86.  
  87. Speed is another major character in F-PC.  Most of its text interpreter
  88. and compiler are coded in assembly to make sure that it matches the speed
  89. and convenience of a block based system.  64K byte memory limit is
  90. removed by placing code, names, colon definitions, and text files in
  91. different segments in the 1M byte addressing space.  Utility is also
  92. provided to address extended memory.
  93.  
  94. Since F-PC is a public domain software package, it has attracted many
  95. experienced Forth programmers to contribute utilities and applications.
  96. It is quickly becoming a huge resource pool where old and new Forth users
  97. can draw inspirations and practical solutions to their programming needs.
  98.  
  99. Because the sequential files were the major focus of F-PC when it was
  100. first evolved it is important that we summarize the distinct advantages
  101. of using sequential files to store source code.  Here is a partial list:
  102.  
  103. 1.      Source files are smaller, so backing up or transporting files is
  104.         easier.
  105.  
  106. 2.      Sequential source files can be manipulated or examined by editors
  107.         that other people have, not just by the Forth block editor.
  108.  
  109. 3.      There is no artificial limit on the size of a file.  The file can
  110.         be extended as needed.  White space in a file does not take up
  111.         extra bytes.
  112.  
  113. 4.      There is no artificial limit placed on the size of word
  114.         definitions.  In the block based system we usually give up line
  115.         zero for a comment line, and line 15 for nudge space.
  116.  
  117. 5.      There is no artificial limit placed on the amount of comments one
  118.         can place with the source.  Again, compared to blocks with
  119.         shadows, 16 lines of shadow were either too much or too little.
  120.  
  121. 6.      Sequential files provide a much more natural interface to the
  122.         operating systems which were designed to handle them.
  123.  
  124. 7.      It allows plenty of room for inserting a new line in the middle
  125.         of a source file, without having to drop out of the editor, and
  126.         use special commands to move things around.  All we have to do is
  127.         pressing <enter>.
  128.  
  129. So here we are at the end (or beginning) of a long road, looking back at
  130. what we have done, and looking forward to the future.  Blocks were
  131. certainly very useful for forcing us to modularize our code.  That was a
  132. big advantage while we were learning Forth.  Maybe newcomers to Forth
  133. should be required to learn the system on a BLOCK version.  But now that
  134. we have come of age, we should know where to modularize our code better
  135. than the computer does.
  136.  
  137.  
  138. 1.2.    F-PC, WHAT IS IT ALL ABOUT?
  139.  
  140.  
  141. This Forth was implemented by Tom Zimmer, with substantial help from
  142. Robert L. Smith.  Some of the direct threaded low level code
  143. modifications came from a LaForth implementation by Bob and LaFarr Stuart
  144. .  George Hawkins contributed the Browser.  This is yet another step in
  145. the Forth evolution being undertaken to obtain the ideal Forth system.
  146. This Forth maintains very high compatibility with F83, which was its
  147. predecessor.
  148.  
  149. F-PC is a Forth that uses three main segments for Forth itself, and
  150. additional segments for other purposes, like the editor, screen saving,
  151. etc.  The three main segments in F-PC are:  First, a 64K Code Segment for
  152. code, variables, and any user arrays that are not specifically placed in
  153. an external segment.  The compiler also places the code field of all
  154. colon definitions in this Code Segment.  Code fields in F-PC are three
  155. (3) bytes in length.  The second List Segment contains the bodies of
  156. colon definitions and strings.  Its size is not limited to 64K bytes, and
  157. can use as much memory as allowed by the operating system.  The third
  158. segment of 64k contains the heads, or symbols in F-PC.
  159.  
  160. Since a typical program is about half program and half data, the
  161. separation of code and colon space results in an easy doubling or more of
  162. effective program space.  About 300K of total data/program space is
  163. available, with most useful utilities already loaded.  This can be
  164. increased to over 400k by deleting things you don't need. A small loss
  165. (about 5%) in performance resulted from this separation of colon
  166. definitions from the code space, but the benefits of expanded program
  167. space greatly exceeds the disadvantages.
  168.  
  169. The primary difference from other Forth systems that you are likely to
  170. encounter is that code fields are three (3) bytes rather than 2, and the
  171. code field of a low level code word does not point to code, but contains
  172. code.  This is generally known as 'direct threaded code (DTC).'   F-PC
  173. has moved the address list in a colon word to a separate List segment, so
  174. there are two bytes in the body (parameter field) of each colon
  175. definition that points into the List space of the colon definition which
  176. contains a list of code field addresses.  The List space can expand to
  177. fill all available RAM memory.  It is not limited to a single 64K byte
  178. segment.
  179.  
  180. Variables, constants, and strings are handled in the same way as in F83.
  181. That is, they are in the Code space.  This segmentation seems to provide
  182. a reasonable balance.  As the dictionary expands, more user data space is
  183. needed, which works well with F-PC, as most of the free space is in
  184. Code/Data space.
  185.  
  186. This system comes with a meta compiler.  It can thus regenerate itself
  187. with user extensions.  DOS batch files are provided to ease the meta
  188. compilation.  Users can also produce turnkey systems without having to go
  189. through the meta compilation process.
  190.  
  191. As F-PC currently exists, there is about 27k of List dictionary space, 27
  192. K of Head space, and 35k of Code space.  The List space can be increased
  193. by changing the number of segments assigned to it and save the system.
  194. The new system thus saved will have a larger List space when executed.
  195. The usable memory can also be expanded by removing some of the optional
  196. files from the list of load files in F-PC.SEQ. The removable files are
  197. marked in F-PC.SEQ. Some of these files are listed as follows:
  198.  
  199.                 PATHSET.SEQ     WORDS.SEQ       COLOR.SEQ      DUMP.SEQ
  200.                 DECOM.SEQ         DEBUG.SEQ       STATUS.SEQ MACROS.SEQ
  201.                 PATCHER.SEQ     FILSTAT.SEQ     FWORDS.SEQ
  202.  
  203. If some of these files are removed, a significant savings in dictionary
  204. space will result. Fairly large programs can now be coded in F-PC,
  205. although there are still some obvious limits.  It is doubtful that
  206. ZoomRacks the database Tom coded while at QuickView Systems could be
  207. compiled in F-PC without overlays.  ZoomRacks consisted of more than 2M
  208. bytes of source screens, and used all RAM outside the program as
  209. contiguous data space for the user.
  210.  
  211.  
  212. 1.3.    FEATURES IN F-PC 2.25
  213.  
  214.  
  215. The first thing you should know is that F-PC is trying to achieve a
  216. number of conflicting goals.  It is intended to be a Forth system that
  217. provides all of the following:
  218.  
  219.         Compatible to F83 and Forth-83 Standard
  220.         Smooth Interface to DOS, using sequential files
  221.         Fast compilation and execution
  222.         Integrated text file editor for easy programming and documentation
  223.         Many utilities and tools
  224.         Room for very large application programs
  225.  
  226. Impossible, you say.  Perhaps, but if you give F-PC a chance you may find
  227. some things you like. In line with the above goals, here is a list of
  228. some of F-PC's major features:
  229.  
  230.         Direct threaded dictionary for speed
  231.         Separated lists and heads to increase space
  232.         Prefix assembler to enhance readability
  233.         Postfix assembly syntax for compatibility with  F83
  234.         Full DOS access from system and command shell level control
  235.         Full directory/path based file system
  236.         Viewing words across directory boundaries
  237.         Full user configurable sequential text editor provided in source
  238.         Full DOS memory management interface
  239.         Headers can be selectively removed
  240.         Many contributions from users on a wide range of applications
  241.  
  242.  
  243. F-PC is a Forth derived from many sources. Henry Laxen, and Michael Perry
  244. being the original developers of F83. Tom Zimmer, along with Robert L.
  245. Smith, Charles Curley, and Jerry Modrow put together the original
  246. version.  A F-PC Working Group was organized in the Silicon Valley
  247. Chapter of Forth Interest Group to coordinate the testing and
  248. documentation of this system.  F-PC 2.25 was released in November, 1988,
  249. and F-PC 3.5 is released in November 1989.
  250.  
  251. F-PC is a Direct Threaded Code (DTC) Forth. That is it contains code in
  252. the code field rather than pointing to code.  DTC gives a noticeable
  253. boost in performance, which was needed to counteract the next
  254. enhancement.
  255.  
  256. F-PC keeps the body or the list portion of colon definitions in a
  257. separate segment-the List space. This substantially increases the space
  258. available for your program. There is a penalty to pay in performance,
  259. with an extra level of indirect jump required in NEST.
  260.  
  261. F-PC has a prefix assembler. Code definitions are coded with a syntax
  262. similar to MASM, in the form " MOV AX, BX ".  We have found this syntax
  263. to be much more readable to "traditional" programmers than the standard
  264. F83 postfix assembler.  To reduce the pain to current F83 users, the
  265. assembler supports the old F83 assembler syntax as well. Just use the
  266. word POSTFIX to select postfix assembler syntax, and then use PREFIX to
  267. switch back to the prefix syntax.  An 8086 family disassembler is
  268. provided. The disassembler was written by Charles Curley, and includes
  269. 8087 support added by Robert L. Smith.
  270.  
  271. F-PC supports full pathnames and file handles. File names may be up to 63
  272. characters in length including path.  All source is in sequential files.
  273. No blocks in this system. The original F83 BLOCK system is available as a
  274. load-on if needed.  Several powerful file words have been included. FLOOK
  275. allows searching through one or many files for a particular character
  276. sequence. FPRINT allows you to make formatted listings of one, all, or a
  277. set of Forth source files. EDITALL allows you to edit a string through
  278. many files.  INDEX displays the first line of a set of files.
  279.  
  280. The compiler itself has been substantially optimized, with almost all of
  281. WORD being in code. The system currently uses 64 threads, which is just
  282. at the point of diminishing return for a 2000 word vocabulary. With the 8
  283. vocabularies this system has, only about 1k bytes of Code space is used
  284. for the vocabulary head pointers.
  285.  
  286. A help file is provided with each source file, these can be used like F83
  287. shadow screens were used, that is to hold comments about the words in the
  288. source file. The word VIEW accesses the .SEQ file, and the word HELP
  289. accesses the .HLP file. As much or as little text can be placed in the
  290. help file for each word compiled.
  291.  
  292. Many utilities are included. An enhanced debugger allows nesting and
  293. unnesting of colon definitions.
  294.  
  295.  
  296. 1.4.    NEW FEATURES IN F-PC 3.5
  297.  
  298.  
  299. F-PC version 2.25 was released in November 1988.  Tom Zimmer agreed, with
  300. great reluctance, not to make any changes so that it can be distributed
  301. among Forth users as a common programming environment for information
  302. exchange.  Modifications, enhancements, and bug-fixes implemented and
  303. tested over the ten month period were distributed privately by Tom under
  304. the name F-TZ.  The F-PC Working Group in their September 23, 1989
  305. meeting decided to adopt F- TZ and distribute it as F-PC version 3.5.  A
  306. partial list of the added features are:
  307.  
  308.         Hypertext on-line help and documentation
  309.         Browser to examine code and documentation
  310.         Mouse support in editor
  311.         Enhanced pull down menu and pop up windows
  312.         Expanded memory support
  313.         Lots of bug fixes and minor enhancements
  314.         Update and corrections on kernel help files
  315.  
  316. For those who have used F-PC 2.25 and like to know more about the
  317. differences between it and F- PC 3.5, please consult the file
  318. FPCNOTES.TXT where Tom Zimmer logged the bug fixes and the enhancements.
  319.  
  320. User contributed programs are deleted from the new version because of
  321. disk space limitations. However, user contributions will be continually
  322. solicited.  The Silicon Valley Chapter of the Forth Interest Group will
  323. coordinate the consolidation and distribution of user contributed works.
  324.  
  325.