home *** CD-ROM | disk | FTP | other *** search
- This documentation describes the extensions to FORTH which make up
- KFORTH. If you are not familiar with the FORTH language you will
- need to get a book to describe the structure, syntax, and vocabulary
- of the language. A very popular beginning FORTH book is:
-
- Starting FORTH
- By Leo Brodie
- Prentice-Hall 1981
-
- The book will teach you the basics of FORTH. This documentation provides
- you with the information to use this version of FORTH which we call
- KFORTH.
-
- A Few Words About Forth
-
- To start FORTH you run the KFORTH.COM file just as any other .COM file
- by typing KFORTH <carriage return>. To get out of FORTH type BYE <CR>.
-
- FORTH does not create or use standard CP/M files as you are used to seeing.
- In FORTH the "file" you work with is called a screen. KFORTH provides you
- with 150 screens per disk which are kept within a 150 K CP/M file called
- FORTH.SCR. This allows you to put CP/M files on the remainder of the disk
- without getting into your FORTH workspace.
-
- It is possible to create a file FORTH.SCR which is less than 150 K. You
- should avoid this since KFORTH expects to have the full 150 K available
- and will try to read your CP/M files as if they were a FORTH screen. It is
- easy to avoid this by creating a screen or having a FORTH.SCR file on the
- disk with KFORTH.COM. To create a 150 K FORTH.SCR on a blank, formatted
- disk use the FORTH extension MAKE-NEW described below. Or you can use an
- existing FORTH.SCR like the one on this disk. The way you get into trouble
- is when you run KFORTH.COM on a disk that has no FORTH.SCR or use the
- FORTH extension BACK-UP-DISK (described below) without have an empty
- FORTH.SCR in drive B. In either of these cases, KFORTH just builds a
- file FORTH.SCR but only reserves the blocks it needs. Then if you PIP
- CP/M files onto that disk they may fill in the unreserved blocks. The
- next time you use KFORTH, it expects to be able to use all of its 150 K
- workspace even though it never reserved it. If you LIST a screen that
- has a CP/M file residing in its place, well, thats when things get weird.
-
- It is also a good idea if you are new at FORTH, not to put a disk in drive
- B with CP/M files on it unless there is a FORTH.SCR on it as well.
-
- _____________________________________________________________________________
- FORTH.COM--------------------------------------------------------------------
-
- This is the fig-FORTH kernel. It was written in assembly language and
- provides the interpreting core to make it possible to write in FORTH.
- In addition to the source for the
- kernel we will also include any extensions to our KFORTH that are submitted
- as they come in (or until the disk is full).
-
- FORTH.COM is the core of KFORTH.COM. You may extend the FORTH.COM to become
- KFORTH.COM by using the FORTH screens on this disk in the file FORTH.SCR.
-
- To do this use PIP to transfer FORTH.COM and FORTH.SCR to another disk
- (blank and formatted). Then use SYSGEN.COM to put your system tracks on
- this disk as well. Now place this disk in drive A and hit the reset
- button. Once you get the system prompt ( A> ), type in FORTH and a
- carriage return. FORTH will ask you for the date and you may respond or
- answer with a carriage return. Then type in 50 LOAD (must be uppercase)
- and a carriage return. This will cause FORTH to load into memory an
- executable version of the extensions. It will display the first line of
- each screen that it loads. After it has loaded about half of the extensions
- it will type to the screen:
-
- ENTER YOUR INITIALS IN THREE LETTERS
-
- and wait for you to do so. This will customize your editor so that it will
- put your initials on the first line of the FORTH screen whenever you edit.
-
- After you do this FORTH will load the rest of the extensions. Finally
- FORTH will return control to you and give you the OK prompt. Exit FORTH
- by entering:
-
- BYE<carriage return>
-
- Forth will then respond with:
-
- Forth is 61 Records Long
- LEAVING FORTH Have A Nice Day
-
- The number of records is the number of 256 byte pages of memory that FORTH
- now occupies with all of its extensions. But the extended version of FORTH
- is still in memory! To save it on disk as a .COM file you must now enter:
-
- SAVE 61 KFORTH.COM<carriage return>
-
- You now have a file on that disk which is identical to KFORTH.COM on this
- distribution disk but now it will leave your initials in a screen that you
- edit instead of BOB.
-
- _____________________________________________________________________________
- FORTH.SCR--------------------------------------------------------------------
-
- This file contains the screens that have the source for the FORTH extensions.
- Some of the extensions are in the vocabulary of KFORTH and others have to be
- LOADed before they may be used. First lets look at the "built-in" extensions.
-
- STATUS
-
- The line of text at the top of the CRT when you are in KFORTH is due to this
- extension. STATUS shows you the contents of the stack, the number base you
- are working in, and the vocabulary you are working in. Screen 16.
-
- WHERE
-
- This extension will find an error in compilation and underline it. Screen 17.
-
- OOPS ERR
-
- ERR replaces the standard FORTH word ERROR and uses WHERE to find and
- underline a mistake. OOPS puts you in the EDITOR and positions the cursor
- at the mistake. Screen 18.
-
- PATCH
-
- This extension allows you to redefine a word without having to re-compile.
- Puts a call to the new word at the beginning of the old word. Screen 13.
-
- CP/M
-
- This extension has some utilities to allow you to make a CP/M file on disk
- B. Screens 25-27.
-
- SCREEN-ORIENTED EDITOR
-
- The screen editor is loaded into the KFORTH vocabulary. It is very easy to
- use once you get started. The source for this editor is in screens 61-97.
- To use the screen editor you enter the number of the screen you wish to
- edit followed by an E. For example
-
- 100 E will edit screen 100 (empty on this disk)
-
- If you enter that when you are in KFORTH it will display it on the screen
- after it pulls it from the disk. You are now in the editor. A ^Q will
- display the HELP screen which shows you the keypad usage map. The cursor
- control (arrow) keys will move you about the screen and you may edit text
- as you please. To exit either choose exit with no update of the disk file
- or exit and write to disk (^Q to see the HELP screen). After you exit the
- editor the screen will not be written out to disk until you (or a FORTH
- utility) FLUSH the buffer. (Enter FLUSH just to make sure). If you did
- the editor customization above the next time you view the screen you just
- edited your initials and today's date should be on the first line of the
- screen.
-
- The editor also has some FORTH words to re-direct the output while you
- are in FORTH. These are:
-
- PRINTER-ENABLE -- send the output to the printer instead of the CRT
- CRT-ENABLE -- un-does the above (output goes to CRT)
- BOTH-ENABLE -- output to printer and CRT
-
- PRINTER-EMIT -- same as EMIT but to printer
- BOTH-EMIT -- EMIT to CRT and printer
-
- The ASSEMBLER
-
- The assembler is an 8080 assembler and is on screens 108-114. This allows
- you to enter and include 8080 mnemonics in your FORTH programs. The assembler
- works as a standard FORTH assembler does. All code entry must be in reverse
- polish notation. The code segment should start with the FORTH word CODE
- and end with C; (another FORTH word). An example segment would be:
-
- CODE BOP H POP, H PUSH, H PUSH, H PUSH, NEXT, C;
- ^ ^ ^ ^ ^ ^ ^ ^
- | | | | | | | |___________end code segment
- | | | | | | |___________return to interpreter
- | | | | | |________________push H and L registers
- | | | | |________________________push H and L registers
- | | | |________________________________push H and L registers
- | | |________________________________________pop H and L registers
- | |_________________________________________name for this code segment
- |_____________________________________________________begin code segment
-
- This section of code (BOP by name) duplicates the top stack item twice. To
- test this in KFORTH enter the line above (don't forget the commas after the
- instructions). The assembler will create the word BOP and put it in your
- dictionary (type VLIST to confirm this). Then put a number on the stack
- (by typing the number and a carriage return) and then type BOP.
-
- Look at the contents of your stack. The number you entered should now be
- there three times.
-
- DECOMPILER
-
- The decompiler source is in screens 102-106. It allows you to decompile
- FORTH words that you do not have the source for.
-
- As an example you could decompile the FORTH word LIST. To do this you
- would enter:
-
- GOESINTO LIST <carriage return>
-
- Now each time you hit the space bar you will get the next FORTH word used
- by LIST. If you see one of these FORTH words (say PAGE) and want to
- decompile it you may hit the carriage return and the decompiler will work
- on that word, showing you the lower FORTH words that make up that word.
-
- To exit the decompiling session just hit the space bar until the
- decompilation is complete.
-
- NUMBER-BASE
-
- When KFORTH begins the number base is set to DECIMAL. You may choose three
- other bases to use, HEX, BINARY, or OCTAL. Entering any of these words will
- change the number base you are working in. The base you are presently in is
- displayed at the top of the screen by STATUS.
-
- _____________________________________________________________________________
- Extensions Which Are Not Loaded Into KFORTH.COM------------------------------
-
- There are some other FORTH extensions in these screens that are not loaded
- to become part of the KFORTH.COM file. To use these utilities you must load
- them into memory by using the LOAD command. To do this type in the number
- of the screen where it is located followed by a space and the word LOAD.
- Then you may type in the FORTH word and it will execute.
-
- Screen #32 LOG
-
- This word will copy what is on the CRT into a CP/M file on drive B called
- FORTH.LOG. It will begin copying when you type START-LOG and stop when
- you type END-LOG. It does not terminate lines with a carriage return/
- line feed, only a carriage return. If you would want to make a file record
- of the words in your FORTH dictionary enter:
-
- 32 LOAD
- START-LOG
- VLIST
- END-LOG
-
- Screen #33 BACK-UP-DISK
-
- This word will copy any screen with something written in the first line
- to drive B. Backs up all screens. You should have a FORTH.SCR with all
- screens empty in drive B.
-
- To use enter: 33 LOAD
- BACK-UP-DISK
-
- Screen #34 TRIAD-THRU
-
- Use this word to list screens in groups of three followed by a form-feed.
- If you want it to go to the printer, don't forget to type PRINTER-ENABLE
- first. You need to type a beginning screen # and an ending screen #.
- To list screens 30-35 to the printer enter:
-
- 34 LOAD
- PRINTER-ENABLE
- 30 35 TRIAD-THRU
-
- Screen #40 MAKE-NEW
-
- This constructs the CP/M file FORTH.SCR with empty screens. Place a blank
- formatted disk in drive B and enter:
-
- 40 LOAD
- MAKE-NEW
-
- Do this before using BACK-UP-DISK or any time you need a new FORTH
- workspace. Place KFORTH.COM on a disk with this new FORTH.SCR and start
- FORTH with a new slate.
-
-