Mühlviertler Elektronik Glaser
Über das Echtzeit-Betriebssystem
und die Programmierumgebung des
ATLAN Computers
about the Real Time eXecutive Operating System and
Programming Environment of the ATLAN  Computer.
Ing.
Franz Glaser

Glasau 3
A-4191 Vorder-
weissen-
bach
++43/
7219/
6135

Austria

 

Atlan 4th
    *  ist das Betriebssystem, mit dem der ATLANComputer läuft. 
    * ist die Programmiersprache, mit der die RTX - (Real Time eXecutive) 
                    Programme für die Automation laufen. 
    * ist die Bedienungsoberfläche für die Anwender des ATLAN Computers
                    und für die Wartung / Diagnose 
    *  ist eine Entwicklung von MEG aus Fig-FORTH für den 8086, 
                   jetzt für den 80386EX
PROM-fähig Während der Programm-Entwicklung wird der Code ins CMOS-RAM compiliert. Ein großer Teil des Programmes wird erst bei der Inbetriebnahme der Anlage an die örtlichen Verhältnisse angepaßt. Nach der Endabnahme kann der Maschinencode direkt in EPROM's oder Flash - PROMS gespeichert werden. In ATLAN 4th gibt es auch ein SPS-Modul, das mit einer speziellen AWL-Sprache betrieben wird. Für besonders zeitkritische Aufgaben oder für die Erweiterung des BIOS können auch assemblierte Code-Prozeduren mitcompiliert werden.
Interrupt-fähig Alle Steuerprozeduren laufen im Hintergrund, die Bedienung im Vordergrund wird dadurch in keiner Weise beeinträchtigt. Die Verknüpfung zwischen dem Bedienprogramm und den Prozeduren, die die tatsächliche Arbeit machen, geschieht mittels Briefkastenvariablen.
stand alone Der ATLAN hat neben ATLAN 4th kein weiteres Betriebssystem, es ist das Betriebssystem mit BIOS und Bedienungsoberfläche. Es gibt keine Festplatte oder Diskette, niemand kann Spiele laden oder gar Viren ins System bringen. Alle Prozedurnamen, die Variablen und die Konstanten sind mit ihren Namen im Maschinencode enthalten und können für Wartungs- und Diagnosezwecke jederzeit aufgerufen werden, auch bei laufender Anlage. Der ATLAN ist sein eigenes Programmiergerät. Der Quelltext ist während der Entwicklungsphase im CMOS-RAM enthalten, oder er wird über ARCnet von einem PC übertragen.
english only from here downwards
ATLAN 4th
 
is the operating system, the programming language and the user interface of the ATLAN computer for industrial control applications. The compiled code is directly PROMable, is reentrant for nested interrupts and is totally stand alone. It contains a PLC module and allows compilation of assembled CPU code for time critical applications and customized BIOS extensions.

ATLAN 4th is the tool for instant reaction on run time needs. It behalves like a dialogue with the machine or the plant. The developer compiles and invokes test procedures online, while the machines are running. At final installation all the test procedures and the real working procedures, the variables and constants can be invoked with their name, for maintanance and service. 

Only few comfortable dialogue procedures invoked by function keys must be written for the working people, since all standard commands can be entered on the input line. The interpreter  IS  the user interface, it is an integral part of ATLAN 4th.

ATLAN 4th utilizes the Reverse Polish Notation (postfix) which makes the compiler and interpreter so easy to understand and work with.
..

 is a language for direct communication between human beings and machines. 
Using natural-language diction and machine - oriented syntax, Forth provides an economical, productive environment for interactive compilation and execution of programs. Forth also provides low-level access to computer-controlled hardware, and the ability to extend the language itself. This extensibility allows the language to be quickly expanded and adapted to special needs and different hardware systems.
please visit Franz Glasers arts pages
Forth was invented by Mr. Charles Moore to increase programmer productivity without sacrificing machine efficiency. Forth is a layered environment containing the elements of a computer language as well as those of an operating system and a machine monitor. This extensible, layered environment provides for highly interactive program development and testing.
...  : computing  easy ;
.
INTRO
.
FOR THOSE WHO ARE INTERESTED...

First, please forget all that you know about a programming language for a few minutes! 

The ATLAN 4th prompt is    >>     it tells the user that it expects a command line similar to the C:\> prompt of the DOS-COMMAND interpreter.

>> 
." Hello World"  <Enter>   Hello World >>

The  ."  command (dot-quote) instructs the interpreter to scan the input line until the next quote and write the string to the console. <Enter> is the command to interpret the input line andexecute the commands, similar to the COMMAND.COM.

ATLAN 4th can do calculations, it uses the Reverse Polish Notation or Postfix notation. The RPN is one of the main reasons why ATLAN 4th is so easy and simple and why the compiler is so efficient..

25   3   *   .   <Enter>      75   >>

25   5   /    .  <Enter>       5   >>

Note the period before the <Enter>, it is the command to write the result to the screen, usually as a decimal number.

Commands are separated simply by a blank space, so almost any Ascii character can be used in a command, eg. the period as the "write a number to screen" command. Here only integer arithmetic is explained. Numbers and commands (functions and procedures) are all together named "words" in FORTH like words are seperated by blank spaces in a sentence.

The 25 command will put the number (value) 25 on the stack, the 3 command will put the number 3 on the stack, the * (Star) command will take two numbers from the stack, multiply them and return the result on the stack. The  period command takes the number from the top of stack and writes it to the screen. This is the postfix notation, very straightforward and simple. You can see that the stack memory will need no names for the variables, the position on the stack is the only way to retrieve numbers. Of course, ATLAN 4th can hold numbers in named variables as well, but this is not discussed at this point.

The postfix notation does not use any operators + - * / etc. as known with the Adam - Riese - notation, there are no parentheses and no * and / precedencies over + and -
There are simply commands, the + is not an operator, it is the name of the "add" instruction and * is the name of the "multiply" instruction. Even a number entry can be thought of as a command "put the value nnn on the stack".

A very helpful command for integer arithmetics is the  */   scaling command, star-slash. It multiplies two numbers on the stack and divides the result by a third number, using an intermediate double precision result.

6600   100  33   */   .   <Enter>  20000  >>

The intermediate result is 660000 which would not fit in a 16-bit integer (ATLAN 4th  uses 32-bit integers, this is for explanation only), but with the */  command it works pretty.

To multiply 500 by 3.1415926=Pi the bloody integer-arithmetic beginner writes:

500   31416  *  10000  /     (integer arithmetic) but this would overflow.
500   31416  10000  */   will not overflow.

But a skilled FORTH programmer writes it even more accurate:

10000   355  113 */  .  <Enter>  31415 >>    (this is a well known number pair with FORTH programmers, yielding a result accurate to 7 decimals).

Three numbers are expected by the    */    command (function) on the stack, and it returns one number.
---

compile
 
 
 
 

This method is worth a compiled word (programmed function) for later multiple use:

:  PI*    355   113  */   ;  <Enter>

The colon : starts the compiler, then the name of the new word is entered, followed by the commands and finally the semicolon ; finishes compiling. Here you see the creation of the new FORTH word "PI-Star", which takes a number from the stack, multiplies it by pi and returns the result on the stack.

2000  PI*  .  <Enter>    6283  >>

You can test the function immediately after compiling it. The name PI* is mnemonic as good as possible. The new functions have exactly the same properties as the predefined functions have, except concerning their special, desired behaviour.

The parameter consumption and return values on the stack are typical to a particular command, the same way as parameters are for C or Pascal procedures and functions, but there is absolutely no type checking, even runtime checking is rather poor with FORTH.

Now I create another function which multiplies by 2*pi:

:  2PI*   2  *  PI*  ; <Enter>

You see how the previously compiled word (function) is compiled into the new function. The new function can be used at the commandline for immediate application AND as a command in another compiled function as well.  This example is perfect, since the 2 * cannot overrun the intermediate result if the input parameter were too large, it would overrun with the pi* anyway. It could have been defined as 
:  2PI*    PI*   2  *  ;
too, but with some loss in accuracy with certain numbers (it will deliver even numbers only).

Scaling is typical with industrial control applications, assume an A/D converter delivering a number in the range 0 until 4095 representing a weighing scale with a nominal range of 600 kg.   .... nnn  A/D   600  4096 */  ....  delivers a number between 0 and 600 depending on the input voltage. In a real application this is not so easy, there are offsets and limits etc. and the ATLAN computer has a better than 12-bit resolution A/D - converter.

-->

:  5    17  ;<Enter> is a very silly command, but it is possible to compile that  -  and use it to make confusion:
25   5   -    .    <Enter>   8  >>   (note that the   5   in   25   is not redifined, because it is not seperated by blank spaces, i.e. is not a FORTH-word).
FORGET  5  <Enter>

Integer arithmetic is usual for FORTH programmers, but there exist real number operatios as well if needed. Typically a machine control program does not use real numbers since the range of values is well known at compile time and A/D converters do not deliver numbers with many digits anyway. Fractional numbers are maintained in the computer as integers and the decimal point is added in the moment when it is displayed on the screen at the appropriate position.

Parameter passing is very easy and straightforward, it simply and automatically happens on the stack. Input parameters AND results are on the stack. The function result is by definition the input parameter for the next procedure or function, it is already there. There can be more than one result left on the stack by a "function". Note that the return adresses of the called procedures are held on another stack which will not interfere with the number (say parameter-) stack.

As mentioned above the + - * and / are not arithmetic operators but commands. This leads to the fact that new functions and procedures are semantically the same as the few predefined commands, their behaviour and their usage is equal. 

ATLAN 4th can handle decimal and hex and octal etc. input and output, and besides the arithmetic commands + - * / it also has AND  OR   XOR   NOT  etc. for bit - operations.
---

Var
Addresses are treated simply as numbers on the stack, so the procedures can handle VAR parameters easily, and address arithmetics for array indexing and record handling is easily accomplished, but not shown here.

0C48AH  @  2  /  H.   <Enter>    483H  >>

the number 0C48AH is first put on the stack like 25 before. The @ command takes the number, uses it as an address in the memory and reads the contents of the address, then putting the number on the stack. The 2  and  / commands are straightforward and the H-period simply tells ATLAN 4th to write the number from the stack to the screen as a hex value. The result 483H is arbitrary, it depends on the contents of the address.

The stack can be manipulated with some special commands like DUP (copies the number on top of stack), SWAP  (exchanges the top two numbers), DROP (deletes the top number off the stack) etc.

Usually addresses are not entered as a number.

VAR:  SPEED        VAR:  SETVALUE       VAR:   ERROR    <Enter>

creates three "global" variables with addresses somewhere in the RAM area with the names SPEED and SETVALUE and ERROR. The "compiling" is very similar to the : described above, but it creates a "function" which puts an address on the stack, when invoked or used in a compiled procedure. Of course a variable can contain more than one number, eg. an array etc., where the user or programmer simply has to do some address arithmetics on the stack to get the desired pointer, but the variable name simply puts the start address of the array on the stack.  ATLAN 4th has no type-checking (like Pascal has).

Variables are simple constants, which deliver an address in RAM. At compile time the FORTH compiler - command VAR: creates a constant and then advances the V-CLP (current location pointer for variables) by the size of an integer, pointing to the address of the next variable.

SPEED  @   SETVALUE  @   -   DUP   ERROR  !  ."  Speed error="   .    <Enter>

Assumed that "somebody else" filled actual values into the variables SPEED and SETVALUE, the error value is stored into the variable ERROR with the ! (Store) command and additionally (with DUP and period) displayed on the screen, combined with a nice legend. Of course this input line can be easily compiled for later use:

:   SHOWERR    SPEED  @  SETVALUE @   -   DUP  ERROR  !  ." Speed error="  .   ;  <Enter>

SHOWERR  <Enter>   544  >>
SHOWERR  <Enter>   325  >>    (assumed that a background procedure updated the SPEED variable's contents).
I could have named the procedure   :  SE  or     :  ?E     or whatever I think was easily remembered. Note that I named it a procedure, not  a function, since it does not return a value on the stack in the manner how it is defined here. This is not a FORTH consideration, but it could help a Pascal programmer understanding it. The SHOWERR procedure is not a good procedure at all, since it is not flexible, it has no input parameters and the result is not usable anywhere else. But it might be a proper command for the end user, the worker at the plant.

FORGET SHOWERR  <Enter>

SHOWERR  <Enter>   SHOWERR ? <beep>  undefined command

What is not described here is the possibility to extend the compiler itself with additional functionality, but this statement could confuse the reader unnecessarily! ATLAN 4th has IF   ELSE  ENDIF   and   REPEAT  UNTIL    and  WHILE  and   LOOP   commands for conditional execution and loops and a rudimentary but powerful object orientation and much more which is not explained here.

Of course, ATLAN 4th can compile a big source text file as well, and this is simply performed by redirecting the input from the keyboard to a textfile. 

Note also that a compiled procedure is running with full speed, it is not interpreted. The compiled code contains the call-addresses of the compiled commands and procedures. 

Ready made programs of course contain interface procedures for the users comfort, they can be invoked with function keys or menues etc.

Some examples above are not accurate to the FORTH-79 and -83 standard in some respects, especially the entry of hexadecimal numbers with the trailing H and the VAR: - command are unique to ATLAN 4th.
-.

USAGE Did you see why ATLAN 4th is ideally suited for quick response to customer needs and why I said that it has a very close connection between the user and the computer? 
ATLAN 4th (FORTH in general) is not so much intended for writing application programs for the office computer market, yet it is well suited for engineers who have to control a test bench or a radiotelescope online and for artists who control a theatre illumination or animate the T-rex on Spielbergs set. It is a phantastic debugging tool for hardware developers and it is an excellent training tool for learning computer basics since the procedures can be used and tested immediately with real world parameters. 
You should not allow other programmers or ignorant teachers to make you confused with comparisons with C. And you can be sure to be exotic in computing circles if you like FORTH.
MEG-Glaser
. Links  Links 
-
What is FORTH?
http://www.spiritone.com/~fwarren/forth/f_what.html
    If Forth has a credo, it might be summed up as smallness, simplicity, and speed. Forth programmers traditionally disdain the flashy user interfaces and elaborate error handling that characterize most integrated environments nowadays. This attitude has its benefits " for example, a self-contained interactive Forth system including an editor, assembler, and even multitasking support can easily be put in an 8 KB EPROM.
 ? http://www.thenakedeye.com/pic/computer/forth/index.shtml
 http://www.forth.com/
          http://www.yahoo.com/Computers_and_Internet/Programming_Languages/Forth/
http://www.complang.tuwien.ac.at/forth/threaded-code.html
        http://search.dejanews.com/bg.xp?level=comp.lang,comp.compilers
 download a FORTH-83 compiler for Windows ?
 comp.lang.forth FAQ
If you like to test the Reverse Polish Notation you can download the RPN desktop calculator for Windows. Click on the appropriate button below for the download instruction page.
Copyright © 1997 Mühlviertler Elektronik Glaser Austria