KDF9 Programming Languages
We have surviving copies of two KDF9 Algol compilers,
viz: Whetstone Algol and Kidsgrove Algol,
and two assemblers
viz: KDF9 Usercode and KAL4.
The character represntation on KDF9 differs from (pre-dates?) the now ubiquitous ASCII/ISO.
All these compilers take input in Algol Basic Symbols as described here.
KDF9 Algol
KDF9 Algol is of course Algol 60.
The two surviving implementations were produced at English Electric’s
eponymous establishments at Whetstone and Kidsgrove.
The Whetstone system processed Algol programs held on paper tape
in a load-and-go manner.
The Kidsgrove system was embedded in the POST filing system which operated
entirely on magnetic tape, and stored program text in Algol Basic Symbols.
The compiler produced a binary program in a file, for future execution.
There is a facility for running Paper Tape Whetstone Algol
here.
There is a β-version of a facility for running the Kidsgrove compiler
here.
Note: The only I/O routines that work are open(20), close(20), open(30), close(30), writetext(30, ...), output(30, ...) and read(20).
You can type your own Algol 60 program into the text area provided, or create a file and upload it.
Please do not try any lengthy computation.
It is only a very tiny computer that runs this
as was KDF9 by today’s standards.
KDF9 Usercode
Usercode is the language in which most KDF9 software was written,
including both the above Algol 60 implementations.
It is basically an assembly language in that each machine code instruction
in a program is represented by a Usercode mnemonic.
The original manufacturer’s manual is
here.
The manual was extensively revised and republished in 1969 and is available
on bitsavers.
This almost certainly post dates our version of the code.
There is a β-version of a facility for running Usercode programs
here.
The web page still needs improvement, but the Usercode Compiler works.
The two Algol systems survived as lineprinter listings of KDF9 Usercode.
As a prerequisite to rescuing them, it was necessary to produce
a Usercode assembler.
This gives a rather more detailed listing than the original software, and
it is available as an option in the above facility.
The original software (KAA01PT) survived as a listiing in the Science Museum archive,
and is clearly not the final version as it has a bug which the released system
definitely did not have.
We have original manufacturer’s manual pages.
This software is the paper tape version, and has size limitations.
There was another Usercode assembler (KAB84) which ran in the magnetic tape filing system
called POST.
Although it formed part of the Kidsgrove Algol system it has not survived (see below).
KAL4 − KDF9 Assembly Language number 4
This assembly language was developed by John Thomason as an MSc project at Leeds University.
It became a staple part of the Eldon2 system at Leeds.
The Leeds FORTRAN compiler was written in KAL4 and generated code into KAL4.
We have the definitive version from the author.
It reads the source code from an Eldon2 file, and is written in KAL4.
The user manual is here.
There is an α-version of a facility for running KAL4 programs
here.
As a prerequisite to rescuing KAL4, it was necessary to produce
a new KAL4 assembler.
This is also available as an option in the above system, and produces a more
detailed listing than the orignal, although it is not capable
of processing some of KAL4’s for creating constants.
Structure of Whetstone Algol
The structure of the Whetstone Algol system has a pair of overlays.
Firstly, a translator which reads the Algol 60 source code and generates
an intermediate code in much the same way as Java does, or Pascal's P-code.
The program is then run by calling in the other overlay (called controller)
which then executes the user's program by interpreting the intermediate code.
There are links to listings of the two overlays below.
There is good reason to believe that this is a released version of the system
that went into general use.
The system that we have here operated from paper tape.
There was another system that operated within the POST
system, and unlike the paper tape system, included the facility
for procedure bodies written in Usercode.
In 1966±1 this facility was added to the paper tape system at Oxford University,
but unfortunately this version of the system has not survived.
Structure of Kidsgrove Algol
The surviving listing of Kidsgrove Algol (Kalgol) is incomplete,
and almost certainly not a final version.
This listing was printed in Australia and somehow
made its way to Bill Waite in Colorado,
where it was scanned and PDF files transferred over the net to a laptop in the Yorkshire Dales.
The structure of the system has a series of overlays called bricks, and a memory resident I/O module called PANACEA (KAB00).
Compilation proceeds from brick 01 (KAB01)
through to brick 60 (KAB60) which outputs
Usercode to be read by brick 84.
The main compiler listing only lacked brick 20, of which a hand-written version was discovered in the Science Museum.
David Huxtable has turned this into an approximation to the original.
In fact the whole thing is an approximation, as it has become abundantly clear that what we have cannot
possibly be the final released version, because we have found several bugs that we know to have been absent
from the production version.
However, we can compile lots of Algol programs, especially if we avoid using the optimiser.
Although the memory resident KAB00 was among the survivors, its initialisation required
a KAB80 which did not survive, and without which it seems impossible to understand KAB00.
Consequently a new PANACEA (KAB00) has
been implemented.
Another absentee from the surviving listings is the Usercode compiler (brick 84 − KAB84).
This is unfortunate as the output from the compiler is in Usercode.
However, a listing of the Paper Tape Usercode Compiter
(KAA01)
was found in the science Museum.
A new brick 84
(KAB84)
converts the Algol Basic Symbols output by the compiler into
paper tape code and feeds it to KAA01.
Brick 01 (KAB01) takes its input in
Algol Basic Symbol code on a POST format magnetic tape.
The user's Algol 60 program in an ASCII file is converted to an octal dump of
the POST format tape.
This is then read as emulated paper tape by a new brick 81
(KAB81)
which then passes control to the true brick 01.
The new bricks
KAB81, KAB84 and KAB00 are written in the
Leeds University assembly language KAL4.
On the real system the memory resident KAB00 fetched the overlays and other material
from a system tape.
Our newly written KAB00 reproduces this behaviour so the compiler consists of
only 2 files, KAB00.bin and the system tape.
You can download a demo of Kidsgrove Algol
here
which you can run on your own computer.
All you need is a C compiler, and it has run on a whole varity of machines.
Source code listings
There are listings of the original source files produced by modern assemblers.
The left-hand side shows the machine code, and the source code is shown as it would have appeared
on a KDF9 Flexowriter, and with hot links to subroutines.
There are also hot links to the images of the pages of the original listing,
except for the listings of the Kidsgrove compiler which were delivered as PDF files,
as is explained here.
KAA01 Paper Tape Usercode Compiler
EDNKAL4 The KAL4 assembler
KMW02 The Whetstone Algol translator
KMW03 The Whetstone Algol run time system
KAB01 Brick 01 Kalgol Set Up Declaration List etc.
KAB02 Brick 02 Kalgol Update Codes
KAB20 Brick 20 Kalgol Procedure Classification
KAB22 Brick 22 Kalgol Storage Allocation
KAB24 Brick 24 Kalgol Print Level Parameters
KAB40 Brick 40 Kalgol Brick 40 Interim
KAB41 Brick 41 Kalgol For Statement + subscript optimization
KAB42 Brick 42 Kalgol Tidy Up after optimizer
KAB45 Brick 45 Kalgol For Statement Conversion
KAB46 Brick 46 Kalgol optimizing For stmt converter
KAB60 Brick 60 Kalgol Translator -- i.e. code generator
KAB95 Brick 95 Kalgol Terminating + Post Mortem Brick
KAB99 Brick 99 Kalgol Terminating Brick
All the above Kalgol bricks are from the Australian listing, except KAB20 which was missing from the original
(see above);
Also missing was KAB84, the brick that translated the usercode generated by brick 60
into a binary program.
We have been able to make a near equivalent from the Paper Tape Usercode Compiler (KAA01)
which also survived in the Science Museum archives.
KAB84 Brick 84 − new code converting the Compiler output to paper tape code,
and calling the Usercode Paper Tape Compiler.
KAB81 Brick 81 − new code copying the output from mkchan.c to a POST-format mag tape
KAB00 PANACEA − new code implementing the functionality of the original memory resident module.
The Kidsgrove compiler system is not complete without the run-time library
routines.
Owing to a quirk of the EE implementation, we came across a listing of the greater
part of the standard functions and I/O libraries in a listing of a user
program, referred to below as KQX.
Although the libraries are still somewhat volatile, here is the state of play as at June 2020.
-
A0 - standard functions -- derived from KQX with a bit of input from walgol
-
A1 - open and close. includes my version of P295
which interprets all input as stream 20, and all output as stream 30
-
A4 - read and read boolean -- genuine EE code from KQX
but read boolean is unlikely to work with my cut down P295 in A1
-
A5 - write, output, format, write boolean
-
A6 - a combination of A1, A4, A5, A15 for convenience (though not A14)
-
A12 - newline, space, tab gap - genuine EE code from KQX
-
A13 - character I/O and ABS I/O - genuine EE code from KQX
-
A14 - copy text - genuine EE code from KQX
-
A15 - write text - calls P288 which is a Holdsworth special
The above libraries are our best effort at rescuing genuine code, and adding
in new bits to make it all work.
There are also libraries which have been written in the development process:
-
A1?? - special versions used diagnostically, comment at the head of each
-
A106 - This minimal I/O facility is a very simple A6 substitute
working on KDF9 characters and pre-dates our extraction of the libraries from KQX.
-
A104 - a rudimentary read(20)
-
A105 - Genuine library A5 taken from KQX, but with P291 from Walgol
-
A114 - interim A14
The listings were processed by a mixture of OCR and human eyes.