-
Notifications
You must be signed in to change notification settings - Fork 1
UsingBALGOL
The Burroughs Algebraic Compiler for the 220 (BAC-220, or more popularly, "BALGOL") was a variant of the Algol-58 language. It was first released by Burroughs in March 1960 and was actively used through the 1960s, especially at universities and research organizations. Stanford University, Georgia Tech, and Cornell all had 220s and used BALGOL extensively.
This wiki page describes how to use the compiler to compile and run BALGOL programs. It references a number of files in the retro-220 project repository. Unless otherwise specified, all of these files reside under the software/BALGOL/ directory of the repository and its sub-directories.
The compiler was distributed by Burroughs on a magnetic tape, known as the Generator tape. The compiler was accompanied by a Generator program on the tape that would customize the compiler for a given 220 system configuration and generate a magnetic tape from which the compiler could be run. The Generator could also modify and extend the standard set of library functions provided by Burroughs, which were also contained on the Generator tape.
The easiest way to get started using the compiler is to use one of the two pre-built versions of the compiler tape we have created, one with default settings for a 5000-word 220 system, and one with default settings for a 10,000-word 220 system. The tape images are available from the project repository:
No copies of an actual Generator tape are known to exist. The retro-220 project has managed to recover its contents from listings and reconstruct how the tape was organized. A copy of the reconstructed tape in retro-220 tape image format is available as BAC-220-Generator.tape from the project repository.
See the Building the BALGOL Compiler wiki page for more information on the Generator tape, its contents, and how it can be constructed from the compiler source files.
Also see Appendices A and F of Burroughs Algebraic Compiler, Revised Edition, March 1963, Bulletin 220-21017, for information on generating a customized compiler tape from the Generator tape. See the sample card decks BAC-220-Generator-Callout.card and BAC-220-Generator-Callout-10K.card that were used to generate the two compiler tape images above.
The standard BALGOL compiler configuration requires a 220 with at least 5000 words of memory, at least two magnetic tape drives, and a Cardatron punched-card subsystem with at least one card reader (IBM 087/089), card punch (IBM 523), and line printer (IBM 407). The instructions below apply to such a card-based system. Additional information on preparing source programs and operating the compiler are in Appendix B of the compiler manual.
The Generator can customize the compiler to use paper tape instead of cards, and a teletype printer instead of the IBM 407. Instructions for using paper tape are in Appendices A and B of the compiler manual. Instructions for dumping and loading object programs on paper tape are included in the sections below.
A Cardatron card reader requires a punch in a specified column of a card to specify the format of the data on the card and how it will be converted into 220 words. The column was determined by plugboard wiring in the card reader. In the retro-220 emulator, that column is specified on the card reader control panel. This wiki page assumes column 1 for all format selection. For details on the punched-card interfaces, see the Using the Cardatron wiki page.
Source code input to the compiler must have the digit "2" in the Cardatron control column. The range of columns in which the source text can appear can be altered by the Generator program, but by default it is columns 2-72. BALGOL statements are free-form within this range of columns. Columns 73-80 may be used for sequencing or identification. Lines in the text file do not need to be 80 columns in width. The emulator internally will pad shorter lines with spaces and truncate longer lines to be 80 columns.
Data cards to be read by a program should follow the FINISH statement in the source text and have the digit "5" in the Cardatron control column. Columns 2-80 are available for holding data values.
Due to the limitations of the IBM punched-card equipment, BALGOL uses a restricted set of characters. Card decks for the retro-220 emulator are created as simple ASCII text files. The set of characters available for composing BALGOL programs is limited to the following:
- Letters A-Z (the emulator will translate lower-case letters to upper case).
- Digits 0-9
- Space character
- Special characters
+ - = ( ) . , $ / *
-
&
is accepted as a substitute for+
-
;
is accepted as a substitute for$
-
#
is accepted as a substitute for=
-
%
is accepted as a substitute for(
-
¤
(the lozenge) is accepted as a substitute for)
The IBM 407 printer could be configured with interchangeable print wheels. Two wheel sets were common:
- Set A (commercial) used glyphs
& # % ¤
- Set F (scientific) used glyphs
+ = ( )
respectively.
The retro-220 emulator will accept either set of characters on input. On output to card punch and line printer devices, the set is determined by the setting of the ALGOL GLYPHS checkbox on the device control panel. Ticking the checkbox selects Set F.
The colon (:) may not be used in source programs. BALGOL uses two adjacent periods (..) instead.
See the compiler manual for details on the syntax and semantics of the language and on the preparation of input card decks. Several sample programs are available from the project repository and are discussed in a section below. The following simple program illustrates the source format; the spaces in column 2 are for readability and are not required.
2 INTEGER DEGREES, MAXDEGREE;
2 REAL RADS, TORADS;
2 REAL VSQRT, VSIN, VCOS, VTAN, VASIN, VACOS, VATAN;
2
2 INPUT PARAM(MAXDEGREE);
2 OUTPUT RESULTS(DEGREES, RADS, VSQRT, VSIN, VCOS, VTAN,
2 VASIN, VACOS, VATAN);
2 FORMAT F(I2,2F14.8,6F15.8,W2),
2 HEAD(* D RADS*,B10,*SQRT*,B11,*SIN*,B12,*COS*,B12,*TAN*,
2 B12,*ASIN*,B11,*ACOS*,B11,*ATAN*,W2);
2
2 TORADS = 3.1415926/180;
2 WRITE(;; HEAD);
2 INPUT(;; PARAM);
2
2 FOR DEGREES = (1, 1, MAXDEGREE);
2 BEGIN
2 RADS = DEGREES.TORADS;
2 VSQRT = SQRT(RADS);
2 VSIN = SIN(RADS);
2 VCOS = COS(RADS);
2 VTAN = TAN(RADS);
2 VASIN = ARCSIN(VSIN);
2 VACOS = ARCCOS(VCOS);
2 VATAN = ARCTAN(VTAN);
2 WRITE(;; RESULTS, F);
2 END;
2 FINISH;
5 89
This section describes how to compile a program under the retro-220 emulator and the options available for executing the compiled object code.
The following procedures assume a retro-220 emulator with the following configuration:
- At least 5000 words of memory.
- At least two tape drives. Unit designations are specified below.
- A Cardatron Reader designated as unit 1, with format selection in column 1.
- A Cardatron Punch designated as unit 1.
- A Cardatron Printer designated as unit 2.
A different configuration and unit assignments may be required, depending on the options specified when the compiler tape was generated.
To compile a BALGOL program using a compiler with a default configuration, do the following:
- Designate a magnetic tape drive as unit 1.
- Load a tape to this unit that has been formatted with 100-word blocks in both lanes. Any existing data on this tape will be overwritten.
- Make the tape writeable and the drive ready.
- For details on using the magnetic tape drive, see the Using Magnetic Tape wiki page.
- Designate another magnetic tape drive as unit 2.
- Load a generated compiler tape image to that unit.
- Make sure that your 220 configuration meets or exceeds the configuration for which the compiler was generated. In particular, the system must have at least as much memory as that for which the compiler has been generated.
- Do not use the Generator tape -- it will not work You must use a compiler tape image that has been generated by the Generator program or one of the pre-built images available from the project repository, e.g., BAC-220-Compiler.tape.
- Make the drive NOT-WRITE and ready.
- On card reader unit 1:
- Load the card deck BAC-220-Compiler-Callout.card. This is a bootstrap program to load the compiler Main program from tape.
- Load the card-image deck of your BALGOL source statements (with 2s in column 1) into card reader unit 1.
- Optionally, load any data cards for the program (with 5s in column 1) after the source cards. Note that the reader will allow you to load more than one file into its "input hopper," so the source program and data may be in multiple files. Alternatively, you can include the data cards in the same file as the source cards, or wait to load the data until after the program has started execution.
- Click the reader's START button to make it ready.
- On the emulator's Control Console window:
- Click the CLEAR switch to clear the system.
- Enter 1000 60 0000 into the C register. This is a card-read instruction for unit 1.
- Click the EXECUTE lamp to set it.
- Click the START switch to begin the compilation.
The callout deck will load the compiler from tape unit 2 and execute it. By default, the compiler will list the source cards on the line printer, double-spaced, as it compiles them. Each line will be prefixed by the memory address at which the object code for that line begins. Any errors detected by the compiler will be listed on the line printer, sometimes just before and sometimes just after the line where the error was detected. The compiler will write the object code to lane 0 on tape unit 1.
When the FINISH statement is encountered, the compiler Main program will load the Overlay program and branch to it. The primary purpose of Overlay is to process any references to Library routines in the program and add those routines to the object code on tape unit 1.
When overlay completes, it will print a summary on the line printer similar to this:
COMPILED PROGRAM ENDS AT 0531
PROGRAM VARIABLES BEGIN AT 1888
The compiler generates object code starting by default at memory address 0200 and continuing to higher addresses. It allocates data areas and Library routines starting at the maximum memory address for which the compiler was generated and continuing downward. The first number in the summary above is the highest address at which object code for the source program was generated. The second number is the lowest address at which data or Library routines were allocated. The difference between those two numbers is the amount of memory the object program does not occupy.
If the compiler detects errors in the source program, an additional line will print following the summary:
-----ERROR(S) WERE FOUND-----
The system will then halt with 0525 00 5250 ("xx") in the C register. Clicking the START switch on the Console at this point will load and attempt to execute the object program in whatever form the compiler produced. Depending on the nature of the errors detected by the compiler, this may or may not be a useful course of action, and is generally not recommended.
If no errors in the program were detected by the compiler, the system will halt with 0757 00 0725 ("OK") in the C register. Simply click the START switch on the Control Console to execute the compiled program.
If the program executes a STOP statement, the system will halt with 0137 00 7310 in the C register and the value of any expression specified for the statement in the A register. If the statement does not include an expression, the value in A is undefined. The program can be resumed after a STOP by clicking the START switch on the Control Console.
If the program executes the FINISH statement, the system will halt with 9669 00 9669 ("XX") in the C register. The program cannot be continued. Clicking START on the Control Console at this point will execute a read on card reader unit 1. The assumption is that this would normally be done to read the callout deck for another compilation or to execute some other program.
The default behavior of the compiler's Main and Overlay programs can be modified by the Program Control Switches (PCS) on the Control Console. Compiling with all switches off produces the double-spaced listing of source statements described in the prior section. Switches are off in the up position and on (set) in the down position. Setting certain switches on will have the following effect:
- PCS 1 -- The object code will be listed for all Library routines included in the program.
- PCS 2 -- The object code generated by the compiler will be listed in line with the source statements.
- PCS 3 -- The object code will be listed for external machine-language programs supplied to the compilation (see Appendix F in the compiler manual).
- PCS 4 -- The default listing of source statements and their object code addresses will be suppressed. Error messages and the source statements associated with the errors will be listed, however. Setting this switch also suppresses the "OK" halt after a successful compilation, and the object program is loaded and executed automatically.
BALGOL supports a set of diagnostic facilities for tracing program flow and dumping selected data elements to the printer. These facilities can be included by the compiler in an object program by means of the MONITOR, DUMP, and TRACE declarations described in Section 10 of the compiler manual.
For a program compiled with these facilities, diagnostic output on the line printer can be controlled at run time by additional PCS settings:
- PCS 7 -- If set, the name of each label within the scope of a diagnostic declaration is listed as it is encountered in the flow of the program.
- PCS 8 -- If set, diagnostic output will be suppressed for all MONITOR declarations, including "minimum monitoring" (i.e., specification of a MONITOR declaration with an empty monitor list).
- PCS 9 -- If set, diagnostic output will be suppressed for TRACE declarations.
- PCS 10 (also known as PCS 0) -- If set, diagnostic output will be suppressed for MONITOR declarations.
As mentioned above, the compiler writes object code to the magnetic tape on unit 1. If you choose to execute the object program immediately by clicking START after the "OK" halt, the Overlay module simply bootstraps the program from that tape and branches to its entry point.
If you want to save the object code from a compilation and execute it later, the following sections described how to do that. Note, however, that a common practice at 220 installations was not to save the object code, but to simply recompile from source and execute it when needed. The BALGOL compiler was fast enough that recompiling was often faster than reloading an object program from cards or paper tape.
The simplest way to save the object code for a program and execute it later is to unload the tape image from unit 1 and save it as a file on your local workstation. You can then remount that tape image on a magnetic tape drive designated as unit 1 and bootstrap it as follows:
- Load the card deck BAC-220-Object-Program-Callout.card to card reader unit 1 and make the reader ready. This is a bootstrap program for object code on tape.
- If the program requires data cards, load them to the card reader after the callout program.
- On the Control Console, clear the system, enter 1000 60 0000 into the C register, click the EXECUTE lamp to set it, and click the START switch.
- The callout program will load the object program and execute it.
An object card deck can be generated immediately after compilation, or from an object tape image that has been saved and remounted:
- The object tape for the program must be on magnetic tape unit 1 and the unit made ready.
- Load the compiler tape on magnetic tape unit 2 and make it ready.
- Load the card deck BAC-220-Object-Dump-Callout.card to card reader unit 1 and make the reader ready. This is a bootstrap for the compiler's Object Dump program.
- Make sure that PCS 3 and 4 are OFF.
- On the Control Console, clear the system, enter 1000 60 0000 into the C register, click the EXECUTE lamp to set it, and click the START switch.
- The callout program will load the Object Dump program from the compiler tape and execute it. The object deck will be generated on card punch unit 1.
- When the dump completes, the program will stop with 0757 00 7250 ("OK") in the C register.
- Unload the object deck from the punch and save it as a file on your local workstation.
Loading and executing an object card deck requires the Object Program Loader program. This program is on the compiler tape. There are two ways to use it.
The first way to use the Object Program Loader for object programs on cards is to load and execute it directly from the compiler tape:
- Load the compiler tape to magnetic tape unit 2 and make it ready.
- Load the card deck BAC-220-Object-Program-Card-Loader-Callout.card into card reader unit 1. This is a bootstrap that will load the Object Program Loader from the tape.
- Note that there must be a "blank" card after the callout deck and before the object deck for the program. The card must have a "6" in column one; the rest of the card is ignored. The purpose of this card is to allow the Object Program Loader to load the Cardatron format bands before reading the first card of the object deck. This callout deck has such a card at its end.
- Load the object deck for the program to be executed into card reader 1.
- If the program requires data cards, load them to card reader unit 1 after the object deck.
- Make card reader unit 1 ready.
- Make sure that PCS 3 is OFF.
- On the Control Console, clear the system, enter 1000 60 0000 into the C register, click the EXECUTE lamp to set it, and click the START switch.
- The callout program will space the compiler tape forward to the Object Program Loader and load it to memory. The loader will then load the object deck into memory and begin its execution.
- If checksum errors in the object deck are detected, the loader will halt with 9669 00 9669 ("XX") in the C register. No restart from this condition is possible. You must correct the object deck and try again.
The second way to execute the Object Program Loader for object code on cards is to punch the loader onto cards and then load it from cards before the object deck for the program to be run.
The Object Program Loader can be dumped to cards by setting PCS 4 ON during execution of the Object Dump Program described above. The first 51 cards of the deck that is punched will be the Object Program Loader. The remainder of the cards will be the object deck for the compiled program, just as if PCS 4 had not been on. The Object Program Loader cards have a "6" in column 1; the object code cards for the compiled program have a "1" in column 1. Note that this deck is not directly usable as is -- the loader cards first must be extracted and amended as discussed next.
Prepare a loadable object deck for the Object Program Loader as follows. Such a deck has already been prepared for the default compiler configuration, and is available as BAC-220-Object-Program-Card-Loader.card from the project repository.
- Start with the BAC-220-Object-Program-Loader-Bootstrap.card card deck. This is a bootstrap program that will load and execute the loader program from cards.
- Append to this the 51-card deck for the Object Program Loader generated by the Object Program Dump with PCS 4 on.
- Append to this a "blank" card (one with a "6" in column 1; the rest of the card is ignored).
- Save this combined card deck for later use.
To load and execute an object card deck using the loader on cards:
- Load the combined Object Program Loader deck described immediately above (or the one available from the project repository) to card reader unit 1.
- Load the object program card deck to the reader after the Object Program Loader deck. If the object deck was dumped with PCS 4 set, make sure that it does not still have the cards for the Object Program Loader on the front.
- If the program requires data cards, load them to card reader unit 1 after the object deck.
- Make card reader unit 1 ready.
- Make sure that PCS 3 is OFF.
- On the Control Console, clear the system, enter 1000 60 0000 into the C register, click the EXECUTE lamp to set it, and click the START switch.
- The bootstrap deck will load the Object Program Loader, which in turn will load the compiled object deck and execute it.
The object code for a compiled program can be dumped to paper tape immediately after compilation, or from an object tape image that has been saved and remounted, in a manner similar to that for punched cards:
- The object tape for the program must be on magnetic tape unit 1 and the unit made ready.
- Load the compiler tape on magnetic tape unit 2 and make it ready.
- Load the card deck BAC-220-Object-Dump-Callout.card to card reader unit 1 and make the reader ready. This is the bootstrap for the compiler's Object Dump program.
- Make sure that PCS 3 is ON. This directs the output to paper tape instead of cards.
- If PCS 4 is ON, the Object Program Loader will be punched on the paper tape before the object program. If PCS 4 of OFF, no loader will be included on the tape.
- On the Control Console, clear the system, enter 1000 60 0000 into the C register, click the EXECUTE lamp to set it, and click the START switch.
- The callout program will load the Object Dump program from the compiler tape and execute it. The object code will be generated on paper-tape punch unit 1. A short bootstrap program for the Object Program Loader will be output at the beginning of the tape.
- When the dump completes, the program will stop with 0757 00 7250 ("OK") in the C register.
- Unload the object tape from the paper-tape punch and save it as a file on your local workstation. Make a note whether the tape was created with or without PCS 4 being on. This information will be needed when the tape is to be loaded.
Loading and executing an object program from punched paper tape is similar to loading a program from a card deck. It also requires the Object Program Loader program. The procedure to use depends upon whether the loader was included or not when the paper tape was created.
If the paper tape was created without including the Object Program Loader (i.e., PCS 4 was off), the loader will need to be read from the compiler tape:
- Load the compiler tape to magnetic tape unit 2 and make it ready.
- Load the card deck BAC-220-Object-Program-PaperTape-Loader-Callout.card into card reader unit 1. This is a bootstrap that will load the Object Program Loader from the tape.
- If the program requires data cards, load them to card reader unit 1 after the loader callout deck. The callout deck above includes a "blank" card at the end to allow the Cardatron format bands to be loaded before any data cards are read.
- Make card reader unit 1 ready.
- Load the paper tape with the object code for the program to be executed into paper-tape reader 1 and make it ready.
- Make sure that PCS 3 is ON and PCS 4 is OFF.
- On the Control Console, clear the system, enter 1000 60 0000 into the C register, click the EXECUTE lamp to set it, and click the START switch.
- The callout program will space the compiler tape forward to the Object Program Loader and load it to memory. The loader will then load the object program into memory and begin execution.
- If checksum errors in the paper tape are detected, the loader will halt with 9669 00 9669 ("XX") in the C register. No restart from this condition is possible. You must correct the paper tape and try again.
If the paper tape was created with the Object Program Loader (i.e., PCS 4 was on), then the paper tape is self-loading and the compiler tape is not required.
- If the program requires data cards, load them to card reader unit 1 after the loader callout deck, but do not make the reader ready yet.
- Load the paper tape with the object code for the program to be executed into paper-tape reader 1 and make it ready.
- Make sure that PCS 3 and 4 are ON.
- On the Control Console, clear the system and enter 1000 04 0300 in the C register. This is an instruction to read the loader bootstrap from paper tape reader 1 to address 0300.
- Click the EXECUTE lamp to set it, and then click the START switch.
- The bootstrap will load the Object Program Loader from paper tape into memory. The loader will then load the object program and begin execution.
- If you loaded a data deck into card reader unit 1, then once the Object Program Loader has been loaded from the tape and started loading the object program (the address in the P register will be less than 0300), make the card reader ready. If the object program starts executing before you do this, it will simply wait for the reader to become ready.
- If checksum errors in the paper tape are detected, the loader will halt with 9669 00 9669 ("XX") in the C register. No restart from this condition is possible. You must correct the paper tape and try again.
A number of small BALGOL example card decks are available from the project repository in the software/BALGOL/BALGOL-Examples sub-directory. Each example resides in its own sub-directory, along with output from their compilation and execution, including listings of the object code generating by the compiler. All examples are self-contained, and where needed, have sample data decks appended to the program source deck. They may be compiled and executed using the instructions in the sections above.
The first four examples below come from the Section 11 of the March 1963 edition of the compiler reference manual. The fifth example comes from Section 11 of the January 1961 edition of the manual.
The programs were transcribed from text in the manuals. Some had obvious errors that were probably introduced during composition of the manual. These are noted started in column 81 of the affected source lines. A few of the programs were converted to modern Unisys ClearPath MCP ("Emode") Extended Algol or Burroughs B5500 Extended Algol and run to obtain comparative results. These are included in the respective sub-directories for the examples. See the README.txt file from the repository for additional details.
- Reference-Manual/Example-1 -- a program by J. G. Herriot of Stanford University to compute harmonic-boundary values using orthonormal functions. This example includes object code for the program saved as a magnetic tape image, an object card deck, and as a paper tape image. The card and paper-tape forms have two versions, one with the Object Program Loader included and one without. Results from an experimental version of the retro-220 emulator that rounds after floating addition/subtraction are also included.
- Reference-Manual-Example-2 -- a program (author unknown) to do calculations for a closed survey traverse. The program as published does not compute the area of a traverse correctly. A corrected version is also included.
- Reference-Manual-Example-3 -- a program (author unknown) to reduce a square matrix to tridiagonal form using the method of Householder.
- Reference-Manual-Example-4 -- a program by George Forsythe of Stanford University to solve a set of linear equations using Crout's method. This program requires a 220 with at least 8000 words of memory and a compiler configured for a corresponding memory size.
- Reference-Manual-Example-5 -- a program by R. F. Mitchell to do optical ray-tracing calculations.
This program computes the Dirichlet Problem for a bean-shaped region. It is based on a paper by P. J. Davis, plus Philip J. Walsh's ACM Algorithm 127. Detailed references are in the source code. Results from the B5500 and Emode systems are included for comparison.
This program computes sets of values for some compiler Library functions. It was written as a test of the arithmetic logic in the retro-220 emulator and of the transcription of the Library routines. It also includes results from an experimental version of the retro-220 emulator that rounds after floating addition/subtraction.
This program computes the integral of an arbitrary single-argument function between between two points using Simpson's Rule. This example has been adapted to BALGOL from the one at the end of the Algol-58 "Preliminary Report--International Algorithmic Language", Communications of the ACM, Volume 1, Number 12 (December 1958), pages 8-22. It also illustrates the use of the MONITOR declaration to trace variable assignments.