home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
love
/
lfintro.doc
< prev
next >
Wrap
Text File
|
1993-04-11
|
16KB
|
326 lines
L.O.V.E FORTH
INTRODUCTION
It is our opinion that the FORTH computer language is without peer
in the realm of computer languages. No other language has the BAND-WIDTH of
FORTH. Not only can a programmer write high level definitions, but without
missing a beat, step down to the raw power of machine code. This language
can be used to control machines for real-time control applications, for
writing games, systems applications, artificial intelligence (expert
systems), robotics etc. It can even be used to write other languages.
L.O.V.E. FORTH PARTICULARS:
--------------------------
L.O.V.E. Forth is as close to the full 83 Forth standard, as the 8088/86
would allow.
Full memory segmentation is employed by L.O.V.E.. This means that
code, variables, threads, heads and other FORTH constructs occupy separate
and individual memory segments inside the IBM's RAM memory space. Thus 350
Kbytes of memory space is required to load and use L.O.V.E. Forth (DOS
excluded). A full 640 Kbytes of memory is recommended.
L.O.V.E. Forth supports all DOS functions (ver 3.xx and up), and
employs many of the IBM DOS function calls for normal file chores.
However, it still retains the ability to work with individual screens. As
a matter of fact, screens and text files can now be fully intermixed for
maximum flexibility and ease of programming. ( We recommend using the text
editor supplied with L.O.V.E., or a similar product. See the chapter on
editing files.)
As noted above, compiled word definition components are distributed
among the four segments as they are input. The code part of the word goes to
the CODE SEGMENT, the word threading goes to the DATA SEGMENT, data goes to
the EXTRA SEGMENT. Both the parameter and the return stacks use the STACK
SEGMENT. The head part of the word goes to a segment calculated by the
program during loading only, and is normally inactive. This segment we call
the HEADS SEGMENT, but it is not an integral 8080 segment as such. A
separate segment is devoted to local variables as well.
We are currently supplying an assembler, a graphics package, a
screens editor, an improved user interface, support for local variables, an
online help system, an interactive L.O.V.E. Forth Menu ( which allows even
the most amateur programmer in Forth to begin learning how to use L.O.V.E.
FORTH), access to the complete DOS area, and the ability to use ASCII text
files generated by your favorite text editor. We supply a text editor with
shareware versions only. The extensive DOS interface lets you call your
own text editor from within L.O.V.E Forth (provided it leaves you with
enough memory in RAM) to enter code. As mentioned above, text code and
screens code can now be freely intermixed while loading your applications
from within L.O.V.E. Forth.
Currently we are working on giving L.O.V.E. Forth the capacity to
handle object oriented programming structures, and this feature will be
available with version two. Local variables, which form the preliminary part
of object oriented programming, are already included. The Metacompiler and
L.O.V.E. Forth Programming Library are in the works and will become
available in time as well.
GETTING STARTED:
---------------
The files needed for operation are:
1. LOVES.EXE Main Program with menu and demo attached
2. MIN129.EXE "Bare bones" minimum system
3. VASMLINK.VTR Virtual (pull down) assembler and linker
4. VEDIT.VTR Virtual (pull down) screens editor.
5. VUTIL.VTR Virtual (pull down) utilities.
6. VSUTIL.VTR Virtual (pull down) screens/blocks system.
7. HM.EXE } Hyper-help system
8 LOVE.HTX }
9. DEMO-GS.DEM
10. DEMO-LD.DEM
11. DEMO-MU.DEM
12. DEMO-VR.DEM
13. DEMO.SCR
14. 2DEMO.TXT
( Items 9 through 14 are needed only for the demo ).
L.O.V.E Forth contains a lot of its external tools in the form of
virtual memory pull-down overlays which are used as needed, and then
released from memory. These are identified by the .VTR suffix.
Along with the LOVES.EXE, these *.VTR files must also be present
on the default drive and subdirectory, and are used as needed. For example,
if you are editing screens or screens files, you will have opened a file
with the OPEN" <fname.scr> command. Then you can edit screen "n" by typing
"n" edit, and tapping the enter key. This will call the editor into memory
and show that particular screen inside the screen editor on the CRT. A
"screen" is 16 lines by 64 characters wide, and is used as an editing unit
by the screens editor (archaic Forth usage).
Typing HELP or help ( upper_case/lower_case ) will pull down the
HELP system and start the hyper-help system. Typing HELP */MOD will get
you help on */MOD. To get help on any other word that is currently
used by L.O.V.E. Forth, type HELP <word_you_need_help_with>.
To discover what words are available, type WORDS> FORTH <CR> and you
will get an orderly display of all the words currently residing in the FORTH
VOCABULARY (most recently defined word first). Should you forget the ">"
character belonging to WORDS>, and type WORDS FORTH, you will get the words
from the VOCABULARY which is at the top of the search order. If at any time
the search order becomes confused, type in the word DEVELOP, and then check
the search order with the word ORDER. DEVELOP places the VOCABULARY TOOLBOX
at the head of the search order, followed by FORTH and ROOT.
As you may have guessed by now all the "words" in Forth produce
action results. Some desirable, some not desirable. To maintain compactness
and speed, extremely little error checking is done in Forth. You may have to
reboot (start again) your system if you execute words at random to see what
they do. Consult the HELP utility or this manual to avoid problems.
AGAIN, PLEASE REMEMBER THAT SOME OF THE WORDS SHOWN ARE INTERMEDIARY
WORDS BELONGING TO HIGHER LEVEL DEFINITIONS AND MAY CRASH YOUR SYSTEM IF
USED OUT OF THEIR PROPER CONTEXT. REFER TO A FORTH BOOK FOR THE MORE
STANDARD WORDS AND USE OUR ONLINE HELP FACILITY. SIMPLY TYPE HELP
<WORD_NAME>.
FOR NOVICES:
-----------
This part is aimed at first users of FORTH including L.O.V.E. Forth,
but especially at newcomers to computers in general.
Your diskettes were sent out with the write protect tab covering the
notch of each disk. This is to prevent accidental write over of the
diskettes and destroying the information on them. Using the DOS utility
DISKCOPY, make TWO (2) copies of each diskette. Put the original and first
copy in a safe place, and use only the second copy as your working copy.
Consult your DOS manual, or a book on using MS/PC-DOS on the exact
procedure.
If you have a hard drive, simply make a directory by typing: MD
LOVE4TH. Switch to it with: CD\LOVE4TH. Then copy the contents of
L.O.V.E. Forth by placing the L.O.V.E. Forth diskettes in drive A:
(or B: if necessary) closing the floppy drive door and typing: COPY A:*.* .
When the copying is finished, replace the diskette in drive A: with
the other L.O.V.E. Forth diskette, re-type the COPY A:*.* instruction, and
hit ENTER.
Once you have the back-up copies made, or the L.O.V.E. Forth files are
on your hard disk, you can safely begin to use L.O.V.E. Forth.
To use L.O.V.E. Forth simply type LOVES at the command prompt, like
this: A>LOVES (ENTER) (this is the floppy drive system) or, C> LOVES
(ENTER) (this is a hard disk system, and your directory is LOVE4TH)
A> B> C> etc simply indicate the current drive in use, while DOS is
waiting to load some application or utility.
When L.O.V.E. Forth finishes booting (loading) it will present the
L.O.V.E Forth logo on the screen, and below it the initial menu and general
instruction box. Please read the contents of the box carefully. Hitting
any key brings up the interactive menu.
The menu is there to help and assist you through the first
rudimentary Forth activities only, and is NOT intended to act as an
exhaustive tutorial or Forth shell.
Still, if you are a beginner to Forth use and programming, it will
give you an adequate feel and practice of the language. Use the left/right
arrow keys to move the highlight bar along the main topics. Use the enter
key to select a main topic. Then use the up/down arrow keys within a menu to
select a Forth action. Use the enter key to carry out the action. The F1 key
is the help key in all cases.
When an action menu is pulled down, the ESC key will bring you back
up to the main menu bar. To remove the main menu bar itself, and enter
L.O.V.E. Forth in the native Forth mode, use the ESC key also. Typing the
word LOVE <CR>, brings the menu back in control.
If you are perusing the demo part of the menu, the ESC key halts all
action, and re-establishes the main menu bar.
Whatever you do, remember to keep the stack clear of any unwanted
numbers as these may cause trouble, if you continue to use L.O.V.E. Forth
in the native Forth mode.
L.O.V.E. Forth can be used in several modes:
a. INTERACTIVE: You enter numbers or word definitions directly at
the keyboard and L.O.V.E. Forth will execute them.
b. COMPILE MODE: You define a colon word, and then type its name to
execute. (See chapter on how to define Forth words).
c. EDIT MODE: You enter code into a text file, using any ASCII text
editor, save it, and then load the definitions directly from disk to compile
the code. Or you can use the Forth editor to edit either a screens file or
disk screen and then load the screens for compilation.
d. RUN TIME MODE: You write and compile the code, create an
executable file, and save it to disk for execution as a normal *.EXE file.
( * = name of your choice )
Because L.O.V.E. Forth, as most FORTHs, was designed for speed and
efficiency it does NOT have a lot of internal error checking. Consequently,
many words if not chosen with care as to their effect, will crash the
system.
To explain: FORTH in general and L.O.V.E. Forth in particular is a
threaded code language, utilizing two or more "stacks" during operation. A
"stack" is a reserved area of memory for handling numbers. These numbers can
be ordinary literals, constants, variables etc. Many of the L.O.V.E.
definitions or just words as they are commonly called, use these stacks
repeatedly as they are executed.
Therefore, if a word requires some kind of a number to be available
on the stack, and if such number is not there, then the system will crash,
or at best give only a short terse message.
A very good way of avoiding this happening, is to keep using the
interactive help system that we have built in for you. Generally, avoid
entering words at random. Rather, move to the end of this manual, and do the
sample exercises present. Obtain some books on FORTH programming, and begin
to really experience the power and joy of programming in FORTH. Better
still, join with us in the Fig (Forth Interest Group, P.O. Box 8231, San
Jose, California, USA, 95155), and become a part of the world of FORTH
programming.
FORTH is a STACK oriented language. Most definitions require data on
the stack before being called, put data on the stack after being called, or
have no affect on the stack at all. A stack diagram makes this clear, and
allows a programmer to determine the stack requirements of any word that he
himself might be defining or coding. In most Forth source code, the stack
diagram (comment) is placed right after the name of the word itself, ie:
: Hi ( -- ) ." Hi there" ;
The two dashes -- represent execution of the word. The fact that
there is nothing in front of the dashes means that the definition does not
require an item to be placed on the stack. Likewise, the fact that there is
nothing following the dashes, means that the word Hi does not leave anything
on the stack.
NOTE: All L.O.V.E. Forth "words" must have a space following them to
act as delimiters. This does NOT apply to the end quote and right
parenthesis, which serve merely to determine the end of a printable message
or a non compiling remark statement.
LEARNING TO L.O.V.E. FORTH
--------------------------
Now that we have given you the rudiments of L.O.V.E. Forth we should
give you some advice on how to study and learn it.
There are two general approaches that can be taken. Each has its
good and bad points.
A.
With L.O.V.E. Forth booted up and running, this manual and some
other Forth reference by your side, do as many consecutive exercises as
possible.
If possible, get a printout of this manual, and attempt to memorize as
many definitions with their stack diagrams as possible. Use any kind of
memory method available to you, or simply copy the definitions by
long-hand. Do one definition from each alphabet group in turn, to maintain
motivation and variety ( one from A group, one from B etc ). After you have
done this, begin practicing as in A above.
The second method may seem more arduous at first, but for learning
L.O.V.E. Forth it has several advantages.
We recommend it highly. Here's why !
------------------------------------
B.
As you may have noticed L.O.V.E. Forth and all other companion
FORTHs are word definition driven. Execution proceeds when one word calls
the next word in turn. This makes the language very flexible, fast and
expandable in the direction of your application. But this means that,
except for the core or KERNEL words as they are commonly referred to, one
application will have differently named words from the next application.
Navigating through all these word definitions becomes a burden,
unless one has a fairly good cross-sectional sample of the kernel words
committed to memory. This memory intensive study creates a very good map of
L.O.V.E. Forth for you, and makes it much easier to associate word actions
with their definitions, inside your or somebody else's application or
program.
Later, practice at the computer writing and debugging your own
programs, will internalize your understanding of the connectivity and
interaction of FORTH definitions and their uses. You will see that no matter
what the code requirements are, you will write and debug faster than in any
other language that is available today !
-------------------------------------------------------------------------
L.O.V.E. FUNDAMENTALS
-------------------------------------------------------------------------
The Forth language architecture is built around the data stack. While
Forth allows memory locations to be assigned for use as variables,
constants, and work areas, the data stack is used to hold and transfer most
values and parameters (data items) for use by the various sections of a
program. Thus the data stack allows very quick and convenient access to
data items. Since most data items needed by or produced within intermediate
portions of a program are temporary in nature, the data stack proves very
handy.
The way the data stack works is similar to the way RPN type
calculators, like the Hewlett-Packard, work. The following is another
anology.
We have all seen the in/out basket used by secretaries and business
people to organize their work. They take the top item on the basket, work on
it then place the finished work back on the top of another basket for
disposal. Similarly a restaurant has a dish holder to hold clean dishes.
The first ones on the top are the first ones to be taken off.