Digital PDFs
Documents
Guest
Register
Log In
DEC-08-AFC
December 2000
84 pages
Original
1.9MB
view
download
Document:
dec-08-afco-d
Order Number:
DEC-08-AFC
Revision:
Pages:
84
Original Filename:
https://svn.so-much-stuff.com/svn/trunk/pdp8/src/dec/dec-08-afc/dec-08-afco-d.pdf
OCR Text
0.. . IE . C M'ag§t.?ard?fiZZ‘SLthué’éfli'am" 4K EJflEflIEII FORTRAN PDP- 8 PROGRAMMER s REFERENCE MANUAL DEC-08—AFCO-D 4K FORTRAN PROGRAMMER’S REFERENCE MANUAL For additional copies specify Order No. DEC-08-AFCO-D to Program Library, Digital Equipment Corporation, Maynard, Mass. $2.00 O|GITAL EOLJIF’IVIENT CORPORATION E] Price: MAYNARD, MASSACHUSETTS lst Edition October 1966 2nd Edition Revised May 1967 3rd Edition Revised October 1967 4th Edition Revised May 1968 5th Edition January 1969 6th Edition May 1969 Your attention is invited to the last two pages of this manual. The Reader's Comments page, when filled in and returned, is beneficial to both you and DEC. All comments received are considered when documenting subsequent man- uals, and when assistance is required, a knowledgeable DEC representative will contact you. The Software Infor~ mation page offers you a means of keeping up-to-date with DEC '5 software . Copyright © 1966, 1967, 1968, 1969 by Digital Equipment Corporation Instruction times, operating speeds and the like are in- cluded in this manual for reference only; they are not to be taken as specifications. The following are registered trademarks of Digital Equipment Corporation, Maynard, Massachusetts: DEC PDP FLIP CHIP FOCAL DIGITAL COMPUTER LAB PREFACE The program discussed in this manual, though written For use on the Programmed Data Processor-8 computer, can also be used without change on Digital's Programmed Data Processor-5. This compatibility between the libraries of the two computers results in three maior advantages: 1. The PDP—8 comes to the user complete with an extensive selec- tion of system programs and routines pability of the new computer making the full data processing ca- immediately available to each user, elimi- nating many of the common initial programming delays. The PDP-8 programming system takes advantage of the many man—years of field testing by PDP-5 users. 2. 3. Each computer can take immediate advantage of the continuing program developments for the other. CONTENTS Page CHAPTER 1 INTRODUCTION CHAPTER 2 THE FORTRAN LANGUAGE Statements 2-i Program Format 2—1 Types of Statements 2-2 Comments 2—2 Continuation 2—3 The Character Set 2—4 CHAPTER 3 FORTRAN ARITHMETIC 3—1 Arithmetic Expressions Constants 3—2 Variables 3-2 Operators Use of Parentheses 3—4 3-4 Functions The Arithmetic Statement CHAPTER 4 NUMBER REPRESENTATION AND VARIABLE TYPES Integers and Floating Point Numbers 4-1 Fixed- and Floating-Point Representation 4—1 Types of Variables 4-2 CHAPTER 5 SUBSCRIPTED VARIABLES Arrays Subscripts The Dimension Statement CONTENTS (Cont) CHAPTER 6 PROGRAM CONTROL Program Termination END Statement Branches and Loops The GO TO Statement Integer Summation DO Loops Illegal DO Nesting The CONTINUE Statement Computed GO TO CHAPTER 7 INPUT AND OUTPUT Available Devices Input and Output Statements Device Selection and Direction of Transfer Statement Number of Format Statements List Format Specifications Statement Control Elements E and I Input Integer Values - Fixed Point Decimal Fraction Values - - FORMAT (I) Floating Point - FORMAT (E) Correcting Typing Errors Output Data Word Output Floating and Fixed Modes FORMAT (E) and FORMAT (1) - Other Format Control Elements - 7—6 7—7 Quote (") (Hollerith Output) 7-7 Slash (/) 7-8 CHAPTER 8 FORTRAN WITH DECTAPE OPTION FORTRAN Compiler with DECtape I/O Option CONTENTS (Cont) Page Use of Symbolprint with FORTRAN 8—I FORTRAN Operating System with DECtape I/O Option 8—I DECtape FORTRAN Statements and Operation 8—2 CHAPTER 9 PDP-5/8 FORTRAN SYMBOLPRINT APPENDIX A OPERATING PROCEDURES FOR RIM AND BIN PAPER TAPE LOADERS APPENDIX B PREPARATION OF SYMBOLIC (SOURCE) TAPE APPENDIX C FORTRAN OPERATING PROCEDURES APPENDIX D FORMAT OF COMPILER OUTPUT APPENDIX E ASR-33 8-BIT CHARACTER SET APPENDIX F PDP-8 FOR TRAN SOURCE PROGRAM RESTRICTIONS APPENDIX G DIAGNOSTICS ILLUSTRATIONS 2—] I A Fortran 2 Example of Comments 2-3 3 The Continued Statement 2-3 4 Number Representation 4-2 5 Indexing Statements 5-3 6 Schematic Representation of Program Branching 6-2 7 Integer Summation 6—3 8 Use of IF Statement in Integer Summation Problem 6-3 9 IF Statement with Substatement Feature 6-4 IO Fibonacci Series 6-4 II Fibonacci Series Calculation Programmed As a DO Loop 6-5 I2 Nested DO 6-6 Program Loops ILLUSTRATIONS (Cont) DO Loops Program Branching in D0 Loops Input-Output Statement A List Example Examples of Quote and Slash vi CHAPTER 1 INTRODUCTION Using a digital computer to solve a problem generally involves the Following series of steps: Determining the correct procedures to be used, including mathematical formulas, the a. handling of data, the presentation of results, etc. specified b. Arranging the procedures in the proper order. c Determining the sequence of computer instructions that will perform the operations . . Converting the sequence of instructions into binary notations in a physical medium d. capable of being entered into the computer for execution. Much of the progress and development in programming has been made in discovering ways to make the computer perform more of the steps listed above, and leaving the programmer free to concentrate more on the problem itself. At first, programmers entered instructions manually from the computer console or prepared the binary program for direct input. a Later, a symbolic notation was developed for computer instruction set, and programs called assemblers were written that could interpret a tape or card deck punched with this notation. These assemblers translate each symbolic instruction into a ma- chine operation and assemble an executable program. Thus, an assembler can accept input from step c above. An assembler requires that the programmer be familiar with the particular instruction set of the computer being used. programming To solve the same on another computer would usually require complete re- . To free the programmer from the need of learning a given computer's language before using the machine to solve problems, compilers were developed which accept input more closely related to the problem and convert the input into an executable program. FORTRAN is such a compiler. It ac- cepts input in the form of statements which resemble mathematical formulas (hence its name, which stands for FORmula TRANslation) and compiles sequences of instructions necessary to perform the procedures specified. Non-mathematical operations are specified by English words. In terms of the steps given above, a FORTRAN source program is a product of step b; the computer performs steps c and d . A FORTRAN compiler can thus be written for any digital computer to convert a source program into an executable program. Extensive reprogramming is made unnecessary, since the same source program can be compiled on different machines with only minor changes. The PDP-8 FORTRAN System consists of two subsystems: system . l-l the compiler and the object time The FORTRAN Compiler contains the instructions the computer requires to perform the clerical work of translating the FORTRAN version of the problem statement into an object program in the language of the obiect system. When the compiler detects errors in statement format or usage, it prints out diagnostic messages (see Appendix G). The programmer or operator should then take the appropriate corrective measures and recompile the program. Note, however, that the compiler cannot detect all such errors, and also that the diagnostic message may not accurately indicate the cause of the error but rather the symptom. After compilation, the obiect time system is used to execute the program. This system con- tains the interpreter, the arithmetic Function subroutines, and the input/output packages. execution is required, the object time system, into the computer For solution of the problem When program obiect program, and the data it will work with are loaded . This is a one-pass compiler, which means the source language tape must be read only once. The compiler generates one tape which contains coding in a form that is executable under control of the object time system. To use the system, it is only necessary to load the compiler. source language tape and generates the obiect program tape. any time simply by The compiler then processes the This obiect program tape can be run at loading the obiect system, which, in turn, loads and executes the object program. CHAPTER 2 THE FORTRAN LANGUAGE STATEMENTS Figure l is an example of a FORTRAN program, consisting of a title, the body of the program, and the end statement. The first line of the program is the title, which may be anything the programmer writes to identify the program. It is not incorporated into the final executable program. The body of the program is a series of statements, each of which specifies a sequence of mathematical operations, controls the flow of the program, or performs other tasks related to the proper working of the program. The end statement must be physically the last statement of every FORTRAN program. Its function is to indicate to the compiler that nothing more connected with the preceding program is to follow. c; 5; 10; THIS PROGRAM CALCULATES FACTORIALS TYPE 200 ACCEPT 300,x FACT=Y=T. (X) 5,32,30 (X-Y) 41,32,33 TYPE 400,X,FACT IF 30; 32; IF GO TO 10 33; FACT=FACT*(Y=Y+l .) GO TO 30 41; PAUSE 200; 300; 400; FORMAT (/, "PLEASE TYPE A POSITIVE NUMBER", /) FORMAT (E) FORMAT (/,E, "FACTORIAL IS",E) GO TO 5 END Figure l A FORTRAN Program PROGRAM FORMAT Each line contains two fields: the first, which begins at the margin, is an identification field; the second contains the statement proper (see Figure l). 2—] The identification field extends from the left-hand margin up to and including a semicolon This field may be left blank, or it may contain one of the following types of identification: character. 0. The first digit of a statement number. This number, which may be any positive integer from i to 2047 inclusive, identifies the statement on that line for reference by other parts of the pro- gram. ments Statement numbers are used for program control or to assist the programmer in identifying segof his program. b. Up to 40 statements can have statement numbers. The letter C. This identifies the remainder of the line as a comment (see Section Comments). The semicolon (;) is necessary only if the statement is numbered or is a comment, (i .e. , if the identification field is blank, the semicolon may be omitted). The statement field begins immediately after the semicolon and extends through the next car- riage return more Although the continuation character (' ) allows a single statement to extend over two or . lines, no more than one statement can be written on one line. continued by use of the continuation character Note that a comment cannot be (' ). TYPES OF STATEMENTS FORTRAN statements are of several types with differing functions distinguished as follows: a. operations to b . Arithmetic statements resemble algebraic formulas. They specify the mathematical be performed. Program control statements direct the flow of the program . c Specification statements allocate data storage, determine variable and data types, and specify input/output formats . . d . Input/output statements control the transfer of information into and out of the computer. COMMENTS Although a FORTRAN program using English words and mathematical symbols can be read and understood more easily than a symbolic language program, it is helpful to provide comments freely throughout the program to explain the procedures being used. Such comments, identified by a C in the first position of every line intended as a comment, are not interpreted by the compiler and have no effect on the executable program. C; C; CALCULATE PERCENTAGE OF CORRECT RESPONSES PERCENTAGE = -1 IF THERE ARE NO ITEMS IN CATEGORY C DO 471:1, 57 DO 48 J=i , 6 IF 46; (ITMS (J)) 46, 46, 51 (I) -].0 PRCN = Figure 2 Example OF Comments CONTINUATION Frequently, a statement may be too long to fit on one line. If the character single quote (') appears as the last character of a line before the carriage return, the next line is treated as a continuation of the statement on the line above (see Figure 3). A statement may be continued on as many lines as necessary to complete it, but the maximum number of characters in the statement may not exceed 128 . l; ; 2; ; 3; 4; ; 5; FORMAT IF (NR (1) -1) 2, 2, 3 AP=-l4.73 GO TO 6 IF (NR (I) —2) 4, 4, 5 AP=-44.l9 GO TO 6 AP=SH AG Figure 3 (2)*3.0-AG(4)/' (i)+SQTF (AG (14)) The Continued Statement THE CHARACTER SET The characters which are meaningful in FORTRAN belong to the ASCIIset listed in Appendix D. Of these, the acceptable characters are: characters - semicolon all letters and numbers - A through Z, 0 through 9; control (; ), carriage return (CR), line feed (LF), single quote (‘ ), double quote (" ), left parenthesis (, right parenthesis ), period slash (/), asterisk (*), equal sign (=). (.), comma (, ); and the operators - plus (+), minus (-) All other characters are ignored by the compiler except in Hollerith information of FORMAT statements where all Teletype characters are legal. The character space has no grammatical function except in FORMAT statements, but may be used freely to make a program easily readable. 2-4 , CHAPTER 3 FORTRAN ARITHMETIC ARITHMETIC EXPRESSIONS An algebraic formula such as the Following [5a + 4b (x2 x0)] /2a sin 9 - represents a relationship between literal symbols (0, b, x, x0, 9) and constants (5, 4, 2) indicated by mathematical functions and arithmetic signs (+, -, /, multiplication, exponentiation, sine). This same formula can be written as a FORTRAN arithmetic expression with very little change in appearance: (5.*A + 4.*B*(X**2 - XZRO) )/ (2.*A*SINF(THTA)) The construction of both expressions is the same; the differences are notational. The elements of an arithmetic expression are of four types: and Functions. stants, An expression may consist of a single constant, a constants, variables, operators, single variable, or a string of con- variables, and functions connected by operators. The following examples demonstrate the properties of arithmetic expressions. Each expression is shown with its corresponding algebraic form. Algebraic Expression 0x2 + 2 FORTRAN bx + c Expression A*X**2 + B*X + C 2 ELLE?) (0 b) (A**2 - 3w) / (A+B)** 2 + 4-*PI*(R**2)/3- r2 4n 3 W) a ~sin 9 + 20 23“ X (3.*X*PI—2.* (X+Y)) /4.25 ' cos (9 ~45) A*SINF(THTA)+2.*A*COSF(THTA-0.7853982) 2.*SQTF(X)/3. Constants Constants are explicit numerical decimal exponent Form. quantities. They may be integers, decimals, or numbers in Some examples Follow: integers -70 2047 3.14159 -0.00025 5 decimals 18.75 decimal exponent (meaning 1.66 x 10—16) 1.66E-16 These different Forms oF numerical representation are described in detail in Chapter 4. Variables A variable is a literal symbol whose value is not implicit; its value may be changed during the execution 0F the program. A variable name is composed oF one or more characters according to these three rules: a. The only characters which may be used in a variable name are A through Z and 0 b. The First character must be alphabetic (i .e. c. Only the First Four characters oF any variable name are meaningful through 9. , A through Z). . All characters aFter the Fourth are ignored by the compiler. Some examples oF acceptable variable names are: A XZRO K LST8 THTA P5l The name EX IT represents one variable, not two. DC8B EPSL XSUM (Remember that blank spaces have no Function in FORTRAN.) Thus, EX IT, EXIT, or even EXI T, are identical names as Far as the compiler is concerned because they all reference the same variable. The name EPSILON would be interpreted by the compiler as EPSI, since only the First Four characters are meaningFul identical. . For example, the two names XSUM] and XSUM2 would be considered Some incorrect variable names are: 9SRT (first character not alphabetic) GO(5 (illegal character included) CSH$ (illegal character included) Operators The operators are symbols representing the common arithmetic operations. about operators in the FORTRAN arithmetic expressions is this: resented by an operator. Every operation must be explicitly rep— In particular, the multiplication sign must never be left out. exponentiation is also provided since superscript notation is not available. are The important rule A symbol for To illustrate the rule, here the FORTRAN and algebraic forms given in the section on arithmetic expressions: (5.*A +4.*B*(X**2—XZRO) ) / (2.* A*SINF (THTA)) [50 + 4b (x2 - xo)] /2a sing Normally, a FORTRAN expression is evaluated from the left to right iust as an algebraic Formula is. There are exceptions to this rule. Certain operations are always performed before others regardless of order. This priority of evaluation is as follows: lst Expressions . ( ) within parentheses 2nd 3rd 4th 5th . Unary minus —- Exponentiation ** . Multiplication * . Division / Addition + . Subtraction - The term binding strength is sometimes used to refer to the relative position of an operator in a table such as the one above, which is in the order of descending binding strength. Thus, expo— nentiation has a greater binding strength than addition, and multiplication and division have equal binding strength . The unary minus is simply the operator which indicates a quantity whose value is less than zero, such as -53, -GAMME, -K. It refers only to the operand which it precedes as opposed to a binary operator, which refers to operands on either side of itself, as in the expression a-b. A unary minus is recognized by the fact that it is preceded by another operator, not by an operand. For example: A + B**-2/C-D The first minus (indicating a negative exponent) is unary; the second 3—3 (indicating a subtraction) is binary. The left-to-right rule can now be stated more precisely as follows: binding strength is evaluated from left to right. A sequence of operations of equal To change the order of evaluation, evaluated as A-(B*C), right rule not parentheses are required. Thus, the expression A-B*C is (A-B)*C. The example below gives a few more illustrations of the left-to— . The expression is evaluated as A/B*C A/B/C (A/B)*C (A/Bl/C A**B**C (A**B)**C An easy way to check the proper pairing of parentheses is by counting out, illustrated in the following example: (Z+AM*(ZM+I .))/((X**2+C**2)*P) I The procedure is this: 2 I0 12 I 0 Reading the expression from left to right, assign the number I to the first left parenthesis (if you encounter a right parenthesis first, the expression is already wrong!) count by one each time a left parenthesis is read, and decrease the count by one when a right paren- thesis is used. comes zero Increase the When the expression has been completely scanned, the count should be zero. less than zero during the scanning, there are too many right parentheses. at If it be If it is greater than the end of an expression, then the pairing is incorrect. Use of Parentheses Note the use of parentheses in the following example below. They are used to enclose the subscript of the dimensioned variable D, to specify the order of operations of the expression involving A, B, C, and to enclose the argument of the function. D(I+J) In algebra there are several etc. , for = (A+B)**C+SINF (X) devices, such as square brackets ([l ), rococo brackets ( {} ), distinguishing between levels when subexpressions are nested. In FORTRAN, only the curved parentheses are available, so the programmer must be especially careful to make certain that parentheses are properly paired. In a given expression, the number of left parentheses must be equal to the number of right parentheses. Functions Functions are used in FORTRAN an arithmetic expression . just as they are in ordinary mathematics -- as variables in The function name represents a special subprogram which performs the calculation necessary to evaluate the function; the result is used in the computation of the expression in which the function occurs. PDP-5/8 FORTRAN provides several mathematical functions: tangent, exponentiation, and natural square root, sine, cosine, arc logarithm. The argument of a function can be a simple or subscripted variable or an expression The FORTRAN recognizes a term as a function when the term is a pre— argument must be in floating point. defined symbol . ending in F followed by an argument enclosed in parentheses (if the F is missing from the term, the symbol is treated as a subscripted variable). other function or group of functions. The argument of a function can consist of an— For example, the expression: LOGF(SINF(X/2)/COSF(X/2)) is equivalent to log*tan The PDP-5/8 FORTRAN é library currently consists of the following functions: Function Name Meaning SQTF (X) square root of X SINF (X) sine of X, where X is expressed in radians COSF (X) cosine of X, where X is expressed in radians ATNF (X) arc tangent X, where the angle is given in radians EXPF (X) exponential of X LOGF (X) logarithm of X THE ARITHMETIC STATEMENT The arithmetic statement relates a variable V to an arithmetic expression E by means of the equal sign (i). Thus: V : E Such a statement looks like a mathematical equation, but it is treated differently. The equal sign is interpreted in a special sense; it does not represent a relation between left and right members, but it specifies an operation to be performed . NOTE In an arithmetic statement, the value of the expression to the right of the equal sign replaces the value of the variable on the left. This means that the value of the left-hand variable will be different after the execution of an arithmetic statement. A few illustrations of the arithmetic statement are given below. VMAX 0. T P1 = VO + AXT 2.*PI*SQTF(T./G) = 3. 14159 THTA MIN OMGA + ALPH*T**2/2. = MINO = INDX f. = INDX + 2 = With the interpretation of the equal sign defined previously, example f becomes meaningful as an arithmetic statement. If, for example, the value of INDX is 40 before the statement is executed, its value will be 42 after execution. Perhaps another way of looking at the equal sign illustrates its use and interpretation more fully. In arithmetic expressions, a binary operator requires an operand on its left and right. sign of an arithmetic statement is considered to be a binary operator also. The equal This interpretation is dem— onstrated in the following revised table of operators: Operator Interpretation Elie -A negate A ** A**B raise A to the Bth power * A*B multiply A by B A/B divide A by B A+B add B to A A-B subtract B from A A=B replace A with B — - (Unary) (Binary) Treated this way, the equal sign is considered to have the lowest binding strength of all the operators. This means that the expression on the right is evaluated before the operation indicated by : is performed. The most important result of treating the equal sign as a binary operator is that it may be used more Consider the following: than once in an arithmetic statement. CPRM = (CKL - CKG) / (CPG = P*(Q +1.)) The internal arithmetic statement, CPG = P*(Q + 1.), is set off from the rest of the statement by parentheses. The complete statement is a concise way of expressing the Following common type of mathematical procedure: th- Ckg Let he wer c' Cpg : :*+i P(q) Cpg The stating of a relation followed by the conditions for evaluating any of the variables can be expressed in a single arithmetic statement in FORTRAN . Another important result of treating the equal sign as an operator is that the operations may be performed in sequence. Just as there may be a series of additions, A+B+C, so may there be a series of replacements, A=B=C=D. Note that since the operand to the left of an equals sign must be a variable, only the rightmost operand, represented by D in the example, may be an arithmetic expression statement is interpreted as follows: . The ”Let the value of the expression D replace the value of the variable C, which then replaces the value of the variable B" and so on. most expression is given to each of the variables in In other words, the value of the the string to the left. right- A common use for this con- struction is in setting up initial values: XZRO=SZRO=AZRO=O T=T l=T2=T3=6O P=FP=4 *ATM-AK . Only single level replacements will compile correctly in this manner. type A(l) = A(2) = R(l) = For example: Statements of the O.l23 are not allowed and will not compile properly. Another useful result in treating the equal sign as an operator is that the value of an expression on the right of an equal necessary sign is converted to the mode of the left-hand variable before storage, if . Example: A = M CHAPTER 4 NUMBER REPRESENTATION AND VARIABLE TYPES INTEGERS AND FLOATINGcPOINT NUMBERS In mathematics there are many ways to categorize numbers. rational or irrational, whole numbers or Fractions. into integers and decimals, They may be positive or negative, In FORTRAN, the treatment oF numbers is separated distinguished as follows: Integers are positive or negative numbers written without a decimal point. These num9, 17, 147, l024, 2047. The last number, 2047, is the largest quantity that can be a FORTRAN integer. as For Fractional quantities and For numbers larger than i2047 (which expressed is 2H -l), the second type oF number is required. a. bers are integers: When using integer arithmetic, any Fractional results are truncated. expression M=N/3 with N=8 would result in M=2. addition and subtraction yield integral results. For example, the This applies only to division because multiplication, b. Floating point numbers have two Forms. They are simple decimals, such as 0.0025, .4, 2.7l828; or numbers in decimal exponent Form. Numbers in decimal exponent Form are simple decimals multiplied by a power of IO. Numbers in decimal exponent Form wt have an explicit decimal point. 57. , Examples: Mathematical Form FORTRAN Form l023 10"6 1.66 72.xl0l2 6.023 x 6.023E23 1.66E—16 x In general, an a 72.512 Floating point number in decimal exponent Form is NEiK, where N may be integer or simple decimal, and K is an integer From 0 to 99, inclusive. The construction NEiK is used to represent the number leOK. The Following are Floating point representations oF the number l9: l9.0 .l9E2 l.9E+l l900.E-2 l90.0E-l FIXED- AND FLOATING-POINT REPRESENTATION The diFFerence between integers and real numbers in FORTRAN is the way in which each is represented in core memory. A FORTRAN integer is stored in one l2-bit computer word. in high-order bit and the magnitude in the remaining ll bits. in The sign oF the number is kept the This representation, shown schematically Figure 4 is called Fixed point, because the decimal point is always considered to be to the right oF the rightmost digit. A FORTRAN integer may not exceed the range of -2047 through +2047. greater than i2-47 are taken modulo 2048 (that is 2049 is taken as OOOl The floating point format consists of two parts: an , All integers 4099 is taken as 3). exponent (or characteristic) and a mantissa. The mantissa is a decimal fraction with the decimal point assumed to be to the left of the leftmost digit. The mantissa is always normalized; that is, it is stored with leading zeros eliminated so that the leftmost bit is always significant. to obtain The exponent represents the power of two by which the mantissa is multiplied the true value of the number for use in computation. stored in 25 complement form The exponent and mantissa each are . SIGN l Ll I MAGNITUDE ‘ 0 a. FORTRAN INTEGER “ SIGN OF EXPONENT 1 SIGN OF l MANTISSA-fi‘ i I EXPONENT 11 0 1 . 2 L: MANTISSA 3 | MANTISSA J b.FL.OAT|NG POINT Figure 4 Number Representation TYPES OF VARIABLES Since variables represent numeric quantities, the type of representation must be specified in some manner. as In normal programming, variable types are specified using the FORTRAN conventions follows: a. Integer variable names must begin with one of the letters I, J, K, L, M, or N. b. Floating point variables are designated by names beginning with any other letter. These are integer variable names: names: ZXRO, CONT, FICA. INDX, KDTA, M359. These are floating—point variable Integers cannot appear in Floating point expressions except as exponents or subscripts. examples of illegal and legal expressions are as Follows: Expression Legal Mode A(I)*B(J)**2 I(M)*K(N) Yes Floating Yes Fixed 4 .* J No I+D No l6.*B Yes Floating (K+l 6)*3 Yes Fixed A**(I+2)/B Yes Floating 8*A No - _ - Some CHAPTER 5 SUBSCRIPTED VARIABLES ARRAYS An array is a grouping of data. matrix are all arrays. In mathematics, an A column of figures, the elements of a vector, In For example, the sixth element v6. FORTRAN, array elements are similarly identified. The array is given a name subiect to the some rules as the names of variables, described in Chapters 3 and 4. an list, and a element of an array is referenced by means of a symbol de— noting the array and subscripts identifying the position of the element. in a vector v is designated a element of the array is enclosed in parentheses. The subscript which identifies The element referred to in the preceding paragraph would have the following form in FORTRAN: V(6) Such a name designates a subscripted variable, which may be used in computation just like a simple variable. the array The array name determines the mode, integer, or floating point of all the elements in . The example below gives a few illustrations of the use of subscripted variables. a X(I+L)=X(I)+ALPH(I)*P(I) b. X(I+3)=X(I+2)+X(I+I)/2. O C(J)=A(I*J+3) . d. A=B(6) Subscripts As the example above illustrates, subscripts may be quite diverse in form. In fact, may be any acceptable FORTRAN arithmetic expression as long as it is integerwalued. a subscript This means that there may not be any floating-point quantities in a subscript expression. The Dimension Statement Array names must be identified as such to the FORTRAN compiler. must Two items of information be provided in any program using arrays: a. Which are the subscripted variables? b. What is the maximum dimension of the subscript? amount of storage space must be set aside for its elements; 5-] (When an array is used, a certain hence this requirement.) All the above information is provided by the following specification statement: DIMENSION A(20), B(l5) where A and B are array names, and the integer constants 20 and I5 are the maximum dimensions of each subscript. The rules governing the use of array names and the dimension statement are as; follows: DIMENSION may be used as many All array names must appear in a dimension statement. times as desired and may appear anywhere in the FORTRAN program, provided that the DIMENSION of an array appears before any statement which references the array. DIMENSION LIST(30), MAT(l00), REGR(20) In the statement in the example above, the names LIST and MAT designate integer arrays; The third name, REGR, designates a floating-point array. The first array is a list of 30 elements maximum, so that 30 words of storage are set aside for its use. The that is, each element is an integer. third array is floating-point and there are 20 elements in it. Since this array is floating, each element requires 3 words of storage so that 60 words are set aside for the array DIMENSION B(30), . 1(15) This version of the PDP-5/8 FORTRAN does not have the facility for double subscripted variables. To accomplish double subscripting, the programmer has to include indexing statements in the source program as illustrated in Figure 5. In this example the matrices are stored column wise in memory, that is, sequential locations in memory are used as follows: Relative Position Element in Memory (INDX) al I 02 ll ONIO‘tn-P-OJN—I 03 ll a4l| 05 ll aéll a122 a222 056 35 a6<5 36; If referencing element INDX=M+I*(N-l)=5+6*5=35. 056 in the array, M=5, N=6 (I would be =6 for a 6 by 6 array.), and If referencing element 022, INDX=2+6*I=8. 5-2 MATRIX MULTIPLY DIMENSION A(36), B(36), C(36) ACCEPT I, I FORMAT (I) DO 10 M=I, I DO 10 N=I, I INDX=M+I*(N-]) ACCEPT 2, A(INDX) FORMAT (E) CONTINUE TYPE 15 FORMAT (/,/,/) DO 20 M=I, I DO 20 N=I, I INDX=M+I*(N-1) ACCEPT 2, B(INDX) CUNDXFO 20; CONTINUE DO 30 M=I, I DO 30 N=I, I DO 30 K=I, I IC=N+I*(M—1) IA=K+I*(M-1) IB=N+I*(K-1) C(IC)=C(IC)+A(IA)*B(IB) 30; CONTINUE TYPE 15 DO 40 M=I , I TYPE 21 DO 40 N=I, I INDX=N+I*(M-]) TYPE 2, C(INDX) 40; CONTINUE FORMAT (/) TYPE I5 END Figure 5 Indexing Sfofemenfs CHAPTER 6 PROGRAM CONTROL In this chapter, the FORTRAN statements which have been described as isolated elements It is obvious that FORTRAN statements are discussed in their proper context are executed in the order in which they are written unless instructions are given to the contrary. -- in program sequences. Such instructions are provided by the program control statements, which allow the programmer to alter the sequence, repeat sections, suspend operations, or bring the program to a complete halt. PROGRAM TERMINATION A program arranged so that the last written statement is the final and only stopping place needs no special Most programs, terminating indication. The end statement automatically determines the final halt. however, contain loops and branches so that the last executed statement is often some- Frequently, there may be more than one stopping point. where in the middle of the written program. Such terminations are indicated by the statement: STOP This causes a final, complete halt; no further computation is possible; although the program may be completely restarted from the beginning. When a STOP is encountered during program execution at object time, the system signifies that a stop has occurred by outputting an exclamation point (1) to the Teletype or high speed punch, whichever is being used as the output device. The stop statement prevents further computation after it has been executed. There is a way, however, to suspend operation for a time and then restart the program manually. This procedure is frequently necessary when the operator must do such tasks as loading and unloading tapes or card decks in the middle of a program. This kind of temporary halt is provided by the following statement: PAUSE This brings the program to a halt, but the operator may restart it at any time by pressing the CONTINUE key on the computer console. E N D Statement END occurs alone on a line and indicates the physical end of the program to the FORTRAN compiler. statement. It must be followed by carriage return and line feed. Every program must contain an END BRANCHES AND LOOPS The GO TO Statement There are various ways in which program flow may be directed. As shown schematically in Figure 6, a program may be a straight—line sequence (l), or it may branch to an entirely different sequence (2), return to an earlier point (3), or skip to a later point (4). Us 34 —_| Figure 6 Schematic Representation of Program Branching All of these branches can be performed in several ways, the simplest of which is by using the statement: GO TO N where N is a statement number used in the program. The use of this statement is described in the fol- lowing example, which also illustrates the construction of a loop, the name given to program branches of the type shOWn in Figure 6, No. 3. Integer Summation In the following example, the sum of successive integers is accumulated by repeated addition. The main computation is provided by the three-instruction loop beginning with statement 2. The statements preceding this loop provide the starting conditions; this is called the initialization. The partial sum is set to zero, and the First integer is given the value of one. The loop then proceeds to add the integer value to the partial sum, increment the integer, and repeat the operation. SUM OF FIRST N INTEGERS BY ITERATION C; KSUM=O INUM=I 2; KSUM=INUM+KSUM INUM=INUM+I GO TO 2 Figure 7 Integer Summation Limits and Decisions - The IF Statement The program shown in the preceding example performs the required computation, but there is one flaw: the loop is endless. To get out of the loop, the user must know when to stop the iteration and what to do afterwards. The IF statement fulfills both requirements. It has the following form: IF (E)K,L,M where E is any variable name, arithmetic expression, or arithmetic statement, and K, L, and M are statement numbers. The statement is interpreted in this way: if the value of E is less than 0, GO TO statement K value of E is equal to 0, GO TO statement L value of E is greater than 0, GO TO statement M Thus, the IF statement makes the decision of when to stop by evaluating an expression, and also provides the program branch choices which depend on the results of the evaluation. C; SUM OF THE FIRST 50 INTEGERS KSUM=O INUM=I 2; KSUM=INUM+KSUM INUM=INUM+I IF 3; Figure 8 (INUM-50) 2,2,3 STOP Use of IF Statement in Integer Summation Problem 6-3 In this example, the initialization and main loop are the same as For the preceding example except that the GO TO statement of earlier program has been replaced by an IF statement. ment says: This state- If the value of the variable INUM is less than or equal to 50 (which is the same as saying that it the value of the expression INUM-50 is less than or equal to zero), go to statement 2 and continue the computation. IF the value is greater than 50, stop. A further improvement on the example above can be made if the Feature of substatements within an expression is incorporated (refer to pages 3-6 and 3-7). SUM OF THE FIRST 50 INTEGERS C; KSUM=0 INUM =50 2; KSUM=INUM+KSUM 3; STOP IF(INUM=INUM-I) 3,3,2 Figure 9 IF Statement with Substatement Feature In this example, the sum is formed by counting down, but the same results are achieved. The initialization is changed so that INUM starts with the value of 50 instead of O, and the statement INUM=INUM+I is no longer required. A loop may also be used to compute a series of values. to The Following example is a program generate terms in the Fibonacci series of integers, in which each succeeding member of the series is the sum of the two members preceding it: KN"KN-1+KN-2 C; FIBONACCI SERIES, IOO TERMS ; DIMENSION ; ; FIB(1)=1 FIB(2)=I ; K=3 5; 6; ; IO; FIB(I00) FIB(K): FIB(K-l)+FIB(K-2) K= K+I IF (K-tOO) 5,5,10 STOP Figure I0 Fibonacci Series In this program, the initialization includes a dimension statement which reserves space in storage, and two statements which provide the starting values necessary to generate the series. 6-4 Each time a term is computed, the subscript is indexed so that each succeeding term is stored in the next location in the table. As soon as the subscript reaches 100, the calculation stops. DO Loops Iterative procedures such as the loop in the example above are so common that a more con- cise way of presenting them is warranted. In this example, three statements are required to initialize the subscript, increment it, and test for termination. The following type of statement combines all these Functions: DO n I=Ki, K2, K3 Here, n is a statement number, I is a simple (non—subscripted) integer variable, and KT are K2, and K3 simple integer variables or integer constants which provide, in order, the initial value to which I set, the maximum value of I for which the loop will still be executed, and the amount by which I is incremented at each return to the beginning of the loop. sumed equal to one. ; ; ; ; ; 5; ; Figure II FIBONACCI SERIES, 100 TERMS DIMENSION FIB(100) FIB(i) =1 FIB(2) =1 DO 5 K=3, 100 FIB(K)=FIB(K-i)+FIB(K—2) CONTINUE STOP Fibonacci Series Calculation Programmed As a DO Loop In words, the DO statement says: encountered. If K3 is omitted from the statement, it is as- Statement n must be a CONTINUE statement. c; on , Do all statements through statement 5 for Perform the following test: If K+I is less than or equal to in the program by executing the first statement after the DO. next sequential statement following statement 5 is executed. DO K=3, when statement 5 is 100, set K=K+I and continue If the K+I is greater than I00, the In this example this is a STOP. loops are commonly used in computations with subscripted variables. it is usually necessary to perform loops within loops. In these cases, Such nesting of loops is permitted in FORTRAN. ; DO l0 [:1 ,20 ; X(I)=0 ; DO 5 J=2,40,2 X(1)=X(I)+(B(J)-Z(J))**2 ; CONTINUE 5; A(I)=X(I)**2+C(I) CONTINUE l0; Figure 12 Nested DO Loops In the previous example, sequential elements in the X array are formed by summing the square of the difference of every second element in the B and Z arrays. Then the A array is formed by sum- ming every element in a C array and the square of every element in the X array. The algebraic ex— pression For the loop is as Follows: 2 . Ai =Xi —Ci For I l, 2, 3,...20 where 40 X.=2 I (b.-z.) .22 l | I 2 Fori=2,4, 6,...40 A The following general rules about DO loops must be observed. a. DO loops may be nested, but they may not overlap. Nested loops may end on the same statement, but an inner loop may not extend beyond the last statement of an outer loop. schematically illustrates permitted and forbidden arrangements. 1 ‘,______1 '-——2 3 ' ”—2 C4 3 —— 5 6 [—7 b. 0 Figure 13 DO Loops Figure 13 lo. c. DC, the variable I is not initialized as specified Transferring into the range of a DO is allowed as long as: If the user transfers into the range of a in the DO statement. (l) Incrementing and testing start with the present value of I. (2) Control was originally transferred out of the DO other than by completing it. A DO loop must end on a CONTINUE statement. Those in a are permitted; in b are not permitted; loops 5, 6, and 7 end on the same statement. The arrangements loop 3 ends on a statement outside the range of loop l. Illegal DO Nesting DO 10 1:1, 20 DO 20 J=t ,ioo,2 SUM=(X(I)-Y(I))**2 ; CONTINUE 10; Z(J)=SUM+-A(J) 1 CONTINUE 20; rwug (4) U! Figure l4 Program Branching in D0 Loops Branches 2, 5, 6, and 7 are permitted; branches 1, 3, and 4 are not. The CONTINUE Statement Since the DO loop may contain alternate courses of action, programmers frequently wish to make the last executable statement of a loop, a test to determine which of the alternatives should be taken next. However, Rule 3 above forbids a DO loop to end on an IF or GO TO; so a special statement is provided which is not an executable statement itself, but provides a termination For such a DO loop. The statement is: CONTINUE DO loops must be terminated on a CONTINUE statement. Computed GO TO The GO TO statement described in the section on branches and loops is unconditional and provides no alternatives. The IF statement offers a maximum of three branch points. One way of providing a greater number of alternatives is by using the COMPUTED GO TO, which has the following form: GO TO (KI ,K2,K3,. . .Kn),J where the K's are statement numbers, and J is a simple integer variable, which takes on values of I, 2, 3, . . .n according to the results of some previous computation. For example, IVAR =I4*J/2+K GO TO (5, 7, 5, 7, 5, 7, causes a ment IO), IVAR branch to statement 5 when IVAR=I ,3, or 5; to statement 7 when IVAR=2,4, or 6; and to state- I0 when IVAR=7. When IVAR is less than one or greater than seven, the next sequential statement after the GO T0 is executed. 6-8 CHAPTER 7 INPUT AND OUTPUT AVAILABLE DEVICES So far, we have assumed that all information (programs, data, and subprograms) was in memory, without regard to how it got there. Programs, of course, are read in by a special loader, but the programmer is responsible for the input of data and the output of results by including these operations in his program. For any a. input/output procedure, several items must be specified: In which direction is the data going? read into memory; information going out is b. In FORTRAN terms, the data coming in is being being written on whatever medium is specified. Which device is being used? Information can be transferred between core and either of two different input/output devices; each I/O operation must specify which device is involved. Where in core memory is the data coming from or going to? c. its location in the computer storage must be specified. d. In what mode is the data represented? The amount of data and In addition to floating— and fixed—point modes for numeric data, there is the Hollerith mode for transferring alphanumeric or text information. e. What is the arrangement of the data? In FORTRAN terms, the format of incoming or outgoing data is specified. For every data transfer between core memory and an external quired to provide all of the information listed above. device, two statements are re— The first three items are specified by the input/ output statement and the last two items are determined by the FORMAT statement. PDP-5/8 FORTRAN provides for communication of data to and from a program in the following ways. a. ASCII Coded Data - (Appendix E) The Teletype can be used to transfer data to the program either via the keyboard on which the user types the data, or from previously punched paper tape read via the teletype reader. Data can be output from a program to the Teletype, producing a printed copy with or without the corresponding punched paper tape (depending on whether or not the punch is turned on). The high—speed reader and punch can also be used for data transfer via punched paper tape. No printed copy is made when output is to the high-speed punch. b. BINARY Coded Data DECtape can also be used for data transfer in which case the data is stored as a core image on tape in 128 word blocks of 12-bit binary words. Integers are read and written as single 12bit words, floating point numbers as three words. Alphanumeric information is transmitted as 8—bit ASCII coded characters right iustified in 12—bit words (one character per word). IN PUT/OUTPUT STATEME NTS The input/output statements control this transfer of information. 1/0 statements consist of three basic items of information: As illustrated in Figure 15, the device being accessed and the direction of transfer; the number of the FORMAT statement that controls the arrangement of data; and the list of names of the variables whose values are to be output or changed by new inputs. ACCEPT N,V(I), L V(I+l), V(I+2) List of variable names Statement number of FORMAT statement Device selection and direction of transfer Figure I5 Input/Output Statement Device Selection and Direction of Transfer ACCEPT and TYPE transfer information between the Teletype and the PDP-5/8. ACCEPT causes information to be accepted into core memory from either the Teletype paper- tape reader, the keyboard, or the photo—electric reader, depending on a switch option selected at run time. TYPE causes information to be transferred from core memory to the Teletype printer, or the printer and paper tape punch depending on whether the punch is activated or not, or to the high—speed punch depending on a switch option selected at run time. READ causes information to be read into core memory from DECtape. (See Chapter 8 for details.) WRITE causes information to be written on ;READ ;WRITE UNIT, UNIT, DECtape from core memory. BLOCK, BLOCK, FORMAT, FORMAT, LIST LIST where UNIT and BLOCK specify the DECtape unit to be used, and the position of information on tape respectively (UNIT and BLOCK can be either integer constants or simple integer variables). The balance of these statements is exactly analogous to the corresponding information in a TYPE statement. FORMAT specifies the format statement, and LIST specifies the variables to be written from, or read into core. Bit 0 of the SWITCH REGISTER must be set to I (up) when compiling or running a program containing READ and WRITE statements and 0 (down) otherwise. cause error diagnostics. (See Appendix G.) 7—2 Failure to properly set the switch will Statement Number of Format Statement Following the instruction that selects the device and direction of transfer is the statement number of the FORMAT statement that controls the arrangement of the information being transferred. Example: ACCEPT 10, A FORMAT (E) 10,- Every [/0 statement must have a reference to a FORMAT statement. List The Final item of specification in the I/O statement is the LIST of variables. This is a sequential list of the m of the variables and array elements whose values are to be transferred in There is no restriction on the number of names which may appear in the list of an the m transfer. [/0 statement as long as the total statement length does not exceed 128 characters. The modes of the variables named need not agree with the corresponding FORMAT statement, however, the modes speci— fied in the FORMAT statement take precedence. Example: TYPE 23, 23; A, J, KAL, BOB (where A=3.2 J=27 KAL=302 and BOB=7.58) FORMAT (I,E,I,E) The decimal portion of A will be dropped and the 3 typed as an integer; the value of J will be typed as a normalized number; KAL will be typed as an integer; and BOB as a normalized number. The output will look like the following: + 3 +0 2700000E+02 . + 302 +0 7580000510] . Array names included in 1/0 lists must be subscripted in one of the following forms: v +c' AV or _ c Ac Av' where A is the array name, v is a simple integer variable and c is an integer constant. ; 10; TYPE 10,A,I,B,C(I+K),N(J+L) FORMAT (E,I,E,/) ; A=A+(C(J)**é—C(N)**2) ; TYPE 10, A,J,B,C(N) Figure l6 A List Example 7—3 IF the list contains more names than there are elements in the FORMAT statement, when the elements are exhausted the FORMAT statement is reinitialized, and the First element in the FORMAT statement corresponds to the next name in the list. For instance in the preceding example when the value oF the variable B is typed in the E For- mat, the control character slash (/) causes a carriage-return line-Feed to occur. statement is Then the FORMAT reinitialized, and the array element C(I+K) is typed in the E Format and the array element N(J+L) in the I Format. Correspondingly, the list does not have to exhaust the elements of a FORMAT statement. IF there are Fewer names in the list than there are elements in the FORMAT statement, the program com— pletes the I/O operation and proceeds to the next sequential FORTRAN statement. ment is IF this next state- another I/O statement that reFerences a previously unexhausted FORMAT statement, that FORMAT statement is reinitialized. In other words, FORMAT statements are reinitialized when they are First reFerenced or when all oF their elements are exhausted. FORMAT SPECIFICATIONS STATEME NT As already mentioned in the previous description oF statement names input/output statements, the FORMAT controls the arrangement and mode oF the inFormation being transFerred. The values oF the appearing in the list oF the [/0 statement are transFerred in the mode speciFied by the corre- sponding element in the FORMAT statement. These controlling elements consist oF the characters E, I, slash (/) and quote ("). The set oF elements must be enclosed in parentheses and separated by commas. Example: FORMAT (E,I,/, "HOLLERITH") Control Elements E and I The control elements E and I are used For deFining the mode oF the data being transFerred. When a variable is transFerred in the E Format, it is stored or output in Floating point. IF the variable is transFerred in the I Format, it is stored or output in Fixed point. input or output can Mode conversion on be accomplished because the elements in the FORMAT statement define the mode oF the data and the mode of the variable is overriden. Example: ; 10; TYPE TO, A FORMAT (I) The variable A is typed as an integer and the Fractional part oF A is truncated. iF A has a value oF l4.96, only the integer part, 14, would be typed. less than one, zero would be typed. For instance, IF A has an absolute value oF Input Input data words consist of a sign, the decimal value, an exponent value iF the data is floating point, and a Field terminating character such as space. Any character that is not a number, decimal point, sign, or E can be used to terminate a Field except the character rubout. When typing data, any number of spaces or other non-numeric characters can be typed before the Sign or decimal value is typed to make the data sheet more readable. It a mistake is made when typing data words, the last word or partial word can be erased From core memory by typing the character rubout. These input words can be transferred into core memory From either the Teletype paper-tape reader, the keyboard, the photo-electric reader or DECtape. floating-point modes For integers or decimal Fractions. They can be entered in either Fixed- or The mode in which they will be stored is con- trolled by the corresponding element in the FORMAT statement. Integer Values An - Fixed Point — FORMAT (I) integer data Field consists ot a sign (minus or space) and up to Four decimal characters. Some examples of integer values are as Follows: Decimal Fraction Values - A Floating-point acters, an Typed Numbers Values Accepted —2001 -200l —4O -OO4O -0040 -0040 I6 0016 -2047 -2047 Floating Point - FORMAT (E) input word consists oF a sign*, the data value of up to seven decimal char- E if an exponent is to be included, the sign oF an exponent, and the exponent which is the power of ten that the data word is multiplied by. Example: dddd.dddEnn The d's represent characters in the data word and n represents the power oF ten of the ex-- ponent. Either the sign, the decimal point, or the entire exponent part can be omitted. IF the sign is leFt out, the number is assumed to be positive; iF the decimal point is leFt out, it is assumed to appear after the rightmost decimal character. It the exponent is omitted, the power oF ten is taken as zero. *Plus sign can be represented by a plus or space character. Minus is represented by a minus character. IF a sign character is absent From the data word, the data is stored as positive. 7—5 Examples of floating—point values are as follows: Values Accepted Typed Numbers l02 O.i6x 102 O.l6X102 0. l6 X l6. .iéEOZ l600.E-02 Correcting Typing Errors If a mistake is made when typing data words into a FORTRAN program, the mistake can be corrected by canceling or erasing the data word before typing the terminating character and then re- typing the data word that is in error. To cancel or erase a word, type a rubout character. When this character is detected during the acceptance of a data word and before the ter— mination character has been transmitted, the data word appearing before the character rubout is erased from memory. Operations on the names in the list do not advance to the next sequential name until a complete data word and the terminating character have been received. Output Data Word Output - Floating and Fixed Modes - FORMAT (E) and FORMAT (I) Integer values are always printed as the sign and a maximum of four characters with spaces replacing leading zeros. Floating-point values are printed in a floating-point format which consists of sign, leading zero, decimal point, seven decimal characters, the character E, the sign of the ex— ponent (minus or plus), and an exponent value of two characters. Examples: Integer Values Output Format -iO43 —lO43 -0016 — +0016 + l6 16 Floating-point values are printed as per example SO dddddddsxxxx . where S is the sign, minus sign, d is the seven decimal 5 or space digits of the data word is the sign of the exponent value xxxx is the exponent value Decimal Value Output Format -O 8388608E+07 -8 , 388 , 608 O . . +. 0000001 192092 0. l l92092E-06 OTHER FORMAT CONTROL ELEMENTS In most cases when data is to be presented it must be labeled and arranged properly on a data sheet. In order that this can be accomplished with FORTRAN, a provision has been made so that text information and spacing can be typed out along with the data words. These features are provided by the special FORMAT control elements quote (") and slash (/). Quote (") (Hollerith Output) When text information is contained as part of a FORMAT and this information is enclosed in quotes, it is output to the specified device as it appears in the statement. This output occurs when a TYPE or WRITE statement references a FORMAT statement containing text and all other elements of that FORMAT statement previous to the text have been used. TYPE 10 TO; HOLLERITH",/) FORMAT (/, ”THIS IS TYPE 100, AMIN, AMAX TOO; FORMAT (/, "MINIMUM=",E,/, ”MAXIMUM=”,E,/) TYPE 210 210; FORMAT (/,/," " DISTRIBUTION",/,/' FREQUENCY",/) CUMULATIVE INCREMENTS DO 220 K=l ,100 TYPE 250, 200; 250; K,VALU(L), VALU(K+I), COUNT(K) CONTINUE FORMAT (1," ",,"E Figure 17 All pendix D). ”,,"E ",E,/) Examples of Quote and Slash legal Teletype characters can be contained within quotes and are output as text (Ap— If a statement continues on another line the Hollerith field must be ended before typing the continuation character ('); it may be re-opened on the next line. Before text is output, the elements of the FORMAT statement that appear in front of the Hollerith information must have been used. Example: 1 TYPE 10; 10, VAR,SD FORMAT (E,E,E, ”VARIANCE AND STANDARD DEVIATION",/) In this example, the text is not typed because one of the E elements was not used. If a FORMAT statement containing a Hollerith field is referenced by an ACCEPT statement, the original text will be replaced character by character until the closing quote mark is encountered. All ASCII characters except line-feed will be read. numeric data printed in either E or I format, Because of the variable number of spaces following precautions must be taken when text and data are inter— mixed in a punched tape which is to be read by a FORTRAN program. The technique has been used successfully, however. If a FORMAT statement containing a Hollerith field is referenced by a READ statement, the original text will be replaced character by character with 12-bit words from the DECtape. Because the E and I format for DECtape I/O are fixed lengths, there is essentially no difficulty here. it is possible to read text from Note that DECtape with an I format in order to manipulate the numeric equivalent of the ASCII character. Slash (/) The slash character is used for typing a carriage return and line feed for advancing the paper of the tape teleprinter. A carriage-return line-feed will be typed for every slash that appears in the statement. Example: ; 10; TYPE TO, A, B FORMAT (/,/,/,E,/,/,E,/,/) Three carriage-return line-feeds will be typed before the value of A; then two carriage-return linefeeds will be typed before and after the value of B is typed. The input subroutine of the obiect time system ignores all non-numeric characters except as data word delimiters so that input can be labeled and spaced in intermixing the appropriate text and carriage-return line-feeds with the data. 7-8 CHAPTER 8 FORTRAN WITH DECTAPE OPTION PDP-8 FORTRAN includes provisions for storage of data on programs requiring DECtape. In this way FORTRAN large amounts of accessible data may be readily written to run on a 4K PDP-5 or PDP-8. The standard library version of the FORTRAN Compiler is written such that the type of DEC- tape hardware to be used is irrelevant. is written to handle the TCOI The standard library version of the FORTRAN Operating System DECtape Control with TU55 Tape Transports since these are more common. There is, however, an overlay tape to convert the OP SYS to do the same operations using the 552 Control with 555 DECtape Transports. If this overlay is required the user should so specify when making requests to the library. FORTRAN Compiler with DECtape I/O Option When the FORTRAN Compiler is read into core, it is equipped with a switch option govern- ing the compilation of DECtape I/O statements (READ and WRITE). program containing If the user wishes to compile a DECtape I/O statements, he must set Switch Register bit 0 to I (up) before starting any compilation. The Compiler is designed so that the space occupied by the processing routines for this option becomes part of the input statement buffer if SR bit 0 is set to 0. This means that the DECtape I/O processing routines are destroyed if any compilation is done with bit 0 set to 0 and the Compiler must be reloaded into core to regain the option. Any program containing DECtape I/O statements must limit the length of the source statements to I00 characters per statement. Use of Symbolprint with FORTRAN Symbolprint destroys a portion of the DECtape Compiler in core. loaded if it is to be used to accept a symbolic program containing FORTRAN Operating System with The compiler must be re- DECtape I/O statements. DECtape I/O Option When the FORTRAN Operating System is read into core, it is equipped with a switch option governing the execution of DECtape I/O statements. If the user wishes to run a program containing such statements he must set Switch Register bit 0 to 1 before running his program. There is a further condition which must be observed, since considerable amount of additional processing routines. DECtape [/0 requires a Like the Compiler, the OP SYS destroys its DECtape handling routines if it is used with SR bit 0 set to 0, thus gaining extra space. This requires, however, that the OP SYS must be reloaded into core to regain the option. DECtape FORTRAN Statements and Operation When using DECtape, the FORTRAN Operating System contains a buffer area which is de- fined as a page of memory reserved to handle transfers to and from a block of DECtape (12810 data words). The DECtape routines transfer one full block from tape to one page of core (and vice versa), therefore, even if the block contains only one data word, the whole block will be read into the OP SYS buffer, overlaying whatever had been there. To store variables or arrays of data on DECtape requires two steps: From the locations assigned by the OP SYS to the variables or allotted to the arrays by a. DIMENSION statement, the programmer must collect the data and put it in the OP SYS buffer. This is done with pseudo WRITE statements (in a DO loop in the case of arrays). (See below.) a b. He must write the buffer onto a block of DECtape. This is done by a physical WRITE (See below.) The programmer must be aware of how much data he has in the buffer and write it out on DECtape, before he overflows the buffer. Overflow will cause an error diagnostic. statement. To retrieve data from a. DECtape is also a multiple operation. The programmer is responsible for remembering which block contains the data he wishes to retrieve. b. He must read this block into the OP SYS buffer using a physical READ. c. He must remember in which order he stored the variables or arrays and reference them here (See below.) in the same order. d. He must disperse the data from the buffer to the locations assigned by the OP SYS or allotted by a DIMENSION statement. This is done by pseudo READ (in a DO loop for arrays). (See below.) NOTE Data which has been brought from tape into the buffer is not yet available for use within the program. It must be dispersed first. Pseudo WRITE and pseudo READ statements operate between the user program and the buffer only. They are used to collect into the buffer data from within the user program and to disperse into the user program data in the buffer. They have no effect on the physical DECtape. 8-2 The user specifies pseudo READ or WRITE by specifying UNIT 0 and BLOCK 0 in the READ or WRITE statement. Specifying any unit other than 0 will indicate that the user wishes to read from DECtape into the buffer or write the buffer out on tape. Pseudo READ and WRITE are of the form; READ O, 0, FORMAT, LIST WRITE 0,0, FORMAT, LIST Physical READ and physical WRITE statements operate between the buffer of the OP SYS and the DECtape. They cause the actual reading or writing of tape. The user specifies physical READ or WRITE by specifying 0 UNIT number from I-7 and the number of the actual block on which the data has been stored or is to be stored. They are of the form; READ UNIT, BLOCK, FORMAT, LIST BLOCK, FORMAT, LIST WRITE UNIT, It is not necessary to specify a list on a physical READ or WRITE but it is advisable, since it does harm and is an aid to remembering which variables in which order are on which block. Two examples Follow which demonstrate the storage and retrieval of data. f DIMENSION IDAT (128) \ no,- FORMAT (1) Part I J has been previously detinedS 128 DO IOO I=I ,J 0, IIO, IDAT (I) CONTINUE 100; j k WRITE 0, Part 2 WRITE MU, This DO loop will WRITE J number of elements of IDAT into the butter This statement will then store data MBLK, IIO From buffer to tape IDAT DEC BUFFER ‘0 0900 ~ ~ ‘x \><° 50‘“ 1 V0“ \e TAPE to‘“ ............. ............. MUNT=TAPE UNIT TO BE SELECTED MBLK=BLOCK TO BE WRITTEN ON IBLK=INITIAL BLOCK TO BE SEARCHED FOR (TO REWIND TAPE) VALUES FOR J AND K AS DETERMINED BY USER MUST BE LESS THAN 200 no DIMENSION IBFI (200), IBF2 (200) 90;FORMAT (I) I99; ACCEPT 90, J,K, MUNT, MBLK, IBLK DO IO 1:] , J ACCEPT 90, IBFI (I) IO;CONTINUE C; C; C; C; ::::::::::::: DATA HAS BEEN ACCEPTED NOW WE READ BLOCK '0' THIS INITIALIZES AND REWINDS THE TAPE A GOOD IDEA TO DO THIS BUT NOT ESSENTIAL c., READ MUNT, ............. ............. IBLK, 90 C; C; C; C; C; C; ::::::::::::: TIME TO TAKE ACCEPTED DATA AND WRITE IT INTO THE BUFFER, NOT ONTO THE ACTUAL TAPE. SEE PART ONE OF DIAGRAM. BUFFER IS WRITTEN BY SELECTING UNIT '0' DO LOOP NEEDED SINCE DATA IS IN AN ARRAY ::::::::::::: DO 31 I=I ,J WRITE O, 0, 90, IBFI (I) 3I;CONTINUE C; C; C; C; C; C; C; C; ::::::::::::: TAPE IS NOW PHYSICALLY WRITTEN BY SELECTING A LOGICAL UNIT, OTHER THAN ZERO. ::::::::::::: READ BUFFER AND STORE IT IN ANOTHER ARRAY DO LOOP NEEDED BECAUSE OF ARRAY ::::::::::::: DO 32 I=I,K IBF2(I) READ 0, 0, 90, 32; CONTINUE . ************* I on on ; ALL I/O DONE HALT. I I SEE PART TWO OF DIAGRAM. ::::::::::::: ***~k-k*****-k** DO 13 I=],K TYPE 91,1BF2 (I) 91;FORMAT (/,I) 13;CONTINUE PAUSE GO TO 199 END 8—5 CHAPTER 9 PDP-5/8 FORTRAN SYMBOLPRINT FORTRAN Symbolprint is a useful aid in finding where a FORTRAN program is stored in interpretive memory, the exact memory locations assigned to each FORTRAN variable, and the amount and location of interpretive core memory that is not used by a FORTRAN program. Symbolprint loads over the FORTRAN Compiler and starts at address 600. The Following is a typical example of the typeout. List of Variable Names Assigned Location HW 7546 TB 7543 G 7540 TF 7535 MC 7534 DSR 753i Cl 7526 C2 7515 C3 7504 C4 7470 6312 724] Note that a single word only has been assigned for the fixed point variable MC. The last two octal constants typed indicate respectively the highest address used by the program in interpretive memory and the lowest address used for data. Therefore the area of core be- tWeen these two addresses is available. In the example there are 724T -6312 -1 =726 octal locations free. A machine language subroutine may occupy this available space. statement to Use the FORTRAN PAUSE link the FORTRAN program to the subroutine. If PAUSE is followed by a number (decimal), FORTRAN compiles (in effect) JMS to that address. For example: ;PAUSE 3328 effects JMS 6400. Location 6400 should contain coding such as the following: SUBR, o JMP I SUBR constituting the desired machine language program. 9—2 APPENDIX A OPERATING PROCEDURES FOR RIM AND BIN PAPER TAPE LOADERS READ-IN-MODE LOADER (RIM) l. The RIM Loader is a minimum-length, basic paper tape loader for the PDP-8. It is stored in memory by way of the CONTROL console switches. Once stored, it is considered initially permanent occupant of locations 7756 through 7777 (absolute octal addresses) and care should be taken to keep it from being destroyed. to be a 2. A paper tape to be read in by the RIM Loader must be in RIM format: Tape Channel G) 7654S321 0 0 0 0 CD<DOC>O<DO—I .—a 3. I AI 0 A3 0 XI 0 X3 I A3 0 A3 0 XI 0 X3 . . . . . . . O O 0 Leader/Trailer code A2 Absolute address to A4 contain next 4 digits X2 Contents of previous X4 4 digit address A4 A4 . X2 . X4 Address Contents (ETC.) 0 0 0 0 . (ETC .) Lead/Trailer code 0 0 The complete PDP-8 RIM Loader for the ASR33 (SA 7756) is as Follows: Abs Addr Octal . . Symbolic Contents /clear AC and flag /skip if flag=l 7756, 7757, 6032 603] KSF 7760 5357 JMP .-I 7761 6036 KRB 7762, 7763, 7764, 7765, 7766, 7106 CLL RTL 7006 RTL /ch 8 in ACO 7510 SPA /checking For leader 5357 JMP BEG +l 7006 RTL /found leader /OK, ch7 in link 7767, 7770, 777], 6031 KSF 5367 JMP .-l 6034 KRS /read, do not clear 7772, 7773, 7420 SNL 3776 DCA I TEMP /checking For address /store contents BEG, KCC /looking For char /read buffer Abs Symbolic Contents . 7774, 7775, 3376 7776, 7777, 0 4. as Octal . Addr DCA TEMP 5356 JMP BEG TEMP, 5301 /store address /next word /temp storage /iump to start of bin loader 0 0 Placing the RIM Loader in memory by way of the console switch register is accomplished follows: 5. Q a Set 7756 in the switch register (SR) 0— Press LOAD ADDRESS . 0 Set the First instruction in the SR (6032) Q. Press DE POS IT e. Set the next instruction in the SR f. Press DEPOSIT 9. Repeat steps e and f until all 16 instructions have been deposited. To load a tape in RIM format, place the tape in the reader, set the SR to 7756, press LOAD ADDRESS, press START, and start reader. 6. The complete PDP-8 RIM Loader for the high-speed reader 750 (SA Abs Oc_ral . Addr . 7755) is as follows: Symbolic Contents RFC /clear flag and fetch char. into 601 1 RSF /skip when flag=1 7760 5357 JMP .-I 776 1 60 I 6 RRB RFC /read buffer into AC, get next 7762 7106 CLL RTL 7763 7006 RTL 7764 7510 SPA /rotate channel 8 into /AC bit 0 /is it leader 7765 5374 JMP TEMP—2 /yes clear AC 7766 7006 RTL /NO rotate channel 7 to LINK 7767 6011 RSF 7770 5367 JMP .-I 7771 6016 RRB RFC 7772 7420 SNL 7773 3776 DCA I TEMP 7774 3376 DCA TEMP 7775 5357 JMP BEG +1 7776 0000 7777 5301 7756 6014 7757 BECL buffer char. into buffer TEMP, 0 0 /link set=origin /store data /store address /next word /temporary storage /JMP to start of BIN Loader BINARY LOADER (BIN) l. The BIN Loader is used to read in the machine language tapes. length oF a comparable RIM Formatted tape. is about one halF the It can, A binary-Formatted tape therefore, be read in about twice as Fast as 0 RIM tape and is, For this reason, the more desirable format to use with the IQ cps ASR33 Reader. 2. To load a tape in BIN Format, place the tape in the reader, set the SR to 7777; press LOAD ADDRESS, press START, and start reader. 3. AFter a BIN has been read in, one oF the two following conditions exist: a. No checksum error: halt with AC=0. Checksum error: halt with AC (computer checksum) (tape checksum). IF a checksum error exists, a character was misread From the binary tape or is mispunched on the b. - The operator should reload the binary tape; and iF the same checksum error appears in the AC indicator aFter readin, the binary tape was mispunched and a new copy tape. should be obtained. IF a diFFerent checksum error appears aFter readin, the appropriate maintenance procedure should be Followed. APPENDIX B PREPARATION OF SYMBOLIC (SOURCE) TAPE I. use Symbolic tape preparation using Symbolic Tape Editor. (It is to the user's benefit to the Editor to put his source program on tape since using the Editor minimizes the chance of ex- traneous characters getting on the tape and also Facilitates deletion and correction of statements). a. Load Symbolic Tape Editor using Binary Loader. b. Start Editor at I76 (Load Address, c. Type Ag and type the symbolic source program. d. Hold the CTRL key and press the FORM key; the bell will sound. e. Type PD), followed by FA) when punching stops. Start). NOTE For complete explanation of Editor, see Symbolic Tape Editor Manual. 2. Symbol tape preparation off-line using Teletype only. a. Turn power on in computer (key on left in PDP-8, switch on right in PDP-5). b. Turn Teletype LINE-OFF-LOCAL knob to LOCAL to disconnect Teletype from computer. 3. c. Press PUNCH ON button on the Teletype. d. Generate leader.* e. Type the source program. f. Generate trailer.* Manual symbolic tape editing using the ASR33. a. An incorrect character might be typed while preparing the symbolic tape: (the error is detected N characters after typing the incorrect character) press the PUNCH B.SP. button N+l times, press rubout N+l times, and continue. b. Characters, words, or statements can be inserted or deleted after the entire symbolic tape has been prepared. Use the following procedures to accomplish such changes. Duplicate the tape up to the point at which it is desired to make placing the tape in the reader, starting the with READER switch using the printout as a the reader the and reader, stopping Continue guide). Next type the insertion. by pressing the READER switch to start and duplicate the remainder of the tape. (I) an Insertions - insertion (by turning the punch on, (2) Deletions Duplicate the tape up to the point at which it is desired to make a deletion (see Insertions). Next, turn the punch off; start the reader; and using the printout of the information to be deleted as a guide, stop the reader. Continue by turning the punch on and starting the reader to duplicate the remainder of the tape. - *To generate leader/trailer (200 code), hold the CTRL and SHIFT keys with the left hand, depress the Release in reverse order or a P will be punched on the REPT key and then the P with the right hand. tape. APPENDIX C FORTRAN OPERATING PROCEDURES COMPILER 1. Load the Compiler with the Binary Loader (see Appendix A). 2. Put the starting address of the Compiler (0200 octal) into the switch register and press LOAD ADDRESS. reader, out See I/O Control. 3. Set I/O switches. 4. Place the source language tape in the selected reader and turn' on the reader and punch. 5. Press START. 6. At the end of compilation, the computer will halt with the run light off. 7. To compile additional programs, turn the reader and (Conditional) place the source language tape in the appropriate I/O selections cannot be changed with- punch on, and press CONTINUE. reloading compiler. SYMBOLPRINT Symbolprint is run immediately after compiling a program and before compiling another or loading the Operating System. (It cannot be run if- the Operating System has been loaded into core.) Use of Symbolprint destroys the portion of the Compiler which processes WRITE statements. DECtape READ and The Compiler must therefore be reloaded if it is to compile a source program con- taining such statements. 1. Load Symbolprint with the Binary Loader. 2. Set 0600 in the switch register. 3. Press LOAD ADDRESS and START, see Chapter 8. OPERATING SYSTEM (OBJECT TIME SYSTEM) l . To load a compiled program: 0. Load the FORTRAN Operating System using the Binary Loader. If using 552 DEC- tape, load the 552 overlay tape using the Binary Loader. b. Place the Compiler output (interpretive code object tape) in the Teletype or photoTurn on the reader, making sure ASR33 is ON LINE. electric reader. c. Load the SWITCH REGISTER with 0200, and press LOAD ADDRESS. d. Set switch register bit 1 to read in compiled tape from photo-electric reader or Teletype (as shown below). e. Press START. The Operating System reads the compiler output tape. The Operating System halts at the end of loading. The loading is correct if the checksum difference which appears in the AC equals 0. f. 9. 2. Turn off the reader and remove the compiler output tape from it. To execute a program after loading a. b. Set SWITCH REGISTER bits 0, I, and 2 (as shown below). If input is to be from paper tape, put the data tape in the appropriate reader and If output is to be punched, turn punch on. turn the reader on. c. Press CONTINUE. NOTE I. Once loaded, a program can be executed any number of times. The Operating System need not be reloaded to run than one program in succession. To do so start at b step of Section I. 2. more 3. To Re—execute a Loaded Program a. Set the SWITCH REGISTER to 020i; press the LOAD ADDRESS key. b. Set the SWITCH REGISTER for the 1/0 (as shown below). c. Press START. The FORTRAN Operating System checks each of its internal stacks after the execution of each interpretive instruction to insure that there is neither stack overflow nor stack underflow. If a FORTRAN program has been debugged and is known to operate correctly, this test may be NOPed by changing C(0404) to 7000 (NOP). This will speed up the execution of the program by a factor of about 2. I/O CONTROL The selection of I/O devices for both COMPILER and OP SYS is controlled by setting the switches as shown below: .91 Switch Meaning Number Posutlon 0 0 The program contains only paper tape I/O statements. I The program contains 0 Compiler: I __ OP SYS: DECtape I/O statements. Use the Teletype reader for input of source tape. Use the Teletype reader for loading the object program and the keyboard for ACCEPT statements. C-2 Bit Switch Number Position 2 m 1 Use the high-speed reader. O Compiler: Use the Teletype printer/punch For compiler output (interpretive code) tape and error diagnostics. OP SYS: 1 Use the Teletype printer/punch for TYPE statements. Use the high-speed punch (error diagnostics still come on Teletype). APPENDIX D FORMAT OF COMPILER OUTPUT INTERPRETIVE CO DE 200 codes (leader, ignored by loader). Data blocks, each as Follows: Cl. Origin (2 Frames, First has bit 7 punched) b. Data words (2 Frames/word) Forward referencing table — First Frame has bits 7 and 8 (only) punched. Checksum a. First has bit 6, 7, and 8 (only) punched b. Next two Frames are Checksum 200 codes (trailer, ignored by loader which stops aFter Checksum). Error comments, iF any, in ASCII. APPENDIX E ASR33 8-BIT CHARACTER SET M 8-Bit Code M (in Octal) 8-Bit Code (in Octal) 301 1 241 B 302 " 242 c 303 # D 304 $ E 305 % F 306 8. G 307 ' H 310 I 311 ( ) J 312 * K 313 + L 314 M 315 N 316 O 317 / 257 P 320 : 272 Q 321 ; 273 R < 274 S 322 323 = 275 T 324 > U ? @ 300 w 325 326 327 276 277 330 Y 331 E / j 333 X Z 332 1 336 0 260 * 337 1 261 262 Leader/Trai Ier Carriage Return Space 215 Rubout 377* 6 263 264 265 266 Blank 000* 7 267 8 270 9 271 A V 2 3 4 5 , - . Line Feed 243 244 245 246 247 250 251 252 253 254 255 256 334 335 200* 212* 240 *Ignored by the operating system E-1 APPENDIX F PDP-8 FORTRAN SOURCE PROGRAM RESTRICTIONS The Following limits are imposed upon all FORTRAN source programs for the PDP—8: Not more than 896 1. data cells. This includes all dimensioned variables, user-defined variables, constants, and all constants generated by the usage of a DO loop. Not more than 20 undefined forward references to unique statement numbers per program. 2. An undefined forward reference is a reference to any statement label that has not previously occurred Multiple references to the same undefined statement numbers are considered as one in the program. reference. 3. Not more than 64 different variable names per program. 4. Not more than l28 characters per input statement. (When using the DECtape Compiler, the input statement size is reduced to 100 characters.) Not more than 40 numbered statements per program. 5. PDP-8 COMPILER AND OPERATING SYSTEM CORE MAP The Compiler occupies the following core locations: 3 - 7200 — Compiler itself plus tables 7600 Compiler tables (undefined forward reference 7600 table, etc.) The Operating System occupies locations: 0 0 Locations 5200 cations 6000 - - - - 5200 Operating System for paper tape I/O 6000 Operating System for DECtape [/0 7576 are available for the user's program when using paper tape input/output or lo- 7576 when using DECtape. NOTE The 89610 data word restriction applies. F-i APPENDIX G DIAGNOSTICS Diagnostic procedures are provided in the compiler to assist the programmer in program compilation. When the compiler detects errors in a FORTRAN source program, it prints out error mes- sages on the on-line tape-teleprinter. These messages indicate the source of the error and direct the programmer's efforts to correct the error. To speed up the compiler process, the compiler prints out only an error code. mer The program- then looks up the error message corresponding to the code in Table A-l and takes the appropriate corrective measures . DYNAMIC ERROR CORRECTION A user may choose to compile in either of two modes: rection mode. the normal mode or the dynamic cor- The latter allows the user to correct a statement, which the compiler has determined contains a source-language error, by reentering the offending line via the tape teleprinter without having to physically correct the symbolic tape and recompile. This Feature is not implemented in the high-speed reader version of the compiler since the higher speed of the device makes recompilation easy. To choose the dynamic correction mode: I. Load the starting address of the compiler (0200) in the console switches and press LOAD ADDRESS. 2. Set SR bit II to I, press START (can only be used with low-speed paper tape I/O). IF an error is detected, the diagnostic prints out in the normal Fashion and the computer halts. To correct the statement: I. Turn READER switch to FREE. 2. With the READER switch still in the FREE position, press CONTINUE. 3. Type the new line in its entirety,* obeying all rules For the source language and ter- minating the statement with a carriage-return line-Feed. 4. Turn reader on and compilation will continue. To leave the dynamic correction mode, restart the compiler in the normal Fashion. *If the statement was numbered, do not reenter the statement number unless it was in error. 6-] COMPILE TIME DIAG NOSTICS Format of Diagnostics XX XXXX XX l—The identifying condition code The number of statements since the appearance of a numbered statement (octal value). The statement number of the last numbered statement Example: A=I (J+i) 10; B=A*(B+SINF(THTA)) During compilation of the above statements the following error code would be printed, l0 ll ll indicating that a statement which occurs eleven statements octal (eight decimal) after the appearance of statement 10 is in error. The message corresponding to code ll shows that the number of left and right parentheses in the statement is not equal. The statement is examined and corrected; then com— pilation is resumed. Table A—l DEZZZC:HC Conditions 00 Fixed— and floating-point modes have been mixed in an expression. Oi Two operators appear adjacent to each other (i.e. , a variable has been left out of an expression) e.g. , A=C + 02 Compiler error - * D. Reload Compiler and repeat compilation process. Contact Software Quality Control, PDP-8 Division if this reoccurs. 03 A comma has been used illegally in an arithmetic statement. 04 Too many operators appear in a single statement. 05 A function argument is in fixed mode, e.g. , SINF(INC). Table A-l (Cont) Diagnostic . 06 . Condltlons Code A variable subscript is in floating-point mode. dicate that an operator is missing, e.g. , O7 This could also in- A+B(C+l .) for A=B*(C+l .). More than 64 (decimal) different variable names have been used in the program. requirements have overlapped. 10 Program too large ll There is an unequal number of right and left parentheses in a state- - program and data ment. 12 l3 An illegal character was detected and ignored. The compiler is unable to recognize or process this statement due to some 14 15 error in its format. Two statements with the same statement number. A subscripted variable is defined before the appearance of a dimen- subscripted variable does not appear in a diIt might also indicate that an operator is missing in a fixed-mode expression, e.g. A=I(J-K) for A:I*(J-K). sion statement, or a mension statement. , 16 long; more than 128 characters have been counted including spaces except in format statements where all legal TTY Statement too not characters are counted. 17 A floating—point operand should have been fixed—point, e.g. , DO TO 1:1, 7.3. 20 A statement number that has been referenced does not appear in the program. See the paragraph on the next page. 2] There are more than 40 numbered statements in the source program. 22 A statement cannot be compiled because it has too many incomplete operations, e.g 23 Too many are 24 . , C=A+(C+(D+(E+. . . . (more than 20) statements have been referenced before they defined. Attempt to compile a READ or WRITE program statement after starting program without switch 0 set. If a statement number is referenced but does not appear in the source program, the diagnostic code will be printed as follows: xxxx 77 20 where the number usually reserved for the last numbered statement (xxxx) is replaced by the missing statement number. e.g., GO TO TOO The diagnostic would appear as follows where statement l00 is never defined. 100 77 20 OPERATING SYSTEM DIAGNOSTICS Not all errors are detected by the compiler. Some errors can only be detected by the object time system. obiect system. Also, there are some conditions which indicate errors on the part of the compiler and/or When such an error occurs during running of a program, the computer types out an error message containing the word "TILT'I and an error number. The computer then halts. If the CONTINUE toggle is pressed, the computer takes the action listed in the following table. Table A-2 E rr o r . Possnble Cause Number ll Attempt to divide by zero . Action Taken Quotient set to plus or minus largest number representable in computer; then continue executing instructions. 12 Floating point exponent on input greater than plus or minus System executes next instruction. 2047 13 Illegal operation code (either System executes next instruction. compiler error, or data stored over program, or transfer to data section) 14 Transfer to core location zero or No recovery possible. one 15 Non-format statement used for a System executes next instruction. format 16 Illegal format statement consti- System examines next constituent. tuent l7 Attempt to fix large floating point number 20 Attempt to take square root of a System takes square root of absolute value. negative number 2] Attempt to raise a negative number to a power 22 Attempt to find the logarithm of zero or a negative number System raises absolute value to the power specified. System attempts to find logarithm of absolute value. Note that log (absolute value (0)) still gives an error halt. Table A-2 (Cont) Error 31 Action Taken Possible Cause Number The operating system halts with the called unit in bits 0-2 of the AC (0-3 is using 552/ Select error Recovery is. possible by correcting the logical unit and pressing continue. 555). 32 The program halts with the error status in the Physical Tape Error AC. (The configuration of bits is dependent upon the tape control being used.) 33 DECtape buffer exceeded 34 DECtape control switch set incorrectly 76 One of the stacks used by the system has underflowed. more (i.e. No rec0very possible. , program. data has been requested than was placed on the stack) 77 One of the stacks has overflowed (i.e. , more data placed on it than there is storage in the ma- chine.) Same as Error 76 Try recompiling the INDEX Arithmetic 7-2 Selection Algebraic 3-I Diagnostics (see Errors) Constants 3-2 Compiler G-2, -3 3-I Expressions Functions Operating System 6-4, -5 3-4 DIMENSION Statement Integers 3-2 Statements DO statement 3-4, -5 6-5, -6, -7 Illegal Nesting Variables 3-2 Arrays 5-2 Array Names Operators 3-3, 3—6, —7 5-] 6-7 Loops 6—5, -6 Nesting Loops 6-6 5-I Subscripted 5—l E Format 7-4, -5, -6 Branches and Loops 6-2, 6-8 Editor, Symbolic Tape B—l Character Set 2-4, E-I END Statement COMMENTS 2-2, -3 Errors 6-I (see Diagnostics) Corrections 7-6, G-I Compiler Diagnostics 6—I Messages G-I Operating Procedures C-I Expressions, Arithmetic 3-I Output D-I Field 8-I with DECtape Constants Identification Fixed Numbers 4-I, -2 3-2 CONTINUE Statement 2-3, 6-7 Floating-point Decimal Fraction and Integer 7-5 Core Map Compiler and OP SYS F—I Format 4-2 Numbers 4-I DECtape I/O Options 8-I Statement and Operation 8-2 Decimal Integers Exponents 3—2 3-2 Representation 4-I, —2 Format Control Elements 7-7, -8 E andI 7—4, -5, -6 Floating-point Devices I/O 2—2 7-1 Hollerith 7-I 4-2 Input Operating Procedures 7-5 A-3 Program 2—] BIN Slash 7-8 Compiler Statement Number I/O Control C-2, -3 7—3 Operating System (OPSYS) 7-3, 7-6 FORMAT Statement Functions, Arithmetic 3-4 RIM 6—2 GO TO Statement Compiler 8-l, C-l DECtape 8-l, -2 Output 7-7, -8 7-4, -5, -6 Operating System Input/output System 8—], C—1, -2, -3 7-] FORMAT Statements Operators Unary Minus 3-3 7-2, -3 , 6-5 Output 7-5 E and I Format Floating and Fixed Modes 7-6 FORMAT Loaders Parentheses, use of 3-4 A-I, -2, -3 Numbers Fixed 7-6 Data Word 6-2 RIM and BIN 3-3, -4 Arithmetic 7-5 Integers 3-2, 4-l Summation 3-3 Operators 4-], -2 PAUSE statement Floating-point 4-], -2 Positive or Negative Statement 4-] 4-2 2-2, 7-3 6-I Example 2-l 2-] Restrictions Variables, Types of 4-2 Operating Procedures Control Format OP SYS (Operating Procedures) C-I 6-] Program Integers 4-] Representation 8-l 8-l Symbolprint DECtape Options 8—I Devices A-l, -2, -3 Loaders 6-3 IF Statement C-l Operation Hollerith Format I Format C-l , -2 A-l Symbolprint 6-8 Computed C-l F-I Source Preparation 8-2 Termination B-I 6-I Terminator (END) 6-] 7-6 Quote, Hollerith Output 7-7 2-3 Single Quote, use of READ Statement 8-2, -3 F-l Semicolon 2-2 Slash, Control Element Format 7-8 Statements 2-] 2-2 Comment Continuation DECtape 7-8 3-4 Arithmetic 2-3 8-2 6-] GOTO 6-2 Input/Output 7-2, -3 Number 2-2 PAUSE 6-1 READ 8—2, -3 STOP 6-] Types of 2-2 Variables 3-2 STOP 3-2 WRITE Statement Source Program WRITE Arithmetic Subscripted 5-], -2 Restrictions END Variables, types of 4-2, -3 8-2, —3 6—] Subscripts 5-l Arrays 5—] Variables 5-l Symbolprint 8-], 9—l, -2 Operating Procedures C-l with DECtape 8-] Tape, Symbolic Preparation 8-] 8-2, -3 323:;rEfl'SZL‘Z'LthEé’éfl‘é'a‘i°" printed in USA. EflEflIEII
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies