home *** CD-ROM | disk | FTP | other *** search
- Notes on the Book 'Starting Forth' by Brodie
- --------------------------------------------
- L.O.V.E. Forth matches closely the Forth 83 standard, as does
- the book 'Starting Forth'. Here are some notes on differences between
- L.O.V.E. Forth and the words and examples described in this book (2nd
- edition is assumed). Remember to type HELP (wordname) or the Alt-F1
- key if you have any difficulty.
-
- Chapter 3 Working with Forth
- ---------
- It is necessary to have the block disk words included in
- L.O.V.E. Forth in order to use many of the words described in this
- chapter. The shareware DEMO program has these included. To include
- them in BARE system type: INCLUDE" LOADBLK.TXT" (enter) . Many users
- will, of coarse, prefer to use text files using their favorite text
- editor to compose programs.
-
- To open a new screens file when using block disk words type:
- OPEN-NEW" myfile.scr" (enter) . This will create a brand new file named
- MYFILE.SCR (or the name of your choice). To extend the file to include
- more screens, type: n SCREENS (enter) where n is the total number you
- want (maximum is 32767, but don't type that many unless you have a BIG
- disk). For more information see the file SOURCE.DOC.
-
- To switch on the printer type the word PR-ON. This causes all
- activity to be both printed and displayed. Type PR-OFF when done. The
- printer LPT1 is used.
-
- There is a word called L which is like LIST but is
- much faster. LN lists the next screen up, LB lists back one, and EL
- edits the current last screen displayed in this way (see EDITOR below).
- There is no word TRIAD. The word SHOW displays a range of screens
- rapidly on the display. To use it type the first screen and last
- screen followed by the word SHOW.
-
- The EDITOR described in 'Starting Forth' is antiquated and is no
- longer used in most forth systems. L.O.V.E. Forth has a full screen
- (one screen) editor with cursor control and other features. To use it
- type: n EDIT where n is the screen number you wish to edit. Type
- Ctrl-X to get help.
-
- Chapter 7 A number of kinds of numbers
- ---------
- L.O.V.E. Forth stores the decimal place in a variable called
- DPL. If no decimal point was used in the last number converted, DPL
- contains -1.
-
- M/ has a slightly different meaning in L.O.V.E. Forth
-
- M*/ must be loaded from the file MISC.TXT (it is loaded with
- the block disk words). It assumes the Forth '79 conventions for
- division.
-
- Chapter 8 Variables constants and arrays
- ---------
- Note that the dictionary structure is different in L.O.V.E.
- Forth than what is shown here. ? is not defined. Try:
- : ? @ . ;
-
- L.O.V.E. Forth defines defines double number words such as 2!
- 2@ 2DUP etc. also as D! D@ DDUP which may be more meaningful names
- in some applications.
-
- Chapter 9 Under the hood
- ---------
- The dictionary structure is different in L.O.V.E. Forth from
- what is shown. The word ' returns the compilation address of the
- following word in the thread segment. This doesn't matter, really.
- Words such as EXECUTE and vectored execution as described, all work as
- expected.
-
- The word DUMP in L.O.V.E. Forth works from the data segment.
- You can use it to show your data. Use TS:DUMP to see the portion
- of your words that are in the thread segment (give it the compilation
- address), HS:DUMP from the head segment (>NAME may be used to convert
- the compilation address) and CS:DUMP from the code segment (machine
- code).
-
- The word @EXECUTE is not present.
-
- The structure of dictionary entries varies from what is shown in
- the book. The main differences occur because L.O.V.E. Forth divides
- each word out between various segments. More is said in accompanying
- technical notes, but here is a summary. The dictionary head,
- including the NAME and LINK as described go into the HEAD SEGMENT.
- The CODE POINTER and BODY go into the THREAD SEGMENT. There is one
- exception. VARIABLEs and other data words have their BODY (ie. the
- data) stored in the DATA SEGMENT (or VS: for 'variables segment').
- When an assembler is used, it's resulting code goes into the CODE
- SEGMENT. The parameter and return stacks are contained in the STACK
- SEGMENT.
-
- The word >BODY takes the address from ' (ie. the compilation
- address) and returns an address in the data segment (eg. address of
- data for a VARIABLE). The word TS:>BODY takes the address from ' and
- returns an address in the thread segment (eg. the body of a colon
- definition). There is no error checking in these words, if there
- isn't, for example, a data segment field for the word that was 'ed the
- address returned will be meaningless.
-
- See the file COMPAT.DOC for more information on changing the
- values of constants and other issues related to the compatibility of
- L.O.V.E. Forth.
-
- The memory map of L.O.V.E. Forth is quit different from that
- shown. Each segment in L.O.V.E. Forth has it's own dictionary pointer.
- They are only incremented in segments where data are added. It suffices
- to say here simply that the more code you add, the farther up the
- dictionary points move. Try the command MEM-MAP to see the L.O.V.E.
- Forth segments and how full they are.
-
- L.O.V.E. Forth does not have an 'electives block'. It has
- however many other files of useful code that you may compile such as
- the block words mentioned above.
-
- ALLOT, HERE and PAD work with the VS: in L.O.V.E. Forth. The
- variable DP is reserved for the thread segment and should not be
- manipulated casually.
-
- The word EMPTY is not present.
-
- SP@ and S0 are present but return addresses in the STACK
- SEGMENT. Therefore, if we wanted to access the stack area we would use
- SS:@ not @ as described.
-
- TIB returns an address the VS: and works as described.
-
- There are no USER VARIABLES.
-
- BLOCK BUFFERS are in high memory as described (in the VS: too).
-
- Vocabularies are very similar to what is described. There are
- several provided. ROOT (which contains some words for manipulating
- vocabularies), FORTH (with the majority of standard words), MSDOS (with
- file handling and other words to access DOS), VIRTUAL (with words for
- handling virtual vocabularies), TOOLBOX (with programming utilities).
- There are also vocabularies which are loaded instantly when referenced,
- called virtual vocabularies. These are ASSEMBLER, UTILITIES, EDITOR,
- SCREEN-UTILS (the latter two are only available when block words are
- loaded).
-
- A major difference between L.O.V.E. Forth and what is
- described, is that the vocabulary search order in L.O.V.E. Forth is
- implemented as a vocabulary stack, the top being the first one
- searched. Executing a vocabulary (ie. the word) makes it the first one
- in the search order. The word ALSO allows a vocabulary to be added to
- the search order. VDROP removes the top one. CONTEXT always holds the
- top of the vocabulary stack. ONLY resets the vocabulary stack to just
- ROOT. The word DEFINITIONS works as expected. CONTEXT (ie. the top of
- the vocabulary stack) becomes the vocabulary into which new definitions
- are added.
-
- Use ORDER to display the current search order, WORDS displays
- words from the CONTEXT vocabulary, WORDS> followed by any vocabulary
- name, displays words from that vocabulary. The word DEVELOP resets
- the vocabularies to ROOT, FORTH, and TOOLBOX which is the usual order
- for normal programming and experimention. (If in doubt, type DEVELOP).
-
- Chapter 10 I/O any you
- ----------
- Make sure the block disk words are loaded with
- INCLUDE" LOADBLK.TXT"
-
- The word >TYPE is not defined.
-
- Though CMOVE and CMOVE> are included, the word BMOVE (same
- arguments) is much more useful. It checks prior to the move, whether
- there will be any bytes written over by the move, and adjusts the
- direction of the move accordingly. (For all that explanation, the
- overhead is very slight).
-
- The word BLANK is not included. Try: : BLANK BL FILL ;
-
- L.O.V.E. Forth defines two words to check for keypresses. The
- word QTERM simply checks for a key and returns a flag, true if there is
- one available for KEY. The word ?TERMINAL does the same thing, but
- removes it if one is found.
-
- The word NUMBER only recognizes a decimal point within a number
- being converted.
-
- The word STRING is not provided, but the word ,"
- (comma-quote) provides this function. The word LIT" is also not
- provided. The word " (quote) provides this function, note that it
- returns just an address and can be executed from the keyboard as well
- (it places the string at PAD). Note that all string words allow the
- inclusion of control characters using UNIX conventions. See the file
- STRINGS.DOC for more information.
-
- Chapter 11 Extending the Compiler with Defining and Compiling Words
- ----------
- The example given for dot" will not operate in L.O.V.E.
- Forth because string literals are actually stored in the VS:. B."
- would work however, if the word BRIGHT were available. The word ASCII
- is provided and is state-smart.
-
- Chapter 12 3-1/2 Examples
- ----------
- The words ASCII and \ are already provided.
-
- The word ," is defined differently in the second example.
- Either define STRING as ," first, or use " instead of ," .
-
- The rpn assember provided with L83 has a similar
- implementation, but remember that code goes into the code segment.