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