Digital PDFs
Documents
Guest
Register
Log In
AA-0196C-TK
April 1977
128 pages
Original
5.1MB
view
download
OCR Version
4.7MB
view
download
Document:
DECsystem10/20
ALGOL Programmer's Guide
Order Number:
AA-0196C-TK
Revision:
000
Pages:
128
Original Filename:
AA-0196C-TK_ALGOL_Pgmr_Apr77.pdf
OCR Text
decsyUstemio/20 ALGOL PROGRAMMER’'S GUIDE AA-0196C-TK digital equipment corporation - maynard. massachusetts First Printing: Revised: September September December May December July 1971 1971 1971 1972 1972 1973 July 1974 May 1975 September 1975 1976 Second Printing: Revised: March April 1977 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document. The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. Digital Equipment Corporation assumes no responsibility for the use or reliability of its software on equipment that is not supplied by DIGITAL. Copyright (C) 1971, 1972, 1973, 1974, 1975, 1976, 1977 by Digital Equipment Corporation The postage prepaid READER'S document requests the user's paring future documentation. COMMENTS critical The of Digital Equipment Corporation: following are trademarks form on the last page of this evaluation to assist us in pre- DIGITAL DECsystem-10 MASSBUS DEC DECtape OMNIBUS PDP DIBOL 0Ss/8 DECUS EDUSYSTEM PHA UNIBUS FLIP RSTS COMPUTER LABS FOCAL RSX COMTEX INDAC TYPESET-8 DDT LAB-8 TYPESET-10 DECCOMM DECSYSTEM-20 TYPESET-11 CHIP 1/7915 CONTENTS Page CHAPTER 1 INTRODUCTION 1.1 1.2 GENERAL DECSYSTEM~-10/20 1.3 THE 1.3.1 1.3.2 CHAPTER CHAPTER CHAPTER CHAPTER 1-1 1-1 ALGOL COMPILER Compiler Extensions 1-1 1-2 Compiler 1-2 ALGOL Restrictions 1.4 THE 1.5 TERMINOLOGY 2 PROGRAM 2.1 2.2 BASIC SYMBOLS COMPOUND SYMBOLS 2.3 DELIMITER WORDS 2.4 USE 3 IDENTIFIERS OF OPERATING ENVIRONMENT 1-3 1-3 STRUCTURE 2-1 2-2 2-2 SPACING AND AND COMMENTARY 2-4 DECLARATIONS 3.1 IDENTIFIERS 3-1 3.2 SCALAR 3-2 4 CONSTANTS 4.1 NUMERIC DECLARATIONS CONSTANTS 4-1 4.1.1 Integer 4.1.2 4.1.3 4.1.3.1 Real Constants Long Real Constants Automatic Conversion to Long Constants Real of Real Constants 4.2 OCTAL AND ASCII CONSTANTS 4.4 STRING BOOLEAN CONSTANTS 5 EXPRESSIONS 5.1 5.1.1 5.1.2 5.2 5.2.1 5.2.2 ARITHMETIC EXPRESSIONS Identifiers and Constants Special Functions BOOLEAN EXPRESSIONS Boolean Operators Evaluation of Boolean Variables Arithmetic INTEGER AND 6 STATEMENTS 4-3 Conditions BOOLEAN AND 4-3 4-3 CONSTANTS 5.3 4-1 4-1 4-2 4-2 Constants 4.3 5.2.3 CHAPTER ALGOL CONVERSIONS 5-1 5-2 5-2 5-3 5-3 5-4 5-4 5-6 ASSIGNMENTS 6.1 STATEMENTS 6-1 6.2 ASSIGNMENTS 6-1 6.3 6.4 MULTIPLE ASSIGNMENTS EVALUATION OF EXPRESSIONS 6-2 6-2 iii CONTENTS COMPOUND CONTROL CHAPTER STATEMENTS TRANSFERS, N CONDITIONAL L] (¥ - W N [ . G 00 0O & WHILE FOR STATEMENTS STEP-UNTIL Vo] CHAPTER CONTROL AND WHILE AND TRANSFERS STATEMENTS FOR WHILE LABELS, STATEMENTS UNCONDITIONAL e o] NN LABELS W CONDITIONAL CHAPTER (Cont.) STATEMENTS Element Element STATEMENT GENERAL NOTES ARRAYS GENERAL CHAPTER ARRAY DECLARATIONS ARRAY ELEMENTS BLOCK STRUCTURE GENERAL ARRAYS WITH PARAMETERS CALLED BY "VALUE" PARAMETERS CALLED BY "NAME" PROCEDURE HEADINGS PROCEDURE BODIES PROCEDURE ADVANCED 11.6.1 11.6.2 11.7 11.8 11.9 11.10 11.10.1 11.10.2 CHAPTER BOUNDS PROCEDURES CHAPTER CHAPTER DYNAMIC 11-1 11-1 11-2 11-3 11-5 CALLS USE Jensen's OF 11-6 PROCEDURES Device 11-6 11-6 Recursion LAYOUT OF FORWARD DECLARATIONS WITHIN REFERENCES EXTERNAL PROCEDURES ADDITIONAL METHODS OF COMMENTARY Comment After END Comments Within Procedure 12 SWITCHES 12.1 GENERAL 12.2 SWITCH DECLARATIONS 12.3 USE SWITCHES 13 STRINGS 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.7.1 GENERAL OF STRING BLOCKS 11-7 11-8 11-9 11-10 11-10 Headings 11-10 12-1 12-1 12-1 13-1 EXPRESSIONS BYTE STRINGS BYTE SUBSCRIPING NULL STRINGS STRING COMPARISONS LIBRARY PROCEDURES AND ASSIGNMENTS 13-1 13-1 13-2 13-2 13-3 13-3 13.7.2 13.7.3 Concatenation Length and Size Copying 13-3 13.7.4 Newstring 13-4 iv 13-3 13-4 CONTENTS 13.7.5 CHAPTER CHAPTER (Cont.) Delete 13-4 14 CONDITIONAL EXPRESSIONS AND STATEMENTS 14.1 GENERAL 14.2 CONDITIONAL OPERANDS 14-1 14.3 CONDITIONAL STATEMENTS 14-2 14.4 DESIGNATIONAL 15 OWN 14-1 14-4 EXPRESSIONS VARIABLES GENERAL OWN ARRAYS DATA CHAPTER TRANSMISSION GENERAL ALLOCATION Device OF PERIPHERAL DEVICES lo-2 Modes Buffering Error FILE 16-3 l6-3 Returns SELECTING INPUT/OUTPUT CHANNELS lo-4 DEVICES Error BASTC 16-4 16-5 Returns RELEASING 16-5 DEVICES TNPOT/QUTPIT PROCEDURES 16-6 Byte Processing Procedures String Output Miscellaneous Symbol Procedures 16-8 Numeric Numeric 16-8 and String Input Data Procedures DEFAULT CHAPTER 16-10 INPUT/OUTPUT 16-11 OPERATIONS l16-11 STATUS 16-12 TRANSFERRING FILES CURRENTLY SELECTED CHANNEL 16-13 CHANNEL DECSYSTEM-10/20 MATHEMATICAL 17.2 STRING 17.3 UTILITY Array 17.3.3 16-10 INPUT/OUTPUT 17.1 17.4 16-9 SPECIAL THE 17.3.2 l6-6 LOGICAL I/0 17.3.1 16-6 lo-8 Numeric Output Data Octal Input/Output CHAPTER 16-1 l16-1 NUMBERS OPERATING ENVIRONMENT PROCEDURES 17-1 17-2 PROCEDURE 17-2 PROCEDURES Dimension Procedures 17-2 Minima and Maxima Procedures Field Manipulations DATA 16-13 TRANSMISSION 17-3 17-3 PROCEDURES 17-4 PROCEDURES 17-4 17.5 FORTRAN INTERFACE 17.6 GENERAL INFORMATION 17.7 DATE 17.8 RANDOM NUMBER 17.9 ONTRACE AND 17.10 PAUSE 17-6 17.11 DUMP 17-6 18 RUNNING 18.1 COMPILATION 18.1.1 AND TIME AND IN ROUTINE ASCII 17-5 FORMAT 17-5 ROUTINES 17-6 17-6 OFFTRACE DEBUGGING OF Compilation ALGOL of PROGRAMS 18.2 18.3 LOADING ALGOL PROGRAMS RUNNING ALGOL PROGRAMS 18.4 CONCISE COMMAND LANGUAGE v 18-1 PROGRAMS Free-Standing Procedures 18-4 18-4 18-5 18-5 CONTENTS 18.5 18.5.1 18.5.1.1 18.5.1.2 18.5.1.3 18.6 RUN-TIME DIAGNOSTICS AND DEBUGGING Facilities to Aid in Program Debugging Checking 18.7 STACK TRACE Dynamic 18.8.2 18.9.2 18-9 18-9 Trace Post-Mortem Trace 18-11 18-11 Utilization 19 TECHNICAL NOTES CHAPTER 20 THE DYNAMIC 18-12 DEBUGGING SYSTEM 20.4 SUMMARY OF FEATURES REMARKS TYPEOUT COMMANDS CHANGING ALGOL VARIABLES 20-1 20-1 20-2 20-6 20.5 20.6 20.7 PAUSES EXECUTE DUMP 20-7 20-12 20-13 20.8 MISCELLANEOUS 20-14 20.9 SUMMARY 20-17 21 THE 20.2 20.3 CHAPTER 18-11 PERFORMANCE ANALYSIS Heap Space ALGOL 18-7 18-8 18-8 18-8 CHAPTER 20.1 Program ANALYSIS Code 18-5 18-7 18-7 Controlling Listing of the Source Setting Line Numbers in Listings CROSS REFERENCE LISTING 18.8 18.8.1 18.9 18.9.1 (Cont.) GENERAL COMMANDS OF COMMANDS COMMANDS DECSYSTEM-10 MACRO SUBROUTINES 21.1 GENERAL 21.2 PROCEDURE HEADINGS 21.3 21.4 ACCESSING RETURN OF FORMAL PARAMETERS RESULTS FROM TYPED 21.5 21.6 21.7 PROCEDURE EXITS FORMATS OF VARIABLES PROCEDURES WITH A VARIABLE OF 21-1 21-1 PROCEDURES 21-3 21-5 21-6 21-6 NUMBER PARAMETERS 21-7 21.8 21.9 21.9.1 21.9.2 21.9.2.1 21.9.2.2 INCLUDING PROCEDURE UTILITY ROUTINES Getting Core Input/Output Device Open File Open 21.9.2.3 21.9.2.4 File Close Release Channel 21-9 21-9 21.9.2.5 21.9.2.6 21.9.2.7 Select Channel Read Byte Write Byte 21-9 21-9 21-9 21.9.2.8 21.9.2.9 21.9.2.10 Break Output Read Number Print Number 21-9 21-10 21-10 21.9.2.11 21.10 String GENERAL Output to IN THE LIBRARY 21-8 21-8 21-8 21-8 21-8 21-9 Terminal NOTES 21-10 21-10 2-1 DECsystem=-10/20 2-2 2-3 Compound Symbols Delimiter Words Used ALGOL 5-1 Operator Precedence vi Symbols in 2~ - TABLE 2~ DECsystem-10/20 ALGOLZ2- HWwN TABLES 5~ CONTENTS 5-2 (Cont.) 5-3 11-1 Function of Boolean Operators Boolean Expressions Parameters in a Procedure Call l6-1 Standard Device 17-1 FORTRAN Interface Names Procedures vii 5-4 5-5 11-1 16-2 17-4 CHAPTER 1 INTRODUCTION 1.1 GENERAL DECsystem-10/20 ALGOL is an implementation of ALGOL-60; ALGOL of ALGOrithmic Language, and 1960 is the year authoritative definition of ALGOL-60 is contained abbreviation defined. The "Revised Report referred ALGOL-60 to as the features implementer of features. Many since the rigorous the Algorithmic the Language 1language some latitude these features have of Revised Report; of the interpretations Where there ALGOL-60", (1) in varicus 1in been hereafter number permits of the other interpreting discussed some have versions of ALGOL, in Revised extensively been given particularly Language. (2) is need for interpretations ALGOL opinion. 1.2 the "Revised Report". This report leaves a undefined, notably input/output, and publication ALGOL-68 basis. on is an it was in the These interpretation as seem reasonable Where no guidelines points are discussed the have been made in exist, ALGOL-68 in Chapter Report, such light of current 1is wused as a 19. DECSYSTEM-10/20 ALGOL The purpose of this manual is to teach ALGOL. The manual is written both for the use of DECsystem-10/20 the user who is familiar with ALGOL implementations and for the user who has no knowledge of ALGOL but 1is reasonably fluent 1in a high-level scientific programming language such as FORTRAN 1IV. This manual 1is not a primer 1in high-level languages. (3) Readers not thoroughly familiar with manual. Readers already familiar chapters except Chapters 5, 6, 7, 8, be referred to only briefly. 1.3 THE ALGOL ALGOL should read the entire with ALGOL-60 should read all 9, 10, 11, 12, and 14, which need COMPILER The DECsystem-10/20 ALGOL Compiler is that part of the DECsystem-10/20 ALGOL System that reads programs written in DECsystem-10/20 ALGOL and converts the them into DECsystem-10 a or form (relocatable DECsytem-20 responsible for finding errors reporting them to the user. Slight constraints are imposed These constraints, made to single-pass compiler, concern 1in on binary) Linking the the way that Loader. wuser's the user is The acceptable compiler source writes gain the most desirable the order in which the user 1-1 to is also program and his program. feature of a declares the INTRODUCTION identifiers the program and the use of forward declarations under in certain special circumstances. not does and rapidly programs ALGOL process Such a compiler can The minor restrictions imposed the use of any backing store. require will the user. not normally affect Compiler 1.3.1 Extensions The following ALGOL-60 extensions are allowed by the compiler: 1. A LONG REAL type, equivalent to FORTRAN's double precision, is added that gives the user power to handle double-precision numbers. real 2. An EXTERNAL procedure facility allows the wuser procedures separately from the main program. 3. A WHILE statement, and an abbreviated form of the FOR statement, allow the user greater flexibility of iteration. 4. A new type STRING allows the user to manipulate strings of various size bytes. 1In addition, the user can individually manipulate the bytes within a string by means of a byte subscripting to compile facility. 5. An integer remainder function REM, is provided. 6. Assignments are permitted within expressions. 7. Delimiter words may be represented in either reserved word format or as non-reserved words enclosed in single quotes (primes). 8. Constants of type REAL may be expressed as and a decimal part only as in FORTRAN. an integer The compiler accepts reserved word delimiters in normal mode, also accept Refer 1.3.2 Compiler The compiler can using non-reserved delimiter words enclosed in programs primes. but part to Chapter 18. Restrictions imposes the labels following restrictions on ALGOL-60: 1. Numeric are 2. All formal parameters must be specified. 3. Identifiers are restricted to 64 characters in length. 4. Arrays and scalars not permitted. must be declared before switches and procedures. 5. Forward under references for procedures and labels certain For definitions of the Revised Report. must be given circumstances. terms used, refer to section 1.5 and to the INTRODUCTION 1.4 THE ALGOL Programs OPERATING compiled by environment that facilities for the The ALGOL 1. ALGOL of which 2. The Time System, the smooth services allocation, Chapters 1.5 TERMINOLOGY Some of reader. exists, an 17 such as fault condition for a cannot Word part of normally special a set the as of operating input/output monitoring at run descripion routines, user's program ALGOTS of management, following words, used in this Many have a FORTRAN equivalent, this is enclosed in parentheses. inherent a including running core and 18 - known error and in of: the Delimiter run known as ALGLIB incorporated into Object encounters to consists organizing providing Refer are services, Library, ALGOL for compiler environment are loader. linking ALGOL provides special object program. operating The the ENVIRONMENT in - some by responsible the program peripheral case the and device program time. of ALGLIB manual, and may where and be such ALGOTS. new an to the equivalent a single, English language word that is an the structure of the ALGOL language. Such words be used for other purposes. Examples: BEGIN IF ARRAY. Identifier - represents some Label a 1in transferred Procedure Number) a by Parameter (Formal Argument) See within the an by wuser identifier used of following Function) a the result may Parameter procedure procedure is - part 1In general, be returned. - Procedure. Dummy - that called. declaration, that program. Control “calling". and used - a the mark a certain execution can be 1label. A numeric statement of a the is is not which may supplied as Parameter - are Actual Parameter represents number, program, parameters Variable, Formal to program the statement 1is similar to a FORTRAN DECsystem-10/20 ALGOL. arguments when within program. (Subroutine, invoked established to label which available in be name, quantity (Statement statement the an argument identifier supplied CHAPTER PROGRAM 2.1 BASIC STRUCTURE SYMBOLS DECsystem-10/20 programs the ASCII ALGOL DECsystem-10/20 characters given in Table consist 2-1, is Table Used a-z Lower to construct <case letters and or are they used to Arithmetic addition - Arithmetic subtraction * Arithmetic multiplication / Arithmetic division Arithmetic exponentiation Parentheses; wused ’ ] Square in brackets; Comma; general subscripts, and in construct identifiers. as words. upper string numeric case constants constants operator. operator. arithmetic in enclose array separator, wused Also, 2-1 expressions procedure to and procedure point; subscripting. high-level delimiter treated appear placed numeric used as to and subscript parameters, in and specifications subscript etc. Decimal other operator. used declarations, in operator. parameters array lists, as from individual operator. calls. [ symbols of Symbols identifiers when digits; identifiers. enclose same of meaning Use + () The constants. Decimal and sequence 2-1 letters; except ASCII the ALGOL Meaning A-7 a set. much DECsystem-10/20 Symbol of character languages. 0-9 2 a bounds in lists. between items constants readability in and array switch byte symbol in PROGRAM STRUCTURE Table 2-1 (Cont.) DECsystem-=10/20 ALGOL Symbols Symbol Meaning or Use used to terminate statements. -e Semicolon; separate used to indicate labels, and Colon; and upper bounds in array declarations. 1lower used in arithmetic and string comparisons. = Equality; # Nonequality. < > Less than, & @ Introduces exponent in floating-point numbers. greater than. to enclose delimiter used Prime, or single quote; non-reserved word implementation is the words when used. Opening and closing string quotes. ! Comment. % Introduces an octal constant. $ Introduces an ASCII constant. “ 2.2 Alternative to := (refer to Table 2-2). COMPOUND SYMBOLS Any symbols. two adjacent basic Compound symbols consist of The compound tabs do not affect their use. intervening spaces or symbols are shown in Table 2-2. Table Compound 2-2 Symbols Usage Symbol 2.3 := Assignment <= Less than or equal to >= Greater than or equal to DELIMITER WORDS Certain letter combinations are reserved as part of the structure of the 1lanquage and may not be used as identifiers unless the compiler Such an option to accept delimiter words in single quotes is in use. Chapter to (refer option switch special a using by option 1is selected 2-2 PROGRAM STRUCTURE 18). The standard reserved words, delimiter word method 1is of assumed delimiter word throughout representation, this manual. For that example, is, the BEGIN will always appear in the text of this manual as shown cannot be used as an identifier in a program. If the method of representation is used, it would appear as above and alternative 'BEGIN' and BEGIN could be used as an identifier. Table delimiter words used in the language. Delimiter Words Reserved Word Table Used in 2-3 contains 2-3 DECsystem-10/20 Chapter 9 BEGIN 10 BOOLEAN 5.2 18 CHECKON 18 COMMENT 2.4 DIV 5.1 GOTO IF INTEGER WO IMP LABEL 11 LINE 18 LISTOFF 18 LISTON 18 LONG 3 NOT 5 OR 5 OWN 1 . NEN) . 1 3.2 REM STRING 5.1 8 1 SWITCH 1 THEN 7 STEP w PROCEDURE REAL — GO L) FOR FORWARD e FALSE NN EQV EXTERNAL (N END ddH QOWD~ — — e WND N Ne N o O » CHECKOFF = 5.2.1 ARRAY ELSE list ALGOL Reference AND DO a of all the PROGRAM STRUCTURE Table.2-3 (Cont.) Delimiter Words Used in DECsystem-10/20 Reserved Word Chapter 2.4 The of USE OF 4.2 UNTIL VALUE 8 11 8 SPACING AND COMMENTARY readability of spacing, tab ALGOL programs can be enhanced by the judicious use formatting, and commentary. Spaces, tabs, and form feeds (page throws) may be the following constraints: l. Spaces, appear 2. 3. Reference TRUE WHILE ALGOL used freely in tabs, line feed, or form within delimiter words. a source program feed subject characters may to not Where two delimiter words are adjacent, or identifier follows a delimiter word, these must by one or more spaces and/or tabs. be Spaces, constants. tabs etc., are significant within string where an separated Comments are introduced by either the word COMMENT or the symbol ! (available in DECsystem-10/20 ALGOL, but not necessarily in other implementations of ALGOL). Such a comment may appear anywhere 1in a program; the comment text 1s terminated by a semicolon. Refer to Section 11.10 for additional means to add comments to a program. 2-4 CHAPTER IDENTIFIERS 3.1 AND 3 DECLARATIONS IDENTIFIERS optionally An identifier must begin with an upper-case letter and followed by one or more upper-case letters and/or decimal digits. identifier may not contain more than 64 characters. be An NOTE Unlike FORTRAN, there is no attached to an identifier. implied type All identifiers 1in a program (except labels) have to be "declared", that is, the use to which identifiers are to be put must be specified, prior to the actual usage. Examples: The following are identifiers: I ALPHA P43 J4K5 HOUSEHOLDERTRIDIAGONALIZATION The following are not identifiers: 4P does BOOLEAN unless the representation ONCE AGAIN space not not begin with is letter non-reserved used word delimiter allowed decimal ALGOL also permits the use of a symbol" in the alphabetic portion of identifiers. readability symbols can appear between two alphabetic characters identifier and are ignored by the compiler. Thus: DECsystem-10/20 "readability ONCE.AGAIN a These of an IDENTIFIERS AND DECLARATIONS and PI.BY.TWO have exactly the same effect as ONCEAGAIN and PIBYTWO respectively. Note that ALPHA3.5 and BETA.22 are not two 3.2 identifiers, alphabetic since the decimal point does not characters. appear between SCALAR DECLARATIONS A declaration reserves an identifier to represent a particular quantity used in a program. Such declarations are mandatory in ALGOL. At any particular point during program execution, the form of variable or quantity associated with the identifier depends on type of variable. The type of variable identifier which represents it. is determined by the There are five types of scalar variables, contain a single value: that 1is, type variables the the of which Integer Real Long Real Boolean String Integer, real, and 1long real variables are capable of holding numerical values of the appropriate type (and only of that type). The range of values is as follows: integer: -34,359,738,368 through 34,359,738,367; real and 1long real: approximately -1.7&38 through 1.7&38; values less than approximately 1.4&-39 in magnitude are represented by zero. Boolean variables (similar to FORTRAN's Logical variables) Boolean gquantity, which 1is wusually one of the but, in general, can be any pattern of 36 bits. can hold states TRUE or a FALSE String variables are somewhat more complicated. The user is referred to Chapter 13 for a full description of the subject. All of the above variables can be declared for use by preceding a list of the identifiers to be used by the appropriate delimiter word for their type. Throughout this manual, a "list of items" consists of those items arranged sequentially and separated by commas. IDENTIFIERS AND DECLARATIONS Examples: INTEGER I,J,K; LONG REAL BOOLEAN STRING DOUBLE,P,Q,ELEPHANT; ISITREALLYTRUE; S,T; CHAPTER 4 CONSTANTS 4.1 NUMERIC There are CONSTANTS three forms of 1. 1Integer 2. Real constants 3. Long Real 4.1.1 Integer Integer subject range 0 numeric constants: constants constants Constants constants consist of a number of to the constraint that the number through 34,359,738,367. adjacent decimal digits, represented must be in the NOTE Any preceding sign that appears 1in program 1is not considered part of the the constant. Examples: 3 24 9276541 See 4.1.2 also Real Section 4.3 Constants Real constants consist of a decimal number integral part or a fractional part, or both) exponent. If the value of a decimal number is omitted, the the the and the real constant solely (containing followed by either an an optional unity, this represented by then the may exponent be (see last example in this section). The exponent <consists of either & or @ symbol followed by an optionally signed integer. This has effect of multiplying the decimal number by the power of ten specified in the unity is assumed. exponent. 1If no decimal number appears, a value of CONSTANTS The range of real constants 1is approximately 1.4&-39 to 1.7&38; numbers less than 1.4&-39 are represented by zero. Real numbers are stored to a significance of approximately eight and one-half decimal digits. Examples: 4.1.3 Long Representation Value 3.141592653589793 .0001 4.37&5 3.14159265 0.0001 437000.0 5&-3 0.005 &-6 0.000001 Long real Real Constants constants are wused to represent numeric quantities to approximately twice the precision available with real numbers: about seventeen decimal digits. Long real constants are formed by writing a real constant in floating-point form, but replacing the & or @ by && or @@. The range of long real constants is the same as that of real constants, represented except numbers below to single precision due approximately 3.0&&-30 can only to hardware considerations. be Examples: Representation Value 3.14159265358979323846&&0 128&-3 3.1415926535897932 0.012 4.1.3.1 Automatic Conversion of Constants to Long Real Constants The compiler keeps all real constants internally to the precision available with 1long real variables and determines the precision required by the context 1in which the constant is used. This is to avoid loss of precision in arithmetic expressions involving long real variables and real constants, thus making easier the conversion of programs to use long real variables. As a result of this, a long real constant only needs to be specified explicitly if it is desired to force a calculation to be done to long real precision irrespectively. For the example, if following LR is two a long real variable assignments would and X produce is real variable, (slightly) a different results: 1. LR:=0.1+4X would perform the addition, real and assign this to LR. 2. then convert the result to 1long real, then LR:=0.1@@0+X would take the value of X and convert to 1long perform the addition to long real precision and assign the result to LR. If X was a long real variable, however, .there would be no difference, as the addition would be performed to long real precision in both cases. 4-2 CONSTANTS 4.2 OCTAL AND BOOLEAN CONSTANTS Octal constants consist of the symbol % followed by digits. Up to twelve significant digits may appear ignored); these digits are right justified. a number (leading of octal zeros are Examples: $777777777774 $0470 Octal constants Boolean constants equivalent to respectively. 4.3 may ASCII only be consist the used of octal in the Boolean words constants expressions. TRUE and %777777777777 FALSE. and They are %000000000000, CONSTANTS Up to five ASCII symbols can be packed right Jjustified to give an integer-type constant. The format is a dollar sign ($), followed by up to five ASCII symbols enclosed within a delimiting symbol pair. The 1leading delimiter symbol immediately follows the $, and may be a readable character or an invisible one such as a space. Thus, the user can dgenerate a single ASCII character constant by placing one space on each side of it, and preceding the triplet by a dollar sign. Examples: Text S Octal A $/01234/ 4.4 000000 000101 160713 516674 STRING CONSTANTS String of Value constants ASCII allow characters the user within a to store program. any reasonable The length of length such a string constant is restricted only by the amount of core storage available to the user for the execution of the program. String constants may be used, typically, to output a message during the execution of the program or as values assigned to string variables. The string of symbols 1is enclosed within restrictions on the symbols that may appear 1. [ 2. ; 3. Single ;3 4. ] ; | and and may may not a source, "" of if [ alone. they ] are ; are and properly " are paired. represented by [[ ]] lines of respectively. string the ignored by character. appear appear occurrences and Where ] " quotes ("). There within the string. has to be broken across carriage return and preceding them with line a two feed or more characters control-back can be arrow CONSTANTS NOTE [[ and ]] are stored as such in the byte string generated by the compiler. ;; and "" are stored as a single ; or ", respectively. The restriction on the representation of ; is made to protect the user against quoting the whole program by missing out a ". Square brackets are used to enclose effect when the string is output. symbols that have These are discussed 16.6.2. Examples: "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "REMEMBER THAT "[P5C] INPUT llllllA[[I]] SPACES ETC. DATA:[5C]" s = 0.1;;IIIIII ARE SIGNIFICANT" a specific in Paragraph CHAPTER 5 EXPRESSIONS 5.1 ARITHMETIC EXPRESSIONS DECsystem-10/20 ALGOL arithmetic expressions are written in a form similar to that used in FORTRAN and many other high-level scientific computer languages. The usual algebraic rules concerning precedence of operators and brackets are followed Table Operator (see Table 5-1). 5-1 Precedence Priority (decreasing) Operator parentheses exponentiation multiplication and division addition and subtraction 1 2 3 4 There are two additional operators, DIV and REM, that indicate integer division and remainder, respectively, and these have the same precedence as ordinary division. Within the precedence scheme, the order of evaluation is always from left to right. For example: X Y " Z means I DIV J REM (X ~ Y) yA ~ and Unlike FORTRAN, performed, the The difference the following 7/4 K means when real (I ordinary result between the examples: yields a DIV result is J) REM division not K of rounded various types 1.75, whereas of 7 DIV 4 yields a result of 1, 7 REM 4 yields a result of 3 and one to of integer an by integer division is another is value. <clarified by EXPRESSIONS The interpretation of Let M, N>0, DIVN -M DIV integral M 5.1.1 M, REM N negative integers defined so follows: then -M The integer integer division for = M (-N) DIV (-N) M DIV N = = -(M remainder operator, N: =M - N*¥(M DIV DIV N) REM, 1is that for all N) Identifiers And Constants Arithmetic expressions consist of operands, that is, identifiers and constants, of the three types, integer, real and long real, together with the arithmetic operands + - * / DIV REM and 4 and parentheses where necessary. Since automatic conversion takes place as necessary when an expression is evaluated, the user may freely mix the three different types of identifiers and constants, (refer to section 4.1.3.1 for the effect of mixing real or long real constants and variables). Integer quantities may have more precision than can be represented a real variable. The user must beware of possible 1loss significance in integral quantities used in mixed type expressions. 5.1.2 Special in of Functions Three special functions are provided for use in arithmetic expressions. The first 1is the transfer function, ENTIER, which converts a real or long real quantity into an integer quantity defined as the largest integer value not exceeding the argument. ' Thus ENTIER(3.5) = 3 and ENTIER(-3.5) = -4 The special function ABS yields the absolute value (also known as the modulus) of 1its argument. The argument may be any integer, real, or long real quantity; the result is always of the same type as the argument. Thus ABS(-3.5) = ABS(-3) 3 3.5 and = The special function SIGN is the signum function whose argument can be integer, real, or 1long real. The result is always integral, being minus one or zero or plus one, depending on whether the argument is negative, zero, or greater than zero, respectively. 5-2 EXPRESSIONS Thus SIGN(-3.5) SIGN(0) = -1 =0 SIGN(3.5) =1 NOTE ENTIER, words. ABS, and SIGN are not They may be used purposes Examples of simple in a arithmetic delimiter for other program. expressions follow: X I+ 3 X*Y /2 P+Q/R + X2 ¥ XJ-4 J + ENTIER(K-2) SIGN (ENTIER(J/K) 5.2 + 1) (X + Y) * (-I) BOOLEAN EXPRESSIONS Boolean expressions involve Boolean identifiers, Boolean and octal constants, arithmetic conditions, and Boolean operators interspersed in an order similar to that of arithmetic expressions. 5.2.1 Boolean Operators There are five precedence. Boolean (unary operators 1. NOT 2. AND 3. OR 4, IMP (implication) 5. EQV (equivalence) listed here in decreasing order of operator) NOT is a unary operator that complements a Boolean gquantity in the same way that a unary minus sign negates an arithmetic quantity in an arithmetic expression. 1In this case, FALSE is changed to TRUE, or vice versa. EXPRESSIONS Table 5-2 gives the result of A OP B where OP stands for one of Boolean operators AND, OR, IMP, or EQV, for all values of A and B. Table Function A of 5-2 Boolean Operators FALSE B A AND B A OR A A B IMP B EQV B TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE TRUE In addition, the following A IMP B is equivalent to NOT A OR B, A EQV B 1is equivalent to A AND B 5.2.2 the theorems hold TRUE TRUE true: OR NOT A AND NOT B. Evaluation Of Boolean Variables Actually, Boolean variables may have a value consisting of any pattern of bits, rather than be confined to the values TRUE and FALSE. The logical operations operate on a bit-by-bit basis according to the preceding rules. The actual test expression such as B AND employed to determine the truth of a Boolean C is to evaluate it and regard it as true if the value is nonzero, is, at least one bit is set, otherwise regard as false. that This is particularly important when octal constants are used in Boolean expressions. For example, if the wuser wishes to test a particular bit in a Boolean variable, an appropriate octal constant can be used, B AND for example: %1 is a Boolean expression that is significant) bit of B is a one. 5.2.3 true if and only if the bottom (least Arithmetic Conditions Arithmetic conditions are used as They consist of two arithmetic operands expressions in The comparator, which decides the particular performed on the two expressions, is one of the < less than <= less than or equal to Boolean coupled with expressions. a comparator. type of test following: to be EXPRESSIONS = equals > greater than >= greater than # not equal or equal to to Such an arithmetic <condition can be regarded as true or false according to whether the condition specified by the comparator is met when the arithmetic expressions on each side are evaluated. The resulting condition may form part of a Boolean expression. The following examples of Boolean expressions, also involve arithmetic conditions. shown in Table OR (P=Q) 5-3, Table 5-3 Boolean Expressions Expression NOT B B NOT B EQV X+Y<Z 5.3 NOT AND A OR B Meaning C AND C XY AND B OR P=Q B B AND A OR B EQV (NOT (B C) AND C) (X<Y) (((X+Y)<Z) AND B) INTEGER AND BOOLEAN CONVERSIONS an integer quantity can be converted to a Boolean quantity by means of the dummy function BOOL. Similarly, the dummy function INT converts a Boolean quantity to an integer quantity. The value passed by these functions is unchanged: included for semantic correctness. Thus: the functions are BOOL(I) may be regarded as a Boolean operand, and INT(B) INT (%$400000000000) as integer BOOL by and operands. INT are "declaring" avoided to not them prevent reserved as words required. confusion. and can be However, used for other this practice purposes should be CHAPTER STATEMENTS 6.1 ASSIGNMENTS STATEMENTS The statement an operation, 6.2 AND 6 is the basic operational unit in ALGOL-60 as an assignment, to be performed at such and run describes time. ASSIGNMENTS Assignments convey the wvalue produced by the execution expression to a destination variable of the appropriate type. done by symbols X causes writing : and = :=Y the variables + an the result identifier, to expression followed first by evaluated. Thus an is the be Z of the and to be Z assignment Integer, destination then by the result Y When the and of This of real is the and long of any of these three string expressions can addition placed made to in a the a values variable variable expression, real of the type type expressions may contained differing conversion be 1in the that of X. assigned from 1is to performed. variables types, but not to any other types. Boolean and only be assigned to a variable of the same type. If a a real or rounding I := results in long process When value is assigned to an integer type variable, occurs. X an ENTIER(X being real assigned integral + value equal to 0.5) to I. an integer expression 1is assigned to a real or 1long real variable, a conversion to that type is performed. Real to long real conversion simply consists of zeroing the low-order precision word of the 1long real result after assignment of the real result to the high-order part of the 1long real variable. Long real to real assignments truncate the low-order part of the long real expression, after appropriate rounding. STATEMENTS AND ASSIGNMENTS MULTIPLE ASSIGNMENTS 6.3 A value may be assigned simultaneously to same type by a multiple assignment. This P :=R := S8 ¢2=X+Y - 2 several variables of takes a form such as ; where the result of adding Y to X and subtracting Z R, simultaneously. S and the is assigned to P, All identifiers on the left-hand side of a multiple assignment must be of the same type. If the user wishes to assign a value to two or more different types of variables, the “assignment within expression" (embedded assignment) feature must be used, as below. A parenthesized assignment may be expression. For example, X := (Y := substituted for any operand in an P+Q)/%; This causes the embedded assignment to be made after the inner expression P+Q is evaluated. Where a type conversion is performed as part of an embedded assignment, the operand type is the same as that assigned to the variable in the embedded assignment. Thus X := (I := 3.4) sets I equal to 3 6.4 EVALUATION OF and ; X equal to 3.0. EXPRESSIONS All expressions in DECsystem-10/20 ALGOL are evaluated observing normal algebraic rules of precedence, including bracketing. the Within the precedence structure, expressions are always evaluated from left to right. For example, 1if X 1is a scalar, and F a function procedure (see Chapter 11) that alters X, 1= X may have X This a different := is ; X+F A[I] than F+X known Consider effect as a "side := I+1) effect". also: := (I ; The subscript I is always evaluated before I is incremented, as it 1is to the left of the embedded assignment, within the statement. Thus the above J order X expression is equivalent to :=1I; I := I+1l; A[J] := 1 ; of evaluation of an expression := (P := P+Q)/(P+R) ; The user can always predict and can count on such things the as STATEMENTS being 6.5 evaluated correctly, P := P+Q X := P/(P+R); COMPOUND thus AND ASSIGNMENTS giving the same result as ; STATEMENTS A compound statement consists of a number of statements, BEGIN, separated by semicolons, and terminated by statements, unlike those in FORTRAN, are terminated by a by the end of a line of text. For preceded by END. ALGOL semicolon not example: BEGIN I :=3; J K :=1+ J; X := := 4; K END is a compound BEGIN The or usefulness chapters. statement. before the of END; compound Semicolons BEGIN and do not have to END act as type statements will a become appear of after the bracket. apparent in later CHAPTER 7 CONTROL TRANSFERS, LABELS, AND CONDITIONAL STATEMENTS 7.1 LABELS A label is a method of marking a place in a program so that can be transferred to that point from elsewhere in the program. control These identifiers DECsystem-10/20 ALGOL uses identifiers as labels. Numeric are placed before statements and are followed by a colon. labels are permitted in the Revised Report, but are not implemented in Most implementations of ALGOL-60 do not allow DECsystem-10/20 ALGOL. integer For labels. example: COMP: X is a statement ; Y + =X labeled by COMP. More than one label can be attached to a statement if required; LABl: 7.2 LAB2: ; 0 := Y thus, UNCONDITIONAL CONTROL TRANSFERS A transfer of control, or "jump", to a statement in a program is This statement consists of the word effected by a GOTO statement. relevant 1label attached to the the GOTO followed by the name of GOTO word the of instead used be can TO GO words two The statement. in any statement where GOTO can be used. I,J,K; BEGIN INTEGER LAB: I :=J := K :=1 + GOTO Thus: 3; J; LAB END to write any Clearly, is an example of a somewhat tedious program. y. conditionall jump to able be to necessary is it reasonable program, CONTROL 7.3 TRANSFERS, CONDITIONAL LABELS, AND CONDITIONAL STATEMENTS STATEMENT Conditional statements provide a method to make the execution of either a statement or a compound statement dependent on some condition in the program, such as the value of a variable. The simplest form of a conditional statement 1is IF B B is where THEN S some Boolean expression, and S 1is := I a statement. For example: IF X < 0 THEN X < 0 is the Here, I general IF B THEN and form S1 + Boolean which is obeyed if if X is negative. A more :=1 1 expression only of a ELSE if the and I Boolean conditional 1 is the condition is true, statement + statement that is, is S2 In this case, the statement S1 is obeyed if and only if the Boolean expression B is true, and S2 is obeyed if and only if it is false. 1In order to eliminate the "dangling ELSE ambiguity” (a construction 1in which an ELSE could be paired with either of two THENs), S1 must not be conditional, FOR, or WHILE statement which ends in an ELSE clause. (Refer A to Chapter 14 control transfer, statement. Thus: BEGIN LAB: for a type INTEGER I := I :=1 IF I more complete of information.) statement, can appear in a conditional I; 0; < + 1; 100 THEN GOTO LAB END is a simple way of are shown in methods counting Chapter to 14. one hundred. More sophisticated CHAPTER FOR AND WHILE 8 STATEMENTS FOR STATEMENTS 8.1 The for statement enables in a fashion similar, the user to to but more iterate a portion of the program sophisticated than, FORTRAN's DO loop. The general FOR format 1is V := FORLIST DO where V is a variable and FORLIST can consist of A FOR element commas). l. An S S is any a statement (compound or otherwise). number of one of the elements (separated following forms: taking the form: takes FOR by expression: E 2. A STEP-UNTIL El 3. STEP UNTIL element E B Any number serially. WHILE B is some form: expression. of FOR elements may appear in a FOR statement Consider the following examples: := 3,5,10 FOR X : 2.5,5.0,10.0 :=1,2,5 STEP-UNTIL This particular I the Boolean I FOR E3 taking FOR FOR J The E2 A WHILE where 8.1.1 element DO and executed ..... STEP 5 DO ..... UNTIL 20 DO ..... Element form deserves := 1 STEP statement S is I UNTIL obeyed being incremented by question is , "Is the I closer N with DO I I until after the inspection. Consider S taking the STEP 8-1 1, and final value N is achieved. recalculated during each an initial wvalue of The turn FOR AND WHILE around the loop, value of 12" The or does it answer is slightly more FOR V := E1 This is STEP defined to V Ll: IF E2 have := have a STATEMENTS constant complicated. UNTIL E3 exactly DO the value equal Consider the to the general initial case S same effect as El; (V - E3)*SIGN(E2) > 0 THEN GOTO L2; S; V :=V + GOTO E2; L1; L2: Clearly, the value of I following the STEP in the previous example is evaluated, if necessary, twice during each turn around the loop, once in the sign test at L1, and again to update V. ALGOL allows the user to modify V, E1, E2, and E3 freely throughout the loop, and takes account of all these changes in the evaluation of the loop. NOTE DECsystem-10/20 the abbreviated FOR instead V A FOR WHILE This is Ll: V := := E1 UNTIL := E1 STEP E3 DO the |user S 1 UNTIL E3 DO S Element statement FOR allows of FOR V 8.1.2 ALGOL form with E a WHILE interpreted single B as V := IF NOT DO WHILE element takes the form S follows: E; B THEN GOTO L2; S; GOTO L1; L2: Once again, the complexity and E within the loop. of the loop may be affected by changing V FOR AND WHILE 8.2 WHILE STATEMENT The WHILE statement DECsystem-10/20 ALGOL. WHILE and STATEMENTS B DO 1is an enhancement The general form of of the ALGOL-60 statement provided is in S is interpreted as follows: Ll: IF NOT B THEN GOTO L2: S; GOTO L1; L2: 8.3 GENERAL l. NOTES Within a FOR statement of any kind, the user can change the controlling variable or any other variable appearing within the action of the loop. Such changes predictably affect the execution of the loop by the rules given above. 2. On exit loop from or by variable has value of a FOR statement exhausting a the other ALGOL-60 Report should either the well-defined controlling value studied Jjumping elements, equal variable. implementations. be by FOR to the last may not be of the in 4.6.4 this of the controlling This Section carefully out the assigned connection. true of Revised CHAPTER 9 ARRAYS 9.1 GENERAL Arrays are essentially collections allowing the user to address each common name and a unique subscript of variables case, an array is a vector and is known matrix is a two-dimensional array, etc. There those 9.2 is no limit to imposed by the the of the as a same one-dimensional subscripts computer to allowed, store the type, by means of a the simplest array. other array. A than ARRAY DECLARATIONS Arrays may these are the array possesses, that the number ability of of variable individually or subscripts. In be of type integer, declared similarly must be stated. a lower subscript, and must be an real, long real, Boolean, or string and to scalar variables, except the size of For each subscript that the array upper bound, called the "bound pair" for given. For example, to declare two one-dimensional with lower bound 1 and upper bound 5: integer arrays A and B INTEGER ARRAY A,B[1:5] NOTE The 1lower enclosed separated When the there are two bound pairs LONG REAL same of the same by more a upper square by ARRAY the commas. be and declaration is similar, and Thus P,Q,R[-5:2,0:10] real arrays, P, Q and R, second subscript and the type but of different statement. REAL bounds must brackets colon. subscripts, separated ARRAY declares three long bounded by -5 and 2 Arrays or are and in A[1:10], B,C[1:10,1:12] with the first subscript bounded by 0 and 10. sizes may be declared in the ARRAYS NOTE In the case of real arrays, the REAL be omitted 1in the declaration, assumed by default, thus: ARRAY A[l1:10], and may is B,C[1:10,1:12] The bounds in an array need not be static, as in the examples above, but may be any arithmetic expressions, which are evaluated to give an integral value for the individual bound pairs. The use of such dynamic array declarations will become apparent later. No bound may exceed 131,072 in magnitude. 9.3 ELEMENTS ARRAY An individual element of an array can be referred to by following the name of the array by a list of subscripts in square brackets. The number of subscripts must be identical to the number 1in the array declaration. Thus, a typical element of A wused 1in the 1last declaration might A[5] or A[9] be or generally, A[I] where I is some integer expression or, whatsoever, with the 1limitation that subscript and evaluated as an integer is the As bounds of an example the of REAL ARRAY and suppose product FOR array A. the use D,E,F of consider the operation required, D and E: I := 1 UNTIL 10 DO := 1 UNTIL 10 DO BEGIN X := the declaration [1:10,1:10] of FOR J arrays, 1in dgeneral, any expression its value when used as a in the range 1 through 10, was to set F equal to the 0; FOR K F[I,J] := := 1 UNTIL 10 DO X := X + D[I,K]*E[K,J]; X END NOTE 1. In the above example X 1is used to accumulate the inner product of the multiplication for all values of I and J. The variable X was used instead of F to facilitate the computation. 2. An element of an array of a particular type may be used anywhere that a scalar variable of the same type may be used, even 1in such places as the controlling variable in a FOR statement. 9-2 matrix CHAPTER BLOCK 10.1 10 STRUCTURE GENERAL ALGOL program structure 1is high-level languages, such as number words of "blocks" BEGIN and somewhat FORTRAN. more complicated than other An ALGOL program consists of a arranged hierarchically. A block END enclosing the declarations consists of the and (optionally) statements. Thus: BEGIN BEGIN END BEGIN BEGIN END END END is in The an ALGOL program, the blocks. block structure assuming offers appropriate the user many declarations interesting available 1in non-block structured languages. may declare an identifier that appears to identifier in an enclosing block. Thus: BEGIN INTEGER BEGIN and statements features not For instance, conflict with the user another different The I; INTEGER I; END END In fact, there I that statements outer block. use the I is no conflict as 1in outer the there are block two can "see", is Is. the one only in the Similarly, any statement in the inner block will always in that block. Such a declaration in an inner block is known as a "local" variable and takes precedence over declarations occurring at an outer or more "global" 1level. In general, all variables can be "seen" from any point in a program that is either in 10-1 BLOCK STRUCTURE the same block as the declaration or in a block that is enclosed by the block in which the declaration of the wvariable occurred. Note that a more local variable 1is always taken 1in preference to a relatively global variable. Consider the following example: BEGIN INTEGER I,J; [1] BEGIN INTEGER J,K [2] END; BEGIN INTEGER I,K [3] END END Any and statements occurring J, which are local, at point [1] can see the declarations of I but cannot see the declarations of J and K in the first inner block, or the declarations of I and K in the second inner block. At [2], the local variables J and K can be seen, as can the global variable I in the outer block. The global variable J is not seen because the local variable J takes precedence over it; the variables I and K in the second inner block are not seen at similar situation occurs at [3]; here both local variables as well as the global variable J, are seen. Note that the "scope" of a variable is the set of program where it can be seen and therefore used. used frequently throughout this text. In general, local variables are more efficient all. I and K, all places in This term will a be to wuse than A global ones. This statement is also true of most ALGOL-60 implementations. Where a global variable is used frequently, a local variable should be assigned as having the same value and used instead. For example: BEGIN INTEGER I := BEGIN I1; ® ® & & = INTEGER IT := ..... II; I; II e o . o END END Here, in the the value of inner block, a local variable global variable I for use the 10-2 II is wused, and assigned the local block. throughout BLOCK 10.2 The ARRAYS concept arrays. WITH of In DYNAMIC the scope STRUCTURE BOUNDS of a variable can ALGOL, all DECsystem-10/20 be applied arrays most are usefully to constructed at execution time (that 1is, no fixed space is reserved during compile-time), irrespective of whether their bounds are static or dynamic. When a declaration of an array is encountered within a block, the space required to construct it is obtained and the array is laid out. When the end of the block enclosing the array 1is reached, that 1is, the utilized by the array variable array is 1is recovered no and longer can within be used scope, later the for space other arrays. Consider used in the case of a problem in which a calculation is dependent on programmer has the choice of making the the the size of an array to be data to be processed. The array large enough to cope with suit the worst case, or constructing the array the size required by the particular data. with dynamic bounds to The first method has the disadvantage occasions. method only construct running has the time of the wasting minor array. of most space on disadvantage Such programs, overhead therefore, many of the 1is very the overhead small second The compared method latter needed is to to the nmore desirable. Consider the following BEGIN INTEGER L: N := example: N; ..... BEGIN ARRAY A[l:N,1:N]}; END; GOTO L END A value for N is calculated in this example, possibly dependent on some data read into the program, and used to declare the array A, which is used to process the data in the inner block. When the end of the inner block 1is reached, the space used by A is recovered and control passes to L, where another value for N is calculated, and the process repeated. 10-3 CHAPTER 11 PROCEDURES Procedures are similar in concept to the FORTRAN more sophisticated and general applications. subroutine, but with A "procedure" is a portion of an ALGOL program that is given a name for identification and can be ‘"called" from any part of a program which is in the scope of the body of the procedure. A procedure can execute a number of statements, and in the case of function procedures can return a value to the procedure body. In addition, it may or may not have parameters. In DECsystem-10/20 ALGOL, a procedure can be one of the following types: integer, real, 1long real, Boolean, string or typeless. The formal parameters of a procedure (know as "dummy variables" 1in FORTRAN), can be one of the following types: integer, real, long real, Boolean or string, as scalars, arrays or procedures, or label. There are eighteen different types of parameters. In addition, all of these parameters may appear in two different modes and strings, neither of which 1is the same as FORTRAN's method of handling parameters. 11.0.1 PARAMETERS CALLED BY "VALUE" Calling parameters by "value" 1is the most common and, with the exception of arrays and strings, the most efficient way to pass a parameter to a procedure. The value of the expression presented in a procedure call, known as the actual parameter, is evaluated on entry to the procedure and assigned to a formal parameter within the procedure. This formal parameter acts as a local variable in the procedure which is initialized, the initial value being that of the actual parameter supplied in the call to the procedure. Since, string should 11.1 in the case of arrays or strings, a new copy of the array or 1is made, this type of parameter-passing for arrays and strings be avoided unless specifically required. PARAMETERS CALLED BY Calling parameters by "NAME" "name" is a useful method of passing a parameter to an ALGOL procedure. Whenever the formal parameter associated with the actual parameter in a procedure body appears in the body of the procedure, the actual parameter is re-evaluated as if it appeared in the procedure body at that point. For example, if the actual parameter were an array element such A[I] 11-1 as PROCEDURES the element would be re-evaluated using the value of I time the formal parameter is used, not the value of I procedure body is entered. available each at the time the Table 11-1 shows the different types of formal parameters, with actual parameters that can be substituted in a procedure call. Table Parameter Formal Parameter in a 11-1 Procedure Permissible Type wvalid Call Actual Parameter Integer Real Any Long arithmetic expression Real Boolean Any Boolean String Any Label A label 12 and Switch string or expression expression switch Paragraph (refer element to Chapter (refer to 13) Chapter 14.4) A switch Integer Array An array of type integer* Array) | An array of type real* An array of type long Boolean Array An array of type Boolean String Array An array of type string Procedure A non-type Real Array (or Long Real Array Integer real* procedure Procedure Real Procedure Long Real Procedure A procedure real of type integer, Boolean A procedure of type Boolean A procedure of type string String Procedure Procedure real, or long *In the case where the array parameter is called by wvalue, any arithmetic type (integer, real or long real) array is allowed as an actual parameter. A type conversion takes place during the copying process. 11.2 PROCEDURE Procedure type of HEADINGS headings identify the type parameters. 11-2 of procedure, the number and the PROCEDURES A procedure heading 1. type The consists of of: procedure (omitted in the <case of typeless procedures). 2. The word PROCEDURE 3. A 4. A list of the followed by a 5. Specifications semicolon Omitting if the REAL BOOLEAN by procedure the has formal parameters, semicolon. of formal LONG followed the parameter PROCEDURE PROCEDURE PROCEDURE formal name of the procedure. no parameters, enclosed otherwise in parentheses, and parameters. specifications, this looks like LR; BOOLEAN (I,J,K); CALC (THETA,X) ; The formal parameter specification that follows consists of a list of descriptions of the formal parameters, appearing in any order, and a value specification if any of the parameters are to be called by value. (If this 1is omitted, the parameters, by default, will be called by parameters VALUE meaning name.) for I,J; that (scalars), the For example, the second example above INTEGER all and and formal J called by name. A typical third example might be: REAL PROCEDURE of the formal be: I,J,K; three 1 specification might THETA; are parameters to be formal ARRAY called by parameter are of value, type while integer K specification is to for be the X; NOTE Procedure headings the procedure. must precede the body of 11.3 PROCEDURE BODIES The body of a procedure is that part which follows the procedure heading, and consists of a single statement, a compound statement, or a block. In the last-mentioned case, there may be declarations of local variables within the block, and also other blocks or Consider the following examples of realistic procedures: l. A a real real procedure, quantity. SQUAREROOT, The first to calculate parameter is the the procedures. square root gquantity, of the second is a label that is used as an escape if the quantity is found to be negative. The result of the procedure is the square root of the quantity. Note how the result of the calculation 1is assigned to the procedure by placing the name of the procedure on the left-hand side of an assignment. 11-3 PROCEDURES REAL PROCEDURE BEGIN IT: VALUE X; REAL Y, Z; IF X < Y := (1 Z : (X/Y IF Y OK: SQUAREROOT (X,L) ; REAL 0 THEN + ABS(Z LABEL GOTO L; L; X)/2; + - :=Z; X; Y)/2; Y) < GOTO SQUAREROOT l&-6 THEN GOTO OK; IT; := Z END The previous example uses the Newton-Rapheson method of finding the square root of a number by taking an initial approximation (1 + X)/2 and iterating until the difference between successive approximations 1is less then 1&-6. The procedure is again described below, with the aid of some commentary. The DECsystem-10/20 ALGOL alternative method of commentary (refer to Chapter 2) is used for brevity: REAL PROCEDURE VALUE BEGIN X; ! SQUAREROOT (X,L):; REAL X; CALCULATES USING L IS THE THE SQRT (X) NEWTON-RAPHESON METHOD. FOR THEN GOTO Y,2; IF X < Y := Z := IF ABS(Z-Y) L; OF USED REAL 0 LABEL AN VALUE ESCAPE L; IF X ! EXIT IF (1+X)/2; ! FIRST (X/Y ! ITERATE; < X 0; < 0; APPROXIMATION; IT: Y + Y)/2; < 1l&-6 THEN GOTO OKj; ! TEST Z; GOTO IT; ! OTHERWISE Z; ! FINAL := FOR CONVERGENCE; CONTINUE; OK: SQUAREROOT := RESULT; END 2. This functiéon procedure times) G where evaluates over N is the the sum integers also 1 of a parameter 11-4 the ..... of values N (that of is, any real iterating the procedure. N PROCEDURES PROCEDURE VALUE BEGIN SUM(G,N); N; REAL INTEGER X := PROCEDURE I; REAL X; 1 UNTIL N G; INTEGER N; 0; FOR I := SUM := DO X := X + G(N); > REAL END NOTE In this example, the formal parameter G is invoked so that the actual procedure substituted for G is called. 11.4 PROCEDURE CALLS In the preceding example, the procedure G was "called". Since G is a function procedure, it is only necessary for its name to appear in an expression for the procedure to be entered with the actual parameters specified substituted for the formal parameters. The procedure P causes An := the example SQUAREROOT SQUAREROOT(Z square root of use the + be of Z + the 0.5 of := SUM(SQUAREROOT,J) " 2; is a example to of the MATRIXMULT(A,B,C,N); VALUE ARRAY BEGIN A,B,C ; INTEGER I,J,K; COMMENT THIS A. THE similar way, for REAL OF B ARRAYS BOUNDS SUM first can J be used integers, to with and the calls: PERFORMS THE MATRIX STORES THE INTEGER N; X; PROCEDURE MULTIPLICATION IN a example: calculated. a procedure PROCEDURE N; in be procedure roots X further called 0.5,ERR) of the sums of the square squared, as follows: Here can AND ARE AND OF FOR I := 1 UNTIL N DO FOR J := 1 UNTIL N DO BEGIN X := C AND ASSUMED 1:N,1:N: 0; 11-5 TO BE RESULT SQUARE calculate the result PROCEDURES := FOR K 1 UNTIL N X DO := X + B[I,K]*C[K,J]; A[{I,J] := X END END A typical call for this procedure might be MATRIXMULT (E,F,G,N); or MATRIXMULT(E,F,F,N); Since the arrays MATRIXMULT (E,E,F,N); are called by would give rather name, a interesting call results. such This call could be made to work by calling B and C of MATRIXMULT B, C, N) by value. However, this would increase the overhead of procedure considerably. 11.5 ADVANCED USE OF 11.5.1 as (A, the PROCEDURES Jensen's Device This method of using a procedure exploits the power and flexibility of the call-by-name concept. Consider the following example: REAL PROCEDURE BEGIN REAL VALUE N; INTEGER I,N; REAL X; Y; SUM := 1 UNTIL N DO Y : 2 := + I = FOR ] :=0 < Y SUM(I,N,X):; END On the surface, However, Z the consider := procedure appears the to calculate the value of N*X. call SUM(J,10,A[J1); and remember that J and A[J] are parameters called by name. Since 1 and consequently J take new values, each X in the loop is evaluated as a particular value of A[J], using the value of J just assigned. Hence the above A{l] Similarly, 2 := call calculates + A[2] the + ..... + A[10]. call SUM(KIMIA[IIK]*B[KIJ] ) H 11-6 PROCEDURES calculates 11.5.2 the (I,J)th inner product of A and B. Recursion ALGOL procedures are recursive, that is, they may call directly or indirectly, to any reasonable depth. restriction is the amount of core storage available to program.) An often-quoted and very inefficient method of the factorial function of a small positive integer N is: INTEGER IF N ELSE = PROCEDURE 1 THEN FACTORIAL(N); FACTORIAL FACTORIAL := := VALUE N; := causes the FACTORIAL (The only the object calculating INTEGER N; 1 N*FACTORIAL (N-1); This procedure has only a single statement, but and can therefore be written in a compact form. J themselves, no local variables, A call such as FACTORIAL(6) ; procedure to be entered with 1inside FACTORIAL enters the N equal to procedure a 6. The call to second time with N equal to 5, but this N is different from the one to the previous N, which retains its value of 6, and is stored in a different space. 1In this particular case, FACTORIAL is entered six times, the last time with 11.6 N equal to 1. LAYOUT OF DECLARATIONS Declarations assignments, 1) scalars Procedure must always procedure and arrays bodies and that WITHIN BLOCKS be made at the head of a block, before any calls, etc., in the following order: 2) procedures and switches (see Chapter 12). occur in a block should at the head of the block, although this necessary. Consider the following example: follow the 1is only declarations enforced when BEGIN PROCEDURE BEGIN P (X); INTEGER VALUE X; REAL X; the body J; END; INTEGER The I; assignment of I to J within of P utilizes the 1 that is | 11 ~ declared following the body of P, rather than some global I. However, the compiler has not yet "seen" this I and, therefore, cannot take any rational action. In a case such as this, the user must declare I before the body of P: PROCEDURES BEGIN INTEGER PROCEDURE BEGIN I; P(X); INTEGER VALUE X; REAL X; J; END If the user neglects to declare I before P, the compiler can easily detect the <condition, because either I is unknown at the time of the assignment to J, or else there is a more global I available, whereupon an error message Will occur when the declaration of I is found following the body of P. 11.7 FORWARD Although REFERENCES most ALGOL-60 DECsystem-10/20 ALGOL compilers operate compiler in operates some minor restrictions have to be restrict the user in other ways. made to two in or one more pass. ALGOL-60 A in passes, the Consequently, order not to forward reference for a procedure has to be given when a procedure is called (either directly, or indirectly, by passing the procedure name as an actual parameter in a procedure call) before its body is encountered by the compiler. 1In most cases the user can avoid this situation by a minor re-ordering of the program. However, 1in rare cases 1like the following, where procedure P calls procedure Q, and vice versa, a forward reference, as shown, must be given. BEGIN FORWARD REAL PROCEDURE BEGIN REAL PROCEDURE P(X); VALUE Q; X; REAL VALUE Z; X; Y; END; REAL BEGIN PROCEDURE REAL Q(Z); F; END; 11-8 REAL Z; PROCEDURES "In general, a forward reference consists of the word FORWARD, followed type of the procedure (omitted if the procedure is typeless), the by For example: the word PROCEDURE, and the name of the procedure. INTEGRATE FORWARD LONG REAL PROCEDURE or PROCEDURE FORWARD PROBLEM NOTE The same forward block reference must occur as procedure the A forward reference has to be given for For cases: rare following 1. The label 2. A variable of in the BEGIN REAL L; BEGIN FORWARD in 1label is used as an actual parameter and has not yet appeared is a body. in the program. the in either of in a procedure call, identical name has appeared in the program scope of the procedure the call. and example: L; P(L); L; * o & o @ END; In this case, a forward reference for L must be given. EXTERNAL PROCEDURES 11.8 If a procedure is to be compiled independently of a program (see Paragraph 18.1.1), an EXTERNAL declaration must be made in the program a of The form of this is the same as that instead of the procedure. but with the word FORWARD replaced by EXTERNAL. declaration, FORWARD For example: EXTERNAL INTEGER PROCEDURE CALC the within any block 1in Such an EXTERNAL declaration can be made program, and has the same scope as if the procedure appeared at that point. 11-9 PROCEDURES At present scanned only the 11.9 all EXTERNAL in a first procedure library must six characters ADDITIONAL METHODS OF names Comment Following the terminated by For a After in program or characters, a as COMMENTARY Two further ways of writing commentary addition to COMMENT and ! described in 11.9.1 referenced differ in their first six are available to LINK. are available Section 2.4. to the user in END delimiter word semicolon, with commentary may END, the user may add commentary, the following restrictions: 1. The only contain letters and 2. If the reserved delimiter word mode employed, any words appearing in the delimiter words. digits. of compilation comment may not |is be example: END ‘OF PROC 11.9.2 INVERT; Comments Within Procedure Headings This method of commentary allows the user to comment formal parameters in a procedure heading. This is done by enclosing the commentary, which may consist of letters only, between the symbols ) and :( and omitting the comma on the left of the formal parameter. This cannot apply to the first formal parameter. The example REAL can thus REAL in Section PROCEDURE be to be := SUM (K, commented Z:=SUM(K) M, (1, X); N, is: as SUM(I) In a similar fashion, The following example Z which SUM rewritten PROCEDURE 11.6.1 COUNT: (N) INCREMENT: (X); a call to such a uses the call to procedure can be commented. SUM in Section 11.6.1: A[I,K]*B[K,J]):; as: COUNTER: (M) CROSS PRODUCT: 11-10 (A[I,K]*B[K,J]); CHAPTER 12 SWITCHES 12.1 GENERAL Switches enable the user to depending to jump one of a number provide automatic detection when such an expression is for 12.2 the labels, of the value of an arithmetic expression, and in addition, on out of range switch. SWITCH DECLARATIONS A switch declaration takes the form of the word SWITCH followed by the These the switch, an assignment (:=), and a list of labels. of name switch the of scope are called switch elements, and must be in the For declaration. SWITCH SW := example: LAB,L1,L2,0K,STOP; A switch name must follow the usual rules of scope and, therefore, must not conflict with any local variable of the same name. In addition to the example above, a switch element may also be one the labels in the switch declaration. 12.3 USE OF of SWITCHES by made 1is declaration switch a in A jump to a particular label the word GOTO with the name of the switch and an arithmetic following expression in square brackets. Thus: GOTO SW[I] This causes control to pass to the 1I'th 1label in the switch declaration, wunless 1 1is negative or zero, or 1is larger than the there case, 1In either number of switches in the switch declaration. 1If the expression in square brackets is of control. transfer no is the Consider usual. as rounded not integral, it is evaluated and following more SWITCH SwW SWITCH TW complicated example: := LAB,L1,L2,0K,STOP; L3,SW[J],L4; GOTO TW(I]; 12-1 SWITCHES If I has More has the the value value 1, a sophisticated 3, a jump jump to switch to LAB L4 occurs. occurs, elements are 12-2 via If SW. I described has in the value 2 and Chapter 14. J CHAPTER 13 STRINGS 13.1 GENERAL DECsystem-10/20 ALGOL-60 includes a major extension to the string features defined 1in the Revised Report. Users wishing to run their programs on machines other than the DECsystem-10 should check whether the compiler they will use offers similar facilities. Scalar, array or procedure variables may be of type STRING, and are declared by the delimiter word STRING. The byte size, length and contents of string variables are defined via the various assignment statements described below. Typical string declarations STRING S,T; STRING PROCEDURE 13.2 STRING STRING might ARRAY B(X); EXPRESSIONS be: SA[1:10]; VALUE X; REAL X; AND ASSIGNMENTS String expressions are 1limited to a single variable, a string procedure call or a string constant. (For a full description of string constants see Section 4.4.) The only string operators are the comparison operators and the assignment operator. All other operations are Section 13.7. String achieved expressions via can be the string assigned library procedures only to string described variables. in For example: S:=T; SA[I]:=SA[3]; SA[2]:=B(Z2); T:="ANY 13.3 BYTE ""OLD"" IRON"; STRINGS The value associated with a string variable is a byte string. A byte string is a sequence of bytes of a uniform size between one and thirty-six, which can be efficiently handled by the DECsystem-10/20 hardware. 1In some ways, byte strings can be thought of as arrays, but the most important difference is that the size of a byte string can vary continuously. Thus when a byte string is created by means of a 13-1 STRINGS READ statement, the programmer need not know how long the be. The routine starts accepting characters after open quotation marks and continues until the close have been When one string will encountering the quotation marks read. string is assigned to another, e.g., S:=T; then a copy of T is made to which S will refer. Any previous value of S is destroyed (and the memory space occupied 1is released). Subsequent changes to the value of T will not affect S, or vice versa, unless a further assignment is made from one to the other. NOTE This is an important implementation Version 13.4 BYTE Byte strings of change from the strings prior to the byte 5. SUBSCRIPTING can mechanism. be modified Individual bytes by means of in a string are subscripting referenced by following the string variable name by a decimal point and number enclosed in square brackets. For example then the subscript S.[I] refers to the I'th byte arithmetic expression array subscript. of and string S. is evaluated The subscript may be any in exactly the same way as an Byte-subscripted string variables are regarded as being of type integer, having an integer value equivalent to the byte to which they refer. Therefore, to change the value of a particular byte in a string, a byte-subscript must appear on the left-hand side of an arithmetic statement with the appropriate new value on the right-hand side. If the new value is too large to be held in the byte, this is simply truncated. No warning is given. 13.5 NULL STRINGS Until a value is assigned to a string by the program, the string takes null value. That is, it is assumed to contain no bytes. Any attempt to reference the string by a byte-subscript will result in a fatal run-time error, though it can be used on the right-hand side of a string assignment, in which case the variable to which it is assigned similarly becomes null. 13.6 STRING COMPARISONS Two byte strings can be compared with comparison operators. For example IF S < T THEN GO TO L; 13-2 each other wusing the usual STRINGS where S and T are string variables, string constants or string procedures. The effect of the comparison is to compare the strings byte-by-byte, the "lesser" string being that with the first lower value byte, working from 1left to right. Thus "ABCD" is less than "ABCE" or "ABCDE". Where the strings to be compared are of different byte sizes, then the smaller bytes are regarded as being extended on the left by null bits. In the special case of ASCII strings (strings of byte size 7, like string constants), trailing nulls and trailing blanks, or any mixture thereof, are treated as equal. Similarly ASCII strings of different lengths will compare equally if the extra length comprises only spaces and nulls. 1In all other cases strings of unequal length can only be regarded as equal if the extra length consists entirely of null bytes. 13.7 LIBRARY PROCEDURES Section 16.6 deals with applicable to strings. the 1input and output The procedures LINK, LINKR and TAIL that were until Version 3B have been dispensed with. 13.8 procedures included the are 1library CONCATENATION A string can be assigned the concatenated value of the in that procedure CONCAT. For two strings with example S:=CONCAT(T,U) ; S:=CONCAT (S,T) ; If, in the first example, T had a different byte size from U, then the size of the first string encountered (T 1in this case), would be adopted by S. The bytes copied from U would be truncated or filled with null bits as appropriate. 13.8.1 Length And Size The primary attributes of a string, that is, length in bytes and byte size 1in bits, are returned by the integer procedures LENGTH and SIZE, respectively. Thus I:=LENGTH(S); J:=SIZE(S); would return the number bits in each byte in J. 13.8.2 of bytes in string S in I, and the number of Copying A new byte string can be generated from an existing one by means of the string procedure COPY. This procedure can have one, two or three parameters. 13-3 STRINGS 1. The effect as a retained 2. Where of COPY simple for there with string the are sake two one parameter assignment, of is but precisely this the feature same has been assigned the continuity. parameters, e.qg., S:=COPY (T,M) ; 3. where M value of If there is an arithmetic expression, then S the first through M'th bytes of T. are three parameters, is e.qg., S:=COPY(T,M,N); where both M and N assigned the value 13.8.3 are arithmetic expressions, of the M'th through N'th bytes then of T. S is Newstring Although bytes in a null string may not be referred to (see Section 13.5 above), a string containing nulls of any appropriate byte sizes can be created by using this string procedure. NEWSTRING takes two parameters, the first being the number of null bytes to be assigned to the string, and the second their size. For example S:=NEWSTRING(100,7) ; causes a null string of 100 ASCII nulls to be assigned to S. Although S 1is 100 bytes long at this point (and thus byte subscripts up to and including S.[100] are valid), any subsequent assignment of another string to S may vary both the length and byte-size of S. 13.8.4 Delete | 13 > In Section 13.5 it was explained that if a null string is assigned to another string, then that string also becomes null, and the value previously held is lost. Any space that the previous value occupied is returned to memory, as with any ordinary string assignment. The typeless procedure DELETE has the same effect on the string passed to it as a parameter, as the assignment of a null string would have. Deleting a null string has no effect, beyond using computer time. CHAPTER CONDITIONAL 14.1 14 EXPRESSIONS AND STATEMENTS GENERAL ALGOL-60 allows and conditions. Consider, according great flexibility for example, to the value in a variable I of a Boolean the construction which could variable B: of expressions be set equal to 0 or 1 this could be written as: I := 0; IF B THEN I := 1; Also, consider the case where depending on the value of B: IF 14.2 B THEN X1 Y; IF NOT user B wants THEN X2 to := perform some action, Y; CONDITIONAL OPERANDS ALGOL-60 allows operand 1in IF THEN ..... For := a := Clearly, J IF the B this :=J user to expression ..... instance, I the an + by 0 example ELSE a conditional operand use of a construction for any involving compact (IF 1 < THEN Note that the conditional unbracketed when it forms above can be rewritten 1; is more K the ELSE. first THEN substitute and 1 of -K great ELSE operand must complete the use in cases such as: K-1); be bracketed, and may expression itself. only be In general, a conditional operand may replace an operand in any arithmetic or Boolean expression. 1In addition, a conditional operand may also replace a label and act as an element in a switch 1list, for example: SWITCH SW := L1, IF It is also permitted, in subscript), for example: X := A[I, IF L = 0 B THEN an THEN L2 ELSE L3, L4; array subscript J J+1]; ELSE 14-1 (and also 1in a byte CONDITIONAL EXPRESSIONS AND STATEMENTS Since a conditional operand may replace any operand in an expression, operands may also be replaced in conditional expressions. Consider the following example: IF This IF B looks THEN Bl ELSE complicated 14.3 The (IF B THEN Bl CONDITIONAL reader IF B was THEN in Chapter 7. demonstrated. First, S1 IF I := is really ELSE B2) THEN Thus: introduced S1 ELSE I + 1; quite I := I simple + if brackets are 1; and S2 can < THEN to conditional statements of the form S2 full BEGIN END I STATEMENTS The 0 THEN but inserted for clarity. IF B2 power be of this compound I := -I; B I := I+ 1; type of statements := statement or blocks. can For now be example: FALSE ELSE BEGIN GOTO L2 END Second, can be the whole structure of made more powerful themselves. For example: This IF X is equivalent Ll: < 0 THEN IF NOT X := IF NOT GOTO X := to X < 0; B 0 the ELSE the by IF IF ..... THEN ..... ELSE statement using conditional statements within B following 0 THEN GOTO L2; THEN GOTO GOTO THEN GOTO sequence L of statements: L1; L2; L; L2: Clearly the former method of expression elegant. Conditional statements take the IF B where S1 is any clarify IF THEN S1 ELSE and S2 may ambigquity, both be conditional bracketing wusing Consider the B IF THEN X = and more S2 this. THEN 1is both briefer general form 0 following Y := Z example: ELSE 14-2 statements. However, if there BEGIN and END must be used to P := Q; CONDITIONAL This could IF B be interpreted EXPRESSIONS AND STATEMENTS as THEN BEGIN IF X = 0 THEN ELSE P := Q IF THEN Y := 2 Y := Z END or B BEGIN IF X = 0 THEN case is ELSE P := Q END The first Ll: interpreted IF NOT B THEN IF NOT X = Y : X; P := Q; GOTO 0 THEN GOTO L2; as: L1; GOTO L2; L2: The second Ll: case is interpreted IF NOT B THEN IF NOT X = Y := Z; P := Q; GOTO 0 THEN GOTO L2; as: L2; GOTO L1; L2: ALGOL-60 forbids IF THEN ..... 14.4 such ..... DESIGNATIONAL A designational GOTO ambiquities either parameter of element. Thus the L1 type forbidding the sequence is something directly, label. This following or that acts indirectly may are as via an a argument formal simply be designational a label or expressions: X+Y TW[J] L IF B THEN IF X < 0 THEN THEN EXPRESSIONS expression statement, by ELSE. ELSE L2 SW[I] ELSE IF 14-3 >= Z THEN ELSE L in a procedure a switch CONDITIONAL EXPRESSIONS AND STATEMENTS These designational expressions would be used GOTO L; GOTO GOTO IF B THEN L1 ELSE L2; IF X < 0 THEN SW[I] ELSE IF X+Y >= in the following manner: Z THEN TW[J] ELSE L; CHAPTER 15 OWN VARIABLES 15.1 GENERAL OWN variables are a special kind of ALGOL variable, and may be of type 1long real, Boolean or string, either scalar or array. real, integer, The variables have the following properties: 1. Although following the normal scope rules, the variables are not recursive; the same copy of each variable being used in all occurrences of a procedure or block. 2. When control passes out of a block, the values are retained and are still available when the block is re-entered. 3. of execution before zero The initial value is set to in the case of Boolean OWN variables.) (FALSE program. STRINGS are initialized to possess no byte string. the OWN with the OWN variables are declared by writing the usual declaration it. word OWN preceding OWN INTEGER For example: I,J,K; OWN REAL ARRAY THETA[1:M]; 15.2 OWN ARRAYS implemented are arrays OWN The ALGOL. DECsystem-10/20 following 1. rules. If this is the first time the array is declared, space 1is obtained and then the array laid out. If the array has been laid out before, 2. proceed to Step 2. The bounds are examined to ensure that these are identical to ones of the previous construction of this array, and the the array is left unaltered if found to be of the same dimension; otherwise, 3. in fashion completely dynamic a 1in according to the declaration proceeds proceed to Step 3. any, 1if A new array is constructed and the common elements the remaining elements are the old array; from copied are allocated the and deleted then The o0ld array is zeroed. space For example, is recovered for future use. if an OWN array A is declared as follows: OWN REAL ARRAY A[1l:M,M:N]; 15-1 OWN where M = 2 and N = 5 time, the elements remaining elements of the first [1,2], the new VARIABLES time, [1,3] array and and are 15-2 M = 1 and [1,4] are zeroed. N = copied 4 the over, second and the CHAPTER DATA 16.1 Data 16 TRANSMISSION GENERAL transmission encompasses the input and output of data between the user's program and peripheral devices, such as disk, DECtape, magnetic tape, card reader, card punch, and line printer. The DECsystem-10/20 ALGOL object-time system, in <conjunction with the ALGOL library, provides the user with a set of basic procedures for handling data from most DECsystem-10 or DECsystem-20 devices in a uniform fashion. The user may also perform input/output operations with wvirtual peripherals that appear as byte strings in the user's program. All peripheral be allocated devices are under the user's control completely and or released at any time throughout the execution of can the program. The user can handle up to sixteen devices simultaneously (seventeen, 1if one of them is the terminal attached to the job), any number of which may be file devices (disk, DECtape) and have independent 16.2 files open. ALLOCATION OF PERIPHERAL DEVICES Peripheral devices are allocated to the user's program by calls to the library procedures INPUT or OUTPUT. A call to one of these procedures usually has two parameters. The first 1is the channel number, an integer in the range 0 to 15, on which the device is to operate. Only one device at a time may be operated on a channel. A channel provides either input or output facilities, except in the case of a terminal, where the input and output functions are performed simultaneously on the same channel. The second parameter is either a string or a string constant. The text contained in the string is the logical name of the device to be allocated to this channel. The DECsystem-10 or DECsystem-20 Users Handbook should be consulted, as appropriate, for an explanation of what constitutes a logical device name. In the simplest case, the name may be the actual name of the peripheral device. Device names shown 1in Table 16-1 are recognized as standard. l6-1 DATA TRANSMISSION Table 16-1 Standard Device Names Device Name Peripheral DSK DTA MTA CDR CDP LPT PTR PTP PLT TTY For example, channel 5, Disk DECtape Magnetic tape Card reader Card punch Line printer Paper-tape reader Paper-tape punch Plotter Terminal to allocate the card reader the user would use the for use as an input device on statement INPUT (5, "CDR") ; or, if S were a string characters CDR in it, possessing a byte string that had the INPUT(5,S); Similarly, if the disk were to be used an as output device on channel 9: OUTPUT (9, "DSK") ; NOTE With the exception of terminals, all devices are allocated to operate in one direction only; thus, if the user wants input and output from the disk, two separate channels must be used. Terminals are always allocated bi-directionally, whether the user uses INPUT or OUTPUT. For example, irrespective of INPUT (O, "TTY") ; allocates 16.2.1 the user's terminal for input and output on channel 0. Device Modes Normally, a device is allocated in ASCII mode, that is, when the user reads a character from the device, the readable text, such as a stored source program or data is represented by a 7-bit byte. To allocate the device in a different mode, a third parameter is specified in the call to the INPUT or OUTPUT procedure. Thus, to allocate a disk to channel 9 in binary image mode (the mode used for the storage of binary data on a disk), the user can OUTPUT (9, "DSK",11); 16-2 use DATA TRANSMISSION The DECsystem-10 or DECsystem-20 Assembly Language Handbook should be consulted, as appropriate, for a full explanation of the different modes used with peripheral devices. The INPUT and OUTPUT procedures allow the wuser to allocate any standard peripheral device in any buffered 16.2.2 The mode. Buffering INPUT and OUTPUT procedures allocated device (terminals normally allocate two buffers are allocated two buffers for for each input and two for output). The user may desire to use either one or more than one buffer for a device. For example, in a non-compute bound job that uses a lot of disk transfers at odd intervals, four or even eight buffers may be desirable to increase the speed of execution of the program. The number of buffers to be used can be controlled by adding a fourth parameter to the procedure call. Thus, to allocate a disk on channel 14 in mode 0 with eight buffers, the call is ouTPUT(14,"DSK",0,8); NOTE The mode must always be allocating buffer space, would be an ambiguity specified otherwise in the when there third parameter. 16.2.3 Error Returns Normally, if the device allocation fails (for example if the device is in use by another job), a suitable message is typed and the program terminated. The user can prevent this by providing, as the fifth parameter to INPUT or OUTPUT, a label to which control is to be passed in the event of an error. For example: ouTPUT (14, "MTA",0,0,ERROR.LABEL) : If the range, actual label parameter is the procedures behave a switch whose subscript 1is out of as though the label parameter were absent. NOTE The third and fourth parameters must be specified in this case to avoid ambiguity. However, if Zeros are specified, then default values will be taken. The default being ASCII mode and 2 buffers for the third and fourth parameter respectively. 16-3 DATA 16.3 SELECTING Before a user has already output uses must All input CHANNELS a device to transfer data, allocated to some channel, been channel channel. selected INPUT/OUTPUT TRANSMISSION be "selected" for use assuming that the device the appropriate input or as the input data input and output always occurs on channel and output channel, respectively. or output the currently The user may change the selection of channels at any time, switching from one channel to another without 1loss of data, irrespective of whether complete 1lines (or records) of data have been read or not. In fact, the DECsystem-10/20 input/output system does not assume any structure in the through data: which To select be made. all input and the user pulls an input This has output channels or pushes data. are regarded as pipelines channel, a call to the procedure SELECTINPUT must one parameter, which is the channel number. Thus SELECTINPUT (5) ; causes input Similarly, channel the 5 to procedure be selected. SELECTOUTPUT channel. 16.4 Some of a FILE is used to select an output DEVICES peripheral devices, such as disk and DECtape, require the opening specifically named file before any input or output operations can be performed. This optionally may be performed on spooled devices (refer to the appropriate Operating System Commands manual for a description of spooling). The opening of this file is performed by means of the procedure OPENFILE, which is called after the device has been allocated to a channel. The procedure call has two parameters: the channel number on which the device has been allocated and a string variable possessing a byte string or a string constant, the text of which is the name of the file. The user can number of a also file specify a by means protection optional integer parameters. For example, on area the user disk [11,50] OPENFILE When a and/or project-programmer and fourth Boolean or of to could open third a file with protection (9,"TEST.DAT",%177,%000011000050); user has finished with a file it should be closed. by using the procedure CLOSEFILE, with a parameter number on which the file is open. Thus, closed channel 177 write A file that is is the CLOSEFILE(9) ; closes The the user file may that also already open, new supplied. name is open on rename use of or delete OPENFILE Thus the (5,"TEST1.DAT"); OPENFILE (5,"TEST2.DAT"); string the file with containing name the new TEST1.DAT name is 9. existing causes sequence OPENFILE causes channel to file be renamed null, 16-4 files: the the to be if a renamed TEST2.DAT. original file is file |is with the If the deleted. DATA TRANSMISSION Thus, OPENFILE (5,"TEST3.DAT"); OPENFILE (5,""); causes the 16.4.1 file Error Normally, if TEST3.DAT optional the operation integer In be deleted. Returns does not exist), a terminated. The user OPENFILE. to requested variable the fails suitable message can prevent this by event of as an the error, (for example 1is typed providing an input and the a 1label fifth and sixth control will be file program and an parameters passed to to the label, with an error-code set into the integer variable if present. The error-codes are those returned by the ENTER and LOOKUP UUO'S (refer to Appendix E of the DECsystem-10 Monitor Calls Manual or Appendix A of the DECsystem-20 Monitor Calls Manual, as appropriate). NOTE The third and fourth parameters must be present if the error return parameter is specified. Defaults will be taken |if both parameters are specified as zero. If the actual range, the absent. 16.5 The The label integer RELEASING procedure parameter procedure is behaves error-code a switch as whose though subscript the 1label parameter is called a device by 1is out parameter of were name. DEVICES RELEASE is used to release allocated to channel from a channel. Thus, RELEASE (5) ; releases the device, and device a file automatically closed. channel input or 1is still Releasing to become free; output operations, open a 5. on device 1If the on if this channel is it is deselected. the device device, a is channel currently a this <causes selected If an attempt is made to allocate a device to a channel that has a device allocated, the allocated device is first released a file is open on the device it is closed before the release. If a user terminates his program without channels, these are automatically released. 16-5 releasing file will be a for already and, if devices on DATA TRANSMISSION 16.6 BASIC 16.6.1 INPUT/OUTPUT PROCEDURES Byte Processing Procedures The following procedures may be used with any device to handle bytes However, because they are bits). 36 to (1 size standard any of they bytes, normally used with devices supplying or accepting ASCII are "symbol" 1. oriented. INSYMBOL(S); causes the input channel - (where S is usually some integer variable) next byte to be read from the currently selected in S. and stored 2. OUTSYMBOL(J); - (where J is usually some integer expression) causes the value of J to be output as a byte to the currently selected output channel. If J is too large for the byte size of the device in use, it is truncated to size. 3. NEXTSYMBOL(S); look-ahead 4, acts in exactly facility of SKIPSYMBOL; channel 5. - the same way as INSYMBOL except that the byte pointer for the input channel is not advanced to the next available byte. This gives the wuser a to one byte. - causes the next byte be BREAKOUTPUT; read - and from the selected causes all bytes in the buffer of an output device to be sent immediately to it. This procedure is normally used to conduct a question-and-answer dialogue on a terminal, with the question and answer on the same line. Normally, a block of data is sent to a device only when buffer is full (the exception being the terminal, break is sent at the end of each line). 16.6.2 input ignored. the where a String Output A byte string may have its contents transferred to the «currently selected output channel by means of the procedure WRITE, whose single that variable string a or constant string parameter is either a possesses the string to be output. For example: WRITE (S) ; or WRITE ("THE MOON IS MADE OF GREEN CHEESE"); following With exceptions explained in the paragraphs, all of the literally, with the exception, of string are output the in bytes fact in not are which constant, string a in quotes the course, of stored in the bytes string at all. NOTE Unlike some other ALGOL implementations, spaces and other non-printing symbols in in meaningful are strings byte DECsystem-10/20 ALGOL. 16-6 DATA Special editing characters the text of a byte string. P C Page or N New TRANSMISSION are permitted These have a within square brackets special function: within throw line T Tab S Space B Break (C stands for carriage return, line feed) output Any combination of these characters, with optional preceding repetition counts, can appear within square brackets in a byte string and are output as their special interpretation demands. For example: WRITE ("ABCD[P2C5S]EFGH") ; causes To the following 1. the symbols 2. two new 3. the symbols output [ the 1 " these must ({ 11 to output: followed and five by a page throw spaces EFGH. or; appear in "" or ;: the form Thus = 3;;"""); text output. be 16.6.3 The ABCD lines WRITE ("""A[[I]] the be symbols respectively. causes to Miscellaneous procedures SPACE, Symbol TAB, Procedures PAGE, and NEWLINE cause number of spaces, tabs, page throws, or new lines number is specified by a single integer parameter. is omitted a value of one is assumed. Thus SPACE (5) ; causes five spaces to be output, be output. whereas SPACE; or SPACE (1) ; cause one space to 16-7 the appropriate to be output. This If the parameter DATA 16.6.4 Numeric and TRANSMISSION String Procedures Numeric procedures are used to read and print numeric quantities. The procedures will normally be used with a device that is operating in ASCII mode, and are capable of processing integer, real, or long real guantities in fixed-point and floating-point representation. 16.6.4.1 Numeric Input Data - Numeric data for input can be represented in any format that would be acceptable as a numeric constant in a program, irrespective of the type of variable involved. When a number 1is read, an automatic type conversion is performed, giving a result of the same type as if an assignment of the data represented as a constant in the program had been executed. There is a minor restriction 1in that no spaces, tabs, or other non-printing symbols may appear in such numeric data except between the exponent sign (& or @ for real, && or @@ for long real) and the exponent. guantity may recommended For Otherwise, any symbol that is not a part of a numeric act as a terminator for such a quantity. It is strongly that spaces, tabs, or new lines be used as separators. example: 3.4 0 ©9.6 1.36 -52 14.9 NOTE In reading terminating symbol that is a numeric quantity, the symbol, that is, the first is not part of the number, lost. DECsystem-10/20 ALGOL also allows the wuser to data written in FORTRAN format, that is, using E && or Q@@. However, no other special effects formatting are introduced. The procedure READ is used to input This may any procedure have installation-dependent maximum), Boolean, or string. The effect is input floating-point for & or @, and D for inherent in FORTRAN as numeric number of type data of and also parameters integer, real, strings. (up to 1long an real, follows: l. For integer, real and long real variables, a number is read and converted to the type appropriate to the parameter and then assigned to the variable. 2. For and 3. For a string variable, the data text is scanned until a quote (") 1is found, and the text following this up to but not including the next free gquote is read in and a byte string generated, which is then possessed by the string variable. If the string Boolean, assigned sequence "" continues. is a number is read to the variable. found, a single 16-8 as " is if for an stored, integer and wvariable, reading of the DATA TRANSMISSION 16.6.4.2 Numeric Output Data - Numeric data is output by means of the procedure PRINT. This procedure may have one, two, or three parameters, the first of which is the variable to be printed. This variable may be an integer, real, or long real. The second and third parameters determine the format to be used and are integer expressions. If omitted, both parameters are assumed to be zero. The effect of the various combinations of the format integers, M and N, is as follows: M>0, N>0: Fixed-point point, N printing, places M - if negative appears before the decimal and the sign moved up This M>0, N=0: The format same M=0, N>O0: preceding Floating-point decimal digits, && a for the space if decimal positive, before the number. point are replaced by to the number. the appears, always before sign, outputs as format A always fractional part is suppressed. This places after. M+N+2 and outputs format, Zeros spaces symbols. except that (2) decimal M+1 the (1) no point symbols. consisting of a sign, a digit, a decimal ©point, N more decimal and an exponent consisting of & for real, long two-digit real followed exponent, by zero the exponent suppressed sign and from the and N+8 left. This format symbols for If only two variables, and N take, parameters appear, outputs N+7 symbols for long real gquantities. format M,0 is real assumed for integer and format O0,N for real and long real quantities, respectively, the value of the second parameter. where M If only one parameter appears, the format is interpreted as 0,0 which assumes standard printing modes of 11,0 for integer quantities, 0,9 for real gquantities, and 0,17 for long real quantities. If the real user or properly requests 1long real rounded more digits numbers, printing of the the to be printed appropriate number to than are number of the significant zeros maximum in follow a precision available. 16.6.4.3 Octal Input/Output - The PRINTOCTAL, respectively, allow quantities in octal the procedures user to READOCTAL input and and output format. On input, for single precision variables, up to 12 octal digits are read, preceded by the symbol %, the terminator being any non-numeric symbol. For long real variables, two such octal numbers must be presented for input, each preceded by the symbol %. On output, 12 octal single precision each with 12 octal The foregoing type integer, digits, preceded variables. digits are by the procedures have one scalar real, real or Boolean. long symbol %, are printed for For long real variables, two quantities printed separated by a space. 16-9 parameter which may be of DATA 16.7 DEFAULT TRANSMISSION INPUT/OUTPUT If the user does not select any input or output <channels, input and output occur via an "invisible" channel from and to the user's terminal. Thus, for simple programs where the user wishes to input a few numbers and print a few results, he simply uses READ, types in the data on line through his terminal, and gets back the results from PRINT. 16.8 LOGICAL INPUT/OUTPUT In addition to the 16 channels used to communicate with devices, an additional 16 channels, numbered from 16 provided. These are input or output channels that use byte a means of storage. peripheral to 31, are strings as By means of the procedures INPUT or OUTPUT, the user can attach a channel to a byte string possessed by a string variable, and can read and write bytes from and to this byte string, either to and from a peripheral device, or to and from another byte string. INPUT (20,S); or ouTPUT (20,S) ; cause the byte string possessed by the string variable S to be used as logical channel 20; this channel may subsequently be selected for input or output, as appropriate. The user is still free, of course, to manipulate the individual bytes within the byte string by means of the byte-subscripting facilities available. Such facilities enable the user to read a file from a peripheral device into a string, process it in any way whatsoever, and output it again. 16.9 SPECIAL OPERATIONS These procedures are used on channels assigned perform operations of BACKSPACE, ENDFILE and takes one parameter, that 1is, the channel operation is to be performed. to magnetic tapes, and REWIND. Each procedure number on which the Since there is no implicit procedures enable the user to magnetic tape, these in any way he chooses. 16.10 structure on a build up formats I/O CHANNEL STATUS The status of any input or output channel can be determined at any time by means of the Boolean procedure IOCHAN, which takes an integer channel number as parameter. The status returned 1is bit coded as follows: 16-10 DATA TRANSMISSION Bit Value Meaning 18 $400000 Device 19 $200000 Directory device 20 $100000 Terminal 21 $040000 ASCII 22 $020000 Magnetic 23 $010000 Plotter 24 $004000 Set 25 $002000 Device is 26 $001000 Device can do 27 $000400 Device is 28 $000200 File open 29 $000100 End of file 30 $000040 Input status 31 $000020 Device can do output 32 3000010 Device is 33 $000004 File 34 $000002 Device quota exceeded 35 $000001 Output is physical if Set (i.e., not logical) device mode for is is tape default TTY on channel -1 spooled input initialized for for input input encountered ok initialized open status for for output output ok Some of these bits are of little use to the user, but, for example, if a device 1is allocated, and the user does not know whether or not the device is file-structured, IOCHAN can be used to determine this. The bits of particular use to the user are the input and output end-of-file. NOTE An end-of-file on output 1is a 1logical status indicating that, for example, a disk quota is exceeded or a DECtape 1is full, or 1in the case of a 1logical device, the byte string is full. When IOCHAN is used, so that the user end-of-file marker is the end-of-file flags are always cleared, if set, may proceed to read a magnetic tape after an found. The following example shows how the user would handle an unknown device whose name is given to the program via the user's terminal: 16-11 DATA TRANSMISSION BEGIN STRING DEVICE, FILE; WRITE ("CHANNEL NO: READ (CHANNEL) ; WRITE READ (" [C]DEVICE "); CHANNEL; BREAK.OUTPUT; NAME: "); BREAK.OUTPUT; (DEVICE); OUTPUT IF INTEGER (CHANNEL, TOCHAN DEVICE) ; (CHANNEL) AND %200000 THEN BEGIN WRITE READ (" [C]FILE NAME: "); BREAK.OUTPUT; (FILE); OPENFILE (CHANNEL, FILE) END; END NOTE When using IOCHAN, Boolean the rules expressions for implementation should See Section 5.2.1. 16.11 TRANSFERRING involving evaluation be borne in in this mind. FILES Once devices have been allocated to an input and an output channel, a complete file of information may be transferred between them automatically by calling the parameter-less procedure TRANSFILE. This procedure copies bytes from one device to another from the currently selected input channel to the currently selected output channel, until an end-of-file 16.12 status CURRENTLY is raised on SELECTED CHANNEL The number of the channel be obtained by use of the either the input or output channel. NUMBERS currently selected integer procedures 16-12 for input INCHAN or or output OUTCHAN. may CHAPTER THE DECSYSTEM-10/20 The operating of those procedures environment the user's program, The former are and those together with of as existing in 17 OPERATING ENVIRONMENT of DECsystem-10/20 ALGOL the DECsystem-10/20 ALGOL the DECsystem-10/20 procedures detailed ALGOL in programs Library Object Chapters those described below. These procedures in a block surrounding the wuser's therefore, are however, are in consists required Time 13 by System. and 16, can be thought program, and, available when called. The names of these procedures, no sense reserved as are words such as BEGIN. Note that these procedures are only present in the user's program when required. They are loaded by the DECsystem-10 or DECsystem-20 Linking Loader when so directed by the DECsystem-10/20 ALGOL Compiler. The user 1is not required to take any action to include these procedures, other than make is given below. 17.1 The a a call MATHEMATICAL following real type to them. A complete list of library PROCEDURES procedures expect one argument, of real type, base e) result. Procedure procedures Name Function SIN Sine cos Cosine ARCTAN Arctangent SQRT Square EXP Exponential LN Logarithm TAN Tangent ARCSIN Arcsine ARCCOS Arccosine SINH Sinh COSH Cosh TANH Tanh 17-1 root (to and yield THE DECSYSTEM-10/20 OPERATING ENVIRONMENT and type, The following procedures expect one argument, of long real vield a long real type result. Note that they are formed by adding an L before the equivalent single precision procedure. Function Procedure Name LSIN Sine LCOS Cosine LARCTAN Arctangent LSQRT Square LEXP Exponential LLN Logarithm root (to base e) The functions ENTIER, ABS and SIGN are also available, Section as described in 5.1.2. NOTE If arguments of type integer or 1long real are given in an ALGOL call to these procedures, the compiler plants the appropriate conversion code. 17.2 STRING PROCEDURES For details of and DELETE, 17.3 see the procedures CONCAT, Paragraph 13.7. LENGTH, SIZE, COPY, NEWSTRING UTILITY PROCEDURES 17.3.1 Array Dimension Procedures The integer procedure DIM, which takes as parameter the name an array of an array of any type, yields a result that is the number of dimensions of the array. This is most useful when the user passes parameter and wishes to check if it is, for example, a matrix. The integer procedures LB and UB also take as first parameters the second parameter is the subscript number. of an array; name as a the The subscript the of respectively, result is the lower or upper bound, The following procedure uses these specified by the second parameter. to clear real matrices. 17-2 THE DECSYSTEM-10/20 OPERATING ENVIRONMENT ZERO(A); PROCEDURE ARRAY A; BEGIN I,J; INTEGER IF DIM(A) 2 THEN = BEGIN INTEGER L1,L2,U01,02; L1 LB(A,1); Ul := UB(A,1l); LB(A,2); U2 := UB(A,2); Ul DO L2 := FOR I := L1 UNTIL FOR J := L2 UNTIL U2 DO A[I,J] := 0 END END 17.3.2 Minima and Maxima Procedures The integer procedures IMIN and IMAX, the real procedures RMIN and RMAX, and the 1long real procedures LMIN and LMAX are used, respectively, to determine the minimum or maximum of a number of arguments of the appropriate type. These procedures normally accept up to ten parameters (this figure may be changed by re-assembling the ALGOL library with For a different parameter). example: I := IMIN(J,K); X := RMAX(Y+Z,RMIN(Y-Z2,Q)); 17.3.3 Field Manipulations The procedures GFIELD and SFIELD enable the user to manipulate a field within any integer, real, long real, Boolean or string variable. The integer parameters I and J specify a byte of 1length J bits whose bit (counting from zero at the left-hand 1I'th the 1is bit leftmost side). The byte specified may be from 1 to 36 in length and may be at any position in the variable. For single word variables (integer, real, Boolean), I may range from 0 the as The integer procedure GFIELD uses I and J first parameter is the variable. the parameters; third and second The result is the For double word variables I + J <=36. <constraint the with 35, to (long real and string), I may range from 0 to 71, with the constraint I <=72. +J value of the byte (right justified) specified by I, J. Thus K := GFIELD(A,3,5); gives the value of the byte consisting of 17-3 bits 3 through 7 of A. THE The procedure parameters type DECSYSTEM-10/20 SFIELD I, J integer. sets to a the OPERATING ENVIRONMENT byte specified by value specified by the the second and third fourth parameter, of Thus SFIELD(A,3,5,0); zeros the 17.4 DATA TRANSMISSION For byte details 17.5 F-10 any of FORTRAN or F-40 programs by other Such specified these FORTRAN separate FORTRAN the first example. PROCEDURES procedures INTERFACE loading in refer to Chapter 16. PROCEDURES subroutines may be incorporated these subroutines with the ALGOL ALGOL in ALGOL object main program (and procedures). subroutines should be specified by an EXTERNAL declaration in the ALGOL program and, depending on the compiler used, the appropriate procedures should be called. Table FORTRAN TYPE NONTYPE 17-1 Interface INTEGER FORTRAN Procedures REAL LONG FORTRAN REAL (DOUBLE BOOLEAN PR.) (LOGICAL) F-10 F10CALL F10ICALL F10RCALL F10DCALL F10LCALL F-40 CALL ICALL RCALL DCALL LCALL The first FORTRAN the as parameter subroutine, appropriate the CALL FlO0CALL CALL is a (or the are procedure must be calls declared non-type). as must an Subsequent be the etc. := of the procedure parameters are of taken procedures. used as single statements, for example: (X,Y) program. must appear in the appropriate context in an thus P name external to FORT FORTRAN IEALL to these (FORT,X,Y) equivalent CALL in type arguments and in which Q + ICALL(Z) NOTE The maybe parameter of of any type, any dimension, string. with CALL, ICALL, including the etc., arrays exception of of expression, THE 17.6 GENERAL The integer specified, DECSYSTEM-10/20 INFORMATION procedure provides OPERATING ENVIRONMENT ROUTINE INFO depending information on the about value of various the parameter aspects of the environment. Parameter For Returns integer in value 0 core size 1 date (15-bit 2 time (ticks 3 time (milliseconds 4 runtime 5 processor type (1l=KA, 6 number stack shifts 7 compiler version word of words format) since midnight) since midnight) (milliseconds) of 2=KI, so 3=KL) far example PRINT (INFO (4)) ; might produce 1134600 - the 17.7 job's DATE runtime AND TIME up to now IN ASCII in milliseconds. FORMAT Three routines are provided for returning the current time and date in string format suitable for printing without modification. The two date routines, FDATE and VDATE, give the option of a standard three-character abbreviation for the month (FDATE) , or a variable-length string with both cases the eight-character year is given in full. string with the current For the name of the example WRITE (VDATE); NEWLINE; WRITE(TIME); might produce 27-JANUARY-1975 12:16:55 17-5 month in full (VDATE). String procedure TIME time as HH:MM:SS. gives 1In an THE DECSYSTEM-10/20 OPERATING ENVIRONMENT 17.8 RANDOM NUMBER ROUTINE Three routines have been included to provide a random number capability. The number generator 1s similar to that used in the FORTRAN library, which is documented in the Science Library manual. The ALGOL version is, however, initialized randomly. If a repeatable sequence of pseudo-random numbers is required then procedure SETRAN should be called before the first call to RAND, with the required initial value. For example, to generate the same sequence as a FORTRAN program using the default starting value currently used by FORTRAN, SETRAN(-1); should be included in the ALGOL program. The third procedure 1is SAVRAN which returns the value of the last random number without invoking the number generator. RAND and 17.9 SAVRAN ONTRACE are AND INTEGER procedures; entry of trace items the TRACE command is 17.10 PAUSE is non-type. OFFTRACE These two typeless parameterless of procedure entry and labels System SETRAN affected procedures on and off turn the dynamic tracing respectively. Neither the into the trace buffer (which is to the REENTER dialogue) or the by the printed Dynamic by use of Debugging procedures. This typeless parameterless procedure merely exits to the Monitor, in such a way as to allow execution to be continued by typing the Monitor command CONTINUE. This is provided to allow, for example, a device to be assigned. 17.11 DUMP This typeless procedure has one integer parameter: the number of block-levels <containing the present one to be dumped. DUMP is identical to the Debugging System command DUMP (see section 20.7), with the following exceptions: l. Output is directed (ignores Debugging 2, Arrays 3. A history trace error is found) are always to the System currently selected REDIRECT commands) channel dumped (similar to the always precedes The integer parameter performs the argument to the DUMP command: a IIALL n output . 17-6 one the produced dump. when same function as value of zero has a run-time the numeric the effect of CHAPTER RUNNING 18.1 COMPILATION OF DECsystem-10/20 under The or the ALGOL ALGOL standard compiler R ALGOL (for the is AND DEBUGGING programs by PROGRAMS PROGRAMS are DECsystem-10 called 18 compiled or by the DECsystem-20 ALGOL timesharing compiler monitor. typing DECsystem-20) ALGOL at monitor The command level. DECsystem-10/20 ALGOL Compiler responds by typing an asterisk the wuser's terminal. compiler, specifying the The wuser then types a command string source file(s) from which the program be compiled, and relocatable binary. output command the The files string for takes 1listing and the form: on to is the output of terminate a to OUTPUT-FILE,LISTING-FILE=SOURCE-FILES followed by a carriage-return command string). A file takes one of the (ALTMODE cannot be used to forms DEVICE:FILE-NAME.FILE-EXTENSION or DEVICE:FILE.NAME for directory devices (disk and DECtape) or FILE-NAME.FILE-EXTENSION or FILE-NAME where In DSK the is case assumed of to be a non-directory default devices, DEVICE? 18-1 device. the format is simply RUNNING AND DEBUGGING PROGRAMS In cases where no FILE-EXTENSIONS are specified, REL for the relocatable binary output file, LST and ALG for the source file are assumed. the for standard defaults the listing file, SOURCE-FILES consist of DEVICE 1is the second one file or a specified for and following list of files separated by commas. If a the first file, and not for succeeding files, files are taken from the same device as the first. Example: EULER,TTY:=EULER [read source DSK:EULER.REL from DSK:EULER.ALG, write relocatable listing on the user's terminall]. binary on and MTAQO:,DSK:SIM26=SIM26 ,PARAM.TST [read source from DSK:SIM26.ALG, binary on device MTAQO, and listing DSK.PARAM.TST, write file on DSK:SIM26.LST]. Certain user switches may be set by the in the relocatable command string. These in compiler's I1/0 checking (see are: BUFFERS:n Set number buffer-ring to of n. buffers CHECKON Compile run-time 18.5.1.1). CHECKOFF Do not <compile regardless of array-bound run-time array-bound checking, any CHECKON statements 1in the source. HEAP:n Set the initial size of the dynamic core area (which 1is wused for I/0 buffers, strings and OWN arrays) to n words. This area 1is dynamically expanded at run-time if necessary; its final size is typed out at the end of execution if the object program is loaded with DDT. HELP *Type helpful KAlOQ Produce code to run on the KI1l0 Produce code to run on the KI1l0 processor. KL10 Produce code to run the LIST *List the source listing-device is command-string). NOERRORS Do not type error-messages NOLIST Do not list the NONUMBERS The source numbers NOQUOTES in Delimiter text. on KAlO processor. KL10 program (default specified in source on does not columns 73 80 are 18-2 the if a the terminal. program. program words processor. to not in have line sequence (default) . quotes (default). RUNNING NOSYMBOL AND Suppress NUMBERS PRODUCTION output .REL file. The source columns Do not to PROGRAMS expanded has SYMBOL Include words symbol length of words: this produces a happen for line trace symbol-table *Delimiter symbol table sequence to the numbers 1in 80. <compile QUOTED Set of program 73 expanded TEMPCODE: n DEBUGGING are in table information to the .REL information in area 1is necessary only to some output quotes. TEMPCODE message or file. in that very .REL file. compiler if the effect, to which complicated n compiler may statement constructs. TRACE Control tracing. NOTE Since only one processor type, the KA20 is available for the DECsystem-20, no switch options are therefore available (unlike the DECsystem-10 which can run on one KI10 of the and three KL10, processors, and therefore KAlO, has three options). Switches an may character. Switches For be asterisk shortened (*) in the Values (n) are after a to a unique above in abbreviation: 1list may those marked given as preceding /. also be a with single decimal. file-specification are set by a example: PROD, PROD=PROD1 /L ,PROD2/NOL/HEAP:2000 . causes file PRODl without 1listing, to be and area to 2000 The ALGOL be set to compiler user's terminal terminal. After another type "C 18.1.1 return words reports (the all and in the compiling a asterisk, to compiled with a listing, the 1initial size of the whereupon to monitor Compilation of default source size program 1listing device program, the the user may PROD2 to run-time is 521 words). errors if it is compiler compile be compiled dynamic core both on the other than the returns with another program, or level. Free-Standing DECsystem-10/20 Procedures ALGOL allows the user to compile procedures independent of ©programs that call them. Such procedures may either follow the main program in the source file or may be in an independent source file either singly or together. The user uses exactly the same process to compile such files. 18-3 RUNNING AND DEBUGGING PROGRAMS NOTE Free-standing procedures must not appear before the main program. If the user requires to call those procedures from the main ALGOL program, the appropriate 18.2 EXTERNAL declarations (refer Paragraph LOADING ALGOL ALGOL programs DECsystem-20 to are loaded Linking DECsystem-10/20 be made PROGRAMS by Loader generated by MACRO-10/20 the must 11.9). 1in means of exactly and FORTRAN are Assembly Language the DECsystem-10/20 the loaded same way as (for details, or programs refer to Handbook). LINK-10 or LINK-20 automatically causes all procedures required from the ALGOL Library (ALGLIB) to be incorporated into the user's program. For example, ALGOL main consider the source file MAIN.ALG which contains the program and the files SUB1l.ALG and SUB2.ALG which contain free-standing procedures. The user may compile these files to give one relocatable binary by typing the following command string to the ALGOL compiler, file MAIN,MAIN=MAIN,SUB1,SUB2 and loading the resulting program by giving the command string MAIN/GO to LINK-10 or LINK-20. Alternatively, the three source files <can be compiled independently by typing three command strings to the ALGOL compiler, for example: MAIN,MAIN=MAIN SUB1,SUB1=SUB1 SUB2,SUB2=SUB2 and giving LINK-10 or LINK-20 the command string. MAIN,SUB1,SUB2/GO After a program has been 18.3 RUNNING ALGOL PROGRAMS ALGOL programs are loaded, executed by it may typing be the executed. console command START or any of its successfully, a the program will wvalid abbreviations. If the message will be printed on the return to monitor command level. 18-4 program executes user's terminal, and RUNNING AND DEBUGGING 18.4 PROGRAMS CONCISE COMMAND LANGUAGE The Concise Command Language (CCL) features 1in the DECsystem-10 or DECsystem—-20 monitor may be wused to facilitate the compilation and execution of ALGOL programs. These features are used in exactly the same way as for programs written in DECsystem-10 or DECsystem=-20 FORTRAN. For details, refer to the DECsystem-10 or DECsystem-20 Users Handbook. Switches to the separated by EXECUTE 18.5 ALGOL slashes. compiler For example: are enclosed in parentheses and FOO (QUOTED/HEAP:2000/KI) RUN-TIME DIAGNOSTICS AND DEBUGGING If a run-time error occurs during the execution of an ALGOL object program, an error message is produced, detailing the type of error, and its address within the user's program. Such errors fall into two fatal - categories and non-fatal. A mechanism has been provided by which DECsystem-10 users non-fatal errors, and when they occur, transfer control can trap to a label within the user's program. Each such error has a unique number, and a table of these appears below. The Library procedure TRAP, used to trap non-fatal errors has the following specification: PROCEDURE INTEGER TRAP N; (N,L); LABEL VALUE N,L; L; Where N is the number of the error to be trapped, and L is a label which control is required to be passed when the error occurs. Once such a trap is set up by a call to TRAP, it remains 1in until another call to TRAP sets a trap to a different label, or the trap TRAP that is, is turned off by (N) omitting the label parameter in a trap call. NOTE 1. TRAP is 2. The trap available label is only a on formal value. The number of caused the jump to the obtained by calling procedure TRAPNO. 18-5 DECsystem-10. parameter by ¢the trap that 1label may be the integer to force until RUNNING AND DEBUGGING Table Error TRAP FLOATING 19 FIXED POINT 32 INPUT OR 33 ILLEGAL 34 INPUT 35 ATTEMPT TO WITHOUT FILE POINT OVERFLOW OVERFLOW OUTPUT MODE READ OR WRITE ON DEVICE CHANNEL DIRECTORY DEVICE OPEN 38 ATTEMPT TO 39 ERROR CONDITION 40 ILLEGAL 41 OVERFLOW 42 ERROR CONDITION 43 ILLEGAL 44 I/0 48 SQRT 49 LN 50 EXP ARGUMENT 51 INVERSE 52 TAN Array UNDEFINED NOT AVAILABLE READ OR RENAME OR WRITE ON CHARACTER IN UNAVAILABLE INPUT OR OUTPUT OR OUTPUT ON FILE FAILURE OVER END-OF-FILE INPUT OR OUTPUT IN NUMERIC ON NUMERIC DATA DATA CLOSING FILE INPUT/OUTPUT OPERATION CHANNEL NUMBER OUT OF ARGUMENT ARGUMENT Facilities DEVICE FOR 37 18.5.1.1 Numbers ERROR 18 18.5.1 18-1 Trap NO. PROGRAMS OR TOO ARGUMENT to Aid NEGATIVE ZERO MATHS NEGATIVE LARGE FUNCTION TOO in RANGE ARGUMENT OUT OF RANGE LARGE Program Debugging Bound Checking - The directive CHECKON when placed from being this in anywhere in point onward range. The a user's in the program causes all array subscripts program to be checked at run-time for directive CHECKOFF action. 18 i this N nullifies RUNNING The compiler override any AND DEBUGGING PROGRAMS switches /CHECKON and /CHECKOFF may also be used: they CHECKON or CHECKOFF statements in the source progranm. NOTE 1. A The CHECKON, the larger, 2. CHECKOFF generated and facility program to run to be causes slightly slower. Most inexplicable errors arising during the execution of an ALGOL program are caused by an array subscript being out of range. the the program array Whenever should bound such errors occur, be recompiled with check feature on, and re-run. 18.5.1.2 Controlling Listing of the Source Program - Normally, a listing of the source program is output with the object program during compilation. The user can suppress this listing entirely by means of the /NOLIST compiler switch. However, if the user wishes to suppress only part of the listing and then continue listing, he can control the listing from within his program by means of the statements LISTOFF LISTON The LISTOFF statement causes listing to be suppressed from the point in the program where LISTOFF was encountered to either the end of the program or until a LISTON statement 1is encountered. The LISTON statement causes listing to continue after it had been suppressed by a LISTOFF if the statement. /NOLIST The switch LISTON is and included LISTOFF in the statements compiler have command no effect string. 18.5.1.3 Setting Line Numbers in Listings - Ordinarily, the lines 1in the listing file are numbered sequentially starting at 1 and incrementing by 1. The user can, however, change the line numbers by placing sequence numbers in columns 73 through 80 of the source program and compiling with the /NUMBERS switch. Another way in which the wuser statement. LINE causes can The change the statement next line numbers 1is by means of the LINE n the integer. The either another terminates. 18.6 1line CROSS 1line LINE REFERENCE The /CREF switch output for CREF. number to numbers be that statement set 1is to n, follow are which 1is a decimal incremented by 1 encountered or until the program to generate LISTING has been implemented, causing ALGOL Output takes the following formats. 18-7 RUNNING AND DEBUGGING Variables and Labels: PROGRAMS Each occurrence of a variable or 1label name is recorded, with a # whenever a defining reference is made. In the case of labels the line reference 1is to the line which causes code for the label to be generated. This may follow the line where the label appears. No distinction is made amongst different incarnations of a variable at various block levels. Blocks: The messages "START OF BLOCK n" and "END OF BLOCK n" are suppressed in the CREF listing. However, there is a separate CREF of blocks on the first page following the program. As with labels, the line-numbers refer to those causing code to be generated, not necessarily those on which BEGIN or END appear 1in the source. 18.7 STACK ANALYSIS The stack the stack analysis takes two forms - if a program stops with an error, is scanned to give the names of the active procedures. Thus a typical error ?RUN-TIME In message now reads: ERROR AT ADDRESS procedure 000162 OPENFILE Called from procedure PQRSTUVWXYZ Called from procedure THISPROCEDUREISNEXTTOINNERMOST Called from procedure THISONEISNEARLYTHEOUTERMOST Called from procedure THISISTHEOUTERMOSTPROCEDURE Called from MAIN PROGRAM File DSK:NOSUCH.FLE not available or rename failure on channel # The above type of analysis is automatic whenever an error is detected. The second type 1is invoked by the Debugging System command PROFILE. This causes a 1list of all the procedures, labels and 1library procedures referenced 1in the program to be printed, together with a count of the actual number of times each was referenced (or passed through in the case of labels). As with the trace print, labels can be distinguished by a trailing colon (:) and library procedures by a trailing asterisk (*), but different procedures with the same name must be identified from the order in which they appear, which 1is the same as the loading order. In the special case of overlaid programs scanned, for only the example: >>PROF PROFILE COUNT PRINT. NAME 1 PQRSTUVWXYZ 1 THISPROCEDUREISNEXTTOINNERMOST 18-8 root segment Iis 1 RUNNING AND 1 THISONEISNEARLYTHEOUTERMOST 1 THISISTHEOUTERMOSTPROCEDURE 0 READ* 1 INPUT* 0 OUTPUT* 1 OPENFILE* TRACE 18.8 18.8.1 Two DEBUGGING PROGRAMS Dynamic Trace types of Trace are available: dynamic and post-mortem. The user who is at a terminal and wishes to see a full dynamic of his program should type the following command sequence: .LOAD trace TRTST ALGOL: TRTST LINK: LOADING EXIT .REE ALGOL DIAGNOSTIC FACILITIES (H SYSTEM FOR HELP)? >>ONTRACE >>START This produces (at 1least) one 1line for follows: **k*kxx*SECTION *kkk*kG6: *kk*xk***PHASE kkkkkkkk*k**WRITE* PHASE kkkkkkk*kk***DRINT* 6 kkkkkkkkk*x*x*WRITE* BEGIN kkkk****PHASE kkkkkkkkk*k**WRITE* END ***x %% *SECTION *kk kg7 . kkkkk*k*k*PHASE *kkkkkkkkx*k**WRITE* kkkkkkkkkkk*xPRINT* PHASE 7 kkkkkhkkhkkkkkWRITE* BEGIN *kkxk*x***PARFOR kkkkkkk*PHASE kkkkkkkkxxk*xWRITE* END 18-9 each trace reference, as RUNNING AND DEBUGGING PROGRAMS Dynamic trace output always clears the terminal output buffer and begins a new line. The current dynamic block level is represented by two asterisks for each level, printed along the 1line. Note that a notional block surrounds the main program and each procedure. A maximum of sixty asterisks are printed before the 1line 1is folded: folding 1is shown by a number in the first two columns representing multiples of thirty dynamic block levels. The name of the procedure asterisks. by a or label As with the profile, trailing asterisk, and labels appears at the end of the 1line of library procedures are distinguished by a trailing Procedures are traced at entry but not exit; exit can be inferred from the block levels. colon. however, a procedure NOTE Ordinary TTY output in Dynamic Trace mode may be interspersed amongst Trace output (as 1in the example above). Dynamic trace may also be turned on and off dynamically by use of the library procedures ONTRACE and OFFTRACE. 18.8.2 Post-Mortem Trace A post-mortem trace will be printed automatically if a batch job gives a run-time error. Under timesharing, after typing out the location and type of error, and the stack analysis, the Debugging System offers the user various options. The TRACE command produces a trace similar to the one described under Dynamic Trace above, but with spaces instead of asterisks to represent block levels, and without, any other TTY output. The post-mortem trace entries are maintained in a circular buffer in the Heap. The default length of the buffer is 100 (decimal) but this can be altered by using the /TRACE switch to the compiler, with an appropriate value. Tracing is the default option: users can compile their programs without trace information by using the /PRODUCTION switch to the compiler. However, the Trace entry mechanism is quite efficient, and users are urged not to exclude 1it, as this also has the effect of making the stack analysis less useful. Library 18.9 procedures PERFORMANCE are always traced. ANALYSIS Various features are provided which are designed to evaluate the performance of their programs. 18.9.1 Heap help users arrays, ALGOL is strings, very I/O flexible buffers in and its so use on is of memory: allocated in called the Heap, which lies between the program code and the The default initial Heap size is 521 (decimal) words. If a needs more Heap than is currently available, the object-time moves the stack up in memory from the Monitor as necessary applied by wishing Space DECsystem-10/20 for to the system). ) to make more (subject to 18-10 space an area stack. program system room, obtaining more core over-riding constraints RUNNING AND DEBUGGING PROGRAMS For most programs this provides a reasonable balance between core use and computation. However, the stack shifting mechanism can be very expensive if used often and for small expansions. The user can find out how the Heap is being used by typing the STATISTICS command (see Chapter 20, section 20.8.6) to the Debugging System after the program has executed (or simply typing CONTINUE immediately after the End of execution message). This produces output of the following format: EXECUTION TIME: ELAPSED TIME: MAXIMUM HEAP SIZE: MAXIMUM # USED OF # OF STACK WORDS IN THE SHIFTS: HEAP TABLE: (The last item is a measure of the fragmentation of the free space 1in the heap and is only produced if the optional Heap Integrity Checker is present in the object-time system, i.e., when assembly switch FTGETCHK is turned on.) If the number of stack in performance could the /HEAP switch value Statistics type-out. 18.9.2 By Code INFO can be be set is larger than, say, ten, an improvement expected from re-compiling the program to the maximum heap size given by with the Utilization judicious placement program's particular shifts profile, sections used to of 1labels and subsequent the frequency with which a of code can be monitored. The obtain more detailed 18-11 timing printing of the program executes 1library procedure information. CHAPTER 19 TECHNICAL NOTES These notes "Revised concern Report implementation. 1. on the authors' the particular Algorithmic interpretation Language ALGOL-60" of and the its ents is At all times, strict left-to-right evaluation of statemhas been Report d Revise the of 3.4.6 n Sectio d. employe tion evalua t o-righ left-t that mean construed by some experts to of expressions is not required. However, there are undoubtedly . many ALGOL-60 programs in existence that rely on this feature Section 4.3.5 of the Revised Report requires that a GOTO Statement with a designational expression which is a switch nt. with a subscript out of range be regarded as a dummy stateme 0 ALGOL-6 other any nor ALGOL Neither ' DECsystem-10/20 this follow , authors the of dge knowle the to implementations, rule; there 1is a side-effect involved in the evaluation of the subscript. 19-1 CHAPTER THE 20.1 SUMMARY OF In ALGDDT, the ALGOL DYNAMIC 20 DEBUGGING SYSTEM FEATURES ALGOL programmer facilities 1. Interrupt 2. Set 3. Examine and 4. Examine various 5. Automatically 6. Continue program execution from where 7. Continue program execution from 20.2 pauses GENERAL 20.2.1 program has and to execution clear alter them ALGOL system type variables in scope parameters ALGOL variables an after it a pause halted appropriate label REMARKS Symbol (.SYM) File ALGDDT requires access at runtime to a file <called Programname.SYM that 1is produced by LINK. If it cannot access the file (perhaps because it has another name, or resides under another PPN) an opportunity is given to supply its name, etc. ALGDDT also needs a free I/0 channel: 1if there is none, it will ask the user to nominate one for it 20.2.2 To to release and use. Entering ALGDDT enter ALGDDT from a terminal When this 1is detected, the complete executing the current to ALGDDT. unable to find "Stopped After a Program execution a .SYM file, at line nnn run-time running error, the a ALGOL program, type °C. ALGOL Dynamic Debugger will attempt to ALGOL statement before passing control will be halted following [,statement ALGDDT will where the be and, message unless will be ALGDDT was typed: n]" entered (except 1in a batch job). However, there are cases current 20-1 statement never completes. THE For example, reads will if "C is data from the be waiting at To overcome this, a ALGDDT may also be REEnter facility. ALGOL DYNAMIC DEBUGGING typed during SYSTEM the execution of a statement which terminal, the other no data will be forthcoming end for the system to enter second is "C as the user ALGDDT mode. required. entered before The program execution of a program by use of the can then be started with the START command . In this <case, the effective "current statement"”, for determining scope of identifiers, is immediately before the first BEGIN of the main program. 20.2.3 ALGDDT The syntax commands; Command Format the ALGDDT commands has been designed to resemble ALGOL all of which are terminated by a semicolon (or carriage-return), and the lists associated with AUTO commands are bracketed by a BEGIN-END pair. However the resemblance is superficial, and for the most part only simple commands can be given in a single "statement". When the debugger is ready to accept a command, ">>" is prompted. All commands and options may be shortened to a wunique abbreviation (except where noted). Blanks and tabs are ignored between elements of a command, as are ‘“readability symbols" (periods) in ALGOL identifiers. A command may be continued on another line by typing a control-backarrow or control-underline. Comments may be introduced by a preceding ! and the rest of the line will be ignored. 20.2.4 of Line Numbers Several ALGDDT commands require line numbers. The compiler only puts line numbers into the symbol table accessed by ALGDDT for those lines where code is generated (including BEGIN and END statements of a block, but not for blank 1lines, declarations, etc.). If the user gives an "unknown" line number, ALGDDT will scan forward to the next known line number and use that; this usually has the desired effect. In a program LINKed from more than one .REL file ("module"), the can qualify a line number with a module-name preceded by "IN": >> The PAUSE 27 module-name IN is six characters), main program. If current module FOO the or the (that name (truncated to the main program-name (.REL-file name) for module-name is not specified, the default is of the external the the use the one that be procedure in which execution was stopped by PAUSE, error, or the main program before execution program can have more than one module with message will user is also the main program, “C or an is started). Although, a the same name, ALGDDT will if any; otherwise an error typed. Additionally, in the OBJECT command, by a preceding number-sign (#). 20-2 an octal address may be specified THE ALGOL 20.3 DYNAMIC DEBUGGING SYSTEM TYPEOUT COMMANDS The command TYPE is used to display the value of an ALGOL variable or array element on the terminal. The keyword is followed by a list of one or more variable names, separated by commas. The whole terminated by a semicolon. If more than one name is given, the names are repeated by 1list is then all the debugger. Examples: >> TYPE REAL.VARIABLE; 1.2345 >> TYPE REAL.VARIABLE, INTEGER.VARIABLE; REAL.VARIABLE = 1.2345 INTEGER.VARIABLE = 12345 >> 20.3.1 String Typeout When string typeout the string 1. are is output requested, first, the length and decimal byte size in parentheses, then In the case of ASCII or SIXBIT strings, the representation of the string is typed in quotes, of character example: >> >> 2. TYPE TYPE STRING.VAR; SIXBIT.VAR; (10,7) (15,6) "A string<CR><XLF>" "A SIXBIT STRING" For strings with a byte size other than octal representation of the byte values, comma, typed. is six each or seven, an separated by a example: >> TYPE NONASCIISTRING; 10,37,17,17,22,1,10,0 Extra bits 20.3.2 at ends of words are If the TYPE correspond of command to TYPE an the is array used 1is structure with typed. of the 1.7 2.3 2.3 1.7 5.4 5.4 [2, 5.4 .... ETC. a single location location element: TYPE array The array: name, format then the entire of the typeout will 1.32 8.1 The contents of of an ARRAYNAME; [0,0] [1,0] >> ignored. Array Typeout contents >> the (8,5) the ELEMENT([1,3,5,200]; may 0.0 20-3 be typed by specifying the THE ALGOL DYNAMIC DEBUGGING SYSTEM NOTE ALGOL variables subscripts. may All not be used subscripts must simple constants. Array is 1imposed on ALGDDT as be bound checking commands where appropriate. Rectangular the portions relevant >> of arrays may be selectively typed by specifying ranges: TYPE ARRAYNAME 1.32 5.4 (0,2] [1,2] [0:1,2:3]; 6.8 8.1 The whole of a particular e.g., A[1:20,*%,1:5]. dimension can be represented by an asterisk, NOTE There must dimension 20.3.3 The Displaying current DIMENSION a specification Current Array dimensions of for a multi-dimensional an every array. Dimensions array can be displayed by using the command: >>DIM 20.3.4 be of A; [0:17,1:5] Typeout of Boolean Variables Boolean variables (or arrays) can be typed using the above commands. Since FALSE is represented by zero, zero elements or variables will be displayed as 'FALSE'; non-zero variables having values of -1 (the value 'TRUE' For wused 1in or octal TYPE assignments), are available typeout, either typed as Bl,B2; Bl= False B2= 012345671234 (True) 20.3.5 General ALGOL only but the two which unwanted “Cs. case On Typeout in scope will possibility exception in the program. variables. Long, Points variables formals, The generated values. example: >> All directly for other is For a variable internal type-outs Occasionally CONTINUE of or (of be side-effects that is reasons, arrays, this may REENTER may for should declared the etc.) but debugger may be return control be 20-4 typed to be never cannot aborted to return including borne in mind. referenced access by such typing the monitor, to ALGDDT. in THE 20.3.6 The Typeout user may statement, OBJECT a PAUSE a the this executed next. current statement error Object request using >> After of ALGOL SYSTEM Code typeout types is is DEBUGGING of the Macro code for the current out a typed marked the code run-time out with for instead an the error, and statement the the asterisk. code that will be generated for the instruction The user can or an OBJECT octal >> In 1line number >> the address: case the if no following decimal "IN module" would (16) number than number #275; OBJECT rather the other 22; OBJECT this thus where examine statements by using the OBJECT command with the relevant (and statement number if necessary). For example: >> ALGOL command After occurred DYNAMIC a dump is specified, the the address is absolute; accumulators: #0; of line ALGOL statements number) to be (words output may if be an octal specified by address typing a in parentheses: >> OBJECT (17) 22; >> OBJECT (13); or the typeout formats may >> where normally specified OBJECT the 7 is be or a's are A SIXBIT S Symbolic or the MODES symbolic MODES instructions. Other option: a,a,a...; from: D Decimal Instructions Integer Octal F or R L Line-number external >> Real Number Long Real may be OBJECT line and (18) (each qualified procedures. This will ASCII and using ASCII 0 on chosen octal, by line-number 6 I in A 27,3 word by complete IN IN and the module-name example EXTPRG next). MODES is if the program has therefore: A,6,S; dump 18 ALGOL statements starting at the fourth statement 27 in the external procedure EXTPRG. The dump will be in SIXBIT characters, and symbolic 20-5 instructions. THE ALGOL DYNAMIC DEBUGGING SYSTEM 20.3.7 System Parameters ALGDDT maintains a table of certain symbolic variables wused 1in the these system variables distinguished by a of contents The system. system the of Most preceding % can be displayed in the usual way. A few are listed as defined in ALGPRM, will be available. variables, below as examples. $DB current data-base $SP stack pointer $CONDL context "DL" $DL pointer to current display $VERSHN version # word of ALGDDT does 20.4 not permit register compiler alteration of used system parameters. CHANGING ALGOL VARIABLES The values of an ALGOL variable may assignment >> be altered but only by INTVARIABLE:= Type conversion will Note, a simple 1235; take place, a single permitted on the right-hand side of the assignment: >> BOOL :=TRUE; >> BOOL := >> INT:=1; INT :=1.0; >> >> >> >> wusing statement: constant is 003007; REAL:=1.2345&7; A[l1,31:=18.4; 8[1,71.[3] := 64; however, that the following are not legal: >> A:=B; > >> C[I,J]:= 20 D[1,6].[I] := 66; rules extra some in nature, Since strings are essentially dynamic size and/or length are specified in the a new byte Unless apply. octal Type-in consists of type-in, then the current values are used. If the numbers typed are too large for the bytes separated by commas. byte-size in force, then they are truncated, and a warning message is A string enclosed by single or double quotes is also allowed issued. if the byte-size is six or seven respectively. A quote may be entered All characters, including carriage returns, by typing two quotes. ALT-modes, semicolons, !s, and so on, are entered exactly as typed. The only exceptions are control-backarrow, which acts as usual; quote, which terminates the string. If more bytes than the and a specified 1If fewer, then the the length is extended. then typed, are length 1line The string may be continued on another extra bytes are zeroed. by typing control-underline. 20-6 THE ALGOL DYNAMIC DEBUGGING SYSTEM NOTE Square brackets have a in strings that are Section 16.6.2). 20.5 special meaning to be output (see PAUSES By setting interrupted 20.5.1 PAUSES, the user automatically when Setting Pauses may ALGDDT command: be may cause program execution specific points are reached. to be PAUSEs applied no before >> PAUSE line >> PAUSE label: >> PAUSE PROCEDURE any [,statement executable no] [IN ALGOL statement by the module-name]; or [IN module-name]; or When this point "Pause is at name is reached line nnnn [IN the module-name]; message [,statement n] in module name" typed. The pause remains in effect, so that subsequent activations of this piece of code will also cause this message to be printed. Note that the portions of the command in brackets are optional. If the statement number 1is absent, then the first (or only) statement beginning on that line is assumed. If module name is absent, the current module 1is assumed; the main program is the current module before program execution starts. If the statement specified does not exist, or has no generated code, the PAUSE is placed on the next suitable statement, if any. Labels and procedures must, like all other identifiers, be in scope. There If a is no restriction number then the (n) execution is An upper limit >> is typed resultant PAUSE on in pause the number of parentheses will be after a n-1 user can PAUSE times establish. instruction, before program halted. may also be specified for a PAUSE in the form of (n:m); will cause the break to be taken including the m'th time that the location. On completion of the break PAUSE will be killed automatically. with a bypassed This PAUSE; pauses no line current statement number (after a or label from the program action specified, "C has been 20-7 typed). n'th time up to and reaches the breakpoint after the m'th pass, sets a PAUSE at the THE 20.5.2 Resetting Of When a pause is ALGOL PAUSE DYNAMIC Proceed established >> PAUSE (n); >> PAUSE (n:nl); using DEBUGGING SYSTEM Count the ALGDDT command: or This pause will occur on the n'th time after the program reaches the breakpoint location. Once the break has occurred, it will repeat each time the program reaches this point. To stop subsequent unnecessary pauses, the count can be reset by specifying the command >> CONTINUE m; This will result in the pause to be taken only on the m'th subsequent pass and the m'th subsequent pass after that and so on until the PAUSE is KILLed. NOTE This command may be given as a direct ALGDDT command, or in an AUTO-list. 20.5.3 Clearing A KILL command varieties >> kills are PAUSEs 1is provided available. for After <clearing pauses. Three possible a Pause, KILL; the current pause. >> KILL line-number >> KILL label:; >> KILL [,statement-number] [IN module]; or or (at PROCEDURE least procname; PR must be typed) kills the specific pause referred specified does not exist." >> kills KILL ALL; all ! currently ALL must set to, be or typed results in in the message full; pauses. NOTE If there labels in the are or on two or more procedures with PAUSEs the same name same module, set a block-number (the one given in 1listings in the START OF BLOCK n messages, or in the block CREF) must be given, thus: 20-8 "Pause THE >> 20.5.4 The of currently LIST >> lists KILL DYNAMIC LABEL: DEBUGGING SYSTEM 3 [IN modulel; thereby resolving the ambiguity. >> A; Listing the ALGOL KILL 'kills AUTO-list ! 3 is block-number; may be listed A; PAUSEs set PAUSEs, command, and which their has the AUTO-lists, following by use formats: LIST; all PAUSEs and the names of all DEFINEd AUTO-lists. >> LIST line-number[,statement-number]; >> LIST label:; or lists the >> PAUSE LIST ! etc.; specified together with its AUTO-list, if any. A; lists AUTO-1list A. >> lists For LIST all ALL;! PAUSEs ALL and must all be DEFINEd typed in full; AUTO-lists. example: >> LIST Proceed-count Autolist Where 19 0 0 Private A 27,3 in FOO LABELl: in MUMBLE 293 in FOO PROC1 in FOO 88 Defined Autolists: >> LIST 27,3; Proceed count DIM TYPE A: !Type = 19, the A,C-E,J,L,S-Q private dimensions Autolist: of array A; I,J,K; CONTINUE; >> See note in Section 20.5.2 about ambiguous 20-9 labels and procedure-names. THE ALGOL DYNAMIC DEBUGGING SYSTEM Automatic Execution of Commands After PAUSE 20.5.5 Any pause can have an associated AUTO-1list, that is a list of commands that are executed whenever the pause 1is reached. AUTO-lists can contain almost any ALGDDT commands. These may either be typed 1in immediately after declaring a PAUSE, or they may be identified by a single letter and referred to indirectly. The following two examples would have the same effect: (direct) >> PAUSE 17 BEGIN; TYPE I, J, >> > K; END; (indirect) >> DEFINE B; >> TYPE >> END: >> PAUSE I, J, K; 17 AUTO B; NOTE when a Tab by The prompt is followed reading an AUTO-list in either mode. The advantage of the indirect method is that the same list can be referred to from different pauses. If the direct method is used, the AUTO-1list is destroyed when the controlling pause is does not check AUTO-lists for consistency, >> PAUSE 17 BEGIN ; TYPE A; KILL; thus ALGDDT KILLed. END would only be obeyed once, since the KILL instruction would kill both pause and list. AUTO-lists are, however, checked for syntax (legality of commands, etc.), but not for semantics (scope of identifiers, etc.) as this depends on the context of the PAUSE from which they are invoked. AUTO-lists are terminated by an END and elements in the list are separated by semicolons or carriage returns. The action on detecting an error during execution of an AUTO-list can be controlled by means of a switch on the AUTO or BEGIN keyword. However, this switch only controls the action for invocation of this AUTO-1list from the PAUSE. IGNORE No error message, to next element of CONTINUE Type error message, continue to next element of KILL Type to this STOP Type error message, go to debugger command level continue AUTO-list. AUTO-1list. error message, KILL reference 1If this is a "private" AUTO-list from this PAUSE. AUTO-1list (defined by BEGIN) it itself is KILLed. (default). It is sometimes useful to suppress the "Pause at..." message when a PAUSE is reached (especially if the associatied AUTO-list ends with a CONTINUE command); this may be done by using the /SILENT switch on the AUTO or BEGIN keyword. Note, however, that error messages will still be typed unless /IGNORE is also used. For example, suppose that 20-10 THE ALGOL DYNAMIC DEBUGGING SYSTEM a program was failing because a variable (I) was not initialized at the start of a loop (on line 25); the following would be a temporary (and cure: inefficient!) >> 25 BEGIN/SILENT; PAUSE >> I:=0; > CONTINUE; >> >> 20.5.6 END; START; DEFINE Command This command is provided to enable the user to define an AUTO-1list use in a subsequent PAUSE or AUTO command. The format is: >> DEFINE A !Or >> (ALGDDT >> END; any valid AUTO-list for name; commands) >> 20.5.7 EXTEND Command EXTEND enables additional commands DEFINEd AUTO-list. The format is: >> EXTEND to be appended to a previously A; >> (ALGDDT >> END; commands) >> This command can therefore be used also be used instead of the to define an DEFINE command. AUTO-list, and can NOTE If an AUTO-list command 1is will not be ending EXTENDed, executed. with a CONTINUE the new commands No error will Dbe printed. 20.5.8 AUTO Command A command format >> is, is provided for AUTO to invoke a DEFINEd AUTO-list example: A; NOTE AUTO may AUTO-list. nesting of appear Up to 26 this kind within another of (decimal) levels are permitted. 20-11 directly. The THE 20.6 EXECUTE 20.6.1 ALGOL DYNAMIC CONTINUE types 20.6.2 GOTO SYSTEM COMMANDS The simplest execute command is execution of the program until user DEBUGGING CONTINUE. This continues it terminates, meets a pause, normal or the “C. GOTO (or GO TO) can take >> GO TO LABEL:; >> GO TO line two forms, or number [,statement In either case, the command is scope, otherwise the message "Identifier does not only exist, number]; valid or is if out of the destination is within scope" is printed. No ALGOL code is executed, and the status of the program is unchanged. Unless a break-point has been set to the destination, program execution will proceed as if CONTINUE had been specified. Formals may be specified as labels. 20.6.3 If the START debugging sequence, 20.6.4 system was program execution RETRY entered may be by way started of by the using initial the START REEnter command. Command This command enables the beginning of the an ALGOL program to be entered and executed statement in which an error has occurred. from NOTE RETRY differs from CONTINUE as the latter continues program execution from the point within the statement where the error has occurred. 20.6.5 The by NEXT NEXT command statement. allows Typing the user NEXT has to step through the same effect control to any point program as setting the next statement PAUSE on CONTINUE (except that the PAUSE cases where the current statement the "next" statement and then typing kills itself when reached). Even in transfers a other than statement (either explicitly by a GOTO or implicitly conditional IF or iterative FOR/WHILE statement), NEXT operation until the KILL command is issued. 20-12 a sequential as part of a remains 1in THE ALGOL DYNAMIC DEBUGGING SYSTEM NOTE If an ALGOL statement includes embedded assignments, extra 1line numbers may be generated. This will cause NEXT to stop after completing the assignment rather than at the second and all 20.7 The end NEXT of the command statement. will rectify enable pauses to be taken subsequent statements. A this between DUMP DUMP command may active variables. SCALARS keyword. absent, then be The This only the used to output the values output of arrays may be command has an optional variables declared in of all suppressed parameter. the current currently by using If this block will the is be dumped. If a numeric parameter, n, is specified, then all wvariables declared in the n enclosing blocks will also be dumped. If "DUMP ALL" is specified, then the variables declared in all the currently active blocks will be dumped. NOTE DUMP is static in nature, variables enclosed recursively-activated only have the value occurrence 20.7.1 that 1is, any in blocks in procedures will of the "latest" dumped. REDIRECT Device:filename.ext [proj,prog] This command causes all ALGDDT output directed to the device designated. If filename is specified, then the resultant file. from DUMP commands to be the device is a disk and the output is appended to that The causes command directed to REDIRECT with the no arguments DUMP output TTY. NOTE The FINISH instead of REDIRECT file will 20.8 MISCELLANEOUS command "C is in not to exit force, be should else closed. COMMANDS 20-13 be used from ALGDDT when the a output to be THE ALGOL DYNAMIC 20.8.1 Accessing DEBUGGING SYSTEM "hidden" Variables - UNWIND and BACK In many cases, there are variables that cannot be accessed because they are "hidden" in the current context, either because there is a variable of the same name in an inner block or in cases of recursion. The UNWIND command is provided to allow access (for display or change) to these variables. It refers to the dynamic block 1levels that are typed in the history trace (produced on error or "C, or by the WHERE It has command). >> UNWIND three formats: n; moves ALGDDT's context for variable accessing to level n; >> UNWIND -n; moves the context n levels program execution was >> UNWIND "out" from the true context stopped); (that at which O0; moves the context out to the outermost block. the Also, command >> UNWIND; >> BACK; or returns the context to the 20.8.2 EXPERT and NOVICE true context. All error messages have a full and an abbreviated form. Normally the full form is typed, but the EXPERT command causes the short form to be used. The NOVICE command causes ALGDDT to revert to the full form. In addition, the wuser may type a ? after a short message, and the full message will be typed. The EXPERT mode also prevents ALGDDT from typing the procedure history (after "C or error) which can be obtained by using the WHERE command. If a line ALGDDT /EXPERT appears in the file SWITCH.INI the user's area, ALGDDT will be entered with EXPERT mode in force (until changed by a NOVICE command). 20.8.3 WHERE The WHERE command causes produced when the error particular use >> for the system to retype (if any) occurred. the stack users of visual display terminals: Where On line 5 in module 8 In procedure PROC1 (level 2) 20-14 trace that was This is intended to be of THE ALGOL Called from line 12 Called from line 16 DYNAMIC DEBUGGING SYSTEM in procedure PROX in main program (level 1) >> (The "levels" 20.8.4 are for use in the UNWIND command, see section 20.8.1.) TRACE The TRACE command causes ALGDDT to type the <contents of the trace buffer. This consists of the names of the most recent labels and procedures encountered, with the most recent first. (The typeout may as usual be aborted by typing two "Cs, or a "0O.) The number of entries in the buffer is 100 (decimal) by default. This value may be changed by giving the /TRACE switch to the compiler. Labels are distinguished by a : and library procedures by a *. The indentation of the names gives the dynamic block level (two spaces per level and each procedure is enclosed by an extra notational level): >> TRACE !ALGOL postmortem trace (latest first) PRINT* LABEL1: LABEL2: LABEL1: FOO OPENFILE* LABEL1: MAIN.PROGRAM >> PROFILE 20.8.5 This command types the history of the program in terms of the number of times each label and procedure has been encountered; typeout is in the same order as the occurrence of the objects in the program. As for TRACE, labels are marked by a : and library procedures by a *. example: PROFILE Profile print Count name OrHHOKFOMW >> LABEL1: LABEL2: LABEL3: FOO BAR PRINT* OPENFILE* SELECTOUTPUT* A4 \% For 20-15 THE 20.8.6 command the program. 20.8.7 all DYNAMIC DEBUGGING SYSTEM STATISTICS This This ALGOL types the execution time, system exit elapsed time, and core size of FINISH command files causes and the releasing all to to the Monitor, first closing devices. NOTE This must be REDIRECT output 20.8.8 ONTRACE and commands is used, in from rather force DUMP to than avoid “C, if losing a the commands. OFFTRACE These two (see while Chapter 18). Note in this connection that tracing executing ALGDDT commands (this is significant as are formal by name may otherwise be traced). 20.8.9 A HELP This command 1is or the dynamic cause execution of pieces ©provided which types the trace of facility is suppressed accessing a code that would contents of file HLP:ALGDDT.HLP. types SOURCE The defaults when those 20.8.11 control SOURCE command >> to HELP SYS:ALGDDT.HLP 20.8.10 provided of any ASCII file. The format is: device:filename.ext|[proj,prog]l; are the : DSK:ALGDDT.ALG; user will 1Indirect Command be PROJ, used. PROG, S.F.D.s or are both not may be omitted accepted. Files In response to a prompt from ALGDDT, the wuser may use an indirect command file by specifying the filename with a preceding @. This will enable commands to be read from that file. If no filename is specified then DSK:ALGDDT.CMD will be taken as default. This feature is particularly useful for inputting frequently used AUTO-lists. 20-16 THE 20.9 SUMMARY OF AUTO * ALGOL DYNAMIC DEBUGGING SYSTEM ALGDDT COMMANDS BACK BREAK CONTINUE * * DEFINE * DIMENSION DUMP END * EXPERT FINISH GOTO * * (OR GO TO) HELP * KILL * LIST NEXT * * NOVICE OBJECT OFFTRACE ONTRACE PAUSE * PROFILE REDIRECT * SOURCE START * STATISTICS TRACE TYPE UNWIND * * WHERE * The commands marked with an asterisk (*) in the abbreviated to a single character, thus S means 20-17 above list START, not may also be STATISTICS. CHAPTER MACRO 21 SUBROUTINES GENERAL 21.1 The subroutines which may be called one of the following attributes: 1. from an ALGOL program must have The routine must obey the FORTRAN calling interface specification, and be called by way of the FORTRAN interface procedures, for example, F1l0CALL, Fl0ICALL and so on. Further information can be found in Chapter 17, section 17.5. 2. “True ALGOL-like call the obtain any return any routines must begin with instructions: OTS routine PARAM; to set up the environment parameters; to provide an exit for PARAM results (in the case of a TYPE procedure). to and to This chapter deals with specific details of the ALGOL implementation. Reference should be made to files ALGSYS and ALGPRM for definitions etc., and to ALGLIB for examples of <correctly written MACRO subroutines. 21.2 THE PROCEDURE SEARCH HEADING ALGPRM,ALGSYS must be included at the beginning of the material uses symbolic names. The first executable instruction in a MACRO procedure the procedure if should the be a rest of call to the OTS routine PARAM. This is followed by a set of descriptor words which describe the type of the procedure and the type of each of the formal parameters. Example: INTEGER REAL would have B; PROCEDURE P(A,B,C); VALUE A; INTEGER A; STRING C; a header similar to the following: LEXIT== JA== .B== .C== JSP AX,PARAM EXP PMB XWD XWD 0,11 SPRO!ISIISSIM 4 21-1 MACRO XWD XWD XWD An SVAR!SI!SFOV, .A SVAR!SR!SFON, .B SVAR!S$S!ISFON, .C explanation 1. SUBROUTINES The follows: first word must normally be JSP AX,PARAM (AX is accumulator 16; PARAM is a macro defined in ALGSYS, by the ALGDIR macro, and which expands to @%ALGDR+1l, i.e. @400011 which contains the address of the OTS routine PARAM.) 2, The second word is zero 1f none). features, PMB: and is the The laid address of the post-mortem block (or post mortem block is used by the TRACE out as follows, 0 XWD WORDS ,CHARS SIXBIT/NAME/ in ; THE 7 IN s PRINTED the low PROFILE THE segment: WORD NAME BY TRACE ETC. NOTE The OTS expects terminated by If the name characters in zeroes 3. The third There may word have is the to be length be parameters, see below. More be any purpose as used for of enough fixed For the For a stack exit of to the space for space local be fixed the can be storage stack exit requested, by the and and the may procedure. needed) 1 word result 1l word result 2 words 3 words Integer,Real ,Boolean,Label,Procedure 1 word Array,String,Long 2 words typed For a procedure For each Real, (always with l-word Boolean) typed procedure with (Long Real, String) parameter (Any each 2-word called by name called by value: type) parameter Real The fourth word describes the procedure in the the number of parameters +1 in the right half. must always be "SPRO!S$SIMITYPE" where required. formal needed: instruction (Integer, For name supplied. must Length 4. the a zero byte ("SIXBITZ"). 1is a multiple of six length, an extra word of "type" SN SI NON-TYPE INTEGER SR SLR REAL LONG $S STRING $B BOOLEAN is one of: REAL 21-2 left The half, and left half MACRO 5. The remaining PARAM where giving the Kind words describe to put kind, type is one SUBROUTINES the them. and formal The status left parameters, half of the $S or $B Real or Long is a bit and tell pattern, parameter: of: SVAR Variable SARR Array SPRO Procedure Type or is one one of $I, $R, SLR, SL SWV SAB Label Any type Arithmetic $SIB SWF SWA Integer Or Boolean Real or Long Real Arithmetic (Integer, Status as described above, of: or Boolean must be one SFON Formal $FOV formal by by "name" "value" Real) of: NOTE All three fields must be included. The right half of each descriptor word is the offset in the fixed stack where PARAM is to store the elaborated parameter. Conventionally, these are in ascending order of parameter position, but this is not necessary, and gaps may be left if desired. PARAM obeys these offsets implicitly (to check them would be inefficient). If insufficient words are allocated, or insufficient fixed stack is requested for each parameter, parameters will overwrite each other and be lost, or worse. The space required for each parameter is as described above. It in is conventional to the example above. use symbolic names for the offsets, as NOTE Word and and for 21.3 ACCESSING Parameters may 1 is always the exit instruction, word 2 (l-word result) or words 2 3 (2-word result) must be reserved the result of a typed procedure. FORMAL be called case, PARAM places the specified by the right parameter MOVE A in the PARAMETERS by "name" or by "value". In actual value on the fixed stack half of the descriptor words: example into the by "value" in the thus location to 1load A3, A3,.A(DL) will suffice. Obviously, two word parameters stack. DL (accumulator 15) is always the base 21-3 occupy two of the fixed words stack. of MACRO SUBROUTINES complicated. more is "name" by Accessing formal parameters PARAM stores instructions on the fixed stack, which the Essentially, and F[l] known as F[0], The three locations are procedure XCT's. F[2]. fetch the will when executed, F[0] contains an instruction which, So, to value). word two a for 1 (and 0 accumulator into parameter load parameter B's value into accumulator 0, in the example, write: XCT .B (DL) NOTE this The instruction in F[0] (.B(DL) in a "MOVEI from anything be may case) actual constant a for AQ,value" a PUSHJ to a complicated to parameter, OTS routine which may in turn call other the user program ("thunks" ). of parts All accumulators except DL, destroyed, and the be may SP and DB stack may be shifted. and The various name parameters must be evaluated exactly once each, Therefore storing 1left to right, to obey the Algol rules. in order into a formal by name is a two-step process. At the correct point in right sequence, an to 1left the in parameters the evaluation of the This elaborates the address of XCTA (XCT 1) of F[0] is written. When it is required to which must now be saved. into A2, parameter store a value (from A0 and perhaps Al) into the parameter, XCT F[l] is (In very simple with A2 set up as it was after the F[0]. written, contains an F[l] and meaning no has A2 cases of actual parameters, a MOVEM.) Thus, to directly, e.g. value the store to instruction store the contents of A3 into parameter B in the example, write: PUSH XCTA pPOP XCT SP,A3 .B (DL) ; THE XCTA MAY CLOBBER ANY AC!! ; SET UP A2 .B+1 (DL) ; SP,A( STORE AQ INTO B. NOTE 1in The XCTA must be in the proper place to right sequence but the XCT 1left the F[1l] need not be. F[2] is never referenced directly by the procedure as it 1is used by PARAM to store information needed to evaluate the parameters. A suppose the example procedure P were called by simple case would be: I:= P(I,123456789,"ABC"); Then the three words for B on the fixed stack would be: .B(DL) .B+1 (DL) .B+2 (DL) F[O] F[1] F[2] MOVE SYSER1 "D123456789 21-4 A0, .B+2(DL) 11, MACRO (The SYSER1 used as In more left a UUO store produces an when actual complicated half, = the cases, delocated Special considerations strings. The code to go to a XCT JUMPN A2 will be error-message, F[2] DL), and apply formal SUBROUTINES is a is used because to store address (right formal arrays, for label formal cannot be the half) context (in the of labels, a thunk. procedures and is: .L (DL) A2, (A2) zero a constant.) : if the actual is a formal arrays, F[0] and F[l] the header word (as arrays are switch F[O0] whose subscript is out of bounds. For in used for pair (see section 21.6) 1is always static): XCT's should stored not be arrays. For strings, XCT F[0] will return with A0 and Al containing the string header and A2 containing the address: XCTA and XCT F[l] are used to store a new string header, but not to store a byte into an existing string. , In some circumstances A2 will point to A0, that is, the string header will be in A0 and Al, and nowhere else. This only happens when the actual parameter is a dynamic expression, i.e. a call To of obey actual a string procedure. a formal procedure, parameter an descriptor XCT of words, F[0] just as 1is coded, though a followed normal by procedure were being called, with the PUSHJ replaced by the XCT F[0]. The first desriptor 1is XWD type of procedure wanted, number of actuals+l. The remaining words, one for each actual, are coded with bits 1 to 11 as described above for formals. Bit 0 is set if dynamic, that is, a formal actual, or a thunk. Bits 18-35 are the value for an immediate constant (simple static expression), the address for a non-immediate constant (regular static expression) or a static (e.g. own) variable, or the Q address for dynamic variables. The Q address is the offset in the fixed stack of the actual variable, and bits 12-17, the P address, are the appropriate procedure level, that is, the offset in the current display of the context DL of the variable. For a thunk (a dynamic expression), the right half 1is the address of the thunk. Before using dynamic variables and expressions as actual parameters to formal procedures, the reader 1is advised to inspect some generated code (with ALGDDT) similar to the case 1in gquestion, as there are complications. 21.4 The the RETURNING procedure case of a the FROM TYPED stores the value two-word result) MOVEM in RESULTS PROCEDURES into the second word (and of the fixed stack, thus: A7,.EXIT+1(DL) example. 21-5 ;where third .EXIT =1 word in MACRO 21.5 PROCEDURE SUBROUTINES EXITS The first word in the fixed stack contains an appropriate Jjump to return to the call-site (via PARAM: the stack must be "unwound", and the result may need its type converted), so the procedure exits by use of: JRST 21.6 .EXIT(DL) FORMATS OF ;Where .EXIT =1 VARIABLES Integer and Real variables are obvious. Long real variables are 1in the format appropriate to the CPU type in use (KA or KI/KL). Boolean variables are zero for "false", and non-zero (including negative values) "true". for String variables are passed as a two word header. 0 5 6 11 12 17 The format is: 18 35 —————— L T T ettt ! 44 | B ! 0 ! address ! —————— T et ! flags ! length in bytes ______ o, b is the ! —————————————————— byte-size. The first word is a byte pointer to the string (such that an ILDB will get the first byte). This word is zero for a null string. The second word is mostly taken up by the length in bytes in the last word may be rubbish). The flags are: bit bit (odd bytes dynamic (not a constant) result of a string-type procedure 1 2 When a new value is assigned to a string, any old string must first be deleted. The safest way to do this is to call the OTS routine STRASS (string assign), which takes the necessary care not to delete constants and PUSH PUSH PUSH PUSH on, thus: SP,word-0-of-new-string's-header SP,word-1-of-new-string's-header SP,word-0-of-old-string's-header SP,word-1-of-o0ld-string's-header PUSHJ ; so SP,STRASS Result in AQ,Al NOTE STRASS will copy the string unless bit 2 is set Arrays are also passed in the new string's header. as a two word header, thus: MACRO SUBROUTINES where: 1. "type" is above). 2. "origin" integer is the etc. address (coded as of (possibly the in descriptor words, imaginary) =zero'th element 1in the array (if one-dimensional), or Iliffe vector (if N-dimensional); see below. in "DV which 3. address" for is the subscript words per address checking dimension, of the (and by containing Dope the the Vector, Debugging low and see the N-1'th is used System): two high bound of each. This applies to a vector. However, for a matrix (two the right half of word 0 is the address of the zero'th Iliffe vector, which is as follows: ——————————————————————————————————— ! origin of row a dimensional), element of the (dimension a:b) ! v origin of row atl 1 o etc. 1 v origin of row b 1 ————————————————— e where the origins are - ——— addresses elements. For more than exists. (The purpose of ——— s of the - — ———— (possibly imaginary) =zero'th two dimensions, a hierarchy of Iliffe vectors this is to allow addresses of elements to be calculated without multiplications). Arrays and strings (except for constant strings) are allocated in the Heap, and occurences local to a block are deleted at block exit. Strings are initialised to "null" (the first word of the header is zero) at block entry. 21.7 PROCEDURES This facility available 1in for some The procedure 1is the library PROC: WITH A VARIABLE NUMBER OF not provided DECsystem-10/20 procedures must have a PARAMETERS by the Algol-60 1language but is ALGOL run-time system. It is needed (IMAX etc., special READ, heading, XWD DL,offset JSP AX,PARQ PRINT, etc.) viz: etc. where "offset" of fshoot of If of is a PARAM) actuals allowed is wild types were location stores the on the number fixed of stack actuals. where The determined by the number of formal used in the formal descriptors, the 21-7 PARO maximum (an number descriptors. actual types MACRO SUBROUTINES can only be obtained by contains (PRGLNK (DL) descriptor words actuals' picking up the the over advanced address, call-site the actuals.) INCLUDING THE PROCEDURE IN THE LIBRARY 21.8 The procedure may simply be added to or FUDGE2 the (ALGLIB.REL) 1library with MAKLIB. If the procedure has a different version for KA and KI/KL processors, An entry LIBENT macro should be used (refer to file ALGSYS.MAC). the must also be made in a table in ALGSTB (in the compiler), to associate this is done by using the LIB macro, which the name with the alias: is described in comments in ALGSTB.MAC. UTILITY ROUTINES AVAILABLE 21.9 A number of the routines in the OTS are available for use by Macro procedures. 21.9.1 Getting Core any amount may be Core may be obtained in the Heap by calling GETOWN; as stack etc. the shift program, the expand will GETOWN and had, necessary. To get Calls are: core: MOVEI AQ,amount wanted or GETCLR if wanted zero'd SP,GETOWN ; PUSHJ on return, Al = address of core. ; To return core: MOVEI MOVE PUSHJ 21.9.2 AQ0,0 Al,address of piece not GETCLR! SP,GETOWN ; Input/Output because the Buffered mode input/output may not be done directly, may later which stack, the above buffers the allocate will monitor the have to expand or be shifted to allow heap to expand. access to the OTS routines is however allowed, as follows. 21.9.3 Device Open MOVE HRLI AQ, [SIXBIT/device/] Al,#-buffers-required ; 0 will give default MOVEI PUSHJ A2,mode SP,INPT ; ; 0 is ASCII or OUTPT HRRI Al,channel-number 21-8 Direct MACRO On return, Al instruction is zero which obtain starting a at 21.9.2.2 On free XCT'd channel %IODR(DB)) File successful. if etc. To if SUBROUTINES will number, for a 1If give scan zero Al,channel A2, [SIXBIT/Filename/] MOVE A3, [SIXBIT/Extension/] A4, [<protection>B9] MOVE A5, [project, ,programmer ] PUSHJ SP,OPFILE channel A0 is (as number action may IOERR 21.9.2.3 be is zero if still in by from Al, If LOOKUP and the not, or Al ,channel Channel standard Al,channel PUSHJ SP,RELESE ;jnon-skip if return error ;skip if Channel Select ; May give error number (channel not in use) OK MOVE1l A?,channel-# HRLM A?,%CHAN (DB) Output: MOVE1l A?,channel-§ HRRM A?,%CHAN (DB) Read Byte SP,INBYTE ; USES Al0-Al3 ;non-skip shere plus if end of file with byte in Al3 21-9 100 error number Input: PUSHJ contains obeying: Release MOVEI 21.9.2.6 it ENTER) Close SP,CLFILE For directory 5, (Al) PUSHJ For successful. returned MOVEI 21.9.2.5 contains an message, (16 words ° obtained PFile 21.9.2.4 I/0O Al failure number MOVE code the standard Open MOVEI return, the word. MOVE error unsuccessful, messages. the monitor octal. The message and MACRO 2149.2.7 Write Byte MOVE Al3,byte PUSHJ SP,OUBYTE ;non-skip if end of 21.9.2.8 Break USES Al0 - Al3 ; USES Al0 - Al3 file OK if Read Number Wme We we W A2,type MOVEI SP,READ. w0 PUSHJ ; =N = O 21.9.2.9 ; Output SP,BRKBYT PUSHJ ;non-skip if end of ;skip file OK. if ;skip : ; SUBROUTINES for integer for for real long for any note uses real type the period almost all ! AC's. here, number is in A0 (and Al if Long Real) type is in A2 if "any" was used. 21.9.2.10 Print Number A2,type ; as above (0,1, or 2) MOVEI number in A0 (and Al if Long Real) A3 = # digits before decimal point A4 = # digits after decimal point ; A3 = A4 = 0 for "standard mode" ; note the period. SP,PRINT. P USHJ ; ; on return, To print an ; integer integer uses characters in most AC's output. standard mode, in AQ String Terminal (regardless of MOVEI PUSHJ -or # SP,IPRINT PUSHJ 21.9.2.11 = A3 PUSHJ Output current channel Al,address of string MONITO MONSIX ; ; SP,MONIT :+ settings) (0 byte ends) 1f no break required, or if break required, or 1f string is sixbit (no break) SP,CRLF ; to type a newline NOTE OTS the Due to the buffering action of using OUTSTR (TTCALL 3,) UUO's may cause output to appear in the wrong order. 21-10 MACRO 21.10 GENERAL 1. any SUBROUTINES NOTES register may be DB=14 Pointer DL=15 Pointer SP=17 Stack destroyed to to by a procedure, except for: database current display pointer NOTE These three correct, registers since (parameter handler, must many fetching, error always 0TS stack handler, overflow etc.) depend them. No register The stack to access formals be "delocated" must is may "relocatedTM® also F[0] Any amount - be to see of needed. left XCT formals to trap or wanted by right XCTA 1in on access OTS routine, SUBI header formals Therefore An, (DB)) by "name". including any stack An, (DB)) after XCT's addresses before, every such call. (returned in addresses all heap "name" order, F[0]. certain side-effects rules these requirements may be constraints). arithmetic The OTS will intercept "C Debugging System (ALGDDT) All any (use and external will by to "name". ADDI stack areas OTS by string to The XCT's on (this in must and Even cases causes version be each formals must will still a entry to procedure extend including by these overflows. the Dynamic 10). accessed, only. by be are to be obeyed. consult the revised 21-11 by OTS errors always once used The and This A2 above.) (subject as over shifted (use applies XCT safe be routines and “Access" name which accessed, (For more report). if in strict here means are the not Algol detail on INDEX ABS, absolute value, 17-2 Actual 5-2, 5-3, BACK, - parameter, 11-9 Addition, Addition, 11-1, 11-2, 2-1 operator precedence, 20-1 ALGDIR, 21-2 ALGLIB, 1-3, 17-1, 21-1, 21-8 ALGOL-60, 1-1, ALGOL-68, 1-1 ALGOL 1-3, 21-1, 21-8, ALGPRM, 20-6, 21-8 ALGSYS, 21-1, 18-4, 7-1 ALT-modes, AND, delimiter ARCCOS, 17-1 ARCSIN, 17-1 17-1, 18-10, 21-11 ARCTAN, 17-1 bound 18-7, Blanks, 20-2 Blocks, 18-8 21-8 Block structure, BOOL, dummy word, 5-3, 5-4 2-3 * checking, subscript, typeout, 2-1, 2-2, 9-1, compiler array Bounds, 9- 2 Bounds, OWN Brackets, Break word, 2- 3 4—3, 5-3, variables, 17-2 arrays, 15 -1 4—3, 1 20- 17 16 -6 special charac ter, le-7, editing 1 6-12, 21-10 Buffers, 16-3 1/0, 18-10 18-2 manipulations, Byte, Byte 18-10 20- 4 dimension output, Byte 2-3 14-1 read , 17-3 21- 9 Byte size, string, 20-3 strings, 13-1, 16 -6 Byte subscripting, restrictionms, 1-2 2-1, 13-2, 16-10 15-1 16-2, 17-5, L6-3, 20-5, constants, 2-2, 16-8, 20-16 4-3 20-7, ASCII strings, 13-3, 20-3 Assembly switch FTGETCHK, Assignment commands, 20-2, 20-17 20-8, 18-11 20-11, 20-9, 20-16 Automatic conversion, Automatic conversion constants, type 20-10, 5-2 of CALL, 20-14 15, 17-4 CALL BY CALL BY 1l1-1, 1l1-6, Card Card reader, Carriage 16 -1, 16-2 CDP, device CDR, device name, 16-2 release, 21-9 number, Channels, le-2, Index-1 2 1-3 return, 4-3, 20-6 name, 16-2 Channel 16-8 NAME, VALUE, 11-1, 11-2, punch, 16-1, 16-2 Channel, 4-2 conversion, 20-13, 20-16 statement, 20-6 Assignments, 1-2, 4-2, 6-1 Automatic scalar BUFFERS:n, - 20-3 Arrays, 5-5 constants, delimiter BREAKOUTPUT, 5-5 9-2 Arrays, AUTO-lists, octal) expressions, Buffering, Array AUTO, (and Boolean, 18-6, delimiter word, 16-11, 10-1 BOOLEAN, BREAK, Array 16-2 function, procedures, operator, declarations, OWN, mode, 21-2, elements, ASCII image 3-3 Boolean variables, Array 20- 10 2-3 20-2 Binary Boolean, 20-4 2-1, » 21-1 9-1 ASCII, 10- 7-2 Arithmetic conditions, 5-4, Arithmetic expressions, 5-3 Arrays, delimiter word, 20-6 Boolean ARRAY, BEGIN, Bound, AND, Array 18-10 6-3, 4-3 17-6 Array Batch, BEGIN, Boolean 2-1 16-1, ALGSTB, ALL, 6-1, symbols, ALGOTS, 17-3, 20 -17 l6-1 0 BEGIN-END, 5-1 ALGDDT, 20-14, BACKSPACE, 16-4 l16-10 21-3 INDEX Channels, undefined, 18-6 Character constant, ASCII, 4-3 18-2 CHECKOFF, /CHECKOFF, compiler switch, 18-7 CHECKOFF, delimiter word, 2-3 CHECKOFF, directive, 18-6 CHECKON, 18-2 COMMENT, 2-4 /CHECKON, compiler switch, 18-7 CHECKON, delimiter word, 2-3 CHECKON, directive, 18-6 CLOSEFILE, l6-4 Comments, 2-2, 2-4, 20-2 Comment after END, 11-10 COMMENT, delimiter word, 2-3 11-10 Commentary, Comparison operators, 13-1 Compilation, independent, 18-3 Compilation, programs, 18-1 Compiler extensions, 1-2 Compiler restrictions, 1-2 Compiler switches, 18-2 Compiler version words, 17-5 Compound statements, 6-3, 14-2 Compound symbols, 2-2 CONCAT, 17-2 Concatenation, 13-3 Conditional operands, 14-1 Conditional statements, 7-2, 14-2 $CONDL, 20-6 Constants, Constants, 4-1, 4-2, 4-3, 5-2 REAL, compiler extension, 1-2 Constraints, compiler, CONTINUE, 18-11, 20-4, 20-12, 20-17 Control-backarrow, Control C, (°C), 20-7, 20-13, 1l-1 20-10, 20-2, 20-6 20-2, 20-4, 20-14, 20-15, 20-16 Control transfers, 7-1, 7-2 Control-underline, 20-2, 20-6 Control-back arrow, 4-3 Controlling listing of the source program, 18-7 Conversion type, 17-2 corPY, 13-3, 13-4, 17-2 Core size, 17-5 cos, 17-1 COSH, 17-1 CREF, 18-8, /CREF, 18-7 20-8 Current data-base register, Dangling ELSE ambiguity, 7-2 Data, numeric output, 16-9 Data transmission, 16-1 20-6 (CONT.) Date, 17-5 $DB, 20-6 DCALL, 17-4 Debugging programs, 18-1, 18-5 Debugging, system, dynamic, 17-6, 20-1 Declaration of an array, 10-3 Declarations, 3-2, 10-1 DECtape, 1l6-1, 16-2, 18-1 Default Input/Output, 16-10 DEFINE, 20-11, 20-17 Delete, files, 16-4 DELETE, typeless procedure, 13-4, 17-2 Delimiter words, 1-2, 1-3, 2-2, 2-3, 5-3, 18-2 Designational expressions, 14-3 Device allocation, 16-1 Device modes, 16-2 Devices, 16-1 DIM, 17-2 Disk, 1l6-1, 16-2, DIMENSION, 20-4 DIMENSION, 20-17 DIV, 5-1, 18-1 5-2 DIV, delimiter word, 2-3 Division, 2-1 Division, operator precedence, 5-1 $DL, 20-6 DO, 8-1 DO, delimiter word, 2-3 DSK, device name, 16-2 DTA, device name, 16-2 Dummy functions, BOOL and INT, 5-5 Dummy variables, 11l-1 DUMP, 17-6, 20-13, 20-17 Dynamic bounds, 10-3 Dynamic Debugging System, 20-1 Dynamic Trace, 17-6, 18-9, 17-6, 20-16 Elapsed time program, 20-16 ELSE, 7-2, 14-2 ELSE, delimiter word, 2-3 Embedded assignments, 6-2, 20-13 END, 6-3, 10-1, 20-2, 20-17 END, delimiter word, 2-3, 11-10 End-of-file, 16-11, 16-12 ENDFILE, 16-10 ENTIER, transfer function, 5-2, 5-3, 6-1, 17-2 EQV, Boolean operator, 5-3, 5-4 EQV, delimiter word, 2-3 Error returns, 16-3, 16-5 Error trap numbers, 18-6 Evaluation, of statements, Index~-2 19-1 INDEX Execution time program, 20-16 FORWARD, EXp, 17-1, 18-6 EXPERT, 20-14, 20-17 cedence, Expressions, EXTEND, declarations, compiler, 1-2 con- FORWARD, delimiter word, references, 11-8 Forward references, compiler restrictions, FTGETCHK, 16-8 FUDGE2, evaluation of, 1-2 assembly switch, 18-11 21-8 Function 6-2 2-3 Forward pre- 5-1 2-2, 11-9 Forward Exponent, optional (real stants), 4-1 Exponentiation, 2-1 Exponentiation, operator Exponents, (CONT.) procedures, 11-1 20-11 EXTERNAL, compiler extension, 1-2 EXTERNAL, 17-4, declaration, GETOWN, 11-9, EXTERNAL, delimiter External procedures, word, Global 2-3 11-9, 11-10, 20-2 GO, GO FORTRAN subroutine, 17-3 10-2 variables, delimiter TO, GoTto, F-10, 21-8 GFIELD, 18-4 7-1, word, 20-12, 7-1, 12-1, 20-12, 20-17 GOTO, delimiter 18-10, 2-3 20-17 14-3, word, 19-1, 2-3 17-4, 21-1 F10CALL, 17-4 F10DCALL, 17-4 HEAP, F10LCALL, 17-4 HEAP:n, F10RCALL, 17-4 F10ICALL, 17-4, HELP, 21-1 F-40, FORTRAN subroutine, FALSE, 3-2, 5-4, False, Boolean FALSE, Boolean OWN 5-3, 17-4 FALSE, delimiter word, FDATE, 17-5 20-16, ICALL, 17-4 IF, 7-2, IF, delimiter word, 14-2 /IGNORE, 18-6, 21-9 20-17 IMAX, 17-3 IMIN, 17-3 IMP, Boolean IMP, delimiter Floating-point, INCHAN, FOR, delimiter Form feeds, Formal format, 16-9 8-3, 9-2 8-2, word, 2-3 Indirect INFO, 11-3, 1-3, 11-5, parameters, 11-1, 11-10, 17-6, double precision, compiler extension, 1-2 FORTRAN, interface procedures, FORTRAN, to 3-2 terminology equivalents ALGOL, 1-3 1l6-2, Input channel, INPUT, library INPUT, statement, INT, 17-4 variables, files, 18-3 20-16 18-11 16-1, INSYMBOL, FORTRAN logical compilation, Input/Output, 21-1 FORTRAN 5-4 5-3, 2-3 l6-3, 1l6-6, 16-10 compiler restrictions, 1-2 FORTRAN, 3-1, 5-1, 16-8, word, command 17-5, Input, operator, 16-12 Independent 2-4 parameters, 11-2, 21-3 Formal 8-1, 2-3 20-10 Fixed-point, printing, 16-9 Floating-point data, 16-8 7-2, 20-17 20-16 Identifiers, 1-3, 2-1, 3-1, 5-2 Identifiers, compiler restrictions, 1-2 2-3 Field manipulations, 17-3 File devices, 16-1, 16-4 Files, 16-4, 16-11, 18-1, FOR, 21-11 4-3 variable, 20-16, 21-8, 20-4 constant, 20-13, 18-2, HLP:ALGDDT.HLP, 15-1 FINISH, 18-11, 18-2 16-4 procedure, 21-8 16-6 dummy function, INTEGER, delimiter Integer constants, conversions, remainder, Index-3 18-6 scalar 2-3 4-1 Integer Integer, 5-5 word, Integer INV, l6-1 16-2 5-5 5-5 variables, 3-2 INDEX I/0 channel status, I/0 directory, 21-9 IOCHAN, $IODR, 16-10, 16-10 16-11, 1l6-12 21-8 Jensen's Device, KAal0, 18-2 KI10, 18-2 KIiLL., 20-8, KLlo0, 18-2 11-6 20-10, (CONT.) Long real, scalar variables, Long real variables, 4-2 LPT, device name, 16-2 LSIN, 17-2 LSQRT, 17-2 MACRO, 18-4, 20-17 MODES, MTA, Labels, 1-3, 2-2, 7-1, 1l1-1, 11-2, 11-9, 12-1, 14-3, 16-3, 16-5, 18-8, 20-7 Labels, compiler restrictions, 1-2 LABEL, delimiter word, 2-3 17-2 Layout of declarations, 11-7 LB, 17-2 LCALL, 17-4 LCOS, 17-2 LENGTH, 13-3, Length, string, LEXP, 20-5 device name, 20-3 17-2 21-8 Library procedures, LINE, 18-5, 13-3, numbers, printer, LINK, 11-10, 20-2 Linking 18-7, 16-1, 13-3, loader, 13-3 LIsT, 18-2, of 2-3 18-4, 20-1, 18-4 20-17 source program, 18-7 LISTOFF, 18-7 LISTOFF, delimiter word, 2-3 LISTON, 18-7 LISTON, delimiter word, 2-3 LLN, 17-2 LN, 17-1, 18-6 Loading programs, 18-4 Local variables, 10-2 Logical device name, 16-1 Logical ., I1/0, 16-10 LONG, delimiter word, 2-3 LONG REAL, compiler extension, 1-2 Long real constants, cedence, 6-~2 2-1 operator pre- 5-1 Name, calling parameters by, New line, special editing character, 16-7 4-1, 11l-1 NEWLINE, symbol procedure, 16-7 NEWSTRING, string procedure, 13-4, 17-2 11-4 NOERRORS, 18-2 NOLIST, 18-2 /NOLIST, compiler switch, 18-7 18-2 NOQUOTES, 18-2 NOSYMBOL, 18-3 NOT, Boolean operator, 20-5 16-2 1-3, 20-9, the Multiplication, Multiplication, NONUMBERS, - LINKR, Listing 18-10 18-7 LINE, delimiter word, Line feed, 4-3 Line Line 16-2 ASSIGNMENTS, Newton-Rapheson Method, NEXT, 20-12, 20-17 NEXTSYMBOL, 16-6 17-2 LIBENT, 21-1 Magnetic tape, 16-1, 16-2, 16-1l1 MAKLIB, 21-8 Mathematical procedures, 17-1 Matrix, 9-1 Modes, device, 16-2, 16-3, 18-6 MULTIPLE LARCTAN, 20-5, 3-2 4-2 NOT, delimiter word, 5-3 2-3 NOVICE, 20-14, 20-17 Null strings, 13-2 /NUMBERS, 18-7 Numeric constants, 2-1, 4-1 Numeric data, 16-9 Numeric labels, 1-3, 7-1 Numeric labels, compiler restrictions, 1-2 Numeric procedures, 16-8 OBJECT, 20-2, 20-17 20-5, Object code, 20-5 Object Time System, 17-1 Octal addresses, 20-2, 20-=5 Octal (and Boolean) constants, 2-2, 4-3 Octal input/output, 16-9 Octal representation of strings, 20-3 Index-4 INDEX OFFTRACE, 17-6, 18-10, 20-16, 20-17 ONTRACE, 17-6, 18-10, 20-16, 16-5, 16-12 (CONT.) Quota, 1l6-11 Quotes, 4-3 20-17 OPENFILE, 16-4, Operating environment, Operator precedence, OR, Boolean OR, delimiter Order of Output, operator, word, 16-6, 16-2, 16-9, channel, OUTPUT, library 17-6 Random number, Range, real 5-1 Read, 1l6-1 16-2 READOCTAL, Real 15-1 OWN, delimiter word, variables, 15-1 18-6 PAGE, symbol throw, procedure, character, PARAM, 21-1, 16-7 16-=7 21-3, REAL, delimiter Real, scalar 1-3, 2-1, Paper-tape punch, Paper-tape reader, Parameter, 1-3, PAUSE, 17-6, 20-8, 11-1, 21-7 16-2 20-5, 20-7, 20-9, 20-17 devices, 16-1 Precedence, 5-1, Precedence, Boolean 5-3 Precision, PRINT, Procedures, Procedure 16-9 1l1-6 1-2 delimiter Procedure headings, Processor type, /PRODUCTION, Program 18-8, 16-4 2-3, word mode, Reserved word 2-4 11-10 quotes, compiler 1-2 11-8, 11-10, 16-8 compiler, 1-2 20-12 report ("Revised Report the Algorithmic Language ALGOL-60"), 1-1, 1-2, 13-1, 19-1 on 16-10 RMAX, 17-3 RMIN, 17-3 2-3 Run-time Run-time 6-1 diagnostics, error, 18-10 18-5 Run-time general information, 17-5 Running programs, 18-1 11-3 18-10 10-1 20-15, SCALARS, 20-13 Scalars, compiler 20-17 number, 16-4 Protection, 1-2 2-3 17-5 Project-programmer file, word, 11-2, switch, structure, PROFILE, word, Reserved Rounding, Procedure calls, 11-5 Procedures, compiler restric- tions, 1-1 extension, files, "REWIND, 11-3 20-4 Revised 5-=2 bodies, PROCEDURE, compiler delimiter operators, 11-1, 20-16, 5-2 REM, 6-=2 1-3, 20-2, REM, RETRY, 18-10 16-10 number, 21-10 OCTAL, 16-5 Restrictions, Restrictions, 16-9, PRINT, PRINT 4-2, 17-6, extension, Peripheral Plotter, 16-2, 16-11 PLT, device name, 16-2 trace, 15-1 20-13, Reserved words, 11-1 Post-mortem REENTER, Rename, 16-2 20-2, variables, 17-6, 5-1, exten- word, 2-3 variables, 3-2 11-7, 20-14 RELEASE, REM, 21-6 Parameters, compiler 1-2 Relocatable binary, 21-4, 3-1, 4-1 20-17 editing 21-2, 2-1, 1l6-9 Recursion, Recursive, special symbol, constants, REDIRECT, Page 16-12 21-10 constants, sion, 2-3 4-2 20-2 REAL, OWN 16-10, number, Readability procedure, 17-6 constants, RCALL, 17-4 READ, 16-8, 16-4 statement, OUTSYMBOL, 1l6-6 Overflow, 5-4 16-3, OUTPUT, arrays, 5-3, 16-10 Output OWN RAND, 2-3 evaluation, 16-1, 1-3 5-1 Scalar variables, Scope, 10-2, 16-4 Scope, SELECTINPUT, device name, 16-2 PTR, device name, 16-2 SELECTOUTPUT, Index-5 11-9, 3-2 20-4, 20-=7 switch declarations, 12-1 file, PTP, restrictions, 1-2 16-4 1l6-4 INDEX 20-6 Semi-colons, Setting line numbers in listings, 18-7 SETRAN, 17-6 17-3, SFIELD, 17-4 evaluation of 19-1 subscripts, 20-4 5-2, 5-3, Side-effects, typeout, SIGN, signum function, 17-2 Significance, Significance, /SILENT, 20-10 SIN, 17-1 precision, 5-2 real numbers, 4-2 Single-pass compiler, SINH, 17-1 SIXBIT, 20-5 strings, SIXBIT, SIZE, 17-2 SKIPSYMBOL, 20-6 20-17 4-3, l6-6, l6-8 Space, special editing charac- SPACE, symbol procedure, ter, SQRT, 1l6-7 17-1, 16-7 18-6 Stack, 18-10, 21-2, 21-11 Stack analysis, 18-8 Stack pointer, 20-6 Stack shifts, 17-5 Stack trace, 20-14 START, 20-2, 20-12, 20-17 Statements, 6-1 STEP-UNTIL, STOP, 20-10 8-1 2-2, 13-2, 1l-2 4-3, length and byte size, String procedures, 17-2 13-3, 2-2 1-2, 12-1, 14-1, 16-3, 18-2, 18-3, 18-5, Symbol procedures, 16-7 Symbol table, 18-3 Symbols, compound, 2-2 SYS:ALGDDT .HLP, 20-16 SYSER1 UUO, 21-5 System parameters, 20-6 special editing character, Tab, 2-2, 2-4, TAIL, 13-3 TAN, 17-1, TANH, 17-1 18-6 7-2, 14-2 THEN, 13-1, 13-3, 16-1, 16-6 String declarations, 13-1 STRING, delimiter word, 2-3 String expressions, assignments, 20-3 String operators, 13-1 String output, 16-6 Switches, THEN, STRING, compiler extension, String constants, 2-1, 2-4, 13-1 Switch option, 16-8, 20-2 18-10 Terminal output buffer, Terminals, 16-2, 16-3 Terminology, 1-3 13-3 String, 5-1 Switch declarations, 12-1 SWITCH, delimiter word, 2-3 Switch element, 14-3 Tabs, String assignments, expressions, String comparisons, Subtraction, operator precedence, 16-7 STATISTICS, 20-16, 20-17 STEP, delimiter word, 2-3 13-1 20-6 16-8, 18-10, 19-1 SWITCH.INI, 20-14 .SYM file, 20-1 Symbol file, 20-1 20-3 2-4, Spaces, 2-2, l6-6, l16-5, 1l-1 16-6 20-16, SOURCE, %SpP, String variables, 13-3, 16-8 Strings, 1-2, 13-1, 13-2, 18-10, Strings, concatenated, 13-3 Subroutine, FORTRAN, 1l1l-1 Subscripting, byte, 2-1, 13-2 Subscripts, 2-1, 9-1 Subtraction, 2-1 Side~-effects, evaluation of expressions, 6-2 Side-effects, (CONT.) TIME, TRACE, delimiter word, 17-5 17-6, 20-15, 18-8, 20-17, 2-3 18-9, 21-2 18-10, /TRACE, switch, 18-10 TRANSFILE, 16-12 TRAP, 18-5 TRAPNO, 18-5 TRUE, 3-2, 5-3, 5-4, 20-4 4-3 TRUE, Boolean constant, TRUE, delimiter word, 2-4 TTY, device name, 16-2 TYPE command, 20-3, 20-17 Type conversion, 6-1, 11-2, 20-6 Typeless procedures, 11-3, 13-4 16-8, String scalar variables, 3-2 String variables, 3-2, 21-6 String typeout, 20-3 UB, 17-2 UNTIL, 8-1, 8-2 UNTIL, delimiter word, UNWIND, 20-14, 20-17 Index-6 2-4 INDEX VALUE, 11-1 VALUE, delimiter word, Variables, VDATE, labels, 2-4 18-8 17-=5 $VERSHN, 20-6 Virtual peripherals, (CONT.) WHERE, 20-14, WHILE, 7-2, WHILE, compiler WHILE, delimiter word, WRITE, 16-7, 16-1 XCTA, Index-7 21-4 20-17 8-1, 8-2, 8=3 extension, 16-12, 2-4 17-5 1-2 DECsystem-10/20 Programmer's ALGOL Guide AA-0196C~-TK READER'S NOTE: This use form is comments for COMMENTS document submitted comments on this only. form at the DIGITAL will company's discretion. Problems with software should be reported on a Software Performance Report (SPR) form. If you require a written reply and are eligible to receive one under SPR form. Did you find service, submit your errors in this manual? If so, Did you find this manual understandable, Please make suggestions for improvement. Is thetre comments on an SPR ‘ sufficient documentation on specify by page. usable, associated and well-organized? system programs required for use of the software described in this manual? what material is missing and where should it be placed? Please indicate the type of user/reader that you most If nearly not, represent. Higher-level language programmer 0000 (J Assembly language programmer [:] Occasional User with programmer little (experienced) programming experience Student programmer Non-programmer interested Name in computer concepts Date Organization Street City State Zip Code or Country and capabilities Fold Here Do Not Tear - Fold Here and Staple FIRST CLASS PERMIT NO. 152 MARLBORO, MASS BUSINESS REPLY MAIL NO POSTAGE STAMP NECESSARY IF MAILED IN THE UNITED STATES Postage will be paid by: dlilgliltlall Software Documentation 200 Forest Avenue MR1-2/E37 Marlboro, Massachusetts 01752 R =
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies