Burroughs MCP: Algol 60 Programming

Let's look at programming using the Algol 60 implementation under time-sharing on Burroughs MCP.

/images/mcp/mcp-algol-syntax-chart.png Algol 60 Syntactical Chart. Burroughs Corporation, 1961. Source: softwarepreservation.org.

MCP had several Algol implementations: the main one which we will consider here is called Extended Algol and according to the manual:

In addition to implementing virtually all of ALGOL 60, Extended ALGOL provides for communication between the processor and input/output devices, enabling editing of data, and facilitates program debugging.

There was also Compatible Algol which

represents a subset of B 6500 Extended ALGOL and should be useful for facilitating conversion to a B 6500 System. This language is intended to be used where character mode manipulation is required without jeopardising the integrity of the operating system or other multiprocessing programs

which makes Extended Algol sound dangerous, but I think this refers to stream processors which were rather difficult to use; see the article The Agony and the Ecstasy of Stream Procedures on the retro-b5500 project blog.

Beyond that there was ESPOL - Executive System Problem Orientated language - for programming MCP itself, and TSPOL which had some extensions for building time-sharing code. We will only look at Extended Algol here, but it would be an interesting project to find all the differences.

To show how to use Extended Algol we will as always work on an implementation of the TPK algorithm.

TPK in Extended Algol

100 BEGIN
110     COMMENT TPK ALGORITHM IN ALGOL 60;
120 
130     REAL PROCEDURE FN(X);
140     VALUE X;
150     REAL X;
160     BEGIN
170         FN := SQRT(ABS(X)) + 5 TIMES X * 3
180     END;
190 
200     COMMENT MAIN PROGRAM;
210     INTEGER N, J;
220     REAL ARRAY A[1:11];
230     FILE OUT DCO 19 (1, 10);
240     FILE IN DCI 19 (1, 10);
250     FORMAT NUM(R11.4);
260     FORMAT PROMPT("PLEASE ENTER 11 NUMBERS");
270     FORMAT RESULTS("RESULTS ARE");
280     WRITE(DCO, PROMPT);
290     N := 11;
300     FOR J := 1 STEP 1 UNTIL N DO
310         READ(DCI, NUM, A[J]);
320     WRITE(DCO, RESULTS);
330     FOR J := N STEP -1 UNTIL 1 DO
340     BEGIN
350         REAL RESULT;
360         FORMAT TOOLARGE("TOO LARGE");
370         RESULT := FN(A[J]);
380         IF RESULT GTR 400.0 THEN
390             WRITE(DCO, TOOLARGE)
400         ELSE
410             WRITE(DCO, NUM, RESULT);
420     END;
430 END.

The line numbers are for entry on CANDE and are not used by the program itself. Keywords like INTEGER are reserved and do not need to be quoted.

On line 170, FN := SQRT(ABS(X)) + 5 TIMES X * 3, note that the multiplication operator is the Algol glyph × but we can't type that so we use the text equivalent TIMES. * here is the exponentiation operator. Similarly on line 380 we use GTR to stand in for >.

I/O is not a part of Algol so each implementation does its own thing. Burroughs did it as follows:

  • FILE introduces an I/O channel. The 19 refers to the device, here the data terminal. Other devices are listed on p105 of the manual. The (1,10) refers to the buffer size used. Note that input and output each needs a separate FILE variable. FILE declarations are block-scoped, so here the devices are closed automatically at the program END.
  • FORMAT works like in Fortran to define how input should be parsed and output presented. We use it here for real numbers (NUM) and some string constants (eg PROMPT).
  • READ and WRITE do the actual I/O, taking the file, format and data as their parameters.

On line 390, I originally had WRITE(DCO, TOOLARGE); ie with a semi-colon on the end. This was correctly raised as a syntax error by the compiler as this is not an end of statement situation as the IF clause extends to the ELSE on the next line. The Dartmouth Algol compiler allowed this.

Apart from this, the rest of the implementation works the same way as standard Algol.

When executing this you need to enter numbers in floating point, eg 1.0 instead of 1.

The code and execution transcript for this can be found on Github.

Other extensions to Algol

The manual is rather terse, as it is intended as a reference rather than a tutorial, and also does not list in a single place what extensions have been added. However, the text follows the format of the Revised Report on the Algorithmic Language Algol and when each part of the language is introduced in Backus-Naur form it prefaces each of them with a tag:

  • 1 means this is the same as the standard
  • 2 means this has differences
  • 3 means this is new syntax

So this is not a comprehensive list, but some of the interesting extensions I noted while reading the manual:

  • Conditional expressions: K := (IF J = 0 THEN 0 ELSE 1 / J);.
  • Fill an array: REAL ARRAY A[1:11]; FILL A WITH 42;
  • ZIP to run an external program in the background: ZIP("HELLO ", "RUPERT "); would run the hello world example we did earlier.
  • TIME(0) gets the current date.
  • WHEN(5) pause for 5s
  • Can recover from errors eg divide-by-zero via testing flags
  • A CASE statement

Further information

See the reference manual from 1969 on bitsavers. The other Algol material noted on the Dartmouth DTSS article may also be useful.

Questions, corrections, comments

I welcome any questions or comments, and also especially any corrections if I have got something wrong. Please email me at rupert@timereshared.com and I will add it here and update the main text.