home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 224b.lha / A4th.doc < prev    next >
Text File  |  1989-04-08  |  30KB  |  679 lines

  1.  
  2.                           A4TH.DOC Notes on..
  3.                           -------------------
  4.  
  5.               A4TH.  A Public Domain Forth system for Amiga's.
  6.                     (based on Laxen & Perry's F83)
  7.  
  8.     This Forth system is Public Domain. You may freely distribute,
  9.     copy and use it, for any legal purposes. I cannot be held
  10.     responsible for any errors and/or omissions, I do not warrant
  11.     this system. I bear no responsibility for any use or abuse,
  12.     with or without intend.
  13.  
  14.  
  15. The system is composed of three 'arced' files:
  16. ( Arc program: AmigArc version 0.23, compatible with ARC v 5.0 )
  17.  
  18. A4THSYS.ARC     The system and system source files.
  19.  
  20.    A4th         The executable kernel.
  21.    Akernel.blk  The source for the kernel.
  22.    Util.blk     The Utilities to extend the kernel.
  23.    Cpu68k.blk   Assembler and debugger support
  24.    Meta.blk     The Meta compiler source.
  25.    Include.blk  The Amiga structures support source
  26.    Tasks.blk    Task support source.
  27.    README       Small warning that the file Util.blk has to be
  28.                 renamed to Utilities.blk before using the system.
  29.  
  30. A4THINC.ARC     The compressed and include files to be used with Include.blk
  31.  
  32.    D1.ARC       The Dx.ARC files are 'arced' directories.
  33.    D2.ARC
  34.    D3.ARC
  35.    D4.ARC
  36.    D5.ARC
  37.    D6.ARC
  38.    D7.ARC
  39.    D8.ARC
  40.    names        A note on naming the romcalls and structures.
  41.    readme       Instructions on how to create the include files.
  42.    unpack.bat   Execute this batch file to recreate the include files.
  43.  
  44.  
  45. A4THDOC.ARC     Documentation and examples.
  46.  
  47.    A4th.doc     This file.
  48.    metavocs.txt Multiple vocabularies using Meta compiler.
  49.    infix.txt    How the infix parser works.
  50.    hello.world  example from intuition manual.
  51.    dotty.blk    dotty window as in demo
  52.    dotty.c      the example for dotty.blk
  53.    gad.blk      gadget example
  54.    gad.c        the example for gad.blk
  55.    Small.blk    A real small hello
  56.  
  57.  
  58.                    How to 'un-arc' the system.
  59.                    ---------------------------
  60.  
  61. I'll describe the way I have my system set up. It could work for you also.
  62.  
  63. Start off with a Workbench disk, with some room on it. Discard what you
  64. think will not be usefull. You will need minimally 25% space on it. That is
  65. what it will take for the include files. Please leave most of the files in
  66. the c directory, enough to execute a batch file.
  67.  
  68. Create a directory on it, I call mine Includes, but you can use any name.
  69. Move the file A4THINC.ARC to that directory.
  70.  
  71. Copy your favorite arc utility to your C: directory and name it 'arc'.
  72.  
  73. Unarc A4THINC.ARC. One of the files will be unpack.bat, which will restore
  74. all the directories and files in the directories for you. Execute it and
  75. let it go.
  76.  
  77. In your startup-sequence routine enter the following:
  78.  
  79.     assign i: df0:includes
  80.  
  81. or the directory name you have chosen. That will make access to the include
  82. files simple from anywhere. ( example: tload i:exec/ports )
  83.  
  84.  
  85. Format a new diskette and move the files A4THSYS.ARC and A4THDOC.ARC to it.
  86. Unarc the files, they are simple arced files, not directories.
  87.  
  88. The file Util.blk in the A4THSYS.ARC file must be renamed to Utilities.blk
  89. before you run A4th.
  90.  
  91.  
  92. In my setup (Amiga1000, 2drives, 512k) I use an interlaced screen
  93. (640x400). That way I can have two A4th systems going at the same time, or
  94. run A4th with a text editor, behind which Dos resides of course. Several
  95. advantages, the biggest one is that I have twice the information in front
  96. of me. I have been using an interlaced screen for some time now, and when I
  97. switch back to a 640x200 display I feel hemmed in. If I enlarge the A4th
  98. window to cover 640x400, I can dump more at the same time, see more words
  99. at the same time etc. I did not change the editor to take advantage of the
  100. large screen, it still expects 640x200, but will work in 640x400.
  101. I also copy some commonly used routines to a ram: disk in order to speed up
  102. some operations. My startup-sequence is as follows:
  103.  
  104. echo "A4th disk.  Release 1.2 version 33.47"
  105. echo " "
  106. echo "current date"
  107. date
  108. echo "enter correct date"
  109. date ?
  110. date
  111. date to df0:s/last-date
  112. stack 8000
  113. addbuffers df0: 25
  114. addbuffers df1: 25
  115. makedir ram:c
  116. copy c:dir ram:c
  117. copy c:type ram:c
  118. copy c:cd ram:c
  119. path ram:c
  120. BindDrivers
  121. assign i: df0:includes
  122. cd df1:forth
  123.  
  124.  
  125.  
  126.                        Starting the kernel.
  127.                        --------------------
  128.  
  129. FROM THE CLI, of course, you can start it by entering:
  130.  
  131. A4th
  132.  
  133. by itself, and the kernel will execute. After it is loaded, you can load
  134. the Utilities by entering, in the forth window:
  135.  
  136. open Utilities.blk ok
  137.  
  138. which will load the extension as listed on screen 1 in the file
  139. Utilities.blk.
  140.  
  141. Doing it this way will give you 64k bytes of space to use for anything
  142. defined. The utilities will be located in that area, and take about 32k if
  143. the distributed version is loaded as is.
  144. Another problem is that you will loose the services of Amiga Dos. This
  145. system does not have a directory utility for instance. It relies on the
  146. Amiga multitasking capabilities for that.
  147.  
  148. Better to start A4th as a seperate task:
  149.  
  150. run A4th 18000 open Utilities.blk ok
  151.  
  152. That will open a 96k byte usable space and load the Utilities in. Make a
  153. batch file out of it if you like. The number is a hex number.
  154.  
  155.  
  156.  
  157.  
  158.  
  159.                         About the system.
  160.                         -----------------
  161.  
  162. GENERAL.
  163.  
  164.     Although the excellent Public Domain system from Laxen & Perry was a
  165.     starting point, this system is NOT the same NOR is it F-83 standard. A
  166.     lot of the utilities present in F83 are also present in A4th.
  167.  
  168.     If you expect lightning speed or super compactness, you will be
  169.     disappointed. It does not crawl, on the contrary, I find it responsive.
  170.     But then I might be a little prejudiced. :)
  171.     Try it out.
  172.  
  173.     If you want support, or more speed, or compactness, or all of these, I
  174.     would suggest you part with (about) $100 and buy one (or both) of the
  175.     commercially available systems:
  176.  
  177.     JFORTH                             Multi-Forth for Amiga
  178.     Box 1051                           Creative Solutions Inc.
  179.     San Rafael, CA 94915               4701 Randolph Road, Suite 12
  180.     415-485-6867                       Rockville, MD 20852
  181.                                        301-984-0262
  182.  
  183.     Both of these are excellent systems and well worth the (just under)
  184.     $100.
  185.  
  186.     Why did I write this, if the above commercially available systems are
  187.     so good?  Well, first of all, I like to be in control of the entire
  188.     system. Secondly I cut my Forth teeth on L&P F83, like so many others,
  189.     and was looking for something similar.
  190.  
  191.     The above mentioned systems use different threading schemes then the
  192.     L&P.
  193.  
  194.     ( If you are not entirely in agreement with the way this turned out,
  195.       you can always change it! And if you think the idea is good, share
  196.       it with the rest of the Forth community. )
  197.  
  198.  
  199.     The system features:
  200.         Indirect threaded
  201.         All numbers default to the address size of 32 bits.
  202.         Stack works on 32 bits at a time.
  203.         Uses two section, a precompiled kernel loaded by Dos, and a
  204.             usable user dictionary, size of which can be specified at
  205.             startup.
  206.         Word dictionary is inline, same as L&P, with 32 bit links.
  207.  
  208.     Since the Amiga is multitasking and has no hardware memory management,
  209.     each program that is to be run must be in a special loader format. It
  210.     will not be run in the same location, and therefore needs relocation
  211.     information with the file.
  212.     That makes it impossible (well not really, nothing in Forth is
  213.     impossible) to save the current version from within the system. In
  214.     order to create a new kernel, you will have to Meta compile the kernel.
  215.     The Meta compiler saves the system in the proper format.
  216.  
  217.     There are ways around this of course, but I chose not to use any of
  218.     them. For instance, use your own loader, or use a different threading
  219.     scheme.
  220.  
  221.     Finally I tried to make a system that doesn't use all of the cpu's
  222.     registers. Naturally I set aside the Forth register:
  223.     SP(a7)  RP(a6)  IP(a5)  W(a4)
  224.     The only additional register I used is >next(a3) which is the address
  225.     of the next routine. All other registers are available.
  226.     To add to that, another 'goal' of mine was to make it possible to read
  227.     some program in one of the Amiga Manuals and convert it for Forth.
  228.     Since most of the published stuff for Amiga is in C, I made some moves
  229.     towards that area, instead of staying more on the Forth track. (see the
  230.     infix parser in the include.blk file.)
  231.  
  232.  
  233. KERNEL
  234.  
  235.   - This kernel supports multitasking, using Amiga Exec, see also TASKS.
  236.     Some variables need to be different for each task. This kernel puts
  237.     these task or as they were called in L&P, user variables ahead of the
  238.     next routine.
  239.     The advantage is that no additional register needs to be used. In L&P
  240.     UP was used as the base address for the tasks. Here I use >next which
  241.     is cpu register a3 as a base register. The variables are located ahead
  242.     of the next routine. The disadvantage is that each task needs its own
  243.     next routine, as it turns out that is exactly what I wanted. One has to
  244.     metacompile in order to increase the number of 'user' variables.
  245.  
  246.     The 'rcall' routine is now (as opposed to version 1.0) right after the
  247.     next routine. It is the bases for calling Amiga Rom routines.
  248.     It is a bit of self modifying code (heavens!). Because of that it
  249.     cannot be used by any other tasks. Each task will need its own copy.
  250.     Since it is now directly after next, it can be copied to any new task,
  251.     together with 'next' and task, or 'user', variables. All that the new
  252.     task will have to do is change the >next register to point to its own
  253.     'next' routine. (Of course the other registers must also be set).
  254.  
  255.     The 'callrom' routine on screen 81 is the routine that sets the code in
  256.     rcall. It uses relative addressing (relative to >next), each task will
  257.     thus use their own rcall, but can use the common callrom.
  258.  
  259.     Calculating the address of a task variable is a matter of adding the
  260.     >next register to the offset. The same is true for task deferred words.
  261.  
  262.   - You realize that having Exec provide the task switching releaves the
  263.     kernel of the 'pause' word, that was used in L&P.
  264.  
  265.   - The cmove and cmove> and also fill routines are limited to 64k bytes.
  266.  
  267.   - In the previous version, I used a stdbuffer for output of single
  268.     characters and multiple characters, such as spaces.
  269.     In this version I use pad for this purpose. Stdbuffer is no longer.
  270.  
  271.   - Note that the common character output routine is 'type', not 'emit' as
  272.     in L&P. In other words, emit calls type, in L&P type called emit.
  273.  
  274.   - In the kernel you will find, on screen 67, 68 and 75 some references to
  275.     words having brackets around them. For example <find>. These words are
  276.     a way to Meta compile in different vocabularies, see Meta compiler
  277.     explanation for more info. Normally these have no effect on finding and
  278.     defining words.
  279.  
  280.   - Doubles are really 64 bits wide. */mod is internally 64 bits. Large
  281.     enough to not need floating point? But you can use Amiga Rom math if
  282.     you want to.
  283.  
  284.   - Defined is now deferred, and defaults to (defined). It is used in
  285.     structure support.
  286.  
  287.   - Of course I have added support for the task variables. Screen 79.
  288.  
  289.   - In the previous version I had a linked list, linking all the declared
  290.     Amiga Library bases together. When the system was exited the list was
  291.     traversed and each library was closed. That caused some complications
  292.     when defining a library base.
  293.     In this version I have made an array of opened library bases, or
  294.     devices for that matter. When the system is exited the array is checked
  295.     and each open library is closed.
  296.     Access to each base is via an index, which are constants with names
  297.     referring to the library, such as >Exec, >Dos and >Intuition.
  298.     These three are opened by the kernel,as they are needed to run the
  299.     kernel. One more is defined, >Graphics, but is opened in the
  300.     Utilities.blk file: it is not required by the kernel, or the Utilities
  301.     for that matter. It is opened as a convenience. (screen 81)
  302.  
  303.   - These library base indices are used to define an Amiga Rom routine. On
  304.     screen 83 are some examples. The registers used in each call are
  305.     defined between (r and r), which simply sets the base to hex and treats
  306.     the registers as hex numbers. It then calculates the mask. No specific
  307.     order of registers is required, I put them in the order they will be
  308.     filled from the stack. In the first call defined, OpenLibrary, the name
  309.     will be stuck in the a1 register, the version in d0.
  310.     The offset and the flag indicating a return value (^) are assembled
  311.     into three words, as tight as I could make it.
  312.     In the Utilities.blk is support in the decompiler to 'see' these
  313.     defined rom call entry points.
  314.  
  315.   - The change in (type), screen 88, was to accomodate the task variable
  316.     #out. Before it was not a task variable. Now it is, so it needs to be
  317.     calculated at run time. It could be used by any task. This is easily
  318.     done in high level. At the end of (type) you can see I switch from code
  319.     to high level using 'c:' but I don't return to code, I simply end the
  320.     word as if it was a colon definition. Works ok.
  321.     Similarily, here and pad are now also in high level, to let the system
  322.     calculate the proper address at runtime.
  323.  
  324.   - To see an example of opening a library look at screen 91, or screen 98.
  325.     That is the only time you need to be concerned with the library base.
  326.     Most of the routines are already declared in the include files, later.
  327.  
  328.   - In the Intuition vocabulary I have added the romcalls, AllocRemember
  329.     and FreeRemember. They support allocating memory and freeing it again.
  330.     A linked list pointer, mem-link, helps to find them. When forgetting
  331.     the list is traversed and any allocated memory, about to be forgotten
  332.     will be released before access to the RememberKey is lost. Tasks use
  333.     them. This method is available to any.
  334.     When exiting A4th close-mem will release all.
  335.  
  336.   - Some new stuff in screens 99-101. The first bunch is some bitfiddling,
  337.     used in Meta, but available for any bitarray. The words >> and << are
  338.     here to make it a little easier to translate programs from 'C' to
  339.     forth.
  340.     Next is a random number generator. I am no statistician, works ok for
  341.     me, if you have a better one, let me 'ave it.(pleese). Randomseed is
  342.     there to be used, if you need variety.
  343.     Tinit is a small code routine used by tasks. I put it here, in order to
  344.     be able to not include Cpu68k.blk. That would leave out the assembler
  345.     and the debugger. Still enough of the system to be usefull, but
  346.     significantly smaller.
  347.     The last ones are some C like string support, that is strings without
  348.     the length byte and with an ending null byte.
  349.  
  350.   - I have added a 'fence' variable. You can set it to prevent forgetting
  351.     by mistake.
  352.  
  353.     Forgetting now traverses the file linked list, the mem linked list and
  354.     the vocabulary linked list.
  355.  
  356.   - The window declared in the Intuition screen is now called 4thw,
  357.     previous version was Window, which collided with the Window structure
  358.     declaration in the Intuition include file.
  359.  
  360.   - There are now dp0 a variable holding the address of the start of the
  361.     usable dictionary, and dpsize a variable holding the size of the usable
  362.     dictionary area. Before they were simple stored in some 'unnamed'
  363.     cells.
  364.  
  365.   - The cold start routine now sets the task variable dp, which has to be
  366.     the first task variable.
  367.  
  368.   - User or task variables are set by temporarily setting the (meta) dp to
  369.     the user area, then filling the locations. This requires that all the
  370.     task variables are set. Screen 111
  371.  
  372.   - All variables are now set in screen 113, again when meta compiling.
  373.  
  374.  
  375.  
  376. META
  377.  
  378.   - Gone is the dump utility, use the kernel's by not forgetting it. Forget
  379.     'out' should be sufficient.
  380.  
  381.   - This Meta compiler supports vocabularies in the target. An additional
  382.     file, METAVOCS.TXT, explains it more.
  383.     What the end result is, is that you are now able to declare
  384.     vocabularies in the target, and declare the same word in different
  385.     vocabularies. You will get the one you want if you control the target
  386.     search order correctly.  This is particularily important if you intend
  387.     to Meta compile more then just the kernel.
  388.     For instance, you could compile the assembler in the kernel and make it
  389.     part of the kernel. The system will load faster.
  390.     Enlarging the target buffer (now 32k in Akernel.blk screen 1) you could
  391.     compile a lot, possibly an application.
  392.     The only hitch is that defining words ( create..does> ) must be handled
  393.     when compiling. The assembler has a few of them. To handle that I made:
  394.  
  395.     h: ado   (s n1 n2 -- n1 )  \ used after does> word is defined
  396.         target-create over ,-tr  ,-t  ;
  397.  
  398.     Then to use the above, eg with sz screen 3 Cpu68k.blk
  399.  
  400.     : sz   (s n -- )   does>  @ size @ and or ;
  401.     00300 ado sz3       00400 ado sz4
  402.     30000 ado sz300                    drop
  403.  
  404.     Since does> in Meta leaves the address for patching, it works.
  405.     There are other problems, all solvable.
  406.  
  407.     Don't forget the width, setting it to 0 will create a headerless
  408.     system, or manipulate it while compiling, and make words disappear.
  409.  
  410.  
  411.   - A user vocabulary is added to Meta.
  412.  
  413.   - Removed the bitfiddlers, they exist in the kernel.
  414.  
  415.   - Removed .relocations, wasn't very usefull.
  416.  
  417.   - Made saving the target system a little more readable. Created some
  418.     words to take the noise out of it.
  419.     But more importantly, block storage section or bss is now optional.
  420.     Before you had to declare some, even if you didn't need it. The target
  421.     is saved with the proper header, and relocation information.
  422.  
  423.   - Vocabulary creates a vocabulary in the target (no kidding). It also
  424.     creates a vocabulary with the same name in the symbol table. Symbols
  425.     are linked to the last one, depending on the vocabulary in <current>
  426.  
  427.   - The Meta compiler determines the size of the task variable area, see
  428.     screen 23.
  429.  
  430.   - Screen 24 allows target symbol table vocabulary manipulation.
  431.     Gone is .symbols, it's not needed, use <words> to see the symbols.
  432.  
  433.  
  434. UTILITIES
  435.  
  436.   - Screen 1 determines the utilities to be loaded, change as required.
  437.  
  438.   - Open the Graphics library, screen 13.
  439.  
  440.   - The editor is unchanged from the previous version. See the alternate or
  441.     help screens for more information.
  442.  
  443.   - The decompiler has been extended to show a" strings, or amiga
  444.     compatible strings. It also shows each library rom call if you want.
  445.     Typing 'see OpenLibrary' gives some detailed information about the
  446.     call.
  447.     User or task variables and deferred words are also decompiled.
  448.  
  449.   - I did not implement any printing by pressing control-P, not in the
  450.     previous version or this one. I hate noisy printers, I love laser
  451.     printers, but they to expensive.  So I very rarely print. If you want
  452.     to, take a look at how the printer is intialized. 'init-pr' is deferred
  453.     and is right now set to some control characters that initialize my
  454.     printer to 132 columns. You will have to set this.
  455.     Also the deferred p-name determines where the printer is connected to.
  456.     Normally it is PRT: for my setup it is SER:. Change it accordingly.
  457.  
  458.  
  459. ASSEMBLER
  460.  
  461.   - The assembler is not changed. A small correction in one of the words.
  462.     Take a look at the Akernel.blk for example usage of the assembler.
  463.  
  464.   - The debugger is changed. Since >next must not change in each task,
  465.     the debugger had to be changed. (Before I changed >next). Now a jump to
  466.     debnext is put in the place of the next routine. Unbug will fix the
  467.     next routine. You will invite problems if you declare a new task when
  468.     debug is in effect.
  469.  
  470.  
  471. INCLUDE
  472.  
  473.   - The first part of the utility to load the predefined structures and
  474.     definitions for the Amiga, is a parser.
  475.     This one is infix, and is extensively used in the Include files, which
  476.     are text files. It also has some use in filling structures, see {fill.
  477.     The text file INFIX.TXT explains the parser in more detail.
  478.     The parser is in screens 4 to 8.
  479.  
  480.   - The next part, screens 12-18, are textfile loading.
  481.     I prefer regular Forth blocks. The textfile loading does not support
  482.     nesting. It was not intended to be the principal method of loading
  483.     programs.  I wrote it to load the Include files, outside of the Forth
  484.     blocks. These are left alone, the text file loading opens a buffer for
  485.     its own use, and when done, releases it.
  486.     In screen 14 some additional Dos words are defined. I load these prior
  487.     to any Include files, as a result these definitions are commented out
  488.     in the include file libraries/dos. The same goes for all the words
  489.     already defined in the kernel. Intuition calls, Exec calls etc
  490.     defined in the kernel are all commented out.
  491.     The text file loading obtains a Lock before it opens the file. Once the
  492.     files has been opened it maintains some pointers into the buffer. It
  493.     scans for LineFeeds as line terminators.
  494.     Getline gets the next line. The line start will be returned by the word
  495.     'line' and the length is returned by the word 'llen'.
  496.     The above three words are in the 'text' vocabulary, hidden normally.
  497.     The words visible are: more?, ttype, tload.
  498.     More? is a small keyboard pause word while listing a file via ttype.
  499.     Ttype, or text-type, takes a file name and lists it. Any key will
  500.     pause, and a return key will stop listing.
  501.     Tload takes the next word in the input stream as a text file and loads
  502.     it. It must be loadable, if it is not the system will not be forgiving;
  503.     it will hang.
  504.     See the examples and Tasks.blk for some example text file loading.
  505.  
  506.   - I tried to keep Include files small. They do not rely on other include
  507.     files, with the exception of libraries/dos and libraries/dosextens.
  508.     The intuition file that comes with the assembler or a C compiler is
  509.     large. I made it a collection of files, each with ROM calls defined at
  510.     the end.
  511.     My model for these include files was Draco. Present on FredFish #76/77.
  512.     It is a compiled language in C and Pascal spirit written by Chris Gray.
  513.  
  514.   - The last part of the Include.blk file is the structures.
  515.  
  516.   - Structures are defined with a {s..s} pair. The field names for the
  517.     structure are hidden in a single linked list of words. The start of
  518.     that word list is put in a variable, scontext, when a structure defined
  519.     with the template, is used. An example is probably a better
  520.     explanation..
  521.     In the file i:exec/lists is the List structure defined:
  522.     {s List
  523.         APTR    lh_Head
  524.         APTR    lh_Tail
  525.         APTR    lh_TailPred
  526.         BYTE    lh_Type
  527.         BYTE    l_pad
  528.        s}
  529.     The opening {s takes the next word and makes it a defining word. This
  530.     word will have the pointer to the linked list of field words and the
  531.     total size of the structure in the parameter field. (The size of a
  532.     structure is <=64k ). To make a definition using the List word:
  533.     List MemEntry
  534.     In this case List creates an actual structure, List is just a template.
  535.     The structure has the name MemEntry, and when it is executed it will
  536.     put the address of the structure on the stack and stick the pointer to
  537.     the linked list of field words in scontext.
  538.     The search order, which was made deferred in the kernel, is now altered
  539.     so that the field words are checked FIRST. Then the rest of the search
  540.     order as set in 'context' is searched.
  541.     For instance, if you want to get the value from the lh_Type field:
  542.     MemEntry lh_Type s@
  543.     That would return the type byte on the stack. What happens, MemEntry
  544.     puts the address of the structure on the stack. Next lh_Type is found
  545.     and executed. It alters the address by the offset of lh_Type to the
  546.     start of the structure and sets the deferred word s@ and s! to that of
  547.     a character fetch and store. Executing s@ will get the byte from that
  548.     address.
  549.  
  550.   - Another example is in i:exec/ports, there the structure for MsgPort is
  551.     defined as follows:
  552.     {s MsgPort
  553.         struct  14 mp_Node      ( { Node=14;exec/nodes )
  554.         BYTE    mp_Flags
  555.         BYTE    mp_SigBit
  556.         APTR    mp_SigTask    -4 soffset +!
  557.         APTR    mp_SoftInt    ( union )
  558.         struct  14 mp_MsgList   ( { List=14;exec/lists )
  559.        s}
  560.     The field defining word 'struct' is actually a synonym for BYTES, but
  561.     in this case it indicates that the next 14 bytes are a nested structure
  562.     with the name mp_Node. At first I concidered nesting of substructures,
  563.     but rejected it. As a compromise I added the reference after the field
  564.     definition in the Include file. Here the nested structure is a Node, is
  565.     14 bytes large and the defininition is in the file exec/nodes. If you
  566.     require access to the nested structure in mp_Node you must load the
  567.     include file i:exec/nodes also. For example if you require the list
  568.     type of mp_MsgList which is a List in the occurance of a MsgPort called
  569.     e.g. myport:
  570.     myport mp_MsgList  { List lh_Type s@
  571.     The sequence  { List  forces the field names for a List structure to
  572.     become available. The '{' is immediate, and must be used in colon
  573.     definitions, because if the occurance of a structure is compiled, it
  574.     does not set the scontext variable to point to its field words.
  575.     : ...........  myport  { MsgPort mp_Flags  s@  ......... ;
  576.     The MsgPort field words will be available until the next '{'. Examples
  577.     of its use are in the examples provided.
  578.     ( The major objection to this way of accessing structures )
  579.  
  580.   - Another peculiarity is the   -4 soffset +!   sequence. That sequence
  581.     resets 'soffset' to what it was before  APRT mp_SigTask  was defined.
  582.     The next line  APTR mp_SoftInt  will point to the same offset as
  583.     mp_SigTask. This is the way I handled unions as they are called in C.
  584.     Not many are present in the include files.
  585.  
  586.   - The field defining words are:
  587.     BYTE BYTES  WORD WORDS  LONG LONGS  STRUCT
  588.     APTR is a synonym for LONG. The plurals expect a value before the
  589.     actual field name. The infix parser is used to get the number.
  590.     STRUCT is used if the structure is defined and known. The next word
  591.     will be the structure template that provides the number of bytes to
  592.     reserve as the fieldsize for the word following.
  593.     These field definitions, when used, set the structured fetch/store
  594.     words, s@/s!, to the appropriate size. If you do not know what the
  595.     field size is you can use s@/s!, or if you do know use the regular
  596.     Forth fetch/store.
  597.  
  598.   - After using a structure word or after setting scontext to a specific
  599.     structure you can see the names of the fields using 'swords'. It will
  600.     print a list of field names, backwards. For instance when the system is
  601.     loaded, as distributed, enter:
  602.     Exec { Task swords
  603.     This will print all the fieldnames, use any keypress to stop/start the
  604.     listing.
  605.     Another way of showing what a structure consists of is:
  606.     .{ Task
  607.     This will show the fieldname and what type it is. And this time in the
  608.     declared order, again use key to stop/start.
  609.     The last aid is {?}. It takes an address of the stack and uses the
  610.     structure which is currently in scontext to show each field, the type,
  611.     the offset and the contents of it in hex. The use of that? Try:
  612.     Exec definitions
  613.     tload i:exec/execbase
  614.     { ExecBase  4 @ {?}
  615.     And the execbase is visible.
  616.  
  617.   - An additional help word is {fill. It is used in one of the example
  618.     files. It uses the infix parser to fill the structure, and all of it,
  619.     from the input. See the example file Gad.blk for its usage.
  620.  
  621.   - As a final note on structures;
  622.     I had to redefine 'forget' since 'defined' would get messed up. The new
  623.     forget will work properly and can even forget itself.
  624.  
  625.  
  626. TASKS
  627.  
  628.   - Tasks use Exec as scheduler. They are simple tasks and require their
  629.     own stack and return stack and task area.
  630.     Task area is taken from the dictionary, in which the task local
  631.     variables, the next routine and the rcall routine are copied.
  632.     The stacks are obtained from Exec and kept in an Intuition Remember
  633.     key, which is linked into the mem-link so the task can be forgotten.
  634.  
  635.   - Tasks can be given parameters, they will be copied to the task stack
  636.     before the task is started. No parameters are expected in return.
  637.  
  638.   - Tasks should not use the A4th console input and output, they should
  639.     define their own input and output file or device. A tasks output file
  640.     could be a window of course.
  641.  
  642.   - Tasks should also have one entrance and one means of exit. If you use
  643.     an abort, things will not work properly.
  644.  
  645.   - Priority of tasks are set at -25 that puts them below any system task.
  646.     This makes sure it behaves as a background task. A4th will continue
  647.     running at full speed, and when time is available the background task
  648.     will run. As it should.
  649.     If for some reason the task must execute at a different priority, you
  650.     can alter it at any time, using 'priority'.
  651.  
  652.   - Tasks cannot compile or do any interpreting, the dp for the task is
  653.     mainly used for number conversion and to find pad which is needed for
  654.     emit.
  655.  
  656.   - The example on screen 17 shows how tasks can be used.
  657.  
  658.   - Each task needs a 'stop', and 'activate' requires the task on the stack
  659.     under which should be the parameter count (0 for none) and the
  660.     parameters under that.
  661.     Tasks can be reassigned on the fly. But be carefull the resources
  662.     allocated by the task will not be released; if a window was opened it
  663.     will stay open. That could be exactly what you want of course.
  664.  
  665.   - The tasks are a minimal approach and it's up to you to make it better
  666.     and/or more fool proof.
  667.  
  668.  
  669.  
  670.  
  671. I appologize for any mistakes I have made that might haunt you, I do hope
  672. you will be able to use this system as a tool and have some fun with Forth.
  673.  
  674.  
  675. Peter Appelman
  676. 05Oct88
  677.  
  678.  
  679.