The Elliott 803 had an excellent compiler for the then new ALGOL 60 programming language. ALGOL 60 was one of the first "block structured" languages and was hugely influential on just about everything that has come since. For more information on ALGOL 60 itself try Wikipedia http://en.wikipedia.org/wiki/ALGOL.
These notes contain the following sections:
The Elliott ALGOL compiler was an almost complete implementation of ALGOL 60, however there were a few limitations and some changes from the defined reference language. In no particular order:
GR
for >
DIV
for ÷
NOTEQ
for ≠
**
for ↑
... and several others Three particularly important (but slightly odd) substitutions are: '
(apostrophe)for ;
(semicolon)£
(GB pound sign)for ‘
(open string quote)?
(question mark)for ’
(close string quote)
As an example here's a simple program in the ALGOL reference notation and in the Elliott format:
ALGOL reference language | Elliott Representation |
---|---|
|
|
To run ALGOL programs on the Elliott 803 you must first load the ALGOL compiler. The compiler was supplied as two large reels of paper tape - tape 1 was the compiler itself and tape 2 was a set of run-time routines used by both the compiler and the executing program. Getting everything to fit in 8K of store was something of a miracle and large programs would often need to overwrite some of the compiler space when they ran, requiring the compiler tapes to be loaded again before the next program could be run. Loading, and particularly re-winding, those large reels of tape was a slow and rather tiresome process - this is something that is much quicker and simpler using the simulator!
Short programs, such as the included samples, were normally run in a "compile, load and go" mode. Once the compiler was loaded, a program source tape was put in the reader and compiled in-store, when compiled it was run and its output was printed to the output teletype. As long as the compiler was not overwritten, further programs could then be compiled and run without the need to reload the compiler tapes.
Use this sequence of operations to load the ALGOL compiler.
tapes/algol
and is called
a104-1.tape
(A104 was the name of the ALGOL library tapes).tapes/algol
and is called
a104-2.tape
At this point the system is ready to compile a program. It will be in the System Wait state with a high pitch tone coming from the speaker.
As an alternative to loading the two compiler tapes each time they are
required it is possible to either start the simulator using a machine image
parameter or use the Load... button on
the simulation control window to restore a machine image containing a pre-loaded
compiler.
A pre-loaded compiler image can be found in samples/machines/algol.803
.
If the pre-loaded image is used you will need to execute a 40 7 instruction to begin compiling a new program.
When the compiler has been loaded it is ready to compile and run programs.
FREE STORE
will be printed.
The program is now in what is known as a Data Wait indicated by a two-tone siren sound coming from the speaker. If the program requires additional data tapes they should be loaded into the readers at this point.
END OF PROGRAM
message will be produced
on the teletype.If all went well the system is now back in a System Wait (high pitch tone) ready to compile and run another program. You can repeat from step (1) above.
If things didn't quite go to plan you may need to press the Reset key on the operator console to get control back. You may then execute a jump (i.e. a 40 instruction to one of several locations to continue. The two most useful are probably:
If things go very wrong the simplest action is to Reset and to reload the whole ALGOL system starting again from Loading the Compiler.
For full details of the compiler (and there is a lot more detail) you can refer to Bill Purvis' scans of the 803 ALGOL Library Program A104 reference manual.
Source Code | samples/algol/hello.algol |
This is a very simple ALGOL "hello world" program. It just prints a short message to the output teletype.
The source code for this program uses only characters from the
standard Elliott telecode character set, so it looks exactly like a
genuine 803 ALGOL program, with the slight exception that it uses the
# (number sign) in place of the £ (GB pound sign), as the GB pound
sign can cause problems with PC character encodings.
Note that it is all in uppercase and has apostrophes (rather than semicolons)
as statement separators and uses the # and ? characters as string quotes.
The PUNCH(3)
command on the PRINT
statement directs
the output to the teletype (rather than a tape punch which would otherwise
be the default).
Source Code | samples/algol/trig.algol |
This program prints out a table of sine and cosine values for some angles between 0 and 360 degrees.
The source code for the program makes use of the extended mapping from Java system characters to telecode characters provided by the simulator to provide better looking source code. In particular both upper- and lowercase characters can be used (though they are treated identically), semicolons can be used as statement separators (rather than apostrophes) and square brackets can be used for array subscripts. The code also uses the number sign (#) instead of the GB pound sign (£) for the open string quote, for easier use on non UK keyboards.
Source Code | samples/algol/sort.algol |
This program creates a array of small random integers then sorts them into ascending order using the recursive Quicksort algorithm.
The source code for the program also makes use of the extended mapping from Java system characters to telecode characters provided by the simulator to provide better looking source code.
A few comments on the code:
Line 17: | This procedure declaration uses the somewhat odd and obscure
"long comma" that was unique to ALGOL 60.
In a procedure declaration or procedure call the sequence of characters
")<any chars>: ( " is syntactically
equivalent to a comma! |
Lines 21 and 57: | All labels have to be declared on a SWITCH statement. |
Lines 28 and 29: | ALGOL 60 does not have a "while" loop as such, only a WHILE
clause on the FOR loop.
These two lines really only want the WHILE part but have to include
a redundant FOR I:=0 control variable part of the statement. |
Line 51: | A rather pointless function procedure definition, but it does demonstrate some aspects of the language, such as assigning the function result to the procedure name. |
Line 53: | This statement reads two integer values from the tape reader.
The actual values to be read are appended to the source code tape after
the final END .
It is assumed the tape will be left in the reader after the source code
has been compiled.
When reading integer values the compiler will simply skip any non digit
characters it encounters, so you can add comments to indicate what the
numbers mean, as has been done here. |
Line 60: | The PUNCH(3) statement directs all output to the teletype. |
Lines 63 to 67: | These lines use the simulator's random number
device to generate some random numbers (between 0 and 511).
The ELLIOTT(...) statement inserts a single line of machine
code, in this case it reads the random number generator to the accumulator
and ANDs the value with 511 (i.e. 9 bits) to create the result.
The real Elliott 803 did not have a random number generator. |
Lines 80 and 81: | These are the data values for the program that are read by the
READ statement on line 53.
There are two sets of values, so the program can be run again to see
some slightly different output. |
Various places: | There are a number of semicolons before after some of the END
statements that are strictly speaking unnecessary, but I prefer to always
put them in as they are harmless and result in less errors when the program
is later changed! |
The QuickSort program is a particularly nice example, since the Quicksort algorithm was invented by Tony Hoare and it was the same Tony Hoare who was responsible for much of the implementation of the Elliott 803 ALGOL compiler.
Source Code | samples/algol/sortacm.algol |
This is a variation on the previous Quicksort program but it is coded using the exact algorithms originally published in the Communications of the ACM, Volume 4, Issue 7 from July 1961. These algorithms (number 63 "Partition" and number 64 "Quicksort" from page 321) were published as ALGOL 60 programs, so have simply been copied from the original journal (and re-formatted a little to help with readability).
In addtion this one is written using only Elliott telecode characters, so looks exactly as an original 803 ALGOL source program would look.
Source Code | samples/algol/plot.algol |
This program demonstrates a simple use of the graph plotter to draw approximate sine and cosine functions. The mechanism used to draw lines on the plotter is deliberately done in a very simple manner, but it seems perfectly adequate for this application.
The ELLIOTT()
statements are used to insert specific
machine code instructions to drive the plotter.
The plotter had paper that was 11 inches wide and a pen that could be
moved in steps of 1/100 inch in any of 8 directions using special machine
instructions:
72 7184
Raise the pen 72 7200
Lower the pen 72 7169
Move one step EAST 72 7170
Move one step WEST 72 7172
Move one step NORTH 72 7176
Move one step SOUTH 72 7173
Move one step NORTH-EAST 72 7174
Move one step NORTH-WEST 72 7177
Move one step SOUTH-EAST 72 7178
Move one step SOUTH-WEST
The Elliott ALGOL compiler included a pre-compiled Plotter Package that would normally be used to drive the plotter. This provided a set of procedures that could be used to set the origin, scale output, draw lines and various other options - including directing the output of PRINT statements to the plotter to add text and labels to graphs. The sample program however does not use the plotter package, mostly because I simply can't remember exactly how it all worked!
Note that the plotFn() procedure in this sample exploits the ALGOL 60 parameter convention of call by name and makes use of a technique known as Jensen's Device to provide the function whose output is to be plotted.
These are some rather more complex example ALGOL programs that have been kindly contributed by Bob Firth. Both these programs do a lot of intensive calculation and both will run very much faster if the CPU and Core Store windows are minimized and the Real time option is deselected.
Source Code | samples/extra/factorial4.algol |
This will calculate factorials of large integers (e.g. 1000!). The value to be calculated should be provided on a tape placed into reader 2.
Source Code | samples/extra/pi4.algol |
This will calculate the value of PI to many decimal places (e.g. 1000). The number of places required should be provided on a tape placed into reader 2.
Tim Baldwin December 2013 tjb803@tinymail.co.uk |
Return to index
© Tim Baldwin 2009,2013 |