Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
MAD (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Language elements == MAD and GOM, but not MAD/I, are composed of the following elements:<ref name="deepblue.lib.umich.edu"/><ref name=GOMManual/><ref name=MADSammet/> === 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 (the name followed by parentheses, with multiple subscripts separated by commas). 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 ({{tt|1, +1, -1, 1K10, 1K}}) or as octal constants (to {{tt|7777777777777K}}); * '''Floating Point''' written with or without an exponent ({{tt|0., 1.5, -0.05, +100.4, -4., .05E-2, -.05E2, 5E02, 5.E2}}); *'''Boolean''' ({{tt|1B}} for true and {{tt|0B}} for false); * '''Statement Label''', and * '''Function Name''' written as a name followed by a period ({{tt|SQRT.}}). The mode of a constant can be redefined by adding the character M followed by a single digit at the end of the constant, where 0 indicates floating point, 1 integer, 2 boolean, 3 function name, and 4 statement label. For GOM six additional modes are added: {{tt|CHARACTER, SHORT INTEGER, BYTE INTEGER, LONG INTEGER, POINTER}}, and {{tt|DYNAMIC RECORD}}. Alphabetic or character constants are stored as integers and written using the dollar sign as a delimiter ({{tt|$ABCDEF$}}) with double dollar-signs used to enter a true dollar sign ({{tt|$$$.56$}} is 56 cents). 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(s<sub>1</sub>,s<sub>2</sub>,s<sub>3</sub>), or using a single subscript, NAME(s<sub>1</sub>). * 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(1)...A(N) would be A(1), A(2), A(3), ..., A(N). * 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. {{Hidden begin|toggle=left |title=<big>List of operators, statements, and functions</big>}} === Operators === {{col-begin}} {{col-2}} ==== Arithmetic operators ==== * .ABS. (unary absolute value) * + (unary identity) * - (unary negation) * + (addition) * - (subtraction) * * (multiplication) * / (division) * .P. (exponentiation) * .N. (bitwise negation) * .A. (bitwise and) * .V. (bitwise or) * .EV. (bitwise exclusive or) * .LS. (left shift) * .RS. (right shift) * .REM. (remainder, GOM only) ==== Pointer operators (GOM only) ==== * : (selection) * .LOC. (location) * .IND. (indirection) {{col-2}} ==== Relational operators ==== * .L. (less than) * .LE. (less than or equal) * .E. (equal) * .NE. (not equal) * .G. (greater than) * .GE. (greater than or equal) ==== Boolean operators ==== * .NOT. (unary logical not) * .OR. (logical or) * .EXOR. (logical exclusive or) * .AND. (logical and) * .THEN. (implies) * .EQV. (equivalence) ==== Bit operators (GOM only) ==== * .SETBIT. (set bit to 1) * .RESETBIT. (reset bit to 0) * .BIT. (test bit) {{col-end}} === Declaration statements === Variables may be implicitly or explicitly declared. By default all implicitly declared variables are assumed to be floating point. The NORMAL MODE IS statement may be used to change this default. {{col-begin}} {{col-2}} * FLOATING POINT var<sub>1</sub>, var<sub>2</sub>, ... (may include dimension information) * INTEGER var<sub>1</sub>, var<sub>2</sub>, ... (may include dimension information) * BOOLEAN var<sub>1</sub>, var<sub>2</sub>, ... (may include dimension information) * FUNCTION NAME ''name''<sub>1</sub>, ''name''<sub>2</sub>, ... (may include dimension information) * STATEMENT LABEL ''label''<sub>1</sub>, ''label''<sub>2</sub>, ... (may include dimension information) * MODE NUMBER ''n'', var<sub>1</sub>, var<sub>2</sub>, ... (may include dimension information) * NORMAL MODE IS ''type-name'' (INTEGER, BOOLEAN, FLOATING POINT, STATEMENT LABEL, or FUNCTION NAME) * NORMAL MODE IS MODE NUMBER ''n'' * DIMENSION ''variable''(''max-dimension'') (declares an array from 0...''max-dimension'') * DIMENSION ''variable''(''from''...''to'') * DIMENSION ''variable''(''subscript<sub>1</sub>'', ''subscript<sub>2</sub>'', ..., ''subscript<sub>n</sub>'') (declares a multidimensional array) {{col-2}} * VECTOR VALUES ''array''(''n'') = c<sub>1</sub>, c<sub>2</sub>, c<sub>3</sub>, ... * VECTOR VALUES ''array''(''m'') ... ''array''(''n'') = constant * DOUBLE STORAGE MODE ''mode-list'' (doubles the amount of storage allocated for the modes listed) * EQUIVALENCE (''a''<sub>1</sub>, ''a''<sub>2</sub>, ..., ''a''<sub>m</sub>), ... * PROGRAM COMMON ''a'', ''b'', ''c'', ... (may include dimension information) * ERASABLE ''a'', ''b'', ''c'', ... (may include dimension information) * PARAMETER ''A''<sub>1</sub>(''B''<sub>1</sub>), ''A''<sub>2</sub>(''B''<sub>2</sub>), ..., ''A''<sub>n</sub>(''B''<sub>n</sub>) * SYMBOL TABLE VECTOR ''variable'' * FULL SYMBOL TABLE VECTOR ''variable'' * LISTING ON (the default) * LISTING OFF * REFERENCES ON * REFERENCES OFF (the default) {{col-end}} === Executable statements === {{col-begin}} {{col-2}} * ''variable'' = ''expression'' (assignment) * TRANSFER TO ''statement-label'' * WHENEVER ''boolean-expression'', ''executable-statement'' (simple conditional) * WHENEVER ''boolean-expression'' (compound conditional) ** OR WHENEVER ''boolean-expression'' ** OTHERWISE ** END OF CONDITIONAL * CONTINUE (do nothing statement, usually used to carry a statement label) {{col-2}} * THROUGH ''statement-label'', FOR VALUES OF ''variable'' = ''expression-list'' (iteration) :(where ''variable'' may be any mode including floating-point) * SET LIST TO ''array-element'', [ ''expression'' ] * SAVE DATA ''list'' * RESTORE DATA ''list'' * PAUSE NO. ''octal-integer'' (stop execution, print an octal number on the operators console, allow manual restart) * END OF PROGRAM (the last statement in all MAD programs) {{col-end}} === Input and output statements === {{col-begin}} {{col-2}} * READ DATA (reads data using a self-defining format, ''var1''=''value1'', ''var2''=''value2'', ..., ''varN''=''valueN'' * READ AND PRINT DATA (similar to READ DATA, but data read is echoed to the printer) * 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''$ (first character of string is carriage control) * PRINT FORMAT ''format'', ''list'' * PRINT ON LINE FORMAT ''format'', ''list'' (display a message for the machine operator) * WRITE BCD TAPE ''n'', ''format'', ''list'' * WRITE BINARY TAPE ''n'', ''list'' {{col-2}} * PUNCH FORMAT ''format'', ''list'' * LOOK AT FORMAT ''format'', ''list'' (read data without advancing to next record) * 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'' (declaration, may include dimension information) {{col-end}} === Functions === Function names end with a period. Internal and external functions are supported. Internal functions are compiled as part of the program in which they are used and share declarations and variables with the main program. External functions are compiled separately and do not share declarations and variables. A one statement definition of internal functions is permitted. Recursive functions are permitted, although the function must do some of the required saving and restoring work itself. {{col-begin}} {{col-2}} * INTERNAL FUNCTION ''function-name''.(''argument-list'') = ''expression'' (single statement definition) * INTERNAL FUNCTION ''function-name''.(''argument-list'') * EXTERNAL FUNCTION ''function-name''.(''argument-list'') * ENTRY TO NAME ''name''. * END OF FUNCTION (last statement in a multiple line definition) * FUNCTION RETURN [ ''expression'' ] {{col-2}} * ERROR RETURN (force an error return to a statement or to the operating system, if no error statement is given as last argument of the call) * SAVE RETURN * RESTORE DATA * RESTORE RETURN * EXECUTE ''procedure''.(''argument-list'') (call a non-single valued function) {{col-end}} {{Hidden end}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)