volksFORTH Version 3.90 Manual#

( work in progress )

english machine-translation by Google


(C) 1985-2010 FORTH-Gesellschaft eV Bernd Penne man. Georg Rehfeld. Klaus Dietrich Weineck Schielslek. Jörg Staben. Klaus Kohl. Carsten Strotmann

The authors have made efforts in this manual for a complete and accurate representation. The information contained in the manual, however, serve only as a product and should not be interpreted as guaranteed characteristics in the legal sense. Any claims for damages against the authors for whatever legal reason are excluded. It is not guaranteed that the procedure given free of third party rights.

We thank the entire FORTH community, particularly Charles Moore, Michael Perry and Henry Laxen

Prolog#

volksFORTH83 is a language which is unusual in several respects. For FORTH itself is not only a language but a programming system, in principle, boundless. One of the main features of the FORTH programming system is its modality. This modularity is ensured by the smallest unit of a FORTH system, the WORD.

In the terms FORTH procedure, routine, program, definition and command are synonymous with all the needed word. FORTH is therefore, like any other natural language also made up of words.

This FORTH-words can be seen as already compiled modules, it being always extended a core of several hundred words through their own words. These words of the core are in a FORTH83 standard set and ensure that standard programs can be run without changes on the respective FORTH system. Unusual is that the program text of the core is a FORTH program itself, in contrast to other programming languages, where a machine language program is based. From this core is produced by a special FORTH program, the meta-compiler, the executable Forth system.

How to add this now runnable kernel add your own words? The compile of the words is introduced in FORTH with COLON ":" and semicolon ";" complete.

• expected: in the execution of a name and assigns that name to all subsequent words. • completed and this assignment of words in the name of the new word and is ready for calls under that name.

Interpreter and Compiler#

A classic FORTH system is always both an interpreter and a compiler. After Einschaltmeldung or pressing the button waiting for the FORTH interpreter with the FORTH-typical "ok" for your input. You can write one or more command words in a cell. folk FORTH starts after pressing the return key with his work in helping processed by the series after each command in the command line. These command words are delimited by spaces. The delimiter (Limiter) for FORTH procedures is, therefore, the space, which also has the syntax of the language FORTH would be described.

The compiler is a FORTH system is thus part of the interpreter interface. There is therefore no compilation process to create the code, as in other compiled languages, but the interpreter is secured with new words as necessary to solve the problem the user program.

Even ":" (COLON), and ";" (semicolon) are compiled words, which turn off the compiler for the system on and off. Since even the words. control the compiler, "normal"-FORTH words are missing from the usual FORTH compiler options in other languages or compiler switches. The FORTH compiler is controlled by FORTH-words.

The call of a FORTH-word is by its name without an explicit CALL or GOSUB. This leads to the FORTH-typical appearance of the word definitions:

: <name> 
    <word1> <word2> <word3>  ... ;

The standard system response in FORTH is the famous "ok". There is no requirement characters like 'A>' for DOS or ']' in good APPLE 11 is not it! This can lead to. that after a successful action, the screen completely blank, true to the motto:

No News Is Always Good News!

And - unusually - FORTH used the so-called Postfix Notation (RPN) is similar to HP calculators, which in some circles are very popular. This means FORTH always expects only the arguments, the action ... Instead of

3 + 2 und (5 + 5) * 10 
It means
2 3 + and 5 5 + 10 *
Since the expressions are evaluated from left to right, there are no brackets in FORTH.

Stack#

Equally unusual is that FORTH performs only actions explicitly requested: the result of your calculations will remain in a special area of memory, the stack, right up there with an output command (usually "will.") Issued on then screen or printer. As the words of the FORTH-subroutines and functions meet other programming languages, they also need the ability to receive data to process and store the result. This function takes the STACK. In FORTH parameters for procedures are often stored in variables, but mostly passed on the stack.

Assembler#

Within a FORTH environment can be instantly programmed into the machine language of the processor without having to leave the interpreter must. Assembler definitions are the equivalent programs FORTH FORTH-words.

Vocabulary Concept#

The state-FORTH has an advanced vocabulary structure that was proposed by W. Ragsdale. This vocabulary-concept allows the classification of the FORTH-words in logical groups.

This allows you to switch on when needed and necessary commands disconnecting after use. In addition, the vocabularies allow the use of the same name for different words, without getting into a name conflict. An approach in action ühnliche catfish offers the UNIT-concept or MODULA PASCAL compiler or the packages in Java.

FORTH-Files#

FORTH often uses special files for its programs. This is a historical basis and the legacy of a tent when Porth very often took over functions of the operating system. Since there were only FORTH systems, the mass completely without even a DOS operating system or intervening management and file structures for your own use. These files are so-called block files and consist of a series of large blocks of 1024 bytes. Such a block, which is often called SCREEN is the basis of the source text editing in FORTH. However, with the volks4TH normal files can be edited in the format of the native operating system (MS-DOS, Atari TOS, Apple DOS, AMS-DOS, CP / M there ...), so-called "stream flow".

In general, any language is behind a certain concept, only with knowledge of this concept is possible to use a language effectively. The language concept of FORTH is described in the book "In FORTH think '(Thinking Forth) by Leo Brodie (Hanser Verlag).

A first impression of volksFORTH83 and our pride in this prologue is intended to provide. volksFORTH83 is an "open source" system, with its performance, the question arises:

Why do we make this system freely available ?#

Die Verbreitung, die die Sprache FORTH gefunden hat, war wesentlich an die Existenz von figFORTH geknüpft. Auch figFORTH ist ein open-source Programm (früher wurde dies Public Domain genannt, aber heute ist der Ausdruck Open-Source genauer), d.h. es darf inklusive des Quelltextes weitergegeben und kopiert werden. Trotzdem haben sich bedauerlicherweise verschiedene Anbieter die einfache Adaption des figFORTH an verschiedene Rechner sehr teuer bezahlen lassen.

Das im Jahr 1979 erschienene figFORTH Ist heute nicht mehr so aktuell, weil mit der weiteren Verbreitung von Forth eine Fülle von eleganten Konzepten entstanden sind, die z.T. in den Forth83-Standard und den Forth ANSI-Standard Eingang gefunden haben. Daraufhin wurde von Laxen und Perry das F83 geschrieben und als Public Domaln verbreitet. Dieses freie 83er-Standard-FORTH für MS-DOS mit seinen zahlreichen Utilities ist recht komplex und wird auch nicht mit Handbuch geliefert.

Wir haben ein neues Forth für verschiedene Rechner entwickelt. Das Ergebnis Ist das volksFORTH83, eines der besten Forth-Systeme, die es gibt. Das volksFORTH soll in die Tradition der oben genannten Systeme, insbesondere des F83, anknüpfen und die Verbreitung der Sprache FORTH fördern.

volksFORTH wurde unter dem Namen ultraFORTH zunächst für den C64 geschrieben. Nach Erscheinen der Rechner der Atari ST-Serie entschlossen wir uns, auch für sie ein volksFORTH83 zu entwickeln. Die erste ausgelieferte Version 3.7 war, was Editor und Massenspeicher betraf, noch stark an den C64 angelehnt. Sie enthielt jedoch schon einen verbesserten Tracer, die GEM-Bibliothek und die anderen Tools für den ST. Der nächste Schritt bestand In der Einbindung der Betriebssystem-Dateien. Nun konnten Quellentexte auch vom Desktop und mit anderen Utilities verarbeitet werden. Die dritte Adaption des volksFORTH entstand für die CP/M-Rechner (8080-Prozessoren), wobei speziell für den Schneider CPC auch die Grafikfähigkeit unterstützt wird. Dann wurde das volksFORTH für die weit verbreiteten Rechner der IBM PC-Serie angepasst.

In den 90er Jahren wurden Rechner mit vielen Megabyte an Hauptspeicher und Festplattenplatz zum Stabndard, und grafische Betriebssysteme wie Windows oder MacOS setzen sich durch.

Aber volksFORTH ist heute immer noch für Rechner mit begrenzten Systemresourcen interessant, sei es auf alten Homecomputern aus den 80er Jahren oder PDAs und Mobiltelefonen.

VolksForth ist in der Version 3.90 für die folgenden Rechnersysteme verfügbar:

  • 6502 CPU
    • Commodore C64
    • Commodore C16
    • Commodore Plus4
    • Atari XL/XE
    • Apple I
    • Apple II
  • Z80 CPU
    • CP/M
    • Amstrad/Schneider CPC unter AMS-DOS
    • Amstrad NC100
    • Sinclair Research Z88
  • 8088 CPU (Intel / AMD)
    • MS-DOS (in einer DOS-BOX auch unter Windows, Linux, OS/2, MacOS)
  • 68000 CPU
    • Atari ST

Warum soll man in volksFORTH83 programmieren?#

Das volksFORTH83 Ist ein ausgesprochen leistungsfähiges und kompaktes Werkzeug. Durch resistente Runtime-Library, Compiler. Editor und Debugger sind die ermüdenden ECLG-Zyklen ("Edit, Compile, Link and Go") überflüssig. Der Code wird Modul für Modul entwickelt, kompiliert und getestet. Der Integrierte Debugger Ist die perfekte Testumgebung für Forth-Worte. Es gibt keine riesigen Hexdumps oder Assemblerlistings, die kaum Ähnlichkeit mit dem Quellentext haben. Ein anderer wichtiger Aspekt ist das Multitasking. So wie man ein Programm in einzelne, unabhängige Module oder Worte aufteilt, so sollte man es auch in einzelne, unabhängige Prozesse aufteilen können. Das ist in den meisten Sprachen nicht möglich. Das volksFORTH83 besitzt einen einfachen, aber leistungsfähigen Multitasker.

Schliesslich besitzt das volksFORTH83 noch eine Fülle von Details, über die andere FORTH-Systeme nicht verfügen:

  • Es benutzt an vielen Stellen Vektoren und sog. deferred Worte, die eine einfache Umgestaltung des Systems für verschiedene Gerätekonfigurationen ermöglichen.
  • Es besitzt einen Heap für "namenlose" Worte oder für Code, der nur zeitweilig benötigt wird. Der Blockmechanismus ist so schnell, dass er auch sinnvoll für die Bearbeitung grosser Datenmengen, die in Files vorliegen, eingesetzt werden kann.
  • Das System umfasst Tracer, Decompiler, Multitasker, Assembler, Editor, Printer-Interface ... Das volksFORTH83 erzeugt, verglichen mit anderen FORTH-Systemen, relativ schnellen Code, der aber langsamer als der anderer Compilersprachen ist.

Mit diesem Handbuch soll die Unterstützung des volksFORTHS3 noch nicht beendet sein. Die FORTH Gesellschaft e.V., ein gemeinnütziger Verein, bietet dafür die Plattform. Sie gibt die Vereins-FORTH-Zeitschrift "VIERTE DIMENSION" heraus. Die Forth Gesellschaft kann über die Webseite http://www.forth-ev.de erreicht werden.

Hinweise des Lektors#

Diesem Handbuch zum volksFORTH83 Ist sowohl als Nachschlagewerk als auch als Lehrbuch für FORTH (speziell volksFORTH) gedacht. Deshalb handelt es sieh nicht, wie bei den anderen volksFORTH-Handbücher, um eine Auflistung des Vokabulars. Statt dessen wird mit ausführlichen Beschreibungen und Programmbeispielen in vielen Kapiteln die Möglichkeiten des FORTH-Systems erklärt. Ergänzt werden die einzelnen Kapitel jeweils um Wortbeschreibungen der darin vorkommenden Befehle (Glossar). Zur Unterscheidung von Beschreibung, FORTH-Worten, Programm-Eingaben und -ausgaben wird mit unterschiedlichen Schrifttypen gearbeitet:

Beschreibungen erfolgen in Proportionalschrift mit Randausgleich. FORTH-Befehle werden Im Text durch Fettschrift hervorgehoben. Eingaben und Programmlistinqs verwenden eine nichtproportionale Schriftart. _Ausgaben_ des FORTH-Interpreter/Compiler sind unterstrichen.

Weiter mit Kapitel 2.