|
* 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 jetzt für den 80386EX
|
|
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.
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. |
||
| ... | : |
| 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. >>
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 -
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.
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
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:
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 >>
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? | |
MEG-Glaser
|
||
| . | Links |
|
-
|