Computing: DOS, OS/2 & Windows Programming

ALGOL 60 and ALGOL 68 programming on DOS.

ALGOL (short for "Algorithmic Language") is a family of imperative computer programming languages originally developed in 1958. ALGOL heavily influenced many other languages and was the standard method for algorithm description used by the Association for Computing Machinery (ACM) in textbooks and academic sources for more than thirty years. In the sense that the syntax of most modern languages is "Algol-like", it was arguably the most influential of the four high-level programming languages of its time (FORTRAN, Lisp, COBOL, ALGOL). It was designed to avoid some of the perceived problems with FORTRAN and eventually gave rise to many other programming languages, including PL/I, Simula, Pascal, and C. ALGOL introduced code blocks and the begin...end pairs for delimiting them. It was also the first language implementing nested function definitions with lexical scope. Moreover, it was the first programming language which gave detailed attention to formal language definition and through the Algol 60 Report introduced the Backus–Naur form, a principal formal grammar notation for language design (for further details, please have a look at the ALGOL article in Wikipedia).

There were three major specifications, named after the years they were first published:

Note: ALGOL 68 is substantially different from ALGOL 60 and was not well received, so in general "ALGOL" means ALGOL 60 and its dialects.

This tutorial is about installing and running an ALGOL 60 and an ALGOL 68 system, in other word about creating and executing ALGOL 60 and ALGOL 68 programs, on DOS. I actually installed the software on MS-DOS 6.22, but I'm quite sure that it should install and run correctly on other DOS distributions, in particular on FreeDOS, too. Both development environments are console based; if you are seriously interested in ALGOL and would like to develop your programs using an IDE, SET's Editor would probably be a good choice. Thanks to its sLisp macros, you can make it do more or less anything you want and add a corresponding item to the program's menu (cf. my Installing and running FreeBASIC on FreeDOS tutorial for details).

ALGOL 60 programming on DOS.

The RHA (Minisystems) Ltd Algol-60 system began life in the early 1970s and was sold until the mid 1980s. It had been implemented (among others) for the Zilog Z80 to run under CP/M (in which the maximum memory available was 64Kb including all the operating system). As soon as 16 bit processors became available, it was implemented on the Intel 8086/8088, to run under both CP/M86 and MS-DOS.

The Algol60 components distributed in Algol60.zip are Copyright by RHA (Minisystems) Ltd, but permission is granted free for personal use. For any other use, including educational, please ask RHA (Minisystems) Ltd. first.

The RHA (Minisystems) Ltd Algol-60 system can be downloaded as algol60.zip from the Algol60 compiler and interpreter page of the Angelfire website.

You can unzip the downloaded archive on Windows and put the extracted files onto a floppy diskette. Supposing that the files on the floppy are in a directory called ALGOL60, run the following commands on your DOS machine to copy them onto your harddisk (directory C:\ALGOL60):
    mkdir c:\algol60
    cd \algol60
    a:
    cd algol60
    copy *.* c:
where the first command creates the harddisk directory, the second one sets the actual directory on drive C: to this newly created directory, the third and fourth ones sets the current directory to the directory on the diskette where the ALGOL 60 files are located, and the last one copies all these files to the C:\ALGOL60 directory.

The screenshot below shows the content of C:\ALGOL60.

ALGOL 60 on MS-DOS: Files of the RHA (Minisystems) Ltd Algol-60 system

As I said above, there is no programming editor or IDE included with the ALGOL installation files. But, source code is text, so you can use EDIT.COM, included with MS-DOS, to read and write ALGOL 60 source files. Note that these files should have the extension .ALG. The screenshot shows the file MMIND.ALG (included with the software), opened in the MS-DOS 6.22 editor. It's a simple Mastermind game, where the player sets the combination and the computer has to find it. At program start you'll be asked if you want to play version 1 or 2. The difference is that version 2 allows to leave some slot(s) empty.

ALGOL 60 on MS-DOS: ALGOL 60 source file opened in MS-DOS 6.22 editor

ALGOL works similar to Java in the sense that the sources are passed to a compiler, that produces byte code that is ready to be read by a virtual machine (an interpreter) that interprets and executes the byte code. The compiler included with the RHA (Minisystems) Ltd Algol-60 system is called ALGOL.EXE. Here some basic ways to invoke it:
    ALGOL outputfile-name=inputfile-name
    ALGOL outputfile-name=inputfile1-name, inputfile2-name, ...
    ALGOL outputfile-name,monitorfile-name=inputfile-name

The first of these commands reads the sourcefile with name inputfile-name.ALG and creates an object file with name outputfile-name. According to the compiler documentation, this object file name should have the extension .ASC. However, on my MS-DOS 6.22, the result of the compilation was a .OBJ file (see further down in the text).

The second command reads the sourcefiles with names outputfile1-name.ALG, outputfile2-name.ALG, ... in turn and produces the output file outputfile-name.OBJ. Typically the input files would consist of groups of commonly required procedures, ending with the file containing the program. It should be noted that the overall source should correspond to the required Algol block structure, from the first BEGIN to the final corresponding END and FINISH.

The third command specifies the name of the file, where the compiler messages should be written to. This is important during the test phase of your program: you can simply open this file (a text file) to view the compiler error messages. This option can also be used to display details about the compilation onto the console; just use CON as monitorfile-name.

The screenshots below show the compiler output when running ALGOL MASMIND=MMIND (screenshot on the left) and the final part of the compiler output when running ALGOL MASMIND,CON=MMIND (screenshot on the right).

ALGOL 60 on MS-DOS: Compiler output (successful compilation)
ALGOL 60 on MS-DOS: Detailed compiler output (successful compilation)

In both cases the compilation, using MMIND.ALG as input, and creating MASMIND.OBJ as output, was successful.

As I said above, the output of the compiler is not intended to be directly run by the operating system, but by an ALGOL 60 interpreter. The interpreter included with the RHA (Minisystems) Ltd Algol-60 system is called ARUN.EXE. To run an ALGOL 60 program, enter the command:
    ARUN programfile-name
where programfile is an output file of the ALGOL 60 compiler, or the ALGOL 60 linker (cf. further down in the text). The extension of programfile is supposed to be .ASC.

No idea, why the compiler produces a .OBJ (and not a .ASC) file. Anyway: 1. the .OBJ file may be "transformed" into a .ASC file, using the linker; 2. the .OBJ file may be used as input for the virtual machine that interprets its content, the only thing, that you'll have to do is to manually add the .OBJ extension to the filename.

The screenshot below shows the file MASMIND.OBJ produced by our compilation and the trial to run it. The command ARUN MASMIND results in the display of "INPUT=" by the interpreter. Awaiting the file MASMIND.ASC and this file not being there, the interpreter asks for the name of the file to be run. Entering "MASMIND.OBJ", the mastermind game startup succeeds.

ALGOL 60 on MS-DOS: Running an ALGOL 60 program

The object file produced by the compiler doesn't normally need to be be linked. In the case where it calls procedures that are external to the program, i.e. located in a library file that has been compiled apart from the main program sources, linkage is, of course, required. The linker included with the RHA (Minisystems) Ltd Algol-60 system is called ALINK.EXE. It can be invoked by the command:
    ALINK programfile-name=mainprogram-name[N], library1-name, library2-name, ...
where mainprogram, library1 and library2 are object files produced by the compiler (normally .ASC files; in our case .OBJ files). The linker option "N" means that there shouldn't be any identifier tables created.

As said before, the MASMIND.OBJ file is correctly executed by ARUN. I actually used ALINK to "transform" it to a .ASC file by running the command ALINK MASMIND=MASMIND.OBJ. This command means that the binary code MASMIND.OBJ is linked into a relocated executable called MASMIND.ASC (.ASC being the default extension of both the linker's input and output files). The result is shown on the screenshot on the left. I suppose that, "Unresolved labels" being followed by an empty list means that all has gone well. I don't know, why the linker asks for further files. Maybe, because I used it with a single file (main program without libraries)? Or, because there is no .ASC input file? No idea. I just entered CTRL+C to terminate the linker. MASMIND.ASC was created and worked well with ARUN. The screenshot on the right shows the different files, that I created during the build of MASMIND: MASMIND.ASC is the executable produced by the linker; MASMIND.OBJ is the object file (also executable) produced by the compiler; MASMIND.MON is a monitor file created by the compiler, invoked with the command ALGOL MASMIND,MASMIND=MMIND.

ALGOL 60 on MS-DOS: Linking a .OBJ file
ALGOL 60 on MS-DOS: Files produced by the compiler and the linker

For further details concerning ALGOL.EXE, ALINK.EXE and ARUN.EXE, cf. the algol60.txt file included in the download archive.

And, to terminate the ALGOL 60 part of the tutorial, here a screenshot of the execution of the Mastermind game, that we used as example in the preceding paragraphs.

ALGOL 60 on MS-DOS: Running an ALGOL 60 Mastermind game program

ALGOL 68 programming on DOS.

The MK 2 Algol 68 compiler from Algol Applications Ltd / Orthogonal Software produces an intermediate code, called Acode which is interpreted by a highly portable run time system (the compiler runs, among others, on Intel 80x86, i386 Protected mode). The Acode system is designed to be consistent across all platforms, and thus even on the 16-bit segmented architecture of the 8086, users of the Acode system have 32-bit arithmetic and no limits on the size of arrays apart from simple memory size (no 64k segment limit). The software requires a 386-based computer running MS-DOS 2.0 or later, preferably with the 4DOS command shell. A 387 is not assumed, but the run-time system will take advantage of one, if present.

The MK 2 Algol 68 compiler is not public domain, but may be used free of charge and without registering for personal use. It may be downloaded using a direct link on the algol68.org website.

You can unzip the download archive on Windows and use a floppy diskette to transfer the extracted files to your DOS machine. Here, copy the whole to some directory, for example C:\ALGOL68. With the files supposed being in the A68MK2 directory on the diskette, do the following:
    mkdir c:\algol68
    cd \algol68
    a:
    cd a68mk2
    copy *.* c:
    cd stdlib
    mkdir c:\algol68\stdlib
    copy *.* c:\algol68\stdlib

The screenshot shows the files of the MK 2 Algol 68 system after I had copied them to the harddisk on my MS-DOS 6.22.

ALGOL 68 on MS-DOS: Files included with the 'MK 2 Algol 68 system' distribution

The ALGOL68 source can be viewed and edited using the DOS editor EDIT.COM. Note that ALGOL 68 source files should have the extension .A68. The screenshot shows the file HELLO.A68 (included with the software), opened in the MS-DOS 6.22 editor.

ALGOL 68 on MS-DOS: ALGOL 68 source file opened in MS-DOS 6.22 editor

How to use the MK 2 Algol 68 system? The ALGOL 68 source (file extension .A68) is compiled and linked into an Acode binary (file extension .ACO), that will be interpreted and executed by the Algol 68 virtual machine. The compiler (plus linker) included with the software is called COMPILE.ACO. Looking at the file extension, you can see that this is not a DOS executable, but an Acode binary. This means that we'll have to run it using the virtual machine, actually called LOAD32.EXE. As this is a 32-bit application, it will not run in the normal MS-DOS shell (COMMAND.COM), but we'll have to use 4DOS. Beside the possibility to start MS-DOS with this shell (replacing COMMAND.COM), we can launch 4DOS each time that we want to run LOAD32.EXE. No need to install any supplemental software; the download ZIP includes the a 4DOS runtime environment; the filename is DOS4GW.EXE.

So, to compile the program file-name.a68 and linking it together with the standard libraries and some custom library located in the directory C:\ALGOL68\MYLIB, we could use the command
    DOS4GW LOAD32 COMPILE file-name /LIBS="STDLIB;MYLIB"
that would produce the Acode file file-name.ACO.

A simpler way to include libraries is to set the environment variable A68LIB (here for the standard library included with the download archive):
    SET A68LIB=STDLIB

We can further simplify the procedure by creating batch files (in fact, these files are included with in the download archive). First a file called START.BAT, to be executed once in order to initialize the ALGOL 68 environment. Besides setting the A68LIB environment variable, this file should also define the options for the compilation (cf. program documentation for details). Content of START.BAT:
    @ECHO OFF
    SET A68LIB=STDLIB
    SET A68OPT=SEG;MSDOS;A32;S

Second, a file called COMPILE.BAT to compile and link an ALGOL 68 source file. Content:
    @ECHO OFF
    DOS4GW LOAD32 COMPILE.ACO %1 %2 %3 %4 %5 %6 %7 %8 %9

This done, compiling the program file-name.a68 and linking it together with the standard libraries can be done by simply running the command:
    COMPILE file-name

To note that we can specify additional parameters (such as defining a custom library) on the command line (command line parameters always overwriting environment variable settings).

The screenshot on the left shows how I initialized my ALGOL 68 system using START.BAT and then launched the compiler to build the ALGOL 68 source file HELLO.A68. The screenshot on the right shows how the DOS/4GW is loaded and via LOAD32 runs the compiler, that by default outputs the details that the ALGOL 60 compiler, described above, only displays if we specify the console as monitor file.

ALGOL 68 on MS-DOS: Initializing the environment and building an ALGOL 68 source file [1]
ALGOL 68 on MS-DOS: Initializing the environment and building an ALGOL 68 source file [2]

The Acode file produced (HELLO.ACO) can be run using LOAD32.EXE (executed using DOS4GW.EXE). Here again, we can make things easier by creating a batch file called RUN.EXE. Content of this file:
    @ECHO OFF
    DOS4GW LOAD32 %1.ACO %2 %3 %4 %5 %6 %7 %8 %9

The screenshots show the files that have been produced by the compilation above (screenshot on the left) and the execution of our "Hello World" program (screenshot on the right).

ALGOL 68 on MS-DOS: Files produced by the MK 2 Algol 68 compiler
ALGOL 68 on MS-DOS: Running an ALGOL 68 program

You can find lots of ALGOL books and program examples on the Internet. However, don't be surprised if the compilation ends with lots of error messages! In fact, there are several Algol dialects and a program having a correct syntax with one of them, may not work correctly with another. One thing that I think to have found out is that with the MK 2 Algol 68 compiler, all variables have to be declared, what seems not always be done in lots of the program examples available.

To terminate the tutorial, a little customization of START.BAT and COMPILE.BAT in order not to have to initialize the ALGOL 68 environment manually, but to automatically launch START.BAT from COMPILE.BAT if the initialization hasn't yet been done.

New COMPILE.BAT content:
    @ECHO OFF
    IF NOT "%A68INIT%"=="true" CALL START.BAT
    DOS4GW LOAD32 COMPILE.ACO %1 %2 %3 %4 %5 %6 %7 %8 %9

And new START.BAT content:
    @ECHO OFF
    SET A68INIT=true
    SET A68LIB=STDLIB
    SET A68OPT=SEG;MSDOS;A32;S


If you find this text helpful, please, support me and this website by signing my guestbook.