MAD (programming language)
MAD is a programming language and compiler for the IBM 704 and later the IBM 709, IBM 7090, IBM 7040, UNIVAC 1107, UNIVAC 1108, Philco 210-211, and eventually the IBM S/370 mainframe computers. Developed in 1959 at the University of Michigan by Bernard Galler, Bruce Arden and Robert M. Graham, MAD is a variant of the ALGOL language. It was widely used to teach programming at colleges and universities during the 1960s and played a minor role in the development of CTSS, Multics, and the Michigan Terminal System computer operating systems.
The archives at the Bentley Historical Library of the University of Michigan contain reference materials on the development of MAD and MAD/I, including three linear feet of printouts with hand-written notations and original printed manuals.
MAD, MAD/I, and GOM
There are three MAD compilers:- Original MAD, the compiler developed in 1959 at the University of Michigan for the IBM 704 and later the IBM 709 and IBM 7090 mainframe computers running the University of Michigan Executive System and the Compatible Time-Sharing System operating systems. In the mid-1960s MAD was ported at the University of Maryland to the UNIVAC 1108. Versions of MAD were also available for the Philco 210-211 and UNIVAC 1107.
- MAD/I, an "extended" version of MAD for the IBM System/360 series of computers running under the Michigan Terminal System. Work on the new compiler started in 1965 as part of the ARPA sponsored CONCOMP project at the University of Michigan. As work progressed it gradually became clear that MAD/I was a new language independent of the original 7090 version of MAD.
- GOM, a reimplementation of the original 7090 MAD for the IBM System/370 series of mainframe computers running the Michigan Terminal System. GOM was created in the early 1980s by Don Boettner at the University of Michigan Computing Center.
History
Programs written in MAD included MAIL, RUNOFF, one of the first text processing systems, and several other utilities all under Compatible Time-Sharing System. Work was done on a design for a MAD compiler for Multics, but it was never implemented.
The following is an interesting quote from An Interview with Brian Kernighan when he was asked "What hooked you on programming?":
MAD was quite fast compared to some of the other compilers of its day. Because a number of people were interested in using the FORTRAN language and yet wanted to obtain the speed of the MAD compiler, a system called MADTRAN was developed. MADTRAN was simply a translator from FORTRAN to MAD, which then produced machine code. MADTRAN was distributed through SHARE.
MAD/I has a syntactic structure similar to ALGOL 60 together with important features from the original MAD and from PL/I. MAD/I was designed as an extensible language. It was available for use under MTS and provided many new ideas which made their way into other languages, but MAD/I compilations were slow and MAD/I never extended itself into widespread use when compared to the original 7090 MAD.
GOM is essentially the 7090 MAD language modified and extended for the 360/370 architecture with some judicious tailoring to better fit current programming practices and problems. The MTS Message System was written in GOM.
MAD, MAD Magazine, and Alfred E. Neuman
In a pre-release version of the original MAD, as a reference to MAD's namesake, MAD magazine, when a program contained too many compile time errors the compiler would print a full-page picture of Alfred E. Neuman using ASCII art. The caption read, "See this man about your program--He might want to publish it. He never worries--but from the looks of your program, you should." This feature was not included in the final official version. However, it was included in the production version for the IBM 7040.And Bernie Galler remembers:
"Hello, world" example
The "hello, world" example program prints the string "Hello, world" to a terminal or screen display.PRINT FORMAT HELLOW
VECTOR VALUES HELLOW=$13h0Hello, world*$
END OF PROGRAM
The first character of the line is treated as logical carriage control, in this example the character "0" which causes a double-spaced line to be printed.
Alternatively, contractions can be used, and the compiler will expand them in the listing:
P'T HELLOW
V'S HELLOW=$13h0Hello, world*$
E'M
Language elements
MAD and GOM, but not MAD/I, are composed of the following elements:Input format
MAD programs are a series of statements written on punched cards, generally one statement per card, although a statement can be continued to multiple cards. Columns 1-10 contains an optional statement label, comments or remarks are flagged using the letter "R" in column 11, and columns 73-80 are unused and could contain a sequence identifier. Spaces are not significant anywhere other than within character constants. For GOM input is free form with no sequence field and lines may be up to 255 characters long; lines that start with an asterisk are comments; and lines that start with a plus-sign are continuation lines.Names
Variable names, function names, and statement labels have the same form, a letter followed by zero to five letters or digits. Function names end with a period. All names can be subscripted. For GOM names may be up to 24 characters long and may include the underscore character.Few keywords in the language are reserved words since most are longer than six letters or are surrounded by periods. There is a standard set of abbreviations which can be used to replace the longer words. These consist of the first and last letters of the keywords with an apostrophe between them, such as W'R for WHENEVER and D'N for DIMENSION.
Data types
MAD uses the term "mode" for its data types. Five basic modes are supported:- Integer written with or without a scale factor or as octal constants ;
- Floating Point written with or without an exponent ;
- Boolean ;
- Statement Label, and
- Function Name written as a name followed by a period.
For GOM six additional modes are added: CHARACTER, SHORT INTEGER, BYTE INTEGER, LONG INTEGER, POINTER, and DYNAMIC RECORD.
Alphabetic or character constants are stored as integers and written using the dollar sign as a delimiter with double dollar-signs used to enter a true dollar sign. Strings longer than six characters are represented using arrays.
Arrays and matrices
- There is no limit on the number of dimensions.
- Negative and zero as well as floating-point subscripts are allowed.
- Matrices are storied in consecutive memory locations in the order determined by varying the rightmost subscript first.
- Matrices may be referenced using a subscript for each dimension, NAME, or using a single subscript, NAME.
- Input-output lists, VECTOR VALUES statements, and some subroutines allow the use of block notation, which has the form A,...,B or A...B, which is a reference to the entire region from A to B. inclusive. In terms of a vector, A...A would be A, A, A,..., A.
- There are facilities that allow changing dimensions at run-time; permitting the programmer to vary the location of the initial element in an array within the overall block which has been set aside for the array; and allowing an arbitrary storage mapping to be specified.
Operators
Arithmetic operators
- .ABS.
- +
- -
- +
- -
- *
- /
- .P.
- .N.
- .A.
- .V.
- .EV.
- .LS.
- .RS.
- .REM.
Pointer operators (GOM only)
- :
- .LOC.
- .IND.
Relational operators
- .L.
- .LE.
- .E.
- .NE.
- .G.
- .GE.
Boolean operators
- .NOT.
- .OR.
- .EXOR.
- .AND.
- .THEN.
- .EQV.
Bit operators (GOM only)
- .SETBIT.
- .RESETBIT.
- .BIT.
Declaration statements
- FLOATING POINT var1, var2,...
- INTEGER var1, var2,...
- BOOLEAN var1, var2,...
- FUNCTION NAME name1, name2,...
- STATEMENT LABEL label1, label2,...
- MODE NUMBER n, var1, var2,...
- NORMAL MODE IS type-name
- NORMAL MODE IS MODE NUMBER n
- DIMENSION variable
- DIMENSION variable
- DIMENSION variable
- VECTOR VALUES array = c1, c2, c3,...
- VECTOR VALUES array... array = constant
- DOUBLE STORAGE MODE mode-list
- EQUIVALENCE,...
- PROGRAM COMMON a, b, c,...
- ERASABLE a, b, c,...
- PARAMETER A1, A2,..., An
- SYMBOL TABLE VECTOR variable
- FULL SYMBOL TABLE VECTOR variable
- LISTING ON
- LISTING OFF
- REFERENCES ON
- REFERENCES OFF
Executable statements
- variable = expression
- TRANSFER TO statement-label
- WHENEVER boolean-expression, executable-statement
- WHENEVER boolean-expression
- * OR WHENEVER boolean-expression
- * OTHERWISE
- * END OF CONDITIONAL
- CONTINUE
- THROUGH statement-label, FOR VALUES OF variable = expression-list
- SET LIST TO array-element,
- SAVE DATA list
- RESTORE DATA list
- PAUSE NO. octal-integer
- END OF PROGRAM
Input and output statements
- READ DATA
- READ FORMAT format, list
- READ BCD TAPE n, format, list
- READ BINARY TAPE n, list
- PRINT RESULTS list
- PRINT BCD RESULTS list
- PRINT OCTAL RESULTS list
- PRINT COMMENT $string$
- PRINT FORMAT format, list
- PRINT ON LINE FORMAT format, list
- WRITE BCD TAPE n, format, list
- WRITE BINARY TAPE n, list
- PUNCH FORMAT format, list
- LOOK AT FORMAT format, list
- REWIND TAPE n
- END OF FILE TAPE n
- BACKSPACE RECORD OF TAPE n
- BACKSPACE RECORD OF TAPE n, IF LOAD POINT TRANSFER TO statement
- BACKSPACE FILE OF TAPE n
- BACKSPACE FILE OF TAPE n, IF LOAD POINT TRANSFER TO statement
- SET LOW DENSITY TAPE n
- SET HIGH DENSITY TABLE n
- REWIND TAPE n
- UNLOAD TAPE n
- FORMAT VARIABLE list
Functions
- INTERNAL FUNCTION function-name. = expression
- INTERNAL FUNCTION function-name.
- EXTERNAL FUNCTION function-name.
- ENTRY TO NAME name.
- END OF FUNCTION
- FUNCTION RETURN
- ERROR RETURN
- SAVE RETURN
- RESTORE DATA
- RESTORE RETURN
- EXECUTE procedure.
Operator definition and redefinition
- DEFINE BINARY OPERATOR defined-op, PRECEDENCE rank existing-op MODE STRUCTURE mode-options
- DEFINE UNARY OPERATOR defined-op, PRECEDENCE rank existing-op MODE STRUCTURE mode-options
- MODE STRUCTURE mode-no = mode-no existing-op mode-no
- MODE STRUCTURE mode-no = mode-no existing-op mode-no SAME SEQUENCE AS mode-no existing-op mode-no
- rank is one of SAME AS, LOWER THAN, or HIGHER THAN; and
- mode-options are the options that appear on the MODE STRUCTURE statement.
- INCLUDE package