Digitized by the Internet Archive in 2013 http://archive.org/details/pilot360referenc875rohn UIUCDCS-R-77-875 /?7X->CV, UILU-ENG 77 1732 PILOT/ 3 60 REFERENCE MANUAL BY R. Douglas Rohn DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN URBANA, ILLINOIS P^port No. UITJCDCS-B- 77-875 PILOT/360 REFERENCE H USUAL by R. Douglas Rohn 1977 Department of Computer Science University of Illinois at Urbana-Champaiqn Urbana, Illinois 618G1 PTI0T/?6C reference Manual T able of Contents 1 1 1 2 ?. 1 3 5 1 U 5 Table of Contents. PILOT Lanquaqe Description, Identifiers, Numbers, Character Strinqs. ^he PILCT Characterset » Identifiers, Numbers, Character Strinqs, Data Ttpms, Declarations. 2 1 2 T!> Scalars. Constants ? 2 it 5 I? r p Arrays, External References, FORMATS. i 1 -) ( 2 2 -> 3. U ■} , 5 ■) t 6 U ft, i u 2 p M a 3 i? '4 u a. , 5 u 6 p '4. 7 TT 5, 5 1 5 2 6 * - 2 Expressions. Arithmetic Operators. Comparison Operators. Loqical Connectives. Operands, Parentheses and PILOT/36 ). Examples Statements Computation. Decision. Loop, Call, Return , Decision Table- Jump. Input-Output Read. Write Example. Proqram Structure, Routine Label. Global, Local and External Names, Fxample. PIL3T/363 ^efwr^nce Manual ""able of Contents Embedded Machine Code. Register Specification. Offset Specification* Instructions, Constant Definitions. Cole Structure. appendices. A PILCT/36C/PL1 Programmer's Guide A 1 A 2 A . 3 A- U \. c Compiler Conventions, Compiler Options, Job Control Language. Source Listing. r rror Messages, PILOI Language Summary. Identifiers, Numbers, Data Items, Declarations. Fxpressions, Statements, Program Structure, Embedded Machine Code. PILOT Program Examples, C 1 C. 2 r. •? Sample Program 1 Samole Program 2 Sample Program 3 ?. indicates that examples follow this section, PTL0T/3 rr Fefer<=»nce Manual EIL2J. L§Q2H§•*/»■• (:)-:♦*. $ • ? I d» % ♦ & | " ■*» 1234*6789 ABCDEFGHIJKLHNOPQRSTUVWXYZ The above lists are the operators, digits, and letters in the VZL^ m characterset , There ace some double character operators as follows: = > -,= -,> -,< <= >= // where the first onerator is assignment to t he right, the next five have obvious meanings, and the last one signifies the start of a comment. It should be noted that all blanks are ignored except within character strings. 1 2 IDENTIFIERS. •\n identifier consists of a letter, followed by an arbitrary number of digits and letters. Only the first six characters in an identifier are meaningful for distinction. Ml identifiers defined in the main routined data section and all routine names are global, i.e., known throughout the entire PILOT program (see section 6.2). All other identifiers (including FGRWRTs and labels) are known only within their defining routine. The first three of the following identifiers are all valid. ^he second and third are indistinguishable. The last two identifiers below are invalid. \ M2345E IDENTIFIERS, NUMBERS, CHARACTER STRINGS, Page 1-2 IDENTIFIERS. A 1 234 5XYZDEF 12AX // may not start in a diqit AX_12 // _ is not a PILOT character 1 , 3 NUMBERS. Ml numbers (like all other data items) must fit into 16 bit signed integers. Numbers denote integers and consist of a string of digits, and potentially letters A through F denoting 10 through 15 in base 16. Numbers are interpreted in base 1C (decimal) if they do not have a leading zero, in base 8 (octal) if they have exactly one leading zero, and in base 16 (hexadecimal) if they have two leading zeroes. Numbers are all unsigned according to the PILOT grammar but they may usually be preceded by an optional unary minus sign. Equivalent ways to write the largest positive integer number: 32767 // decimal 077777 // octal 007FPF // hexadecimal T'guivalent ways to write the smallest negative integer number: 0100COO // octal 008000 // hexadecimal The following are invalid numbers: 657*8 // Too large for 16 bits 09A // 9, A are illegal in base 8 ABC // an identifier, not a number 1 4 CHARACTER STRINGS. Character strings consist of any seguence of EBCDIC characters enclosed within a pair of guotation marks (") . Within character strings is the only place where blanks are significant. A guotation mark within a character string is represented by a pair of guotation marks. Character strings may not overlap card boundaries Character strings longer than 2 characters may only be used to initialize arrays. All strings are padded on the right with a blank, if necessary, to produce a string of even length, n £>; T T F J t CHARACTER STRINGS Page "-^ Strings that- fit into 16 hits (2 bytes) can be used interchangeably with numbers including their optional minus sign. The null string "" is compiled as a zero,. "he first five or the following character strings are all valid. The first and second are indistinguishable. The last one is invalid. "Y T "" // ? bytes .tyre " // 2 bytes "He said, ""No!""" // 14 oytes "" // 2 bytes--compiled as •The sail, "No!" // Unmatched quote CHAPTER 2 DATA ITEMS, DECLARATIONS. 2,1 SCALAFS. A scalar is an identifier denoting a single modifiable value. Its declaration takes the form: identifier // uninitialized identifier = initial value // initialized where initial value is anything which fits into 16 bits and is known at compile time (such as signed numbers, character strings, or predefined constants) . The following declarations create seven scalars and initialize the third of these with the largest possible value and the fourth and fifth with the smallest possible value. The last two are initialized to the same value. FIRST, SECOND, THIRD = 32767, FOURTH = MOOCOC, FIFTH = -32768, SIXTH = 0CD5D6, SEVENTH = "NO" 22 CONSTANTS. a. constant is an identifier denoting a single value. The PILOT compiler will not permit any direct assignment to a constant and will use the value of the constant directly in certain coding operations (such as unit numbers, in input-output statements, in embedded machine code, as array dimensions, and as replication factors) . A constant declaration takes the following form: identifier : initial value where initial value is the same as for scalars. Dv -H ZTFHS, DECLARATIONS Page 2-2 ? N S T A NT S . ""ho followinq declarations create three constants with values 1 , 2 and 2 : ONE : 1, TOO : TWO ^his declaration does not create a constant with value - 1 : MINUS ONT^ = CAPFFF rhe declaration creates a scalar with initial value -1; to declare a constant, • =' must be replaced by • : ' * 2 ■» 5 P F A Y S , ^n array id an identifier denoting a set of modifiable values. ""he declaration takes the form: identifier ( non_neq ) // uninitialized identitier ( non_neg ) = // initialized init , init // as many as desired where init can be one of the following: initial value // single value initial value ( non_nog ) // replication string ( non_neg ) fhe value in parentheses after the identifier lenotes the number of elements in the set and must be non-negative ""here s'houl 1 not be more initialization values than elements A rr-olication factor (the valu^ in parentheses after an initial value) must be ron-negat i ve and indicates how many times the item preceding it is to he duplicated. \rray elements are referenced by means of subscripting, counting the array elements from * on up. No subscript verification is performed, An array element reference takes the form: identifier ( expression ) where the identitier must refer to an array and the expression is the subscript . Assuming that ONI, TWO, FIVE and £?.N are predefined constants with the appropriate values, the following are all valid array declarations. The first and second each are uninitialized arrays The next two are identical 1? element arrays D.A^A TTFMS, DECLARATIONS Page 2-3 A7PAYS, A (MO) , // uninitialized BpK) = TKO p) ; // C replication C (TEN) = "YFS" (FIVE) ; // "YES YES YES YES YES " D (TFN) = "YFS " (FIVE) ; E (FIVE) = 0, ONE, -TWO, TWO (TWO) ; F (TEN) = r ,""; // 8 elements uninitialized Programming Notes: Since no subscript verification is performed, an array of dimension zero can be placed before a group of related declarations to form a primitive type of record. Care should be exercised, however, so as not. to access or destroy data unintentionally. Also note that in initialization, padding of character strings takes place before replication. 2,4 EXTERNAL REFERENCES. In PILOT/36C, an external reference is an identifier denoting a PILOT main routine which was compiled separately. It can be used in call statements (see section 4.4) and in machine code constant definitions (see section 7,4), An external reference must be declared in the main routine, and its declaration takes the form: ( identifier ) The following is an external reference declaration in PILOT/360: (ROUTINE) following this declaration, the identifier 'ROUTIN' (truncated to six characters, as usual) can be used as a routine name, wherever routine names can be referenced, but no definition for the routine 'ROUTIN' should be supplied with this PILOT program. DAT* 71" p v uses the FORTRAN input-output package IBCCHf for its input-output handling. Formatted FLAD and WRITS operations to arbitrary logical units are supported FORMAT declarations occupy at least one card each, and take the following form: identifier // FORTRAN FORMAT // continuation FORMATS ""he identifier is used to reference the FORMAT; the text of the FORMAT (following the // which normally indicates a comment in PILOT) is passed exactly as is to IECOM#. It therefore must. tike the form of a FCFTPAN FORMAT as stored in a FORTRAN array, i e., including the surrounding parentheses. Successive unlabeled comments arc treated as continuations of the previous FCFM.s?, Blanks in a FOPTRAN FORMAT are not ignored, FORMAT identifiers are known only in the th^y are declared routine in which Design Note: T he FORMAT text is not considered part of the PILC T language am] is not syntactically verified. '"his is symbolized by t he requirement that the text should to specif ied in the form of a comment Add it ionally, compiler design was simp lified: ? comment is ignored by tne compiler, and no soecial provisions need to b-» made to avoid th e removal of (significant) bl anks from a FCRMA m text , DATA ITFMS, DECL AP AT IONS . Page 2-5 FOPMATS. The following FORMAT could be used to read a card into a PIL0T/3^r array: FORMAT // (40A2) Programming Note: A FCPMAT can occupy several cards: Its end is signalled only by the closing right parenthesis, and not by a card boundary. The FORMAT part of the card still must be written within the comment section of the card but no new label is reguired. chaptep 3 expressions, 3 1 ARITHMETIC OPERATORS, Addition, subtraction, muit iplicat ion, and truncated (inteqer) division are supported throuqh the operators + - * and / In PIL0"/3e", the operator - can additionally be used as a unary minus. Loqical neqation is supported hy the unary operator -» assiqnment is supported throuqh the operator = >, A unary minus operates on the sinqle operand immediately to its right. A unary not operates on the sinqle operand immediately to its right: a z»ro is changed to a one and a non-zero is chanqed to zero. All other operators (arithmetic and otherwise) have equal precedence and are elaborated from left to riqht s .ssiqnment is from lett to riqht and may be embedded in an expression The value to the left of the assiqnment operator is computed and assiqned to the sinqle operand on th« riqht of the ODerator This operand must be d modifiable reference such as a scalar, subscripted array name, etc., but not a fixed value or a siqned operand. Parentheses may bo used to control the elaboration of an expression. Within the left to riqht order, items inside Dir^nt heses are elaborated first, This applies in particular to an assignment to a subscripted array name: the subscript must be evaluated nrior to the assignment. 3 2 •C v i?AT30N OPERATORS. Operands may be compared for equality, usinq the operator =, and for qreater than and less than relationships, usinq the operators > and < Combinations ot these can be accomplished by usinq the operators: -»= , -•> , -t< , <= , and >=. The result of any comparison is the numerical value 1 indica^inq true, or the value indicating false. Comparisons can therefore be used like any other numerical result. EXPRESSIONS. Paqe 3-2 LOGICAL CONNECTIVES. 3, * LOGICAL CONNECTIVES, Values may be connected with loqical AND, usinq the operator F f , and locrical CF, usinq the operator |. > loqical AND of two nonzero values produces as a result the numerical value 1 indicatinq true, and r otherwise. A loqical OR of two zero values produces as a result the numerical value indicatinq false, and 1 otherwise. The loqical connectives can in particular be used to combine comparisons, Their results can be used like any other numerical value. 3.U OPERANDS. Scalars, subscripted array names, and direct memory references are leqal operands for any operator. Fixed values are leqal operands except as tarqets of the assiqnment operator. Direct references to memory are made with the operator 'd', followed by a locatinq expression enclosed in parentheses. Reference is made to a location in the executable code of the current routine; aliqnment exceptions will result at runtime if the locatinq expression is odd. Any assiqnment to the code clearly would -jeopardize the proqram inteqrity. 3.5 PARENTHESES AND PILOT/360. Consider an accumulator-oriented machine; a lanquaqe with no operator precedence and left to riqht evaluation allows a direct expression elaboration procedure: the first operand is loaded into the accumulator, and each followinq operand is combined with the accumulator as the operator precedinq it dictates. Parentheses are handled by switchinq, stack-fashion, to a new accumulator any time a left parenthesis is found, and savinq, stack- fashion, the operator precedinq the parenthesis. When encounterinq a riqht parenthesis, the current accumulator holds the value inside the parenthesis pair. If this value is an array subscript, it is used as an index value when the stacked operator orecedinq the parenthesis pair is executed. If the value is a memory reference, it is used as an index into proqram memory. If the value is neither a subscript nor a memory reference, the current accumulator and the next older accumulator are directly combined accordinq to the stacked operator. WV PRFS STONS « P^P^NTHKSSS AND PILOT/36' Paqe 3-3 The stack of accumulators in PILOT/36C is implemented as the set of qeneral purpose reqisters precedinq the proqram-base-reqister and down to reqister 1 (see section l.i), "he exact reqister usaqe is: 1U, 15 1? 12 . LOCAL LOCAL-1 . - DATA DATA-1 », PPCG ACC .. 1 subroutine linkaqe in OS/36 r save area in OS/36C local data base reqisters qlonal data base reqisters routine base reqisters accumulator stack scratch purposes This st.rateqy implies that larqe data areas or lacqe routire sizes will require simple expressions. The burden for optimizinq reqister usaqe is Dlaced with the PILC5l/3£ n user: it is advisable to avoid superfluous parentheses, e.q,, at the extreme left of an pxpression. ^ , 6 EXAMPLES. Let the declarations be as in section 2 Then the followinq expressions can be written: ONI? + TWC => ?IFST qkp _ 1 +_ TW0 => SECOND B (FIRST + SECOND) => A (-SECOND) -"NO" => F(3) and at this ooint the followinq comparisons will yield values as indicated : FI°ST -i- SECOND SECOND -»> -F(l) = "NO" E (ONE => SUCCND) = £ (ONE) E (ONE) >= £(E(CKF) ) // 1 // 1 // 1 // 1 // 1 ' n he followinq expressions are illeqal: FIRST => ONE 0N T -' => -FIRST // assiqnment to constant // not modifiable And finally, we will quite definitely create problems with the followinq direct assiqnment to proqram memory: MINNS ONF => a) (THIRD) CHAPTER U STATEMENTS, Basically, the type of a statement is determined by the operator (delimiter) which terminates it, A name followed by a period will be a lump (section 4.7), a name followed by a comma will be a computation (section 4. 1) if the name denotes a data item, or a call (section 4.4) if the name denotes a routine. An expression followed by a comma is a computation (section 4,1) , an expression followed by a colon starts a decision (section 4.2), an expression followed by a pound sign denotes a return from routine (section 4. 5) , and an expression followed by an apostrophe starts a loop (section 4. 3) . The semicolon plays a special role as a delimiter: it is used to terminate a list of thinqs, For example: a list of initial values for an array (section 2. 3) , a list of data elements in an input-output statement (chapter 5) , a list of statements in a decision, loop or action (sections 4.2, 4.3 and 4,6) , a list of machine code instructions (chapter 7) , a list of FO n MAT cards (section 2- c ) , or a list of data declarations (chapter 2) , all are terminated by a semicolon, More complex statements, such as decisions, decision tables and input-output statements, thus will be terminated with a semicolon. The proper balancing of semicolons is crucial to the correctness of a PILOT proqram. All statements can be preceded by an arbitrary number of labels of the form: unique identifier : where the unique identifier is a unique name within its block (routine or decision table). Note that a label definition can not redefine a qlobal data identifier. STATEMENTS Page 4-2 COMPUTATION , 4 « COMPUTATION. A computation is the most frequently used PILOT statement. It provides for the evaluation of an exDression and takes the form: expression , ^xnressions have been , discussed in chapter 3; examples for computations can be found in section 3.6 (where each expression must be followed by a comma to turn it into a computation statement) , 4,2 DECISION. 8 decision provides for the execution of one of two qroups of statements, depending on whether the value of a controllinq expression is nonzero (indicating true) or zero (indicatinq false) » It takes the form: expression : // controlling expression E one or more statements // executed if E nonzero ' // executed if F zero // optional one or more statements // indicates the end Observe that decisions may be nested Although the 'else' part is optional, there cannot be any confusion as to which one of a set of nested decisions it applies, because of the semicolon terminating any decision. The following nested set of decisions illustrates a selection of one out of four cases. The selected case is commented in form of a comparison-computation: A = B : C = D : A = B & (C = D) , A - B 8 (C -i= D) , ; i : = D : a -.= b s (C = D) , i A -= B S (C -= D) , ;; STft •"EVENTS, Page 4-3 LOOP. u ? LOOP. 1 loop statement provides for the repetitive execution of a qrotip of statements, provided a controlling expression (which is evaluated prior to each potential execution of the statement group) is nonzero (indicating true) It takes the form: expression * // initializing expression I expression : // controlling expression C some statements // executed if C nonzero ; // indicates the end Observe that loops may be nested. Note that the initializing expression I (which is executed once) is mandatory, otherwise the loop reverts to the 'else* part, of a decision. The following coding skeleton intends to illustrate how a common control structure is realized in PILOT, Further examples can be found in section 4.6. INITIAL - STEP => CONTROL' CONTROL «■ STEP => CONTROL •»> END: // statements to be iterated for // CONTROL from INITIAL by STEP // including END 4 a CALL, The call statement provides for the invocation of a subroutine. It takes one of the following forms: subroutine name , subroutine name ( parml, parm2, .. ) // up to 8 parms 'he creation of suoroutines is explained in chapter 6, Routines may be called recursively; they do not return a value, per se. So they can not be used in expressions (as functions) ; however, on return the accumulator will contain a return code (see section 4„ 5) The parameters may be scalars, array names or expressions. Scalers are passed by value but upon return they receive the last value the subroutine assigned them (by value result), Array names are passed by reference so that the subroutine works directly on them. Expressions (including subscripted array names) are evaluated first and then passed as dummy scalars. STJi'^SM'SNTS, Paqe u-U CALL. Proqramminq Notes: Unwanted chanqes of scalar values can be avoided by makinq the scalar in expression by surroundinq it with parentheses. This will not work for array names, however.. Also, no parameter type checkinq is oerf ormed . '4 . S R E T Tl R N » The return statement is a way to accomplish immediate return from a subroutine It has the form: expression # ~ontrol is returned to the point -just after the call and the current accumulator in the callinq routine receives the value of the expression. So expression can be viewed as a return code for the subroutine, The return statement can be used in the main routine to establish a user return code. If normal flow reaches the last semicolon in a routine it returns the present accumulator's contents as a return code, Note that a semicolon is still required to terminate a routine. Desiqn Note: The return code miqht seem of little value except to cause immediate return; however, it was implemented with the view of eventually offerinq function calls. The clever proqrammer can still access the return code and it does allow one to set user return codes from the main routine. STATEMENTS. Paqe 4-5 DECISION TABLE. a f DECISION TABLE. A decision table provides for the execution of a selection of qroups of statements (called actions) based on the value of switch expressions. A table consists of one or more set statements followed by a list of actions followed by an optional else part and terminated with a semicolon. A set statement can take one of two forms: ? expression : • swO ' sw1 ... ' swn ? expression : sw * swO • sw1 * ... • swn where in the first form swk is set true only if expression evaluates to k, and in the second form, sw is set true only if expression is non-zero with the rest of the switches set as in the first form. An action takes one of the followinq forms: ! switch expression : statements ! : statements where a switch expression can only involve switches defined in the current decision table and the operators 6, | and -» (and parentheses). The qroup of statements followinq a switch expression is executed only if the expression is true* The second form constitutes the optional 'else' action of the table. Tt may appear once as the last action in the table and its associated statements are executed only if no other action was taken, Decision tables can be nested but switches are only known in the table in which they are defined. Also, switches may only appear in switch expressions. Statements within actions may be labelled and jumps may be made to them from a containinq table or routine or to labels outside a table from within one. However, qood proqramminq style would dictate avoidinq such jumps into and out of control structures. Proqramminq Note: The total number of switches in a decision table or a nested sequence of tables can not exceed 63 minus the level of nestinq (where the first table is at level 1). STATEMENTS, Paqe 4-6 HFCISICN TABL*. Decision tables offer a powerful control mechanism and reauire a certain amount of practice to become proficient in their use. Therefore the followinq example is only a simDle example to show the basic form* The followinq segment of code assigns "* , -1 or +^ to SIGN dependinq on whether NUMBER is zero, neqative or positive respectively. There are easier ways to do this (even with a table) but this example shows most of the features of a decision table. ? NHftBER : NO*: ZERO ? MH^DLR< r : ■ r.'ON NEG • NEG ! -.NOfl 7EP0 : => SIGN, ! UF3 : - 1 => SIGN, ! : 1 => SI3N, ; Thus a decision table can be coded from a truth table tyDe of arranqement. A more common example (the case statement) is demonstrated in section 4.7 and other examples can be found in appendix C\ 4 7 JUMP, The "jump statement serves to implement various control structures in PILOT It takes one of the followinq forms: label name , expression * The first form of the lump statement is an unconditional transfer of control to the indicated label in the same routine. The second form of the "jump statement is intended for system a replications, such as crude load-qo compilers under OS/36% The expression is evaluated and then proqram control is transferred to that point in the qlobal data area. Alignments must be observed, and caution is advised. *ny PILOT statement may be preceded by an arbitrary number of labels. Label names serve primarily as tarqets for -jumps and aro known only locally within a routine. It is thus not possible to leave a PILOT routine by means of a lump. Routines are discussed in chapter 6, r he followinq coding skeletons are intended to illustrate how commonly used control structures may be realized in PILOT: T !NTIL: // statements to be repeated until // a condition is false, STATEMENTS. Paqe U-7 J r JMP. condition : UNTIL. ; WHILE: condition : // statements to be repeated while // a condition is true. WHILE, ; CASE: ? case expression : ' CASEf' • CASE1 • CASE2 ! CASEO : // statements for case ! CASE1 : // statements for case 1 ! CASE2 : // statements tor case 2 t . • • // statements for error condition ; // end of case statement CHAPTER 5 INPUT-OUTPUT. Read and writ© statements in PTLOI/36;. provide tor input and output usinq FORTRAN FORMATS and the usual services of IBTOK*, the CS/36< FORTRAN input output handler 5,1 R 7 ?. D , A read statement is coded as follows: > unit , // denotes loqical unit format name , // denotes FCRtfAT declaration end label : // address on end of file data item , data item // arbitrarily many The loqical unit specification may be any expression. It is optional and, if omitted, defaults to the standard input unit 5. '"he format name must refer to a FORTRAN FORMAT declaration or an array (initialized to contained a FORMAT), see sections 2.3 and ?. 5, Thp end label is optional and, when present, causes a -jump to this label when an end of file condition occurs. See section % .1 on iumps. ^ata items can be scalars, subscripted array nimes, or array names They are the receivers of information from the input file accordinq to the usual FORTRAN conventions. Alternatively, a loop over a set of data items can be specified in place of a sinqle data item; compare section U. 3 on loops: INPUT-OUTPUT* Page 5-2 READ. expression ' // initializing expression I expression : // controlling expression C data item , data item // arbitrarily many ; // indicates the end If more data items follow the loop, the closing semicolon of the loop acts as a separator instead of the usual comma which otherwise separates consecutive data items. Loops, as always, may be nested. 5.2 WRITE, k write statement is coded as follows: < unit , // denotes logical unit format name : // denotes FORMAT declaration data item , data item // arbitrarily many The logical unit specification may be any expression. It is optional and, if omitted, defaults to the standard print unit 6. The format name must refer to a FORTRAN FORMAT declaration or an array name, see sections 2.3 or 2.5. Data items can be expressions or array names. Loops, as described in section 5, 1, may also be specified. They are the sources of information transmitted to the logical unit according to the usual FORTRAN conventions. 5.3 EXAMPLES. The following is part of a PILOT/360 program to copy cards from unit 5 to unit 6 for printing and unit 7 for punching. Each card is printed twice. I, // loop control CARD(UC) // the buffer ; // the end of numeric data INPUT // (U0A2) PRINT // (1X,40A2) ; // the end of all declarations LOOP: // a label > INPUT, END: CARD; < PRINT: 0=>I' I + 1=>I-.>2: CARD;; INPUT-OUTPUT. EXAMPLES. Page 5-? < 7, INPUT: LOOP, E>lD: card; // -jump to repeat // here on end of // end of program file Labels and the -jump statement are explained in section U,7 t overall proqram structure is explained in chapter 6. Programming Notes: F07MAT names are only known within the defining routine. But an array initialized as a FORWA m can be used as an alternate and they can be known globally. This also allows for dynamically changing FORMATS, Also, when -just an array name is used as a data element it represents a set of elements egual in number to its dimension. CHAPTER 6 PROGRAM STRUCTURE. PILOT routines start with a routine label and an optional formal parameter list. Next comes a list of declarations, followed by a list of PCRMAT cards, and finally, any number of, optionally labelled, statements. Each list must be terminated with a semicolon even if it is empty. A routine takes the following form: % routine name ( formal parameter list ) : declarations // arbitrarily many // separated by commas ; // terminates declarations format name // FORTRAN PORMAT // arbitrarily many ; // terminates formats statements // arbitrarily many ; // terminates routine 6 1 ROUTINE LABEL. A routine label must start with a • %* • If the formal parameter list (and its associated parantheses) is present the compiler option (see appendix A, section 2) 'NM* is assumed. The formal parameter list may consist of up to 8 parameters, each of which may have the form: identifier // scalar parameter identifier ( number ) // array parameter identifier ( constant ) // array parameter The parenthesis enclosing the number or constant serve only to identify the formal parameter as an array and the dimension would be used only in input/output statements (see note below). Scalar and array parameters can be used in statements just as one PBCGFAM STRUCTURE. Page 6-2 ROUTINE LABFL. would usg scalars and arrays, respectively. Programming Notes: Since array bounds are not checked, usually an array's dimension would have to be passed as another parameter If an unsubscripted parameter array name is used in an input/output statement the compiler assumes its dimension to be that established in the formal parameter list, 6 2 GLOBAL, LOCAL AND EXTERNAL NAMES. All identifiers declared in the first (main) routine's declaration section can be used in all following routines (subroutines) that do not redefine those identifiers, Labels and FORMATS are known only within the routine in which th^ir definition appears. Also, it an identifier is defined within a subroutine, a global identifier by the same name is not accessible in that subroutine Note that a global identifier can not be redefined as a label in a subseguent routine since the arammar would view the attempt as the beginning of a decision. External references are handled as follows: Compile the main program with no parameters to the main routine. Specify in the main routine's declaration section any number of external references (see section 2. '4) . Use these references in call statements (see section U.U), For each external reference preDare a PILOT program with compiler option 'NM*. These routines, lik° all subroutines, can be passed parameters. Programming Note: Note that each separately compiled program has its own associated global identifiers whether or not the program itself is a subroutine. Also, note that one more level of subroutine nesting can be accomplished by compiling external subroutines. PROGRAM STPUCTURE. Page 6-3 EXAMPLE. 6,3 EXAMPLE. This example intends to illustrate program structure, subroutine calling, and the concept of recursive subroutines. Other complete programs can be found in appendix C. % MAIN : // n! // For any input number, this program will // compute nl. // n! is defined to be 1 if n<=1, and // the product 2*3*. • • *n otherwise. // He use the recursive definition // n! = n * (n-1) I // Declarations, 1=0, // counter N, // the input number, P; // home of n!. INPUT FORMAT // (13) PRINT FORMAT // (1X,I3,', ',I3,M =',I5) // The main routine. LOOP: > INPUT FORMAT, END : N; I ♦ 1 => I, N < 2 : < OUTPUT FORMAT : I, N, 1; i FACTORIAL (N,F) , < OUTPUT FORMAT : I, N, F;; LOOP. END: { // end of the main program. // The recursive subroutine. % FACTORIAL (N,F) : // local parameters ; // no declarations ; // no formats N > 2 : //if N>2 FACTORIAL (N-1, F) , // then F=(N-1)! N * F => F, // F=N*(N-1) ! • // else 2 => F, // F=2! ; // return in either case CHAPTER 7 FF*EF-DDED MACHINE CODE, PTLQT/360 allows statements consisting of sections of machine code for the IBM/360, expressed in an assembler-style notation. The machine instructions can by name refer to entities (labels, variables, etc.) in the PILOT program. Machine code instructions may be labeled, and PILOT statements can directly r3fer to these labels. Familiarity with IBH/36' 1 machine and assembler lanquaqe, as well as section 3 5 of this manual are assumed in this section. 7,1 REGISTER SPECIFICATION, Registers may he specified either absolutely by register number, or relative to the PILOT usage of registers within the current routine To specify a register absolutely, use an unsigned non-negative value (i.e., an unsigned number, constant or scalar character string which is positive) with value between "* and 15. To sDecify a register relative to PILOT'S usage, the following names can be employed: LOCAL DATft PROS ICC // the first base register for local data. // the first base register for the global data, // the first base register for the routine, // the highest-level accumulator. In the case of a name conflict, constant values will take precedence over the PILOT implied value for the register names. These register names may be gualified, but only within their usage range, Specify LOCAL + fixed value DATA ♦ fixed value PR' + fixed value ICC - fixed value to access higher base registers or lower-level accumulators. Note that registers 13 and above cannot be gualified relative to th«^> data base registers, and that these cannot be gualified E^REDD^D MACHINE CODE. Paqe 7-2 F^GISTFP SPECIFICATION. relative to the proqram base registers, and that a neqative value is not a leqal reqister notation. Compare section 3,5 for the standard reqister usaqe in PILOT/360. Assuminq a routine with a local data area of 5K bytes (i.e., two local data base reqisters, reqisters 11 and 12), a qlobal data area of 2K bytes (i.e., one qlobal base reqister, reqister 10) , and a compilation requestinq three proqram base reqisters (reqisters 7, 8, and 9), the resultinq runtime accumulator stack consists of reqisters 6 to 1. The followinq qroups of reqister soecif ica tions are leqal and here equivalent: OCB LOCAL 11 013 DATH 1' 00 A PB03+1 8 010 ACC-3 3 'he followinq specifications are illeqal: 1+U // values must be absolute ACC+3 // relative position is positive PROG+4 // not a proqram base (only three) DATA-1 // relative position is neqative Proqramminq Note: In order to preserve the inteqrity of the reqister usaqe of the PILOT compiler, relative reqister accessinq is stronqly recommended. 7.2 OFFSET SPECIFICATION. Offsets, i.e., combinations of a base reqister and a displacement from the address contained in that register, may be specified absolutely, or in terms of entities elsewhere in the PILOT proqram. The followinq specifications may be used: value // displacement only value ( reqister ) // base reqister specified name // defined elsewhere in proqram name + value // relative to the name name - value LOC // location of this instruction LOC ♦ value // relative to the location LOC - value EMBEDDED MACHINE CODE. Paqe 7-3 OFFSET SPECIFICATION. Values are numbers, constants or scalar character strinqs. » reqister specification must follow the rules in section 7*1. Defined names in the proqram take precedence over the value LOC of the location counter, but LOC takes precedence over some undefined (future) label by the name of LOC Acceptable names are label and format names in the current routine, and array and scalar names in the data area (local or qlobal) . Constant names are taken to be a value, i.e., an absolute offset specification. p ormal parameter names can not be used to specify an offset. Some instructions require index reqister or lenqth specifications. These can be included in standard IBM/36* assembler format as follows: value ( index or lenqth , reqister ) name ( index or lenqth ) LOC ( index or lenqth ) The name and location counter references may include a relative offset as above, Index and lenqth both take the form of a reqister specification, with the exception that a lenqth may take on a value of 1 to 16 or 256 for relevant instructions. Lenqths are the absolute lenqth values, lenqth codes are compiled to be the absolute lenqth value minus 1 If an index reqister is required but not specified, reqister 1 is supplied. \bsolutely specified displacements must be within I3M/36" limits, i.e., to 4"95; displacements implied by names will be adiusted, if possible, throuqh their associated base reqisters. Peference to a point precedinq the data area or the routine area is not possible Immediate operands are specified as fixed values with value between "* and 255. "he followinq examples illustrate a variety of offsets and some immediate operands. Suitable declarations are assumed. 12 // absolute, // displacement or immediate. 1 2 (»CC) // absolute, // accumulator as base. 12(ACC,?R0G) // absolute, // accumulator as index or lenqth, // proqram base as base, LABEL // defined in proqram, // proqram base as base, LABEL (ACC) // as above, but additionally // accumulator as index or lenqth, E^BFDOFD MACHINE CODF. Page 7-U C Pr S ir : SPECIFICATION. LAEFL+CONSTANT // relative to the label, LOC // position of this instruction, // program base as base. LOC-256(256) // position preceding this code, // program base as case, // length 256. 7.3 INSTRUCTIONS, Machine instructions consist of an operation field, followed by a list of operands. The exact contents of the list are determined by the type of the machine instruction: er instructions (operation codes C to 63) reguire two register specifications, RX instructions (operation codes 64 to 127) reguire a register followed by an offset, RS instructions (some codes between 128 and 191) require two registers followed by an offset and no index register. SI instructions (remaining codes in the range) reguire an offset without index register followed by an immediate value. SS instructions with operation codes between 192 and 223 reguire an offset with a length from 1 to 256 and an offset without length or index register. SS instructions with operation codes between 224 and 255 reguire two offsets with lengths between 1 and 16. In the oppration field, the operation code must be specified by a fixed value or a mnemonic name. The extended mnemonic names (for some branch instructions) and the special operation codes for the IBM/36^ Model 67 are not supported. Constant names take precedence over a mnemonic name; in either case the existence of the operation is verified. The operation field is separated from the operand list by a period. Operands are specified as described in sections 7.1 and 7,2. Operands are separated by commas. A special 'conditional no operation' instruction is supported to provide for specific alignments. It takes the form: proqram: batching: Several pilot_proqrams can be compiled in a sinqle run of the compiler. Precede the second and all followinq pilot_proqrams by a card bearing a •*■ in column 1, followed by a strinq of compiler options startinq in column 2. If column 2 is blank, the final options for the previous -job are applied. 52M£2S text formatting control: Card column 1 may contain a spacinq control character: '"• requests that this source card is to be printed at the top of a new paqe, 'V throuqh *9' request that many empty lines in the listinq preceding the source card; any other character in column 1 is iqnored, source text: should appear in columns 2 throuqh 72. SSilil Seeing: Card columns 73 throuqh 8C are iqnored. Sll^cacter strings: must fit in 16 bits if used as a scalar. Strinqs lonqer than 2 characters may only be used in array initialization. names: Only the first 6 characters are used. numbers: must fit into 16 bits (siqned!). Names, numbers, character strinqs and double character operators may not be broken accross card boundaries, comments: follow // until the end of a card. Comments can be compiled, see the 'I' compiler option, blanks : Only those in a comment or a character strinq are not iqnored. PTLOT/36VPL1 PROGRAMMER 1 S GUIDE. CT^TLFP OPTIONS. Paqe A- 2 ft 2 COMPILER OPTIONS. The compiler may be passed the followinq requests in a PPPf? field: A=number: 'number' will replace '50' as maximum number of syntax errors allowed before compilation is aborted. If number is 'C* any number of syntax errors are allowed 2=name: 'name' will replace 'SYSDECK' as DD-name for the obiect module output dataset. Display obiect module cards. Note #1 Display the External Symbol Dictionary Generate a flow trace, i.e. , compile co;ie to display the statement address precedinq the execution of each statement, Note #1 Jfnumber: m he maximum of 192 ani 'number' replaces '192' as the initial number of bytes acquired for the proqram's runtime stack It may be possible to decrease execution time by increasinq this. H= number : 'number' will replace '2 r " ,i * as size of the compiler's work area (i.e., expression stack, forward reference lists, and crossref erences if requested) , T=letter: 'letter' is initially •*. This ODtion chanqes it. Subsequently all comments beq inning //c where • c' >=' letter ' will be compiled, 'letter' can be chanqed durinq compilation. Note that it cannot be cleared once it was specified for a -job. Note #1 MC: Suppress the output of the obiect module. 88: T his proqram is not a PILOI main proqram. ('NM' should be specified if the proqram is to be external to another PILOT proqram, see chapter 5.) NS: Suppress the printinq of the source. Note #1 ?=number: 'number' will replace 'U» as maximum routine size in K~bytes. Note #2 R: Display the Relocation Dictionary. Sfnumber: 'number' will replace '512' as size of the symbol table. PIIOT/360/PL1 PROGRAMMER'S GUIDE. Paqe A-3 COMPILER OPTIONS. Display the qenerated IBM/36 r ' code Note #1 Display a crossref erence table. The address qiven represents the runtime displacement from the appropriate base reqist«r (PROG for labels and FORMATS, LOCAL for local data, DATA for qlobal data, and 13 for switches and formal parameters). Addresses for routines are absolute. The requests must appear in alphabetical order, with no interveninq blanks, separated by commas, The list is not syntactically verified, and the first error terminates scanninq A DD-name must conform to System/36C conventions, the pi lot_proqram name must conform to System/36 n conventions and must be no more than six characters lonq, Numbers cannot exceed four diqits and should bo unsiqned and posit ive. Proqramminq Notes: #1: These options may be complemented anywhere in the source deck. The first appearance enables that particular option and successive appearances chanqe the current 'sense' of the option (enabled to disabled and disabled to enabled) , *?: This option may be chanqed anywhere in the source deck for all routines completely followinq the chanqe- To chanqe options, insert a card with ',' in column 1, and the strinq of options to be chanqed startinq in column 2. The first blank character or error encountered will terminate the scan of the card. The remainder of this card will be iqnored. PTL9T/3€0/PLl PROGRAMMERS GUIDE* Page A-** JOB CONTROL LANGUAGE. A 3 JOB CONTROL LANGUAGE. The -job control language for access to PTL0T/3£ n follows fairlv standard IBM conventions, A number of cataloged procedures are provided to compile, link-edit or load, and execute PIIOT/36'" programs. These cataloged procedures reside in a user procedure library; in order to use them in a job, a P^OCLIP data definition card must be the first card after the -job's •/'"ID 1 cards: Note #3 //PROCLIB DP DSN=USFP. Pnnnn. PROCLIB, DISP-SHR With this card in the -job deck, the following procedures can be used: PILOTC compile a PILOT/36C program. PTLOTCG compile, load and execute. PILOT same as PILOTCG. PILOTCL compile and link-edit, PILOTCLG compile, link-edit and execute. PTL3TLG link-edit and execute, Tn order to use one ot these procedures, prepare the -job deck as follows: /♦ID ,PEGION=28CK //PROCLIF // EXEC /* //GO. SYSIN DD * /* m he procedures have parameters as indicated in the listings below These procedure parameters can be specified in any order. If it is desired to include other options in the PAFM field of the call to the PTLCT compiler, it is Dest to overwrite the °TLOT PARM field as a whole (in this case, the parameters must be specified in alphabetical order as stated in section A. 2) . For morp details, consult the IBM JCL Language Reference Manual. If a PILOT program performs input or output for logical units other than 5 and 6, data definition cards for these units must he supplied. The DD name has the form: FT FC01 PIL0' r /36'VPLl PROGRAMMER' S GUIDE, Page A-5 JOB CONTROL LANGUAGE. Of course, the DD name may not contain any blank, characters. It may generally be wise to include a data control block specification with the DD card. For more details consult the IBM JCL Language Peference Manual or the FORTRAN Programmer's Guide* Programming Note: #3: The library name actually requires a certain Problem Specification Number to be substituted in place of 'nnnn'. PILOTC, //PILCTC PPOC ft = 2C, ERRORS ALLOWED // H = ir-9, SIZE OF WOPKAREA // P=4, ROUTINE SIZE IN K // S=1O0 SYMBOL ^ABLE SIZE //* //* COMPILE A PILOT PROGRAM //* //PILOT EXEC PGM=PILOT,REGION=28CK, // PAPM=•/A=&A,H=&H,NC,P=&P,S=6S , //S^EPLIB DD DSN=U3ER. Pnnnn. PILOTLIB, DISP=SHR //SYSPRINT DD SYSOUT=A EIL2I alias PILCTCG^ //PILOTCG PECC 2=2 A , ERRORS ALLOWFD // H=1u0, SIZE OF WOPKAREA // P=U, ROUTINF SIZE IN K // S = *m, SYMBOL TABLE SIZE // LIBFIL2=' SYS1.NULLIE' //* //* COMPILE, LOAD, AND EXECUTE A PILOT PROGRAM //* //PILOT EXEC PGM=PILOT,REGION=23CK, // FAFM='/A=&A,H=6H,P=&P,S=&S' //S^E?LIB DD DSM=USER. Pnnnn. PILOTLIB , DISP=SHR //SYSDECK DD DSN =S& LNKFI LE , UNIT=DISK , // DISP= (MOD, PASS) ,SPACE=(TPK, (10,1")) //SYSPPINT DD SYS0UT=A //* //1C EXEC PGM=UILOADP,COND= (C, LI, PILOT) //FT06Fv^1 DD SYSCUT=A STANDARD OUTPUT UNIT //SYSLIB DD DSK = f>LIBFILE,DISP=SHE // DD DSN=USER* Pnnnn. PILOTLIB, DISP=SHP // DD DSN=SYS1, PORTRACE,DIS?=SHR PTL07/36C/PL1 PROGRAMMERS GUIDE. Page A-6 JOB CONTROL LANGUAGE, LSN=SYS1, FORT LIB, DISP=SHR DSNAME=*. PILOT, SYSDECK, DISP= (OLD, DELETE) SYSCUT=A LOADER MAP SYSOUT=A COPE DUMP DDNAM?=SYSIN STANDARD INPUT UNIT // DD //SYSLIN DD //SYSLOUT DD //SYSUDUMP DD //FT05F<" r 1 DD PILO/TCL, //PTLOTCL PhOC // // // // // //* //* COMPIL //* //PILOT F3CFC // //STEPLIB' PD //3YSDECK DD // //SYS PRINT DD //* //T.KFD EXEC // //SY3LIB DD // DD // DD // DD //SYSLIN DD // // DD //SYSLMOD DD // // //SY3PRINT DD //SY3UT1 DD // PIT.OTCLG, A = 2*, ERRORS ALLOWED H=1Cfi, SIZE OF WOPKAREA P=4, ROUTINE SIZE IN K N=MAIN MEMBER NAME S=1?0, SYMBOL TABLE SIZE LIBFILE=»SYS1. NULLIB' ! AND LINK-EDIT A PILOT PFOGPA. v FGM=PILOT,REGI0N=2SCK, PA RM= ' /A = SA , H =5 H, P=SP , S= SS • DSN=USER. Pnnnn. PILC TLIB , DIS P=SHF DSN=&SLNKFILE,UNIT=DISK, SPACE= (TRK, (10,10)) ,DISP= (MOD, PASS) SYSOUT=A PGM=IEWL, REGION = 1 G2K,COND= (C , L 71 , PILOT) , PARM=' ^RE^LIST 1 DSN^ftLIBFILF, DISP = 3HF DSN=US^R. Pnnnn, PILOTLIB, DISP=SHR DSN = SYS1- FORTRAN, DI3P=SKR DSN=SYS1- F0ETL1B,DISP=SHR DSNAMF=*- PILOT. SYSDECK, DI5P= (OLD, DELETE) DDNAME=SYSIN PSN=&&GOSET (SN) ,DISP= (MOD, PASS) , UNIT=SY3DA,SPACF= (TRK , (7, 3 , 1) ) , DCB=BLKSTZF=1*2U SYSOUT=A DSN = &&SY3UT'', SPACE= (CYL, (3,1) ,RLSE) , DCB=BLKSIZE=1 C2 U, UNITES YSDA Like P T LOTCL, with the following GO steo added: //GO EXEC PGM=*. LKED. SY SLMO D, CCND= (C,LT, PILOT) //^Tv6F— '1 DD SYS0UT=A STANDAPD OUTPUT ON II //SYSUDUM^ DD SYSOUT=*. CORE DUMP //PT05F^C1 DD DDNAME=SY5IN STANDARD INPUT UNIT PILOTLG. PILOT/36VPL1 PROGRAMMER'S GUIDE. Paqe A-7 JOB CONTROL LANGUAGE. //PILOTLG PROC fc=MAIN, NAME OF MAIN ROUTINE // LIBFILE='SYS1.NULLIB« //* //* LINK-EDIT AND EXECUTE A PILCT PROGRAM //* //LK^D EXEC PGM=IEWL, REGION=1 C2K,COND= (0,LT, PILOT) , // PARM=»XREF, LIST 1 //SYSLTB DD DSN=6LI BFIL E, DISP=S HR // DD DSN=USER. Pnnnn. PILOTLID, DISP=SHP // DD DSN=SYS1. FORTRACE,DISP=SHR // DD DSN = SYS1, FORTLIB,DISP=SHF: //SYSLIN DD DDNJME=SYSIN //SYSLMOD ' DD LS N=5SG0S FT (& N) , DI3P= (MOD, PASS) , // U» 1 IT=SYSDA,SPACF= (TPK , (7,3,1) ) , // DCB=BLKSIZF=1 ^2U //SYSPRINT DD SYSOUT=A //SYSUT1 DD D5N=&SSY3UT1,SP?CE= (CYL, (3,1) , ELSE) , // DCB=BLKSIZE = 1024,UNI rr =SYSDA //* //GO EXEC PGM-*. LKED. SYSLMOD, COND= (C, LI, PILCT) //FTC6FC01 DD SYSOUT=A STANDAPD OUTPUT UNIT //SYSUDUMP DO SYSOUT=A CORE DUMP //FT'5FC~1 DD DDSAME=SYSIN STANDARD INPUT UNIT \ U SOURCE LISTING Assuminq that the ' NS 1 option is not in effect, the following information appears in the compiler's source listinq: . ^rror messaqes have the followinq form: ERROR (seq) - AT CHAR, char - 'left ? riqht' = num: text where se // assiqnment to riqht < // ., LT. comparison -•< // ,NL. comparison >= // , GE, comparison > // • GT, comparison -»> // . NG. comparison <= // ,LE. comparison = // . EQ. comparison -»= // . NE, comparison 6 // .AND, loqical | // .OF. loqical T unary T unary T unary T unary f unary scalar unsiqned_value array_name ( expression ) ( expression ) a) ( expression ) unarv: // unary minus // unary not expression: operand f operator operand 1* Proqramminq Notes: Expressions are evaluated from left to riqht, with no operator takinq precedence over any other, Note that an assiqnment can not be PILOT LANGUAGE SUMMARY. Paqe P-5 EXPRESSIONS, made to a non-modifiable expression, Also, a char_string used as an operand must fit into a half word. If a comparison evaluates as true, its result is ' 1», if it fails, the result is ,0 '. The '£• connection is '1' if both of its arguments are not ,r ', and 'C 1 otherwise; the '|' connection is '0 1 if both of its arguments are ' 0', and M' ot herwise. The unary ' -• • changes a %r ' to '1' and anything else to a T', A subscript locates an element in an array, startinq at • f, • ; 'a)' with subscript locates a position in program memory. Subscripts are never verified, k -jump on an expression is to that position in global data memory. 3.U STATEMENTS. statement: r label_name : 1* r body ] body: expression , lump , return_code # routine_call , table ; read ; write ; expression : non_zero f • zero 1 ; expression • expression : non_zero $ assembly f , assembly 1* ; iump: label_name expression return_code: expression PILC^ LANSUASF SUMMPRY. S^ATKMENTS. Paqe B-6 routine_call: parm_list : parm: table: set : act: else: sv#_exp : sw_ooeran i: sw_operat or : routine_name { ( parm_list ) 1 parm r , parm ]* expression scalar arr ay_name set f set 1* f act 1* [ else ] ? expression : switch f • switch 1* ? expression : ■ switch f • switch 1* sw_exp : T statement ]* : f statement ]* sw_operand f sw_operator sw_operand 1* f i 1 switch r "• 1 ( sw_exp ) switch : read : unit_f ormat : format : if_en 1 : r_data : r_data_it em: r_loor>: writ e: w_data: w data item: name > unit_format [ , if_end ] : r_data expression , format format tormat_name arrav_name labe l_name r_data_item f , r_data 1 r_loop f r_data 1 scalar array_name ( expression ) array_name expression • expression : r_data ; < u nit_f ormat : f w_data 1 w_data_item f , w_data 1 w_loop f w_data ] array_name expression PTL^T LANGUAGE SUMMARY. Page B-7 STATEMENTS, w_loop: expression ' expression : [ w_data ] ; non_zero: \ statement 1* zero: f statement 1* Proqramminq Notes: Switch variables are local to the decision table ir which they are defined. # causes an exit from the current routine returning the valu^ in ACC. Normal flow to the last semicolon returns the current value in the accumulator. 3.^ PPCGSAK STFUCTURE. °ILCT_proqr am: r '* routire_label : routine ; 1* routine: noun_list ; f f ormat_card 1* ; f statement 1* noun_list: r declaration ] declaration r , declaration ]* Proqramminq Notes: The size of the noun list is limited by the hardware- In PTLOT/36C one base reqister is used for every UK bytes or 2 r U8 words of data, and no more than 11 base and accumulator reqisters are available. The size of the main proqram, as well as of any subroutine, is limited by the hardware. In PILOT/36f/PLl the size is limited by the compiler's 'P' option, toqether with the fact that aqain one base reqister is needed for every ^K of code and static data P T L3T LANGUAGE SUMMARY, Paqe R-8 EMBEDDED MACHINE CODE. B f ^MPEDD'D RACHItlE CODE. B 6 1 PILOT/? 60 assembly: f label_name : ]* f a_body I a_bodv: op_36C. op_format def i ne_A def ine_H D unsiqned_valua // C?:OP 6,MCD(f_v,P) op_36*: unsiqned_value mnemonic op_format: req , req // PR req , offset_X // PX req , req , offset // KS offset , unsiqned_ value // SI offset_L , offset^ // SS offset_L , offset_L // S3 r«=>q: unsiqned_value ACC [ - unsiqned_value I LOCAL T ♦ unsiqned_value ] DATA f + unsiqned_value ] PROG f + unsiqned_value I offset _X: unsiqned_value [ ( \ req , I req ) I d^fine_S f ( req ) I offset: unsiqned_value T ( req ) l def ine_S offset_L: unsiqned_value { unsiqned_value , req ) define_S ( unsiqned_va lue ) define_S: any_name \ distance ] distance: ♦ unsiqned_value - unsiqned_value define_H: unsiqned_value define_A: routine_name any_name: label_name array_name scalar f ormat_name LOC P'LOT L»N~UAGE SUMMARY* EMBEDDED MACHINE CODE. Paqa B-9 Proqramminq Note: Unsiqned values in embedded machine code must conform to TRK/36* conventions. APPENDIX C PHOT PROGRAM EXAMPLES "hree sample proqrams are qiven in this appendix, ^ach solution is not necessarily an optimal one. Their primary intent is to reveal some common PILOT proqramrrdnq conventions. r 1 SAMPLE PROGRAM 1. "'his proqram is a staiqhtforward implementation of quicksort. It reads up to iri numbers from cards and sorts them before listinq them in ascendinq order. % MAIN : K:1 r 1, // READ UP TO 103 NUMBERS PLUS DUMMY KEY N=T*, // ASSUME 10 *> INITIALLY I, //INDEX NUMBERS (M)= // NUMBERS TO SORT 32767(M); // ALL SE^ TO LARGEST POSITVE INTEGEP ; // END OP GLOBAL DATA INPUT // (13) F?50P // (' NO INPUT') OUTPUT // (19,18) ; // END OF FORMATS ST1RT: // MAIN ROUTINE >TN?UT,F0F: // FILL NUMBERS -1 => !• I ♦ 1 «> I < N : NUMBERS (I) ; ; PTLOT PRO IP AM EXAMPLES, SAMPLE PROGRAM 1. Paqa C-2 EOF: I - 1 *> N < 0: I" T + 1=>T-,>W : T, NUMBERS (I) ; ; • r , // SET RETURN CODE OF MAIN // END OF MAIN ■* QUICK SOP.TfJ (H) f F,L) : // S^RT X (F) TO X(L) J. , J, TFBP; // INDICES // SWAP VARIABLE // NO FORMATS F >= L: // SORTED? // THEN RETURN // PARTITION THE FILE E ♦ 1 => !• 7(1) < X (E) : T ♦ 1 «> I f ! I => J' V (J) > 7(F) : J - 1 => J, ; WHILE: I < J: // NOW WF HAVE KJ, 7. (I) > = X (F) > = X (J) X(I) => TEMP, // SWAP X(J) => X(I) , ^EMP => X (J) , I ♦ 1 => I« X (I) < X (F) : I + 1 => I,; J - 1 => J' X(J) > V (?) ; J - 1 => J,; WHILE. ; P'LOT PROGRAM EXAMPLES. Pa 9- C ~ 3 SAMPLE PROGRAM 1* v (F) => TEMP, // SWAP v (vT) => X(F) , TEMP => X (J) , QUICK SCr.T(V,F, J-1) , QUICK SOPT (X,J+1 ,L) , ; // END OF QUICK SORT C,2 SAMPLE PR01F?-M 2 The followinq proqram is an emulator for a simple stack machine, "here are six permissable operations: ♦ , -, *, /, LJ and * "he operators behave as tollows: STACK (TOP-1) op S n »CK(T"op) => RTACK(TCP-I) and TOP- 1 => TCP, The L command increments the stack pointer and loads an integer from the source; in+o the top of the stack. This inteqer must appear after the L command and on the same source card. The P command prints the; value of the top of the stack and pops the stack. y v * ■*■ »] • STACK LIMIT: V , // STACK IS 1 f, LEVELS DEEP STACK (S^ACK LIMIT), // STACK Sn»j?CE'(33) , // COMPRESSED SOURCE CARD !=-% // SOURCE CURSOR L?.<5^'ch?-^=-1, // END OF SOURCE CARD 0~P^ NUMBER; // AUXILIARIES ppn-j // (• INSUFFICIENT STACK D^P^H') PO^p // (» STACK LIMIT EXCEEDED') ttipt // (• ILLEGAL OPERATOR AT CHAP', 13) pp.IVT // (• STACK (» ,12,*) = ',16) // END OF FORMATS EMULATOR: GET OPERATOR (OP) , LAS T CHAP >= 0: // IF NOT END OF FILE ? OP: 'ADD 'SUB 'MUL 'DIV 'LOAD 'PRINT ! ADD | SU3|MUL|DIV: TO? < 1: // CHECK FOR TWO OPERANDS < r P. P. 1 : ; PILOT PROGRAM EXAMPLES S»MPLE PROGRAM 2 Page C-4 ! ADD: STACK (TOP-1) ♦ STACK (TOP) => STACK (TCP-1 => TOP) , ! SUB: STACK (TOP-1) - STACK (TOP) => STACK (TOP-1 => TOP) , ! MUL: STACK (TOP-1) * STACK (TOP) => STACK (TOP-1 => TOP) , ! DIV: STACK (TOP-1) / STACK (TOP) => STACK (TOP-1 => TOP) , ! LOAD: TOP + 1 => TOP >= STACK LIMIT: STACK (TOP) , ! PRINT: TOP - 1 => TOP < -1 : OP OPE (6)= // LE3AL OPERATORS " ♦ - * / L P" ; // END OF LOCAL DATA // NO FORMATS PIL^T PROGRAM EXAMPLES, SAMPLE PROGRAM 2 Paqo C-5 I ♦ 1 => T > LAST CHAR: GET CARD, LAST CHAP >= Q: // IF NOT EOF -1 => OP' op + i => op < 6: SOURCE (I) = OPS (OP) : * » // RET UP N IF FOUND // END CF SET OPERATOR * GET NUMBER (N) DTGI*; // RETURN NUMBER FROM SOURCE // LEAVE I <- -> LAST DIGIT // HOLD DIGIT // NO FORMATS EXT => V* // START N = r + 1 => I i> LAST CHAR: // 50 IIL EOF SOURCE (I) - r'UAp-; => DIGIT >= f : DIGIT < 1 J : N * 1* + DIGIT => H, i EXIT. EXIT. I - 1 => I, // SET 1 I TO LAST DIGIT // END OF GET NUMBER % SET C£PD: BUFFER (ft*) , // GET NON-BLANK CARD // AND PACK IT INTC SOUPCE // INPUT BUFFER // BUFFER INDEX L^ET BYTE, EIGHT BYTE; // UNPACKED BYTES CARD IN C\BD ~UT // (U0A2) // END OF FORMATS PILOT PBOSRAM EXAMPLES. Paqe C-6 SAMPL* PROGRAM 2 AGAIN: >CAED IN, EXIT: BUFFER LEFT BYTE, t BUFFER (K)/256 => LEFT BYTE, BUFFEP (K) - (LEFT BYTE*256) => RIGHT BYTE, // STORE BYTES LEFT BYTE + CG4C*0 n => LEFT EYTE -.= " ": LEFT EYTE=>SOURCS (LAST CHAE + 1 ->LAST CHAR), • EIGHT BYTE + OH4000 => RIGHT BYTE -•= " " : RI3HT BYTE=>SOURCE(LAST CHAR+1=>LAST CHAR), K ♦ 1 => K < 40: NEXT WORD,, LAST CHAR < f> : AGAIN, EXIT:; // END OF GET CARD C 3 SA^PL* PROGRAM 3 The followinq subroutine miqht be compiled separately to manaq Q several ordered queues, CP can be r or 1 to indicate insertion or removal, respectively, AFPAY is the area containinq the queue, Q points to the first (or larqest) element in the queue E points to the element to be added or the element -just removed- The KEY on which the queue is ordered is assumed to be located in the second position of each element and the LINK is assumed to be in the first position. The facilities of IBCOM* are used to cause an immediate exit from processinq if an illeqal operation is specified, % ORDERED QUEUE (OP, ARRAY (10?) ,Q,E) : // OP=0 INSERT // CP=1 REMOVE ; // NO GLOBAL DATA ; // NC FORMATS P' r Ij' ,, PR03RAM EXAMPLES. SSK°L^ D POG p AM 3 Paqa C-1 ? OP: • INSERT 'REMOVE I T M «? V Vl T • INSERT (ARRAY, Q,E) , ! REMOVE: REMOVE (ARRAY, Q,E) , !: // ILLEGAL OPERATION $ L. 15,24 (PROG) , B*L TU ,f8 C5) , // CALL IPCOM# // r ND ^F ORDERED QtlElJ X INSS?T(ARPAY p "**) ,Q,F) I // INSERT ELEMENT // Hi CORRECT POSITION DADHY--1, // FATHER OF ELEMENT IN QUEUE SPARCH* i ; // CONTINUE SEARCH (^PUF) ; // NO ^RMATS => ARRAY (?) f ARRAY (F) -•- -1 5 SEARCH: ARPAY (ARRAY (E) +1) > ARRAY (F.+1): , -> SEARCH, i A?.^AY(R) => D?.DBY, ARMY (ASF AY (F) ) => ARRAY (E) , = -1 | (DADDY = - 1) : S => 0, i F => &RRAI (D? DDY) , f // END OF INSERT $ REMOVE (ARRAY (1™) ,0,E) : // NC LOCAL DATA // NC FORMATS // REMOVE T:P // ELEMENT PILOT PROGRAM EXAMPLES. SAMPLE PFOGBAM 3 q => e -»* -1 : ARRAY (Q) => Q, // END DF REMOVE Page C-S PTLOT Reference Manual. Index Index. .•! lachine code Minus . . . . Multiplication Negation . . 'lull string • . Numbers ♦ , Octal , . , . Offset . . . , Operands . . . Operators » Option .... or »'••»•• Output . , „ , Parameter , . . Parentheses . < Precedence . . PROG * . . . . Program structure Pead , . , . • Recursive . . References Registers . . relationships Replication , Return . . . Return code , Pout ine , . . Routine label 1-1, 4-1, 6-2 3-1 7-5 1-2 2-4 1-1 « 7-3 3-2, 7-3 2-1 5-1 1-2 4-5 to 4-6, 5-1 1-1, U-5 to 4-6, 6-2, 7-6 7-3 3-1 1-1 7-2 7-1 1-1, 6-? 4-1, 4-3, 5-1 to 5-2 2-1, 2-3, 7-1, 7-6 3-1 3-1 3-1 1-3 1-2 1-2 7-2 3-2 1-1, 3-1 2-4 3-2 5-1 4-3 3-1 to 3-2 3-1 to 3-2 7-1 6-1 5-1 4-3, 6-3 3-1 to 3-2 3- ■) 7-1 3-1 2-1 to 2-2 U-1 U-tt 2-3, a- 6 6-1 PF . , . . ■ ■ 7-a RS , 7-4 7-u 2-1 4-5 ®X • ,«... ...»t. Set. statement ..... . . i SI ... , .... ► 7-u 3S 7-U . 4-5, Statements * t 7-1 Subroutine . . , . . . ♦ , 4-3, 6-2 Subscript . . , .. . , . , 2-2, 3-1 3-1 Switch ........ • . 4-5 Switch expression - . . . , 4-5 Switch expressions * . , 4-5 ""rue » " < , 3-1 to 3 r !nit ...... ... . , • 2-1, 5-1 Write, . . * « 5-2 IIBLIOGRAPHIC DATA HEET . Title and Subtitle 1. Report No. UIUCDCS-R-77-875 PILOT/360 REFERENCE MANUAL Author(s) RAYMOND DOUGLAS ROHN Performing Organization Name and Address I Department of Computer Science University of Illinois at Urbana-Champaign Urbana, Illinois 61801 I Sponsoring Organization Name and Address Department of Computer Science University of Illinois at Urbana-Champaign Urbana, Illinois 61801 . Supplementary Notes 3. Recipient's Accession No. 5. Report Date JUNE 1977 6. 8. Performing Organization Rept. No. 10. Project/Task/Work Unit No. 11. Contract /Grant No. 13. Type of Report & Period Covered Technical Report 14. Abstracts PILOT/360 is a simple systems implementation language adapted for use on an IBM/360. It is designed for use as an aid in teaching the implementation of operating systems. Its major features include a generalized decision table and an embedded machine code facility. This report describes the use of the language along with its grammar. It is intended as a user's manual. I Key Words and Document Analysis. 17a. Descriptc Compilers Programming languages Machine-oriented languages Operating systems 5 Identifiers /Open-Ended Terms PILOT Systems implemetation languages Decision tables 7 COSATI Field/Group Btvailability Statement °1 NTIS-36 ( 10-70) 19. Security Class (This Report) UNCLASSIFIED 20. Security Class (This Page UNCLASSIFIED 21. No. of Pages 64 22. Price USCOMM-DC 40329-P7 1 v ::w AitU i Iu7u (SVvAl UNIVERSITY OF ILLINOIS-UflBANA 510.84 IL6R no. C002 no.874-879(1977 INDUCE 1 . »n interactive lnductl«« 1n1e 3 (V1 12 088403453