|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 178560 (0x2b980) Types: TextFile Names: »D107«
└─⟦2520239fd⟧ Bits:30005867/disk13.imd Dokumenter (RCSL m.m.) └─⟦this⟧ »D107«
\f T_I_M_E_F_O_R_B_R_U_G_ 80.03.24 SB 3.5 timer skrivning 80.03.25 SB 2.0 timer skrivning 80.04.17 SB 3.5 timer skrivning 80.04.18 SB 7.5 timer skrivning 80.04.22 SB 4.5 timer skrivning 80.05.05 SB 6.5 timer rettelser og skrivning 80.05.06 SB 3.0 timer rettelser og udskrivning 80.05.08 SB 5,0 timer rettelser og udskrivning 80.05.16 SB 875-, \f ALGOL Begin A/S Regnecentralen af 1979 January 1981 Information Department RCSL No 42-i1330 \f AUTHOR: Kjeld Christensen KEYWORDS: Textbook for education, ALGOL, BOSS, FP, administrative data processing. ABSTRACT: The book is a part of a series of textbooks covering fundamental education in computer science. This one is an introduction to the programming language ALGOL. The textbooks are used for teaching purposes at RC Com- puter, but are also well suited for self-tuition. \f i P_R_E_F_A_C_E_ After publishing an RC8000 basic software textbook it is quite natural that the next publication in Regnecentralens textbook series should deal with ALGOL, - because Algol is the main pro- gramming language at Regnecentralen. The language is based on the ALGOL60 report but is much extended in relation to this. This means, that where in general ALGOL has a reputation for being a programming language specially suited to arithmetical problems, and is also a language widely known in connection with articles in periodicals where it is generally used in the publi- cation of algorithms, the version of ALGOL used at Regnecentralen has reached the stage of development where it is a language very suitable for the solution of administrative problems also. This book describes the basic use of ALGOL and it will be fol- lowed by another textbook dealing with input/output handling using ALGOL amongst other things. Programmer Kjeld Christensen from Handelshøjskolens Datacenter in Århus is the author of the book. The good and constructive co-coperation shown by Kjeld Christen- sen in the work on this manual is much appreciated, and thanks must be given to Handelshøjskolens Datacenter for the positive attitude to the project. The book is meant to be used as part of a Regnecentralen course but at the same time is written with the aim that it can be used for self function. Thus suggested solutions are given to the examples in the textbook. It must be emphasized that this book is a textbook and not a ma- mual. That is, the book does not describe all the possibilities of the ALGOL language but on the contrary only a limited and ma- nageable selection. It is thus recommended that the student, as soon as possible after this book is studied, uses the relevant\f ii manuals in daily work so that one does not become too dependent on the textbook. If there are cases where one is in doubt the re- levant chapter in the textbook may be referred to. We hope that the users of this book will be as happy with it as we are at Regnecentralen. April 1979 A/S Regnecentralen \f iii T_A_B_L_E_ _O_F_ _C_O_N_T_E_N_T_S_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _P_A_G_E_ 1. INTRODUCTION .......................................... 1 2. PROBLEM DESCRIPTION ................................... 4 2.1 A File ........................................... 7 2.1.1 Construction .............................. 7 2.1.2 File Organisation ......................... 9 2.2 File Description ................................. 10 2.2.1 Record Description ........................ 11 2.2.2 Data List ................................. 13 2.3 Form Description ................................. 15 2.3.1 Format Sheet .............................. 15 2.3.2 Form Contents ............................. 16 2.4 A Programming Problem ............................ 17 2.4.1 Problem Description ....................... 17 3. CONSTRUCTION OF THE COMPUTER .......................... 24 3.1 Hardware ......................................... 24 3.1.1 Components ................................ 24 3.1.2 Working Store ............................. 26 3.1.3 Backing Store ............................. 29 3.1.4 Terminal .................................. 30 3.1.5 Reader .................................... 30 3.1.6 Punch ..................................... 30 3.1.7 Line Printer .............................. 31 3.2 Software ......................................... 31 3.2.1 The Operating System BOSS ................. 31 4. PROGRAMMING ........................................... 35 4.1 Primary Store Usage .............................. 36 4.2 Description of the Course of Action .............. 43 5. SOFTWARE .............................................. 52 5.1 LOGIN Routine .................................... 52 5.2 JOB .............................................. 53 5.3 Running a Job .................................... 55 \f iv T_A_B_L_E_ _O_F_ _C_O_N_T_E_N_T_S_ _(_c_o_n_t_i_n_u_e_d_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _P_A_G_E_ 5.4 Run Analysis ..................................... 57 5.5 BOSS Commands .................................... 59 5.5.1 JOB Interrupt ............................. 59 5.5.2 End Use of Terminal ....................... 60 5.5.3 Assignment of Line Numbers ................ 61 5.5.4 Editing ................................... 62 5.5.5 Printing .................................. 65 5.5.6 Job File Handling ......................... 66 5.5.7 Messages from BOSS ........................ 68 5.6 FP Commands ...................................... 69 5.6.1 Message from FP ........................... 70 5.7 ALGOL ............................................ 70 5.7.1 Calling ALGOL ............................. 73 5.8 Illustrative Run Examples ........................ 74 6. ALGOL ................................................. 78 6.1 Character Set .................................... 79 6.2 Identifiers ...................................... 80 6.3 Numbers .......................................... 82 6.4 Basic Symbols .................................... 83 6.4.1 Compound Symbols .......................... 91 6.5 Program Structure ................................ 92 6.5.1 Declarations .............................. 93 6.5.2 Statements ................................ 93 7. DECLARATIONS .......................................... 99 7.1 Simple Variable .................................. 99 7.2 Array ............................................ 101 7.3 Field Variable ................................... 104 7.4 Zone ............................................. 106 7.5 Procedure ........................................ 107 7.6 Uniqueness ....................................... 107 \f v T_A_B_L_E_ _O_F_ _C_O_N_T_E_N_T_S_ _(_c_o_n_t_i_n_u_e_d_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _P_A_G_E_ 8. EXPRESSIONS ........................................... 110 8.1 Arithmetic Expression ............................ 110 8.2 Logical Expression ............................... 113 8.3 String Expression ................................ 116 8.4 Multiple Choice Expression ....................... 118 8.5 Two-Way Choice Expression ........................ 119 9. STATEMENTS ............................................ 120 9.1 Unconditional Statement .......................... 122 9.1.1 Simple Statement .......................... 122 9.1.2 Compound Statement ........................ 125 9.1.3 Block ..................................... 126 9.2 Selection Statement .............................. 127 9.2.1 Conditional Statement ..................... 127 9.2.2 CASE Statement ............................ 132 9.3 Loop Statement ................................... 139 9.3.1 FOR STEP Statement ........................ 139 9.3.2 WHILE Statement ........................... 143 9.3.3 REPEAT Statement .......................... 144 9.3.4 FOR Statements ............................ 145 10. CHARACTER INPUT AND OUTPUT ............................ 147 10.1 Integer Procedure READCHAR ....................... 147 10.2 Character String ................................. 148 10.3 Integer Procedure READ ........................... 149 10.4 Integer Procedure WRITE .......................... 151 11. USE OF BACKING STORE .................................. 155 11.1 The Procedure OPEN ............................... 155 11.2 The Procedure CLOSE .............................. 156 11.3 Record Input and Output .......................... 156 11.3.1 Integer Procedure INVAR ................... 157 11.3.2 Integer Procedure OUTVAR .................. 158 \f vi T_A_B_L_E_ _O_F_ _C_O_N_T_E_N_T_S_ _(_c_o_n_t_i_n_u_e_d_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _P_A_G_E_ 12. COMMENTS .............................................. 161 12.1 COMMENT .......................................... 161 12.2 END .............................................. 161 12.3 Comment Brackets ................................. 162 13. PROCEDURES ............................................ 163 13.1 Construction ..................................... 165 13.2 Procedure Declaration ............................ 166 13.3 Procedure Call ................................... 166 13.4 Use .............................................. 167 14. PROGRAM DESIGN ........................................ 172 14.1 Problem Definition ............................... 172 14.2 First Stage ...................................... 173 14.3 Second Stage ..................................... 174 14.4 Third Stage ...................................... 176 14.5 Fourth Stage ..................................... 177 14.5.1 Calculate Groups .......................... 178 14.5.2 Calculate pct ............................. 179 14.5.3 Output Group .............................. 180 14.5.4 Terminate Group ........................... 180 14.5.5 Initialisation ............................ 181 14.5.6 Processing ................................ 181 14.5.7 Termination ............................... 183 14.6 The Last Stage ................................... 183 15. RECOMMENDED SOLUTIONS ................................. 187 A_P_P_E_N_D_I_C_E_S_: A. CHARACTER VALUES AND CHARACTER CLASSES ................ 201 B. SELECTED MESSAGES FROM BOSS ........................... 205 C. SELECTED MESSAGES FROM FP ............................. 209 \f vii T_A_B_L_E_ _O_F_ _C_O_N_T_E_N_T_S_ _(_c_o_n_t_i_n_u_e_d_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _P_A_G_E_ D. SELECTED MESSAGES FROM ALGOL .......................... 210 E. SELECTED MESSAGES FROM THE RUNNING PROGRAM ............ 213 F. INDEX ................................................. 215 \f viii \f 1_._ _ _ _ _ _ _ _ _I_N_T_R_O_D_U_C_T_I_O_N_ 1. The object of this book is to give a description of the program- ming language ALGOL, and to show its use particularly with the view of solving administrative problems. As the title ALGOL BEGIN infers the book is mainly for the use of readers without ALGOL programming experience. In the book the necessary concepts are presented in such a way that readers without any EDP experience can understand them. Naturally this means that those with programming experience must be prepared for a little revision, as the basic terms and the fundamental description tools must necessarily be introduced be- fore the actual description and use of the language. The book is based on a typical but somewhat simplified admini- strative problem and using this as a frame of reference various fundamental terms and some elementary definition methods are in- troduced. The concepts thus dealt with are closely related to the chosen example as it is not the intention to define a complete EDP terminology, but solely to introduce a few concepts which must be familiar before the work of programming can begin. Knowledge of the main principles in the contruction and operation of the computer is also necessary before a start on programming can be made. This subject is dealt with in chapter 3, also very concisely, the basis for treating the subject of the book. In chapter 4 the experience gained from chapters 2 and 3 is used to compose the first ALGOL program in the book. The basic structure of the language and of programs is thus introduced. All programs have a running-in phase, where the completed program is debugged, the syntactical and logical errors are removed, and the program functions as designed. This requires the use of a computer, thus chapter 6 contains guidance in the operation of the computer, solely concerned with the running-in of examples given in the book. It is assumed that the computer is equipped with the BOSS operating system, as is usual for RC4000 & RC8000. \f The loose ends are gathered in the following chapters. Chapter 7 contains a more rigorous description of the components of ALGOL. This description is not complete, dealing only with the most important elements of the language. The principle of treating only the most important concepts holds for the following chapters. These chapters contain syntax des- criptions for permitted constructions together with semantic descriptions which explain their meaning. The chapters deal with declarations, expressions, statements, input, output, and serial use of the backing store. The accompanying examples give the op- portunity to become familiar with the new concepts. Chapter 13 gives a very short introduction to procedures and the book is completed in chapter 14 by a short introduction to pro- gram design illustrated by an example. NOTATION The notation in the book is adopted from the ALGOL ma- nual ref. 1. The following symbols should be known: ::= the symbol is called a defining equality sign, and is used in definitions. The concept to be defined is placed on the left of the symbol, and the definition is placed on the right E_x_. <digit' ::= 0 1 2 3 4 5 6 7 8 9 A digit is defined as being a number in the range 0 to 9. The symbol is used as a separating character between several possibilities. See the previous example. \f < ' The symbol surrounds an explanatory text. E_x_. <number' ::= <integer' <real' The symbol contains a list of several possibilities. M_m_m_ E_x_. <integer' <number'::= P_p_p_ <real' Brackets may be supplied with a number which relates the number of times the element may occur E_x_. M_m_m_ + 1 14 <integer'::= - <digit' P_p_p_ 01 An integer may be signed. There must follow at least one digit and not more than 14 digits. \f 2_._ _ _ _ _ _ _ _ _P_R_O_B_L_E_M_ _D_E_S_C_R_I_P_T_I_O_N_ 2. For all problem solving, the problem must be described in such a way as to give all the necessary information. If the true rate of interest on a mortgage is to be calculated, the basic rate of interest and the exchange rate must be known as these are used in the calculation: true rate = basic rate x 100/exchange rate. The calculations may be carried out manually or on a computer as desired. If the latter, a program must be written which instructs the computer to execute the simple calculation. In this case the problem description must be more detailed as the program to solve the problem must naturally consist of the following three parts: 1. Reading in of the current and basic rates of interest. 2. Calculation of the true rate of interest. 3. Output of the result. To ensure the correct input of the rates of interest it must be previously defined in which order these numbers appear, how they are to be given - for example as reals or integers. Such details are defined in an input description, so-called. The user of the program also requires the input description to define which numbers are valid for the calculation. The calculation gives no speciel problems as the formula is known. To be of use the result of the calculation must be output in a readable form. The method to be used must also be defined as a number can be output in many ways. E.g. the number of decimal places should be given. A detailed description of the problem concerning the calculation of the true rate of interest can be completed without the use of special description tools (programs). It is quite another matter with most administrative problems where normally the input data as well as the output data is very elaborate. \f Even such a simple problem as the printing of a list of all the items in an item file makes big demands on the input and output description. The amount of detail necessary is dependent on the solution of the problem being manual or run on a computer. If the item file is kept on a card index, the list of records can be made manually and an experienced employee can solve the pro- blems despite the vague formulation of the problem. On the other hand if a less experienced employee is to carry out the work a more precise description of the problem is required, as problems will arise which an inexperienced employee cannot solve alone. Such as: Which data is to be put on the list? Where is this data found? A rough outline of the layout of the list answers the first question. E.g. the outline may be thus given: F_i_g_._ _2_._1_ ITEM REPORT I_T_E_M_N_O_N_A_M_E_I_T_E_M_N_O_N_A_M_E_ 1CPU7Core Store 17Line Printer1293Tape Punch 2047Tape Reader3011Terminal 3001Disc Store3500Print Board \f A copy of a card index card with the relevant data solves the second problem: F_i_g_._ _2_._2_ ITEMNO = 2047 NAME = TAPEREADER STOCK = 3000 ITEMS SALES JANUARY 200 MAY 375 SEPTEMBER 423 FEBUARY 10 JUNE 3000 OCTOBER MARCH 119 JULY 25 NOVEMBER APRIL 517 AUGUST 7 DECEMBER The problem description is still not detailed enough for a new employee, and problems such as the following will arise: How many lines to be written on each page. How much space to be allowed for an item no. How much space does an item name use. Where is the item card index. How are the cards ordered in the card index. These questions can be answered with an improved problem descrip- tion. An outline of the item report can be made which defines how much space the individual pieces of data may take, and the maxi- mum number of lines per page can be stated. A more detailed des- cription of the card index may be given stating position, con- tents and sequence. If the item file is stored using a computer, a computer must also be used to print the item report, and thus more demands are made on the program description. The computer which is to do the work is totally without intelligence and all problems must be solved before the task is handed over to it. Only by instructing (pro- gramming) it on what to do in all possible situations can the computer carry out the work. \f The programming work is treated in chapter 4. The basis for the programming work is a detailed problem description in the form of an input and an output data description. The input data for the print problem is the item file, and the next section deals with the concept of files in general, and an appropriate mode of des- cription is shown. Output data on paper, as shown in section 2.3, can be described using a format sheet. 2.1 2_._1_ _ _ _ _ _ _ _A_ _F_i_l_e_ 2_._1_._1_ _ _ _ _ _C_o_n_s_t_r_u_c_t_i_o_n_ 2.1.1 The item file discussed contains information about different items and for it to be of any use it is necessary that the infor- mation is always up to date, so that the file gives a correct picture of the situation. Each time there is a movement in the stock, either outflow or inflow, it must be noted in the item file. Data in the file must thus be stored so that it is easy to make amendments. This holds true for card index files as well as files only accessible via the computer. \f DATA Information found in a state where it can be dealt with is called data. FIELD Thus the item file is a collection of data concerning items. Each piece of information on a card in a card index has a fixed position. A position is usually cal- led a field. It is quite common to use the words field and information interchangeably so that there is no difference between the concept of a field and the in- formation it contains. RECORD A card index card exists for every item containing all the relevant information about the item. The informa- tion about the items is thus organised in such a way that logically coherent data is collected. Such a logical collection of data is called a record. KEY A special field exists to establish a unique correspo- FIELD dence between a record and the object it describes. This field is called key field or record number, as liked. In the item file the item number connects the record with the item. Ex. 2.1. An identification number connects uniquely a record in the identification file with a person. The special meaning of the key field makes it senseless to change just this field. FILE The collection of card index cards which constitute the item file can also be regarded as a collection of similar records. A reasonable file definition, also valid in connection with a file accessible via computer can now be formulated. \f A file is a collection of records. The connection between the different terms is shown more clearly by fig. 2.3. This shows that a file is made up of a collection of similar records. Each record contains a number of fields, and each field holds information. F_i_g_._ _2_._3_ F_I_L_E_ R_E_C_O_R_D_ F_I_E_L_D_ RECORD FIELD 1 INFORMATION 1 FIELD 2 FIELD 3 RECORD 2 RECORD 3 2_._1_._2_ _ _ _ _ _F_i_l_e_ _O_r_g_a_n_i_s_a_t_i_o_n_ 2.1.2 The cards which make up the item file may be sorted in different order, and that chosen defines the organisation of the file. The following possibilities seem equally suitable: Sorting after ascending item number order. Sorting in alphabetical order. \f In choosing the type of organisation it is important to take into account the most common use of the file, as the organisation de- fines the seeking methods which can be used when the file is to be utilised. Ex. 2.2 gives an illustration. E_x_ _2_._2_ Assume that the cards in the item file are ordered alphabetically using the item name, and the item report is to be printed in ascending item number order. Clearly the sorting order of the cards complicates the job of printing the item report. Many different storage methods, each catering for a different utilisation, have been developed for files accessible via a com- puter. It lies beyond the scope of this book to deal with these various methods, and in the book only serial files are used SERIAL In a serial file the records are stored according to the record number, usually in ascending order. Searching in the file can only be carried out by reading the records, starting at the first record and ending with the required record or the last record in the file. END It is difficult to determine when the last record in RECORD a computer stored file is found, as the records are not visible as in a card index file. Thus a special end record is inserted which serves to relate that there are no more records to be found. 2_._2_ _ _ _ _ _ _ _F_i_l_e_ _D_e_s_c_r_i_p_t_i_o_n_ 2.2 To use a file it must be known how the file is organised and how the records are constructed. If one is building a new system the file structure must be described as one quickly forgets details and the users need to know the system also. Incomplete knowledge of a system always results in many expensive misunderstandings. \f The necessity of a good description is made clear in the compre- hensive technical literature found on the subject. Instructions as to how a good file description is prepared may be found in the technical literature. To ensure that all relevant information is described a number of forms are designed. Thus a fairly good de- scription may be achieved by completing a number of forms. If it is a big system lots of forms have to be completed, and if it is a small system fewer forms are necessary. For small systems an adequate file description can be made using two different forms. Records are described using a record de- scription form, and all the data is described by a so-called data list. Both of these forms begin with a heading which should be completed to give the user, date of completion and in what connection the form was used. 2_._2_._1_ _ _ _ _ _R_e_c_o_r_d_ _D_e_s_c_r_i_p_t_i_o_n_ 2.2.1 This form is used to describe records. The fields in a record are numbered, and for each field is stated . Field no. . Field address . Field name . Reference to the data list . Comment, if required The fields in a record are numbered 1,2,3, etc. The field address gives the position of the field in the record. In a computer stored file a field address can be uniquely defined by an integer. This is more fully explained in chapter 4. A field is always named with a descriptive name so that it is immediately obvious what the field is used for. \f A reference to the data list is stated for each field, here the field is described in detail. If there is anything special to note a comment is made. F_i_g_._ _2_._4_ \f 2_._2_._2_ _ _ _ _ _D_a_t_a_ _L_i_s_t_ 2.2.2 All data found in the system is described on this form. For each item of data is stated: . Data name . Abbreviated name . Data type . Range of values . Data definition An item of data is given a name, and a description name should always be used, so that the data name makes it immediately obvious what the information is about. A descriptive name can be quite long, so for those people acquainted with the system an abbreviated name which they can use, is stated. There are two types of data, namely numerical information (num- bers) and alphanumerical information (letters and characters). It is important to distinquish between these two types of data as they are handled differently in the computer. Information regarding the range of values is also important, as this defines the space needed for storage in the computer and when the data is output. \f A complete description of the data is given in the data definition. F_i_g_u_r_e_ _2_._5_ \f 2_._3_ _ _ _ _ _ _ _F_o_r_m_ _D_e_s_c_r_i_p_t_i_o_n_ 2.3 To describe the output data a graphic description and a descrip- tion of the contents of the form are required. 2.3.1 2_._3_._1_ _ _ _ _ _F_o_r_m_a_t_ _S_h_e_e_t_ The form desired is entered on a format sheet, and thus it is possible to see where each item of information is to be written and how much space the information may use. F_i_g_u_r_e_ _2_._6_ \f 2_._3_._2_ _ _ _ _ _F_o_r_m_ _C_o_n_t_e_n_t_s_ 2.3.2 This form is used to describe forms. Each item of information is numbered, named and a reference to the data list is given. An additional comment may be given, if required. F_i_g_u_r_e_ _2_._7_ \f 2_._4_ _ _ _ _ _ _ _A_ _P_r_o_g_a_m_m_i_n_g_ _P_r_o_b_l_e_m_ 2.4 Assume that the item files previously referred to, exist on a RC8000 computer and an item report is required. To this end an ALGOL program is to be written. The remainder of this chapter contains a detailed problem description. The solution of the problem demands knowledge of the construction and action of the computer. This is dealt with in chapter 3, be- fore the problem can be actually tackled in chapter 4. 2_._4_._1_ _ _ _ _ _P_r_o_b_l_e_m_ _D_e_s_c_r_i_p_t_i_o_n_ 2.4.1 On the following pages the problem is described in detail using the four forms previously named. The item file, a serially stored file, is described using a record description form and a data list. The item report is entered on a format sheet, and each field is described individually on the appropriate form. \f RECORD DESCRIPTION\f DATA LIST\f DATA LIST\f DATA LIST\f FORMAT SHEET\f FORM CONTENTS\f 3_._ _ _ _ _ _ _ _ _C_O_N_S_T_R_U_C_T_I_O_N_ _O_F_ _T_H_E_ _C_O_M_P_U_T_E_R_ 3. To obtain full use of the computer a little knowledge of its function and components in necessary, both for programming and implementation of programs. 3_._1_ _ _ _ _ _ _ _H_a_r_d_w_a_r_e_ 3.1. The physical components such as wires and transistors are called hardware. 3_._1_._1_ _ _ _ _ _C_o_m_p_o_n_e_n_t_s_ 3.1.1 F_i_g_u_r_e_ _3_._1_ BACKING STORE HIGH READER WORKING STORE PRINTER MEDIUM TERMINAL TERMINAL PUNCH LOW COLUMN 1 COLUMN 2 COLUMN 3 \f The gereral outline of a computer in figure 3.1 shows that the working store is connected to several units from which or to which data may be transferred. The arrows show the possible di- rection. Thus data may be transferred from the reader in Column 1 to the working store whith data may be transferred in both directions between the working store and the units in Column 2. For the units in Column 3 data may only be transferred in one direction, namely from the working store. Regarding the horizontal division of the diagram it is seen that the units are grouped corresponding to the speed of which the data may be transferred. Distinction is made between low, medium, and high speed. CENTRAL The control of the activity of the computer is carried PROCESSOR out by the C_entral P_rocessor U_nit. The CPU is not shown in figure 3.1. CONFIGU- The size of the following store and the number of RATION peripheral units connected determine the configuration of the computer. The configuration may be altered as necessary, and figure 3.1 thus shows a possible confi- guration. \f 3_._1_._2_ _ _ _ _ _W_o_r_k_i_n_g_ _S_t_o_r_e_ 3.1.2 In the working store, often called the primary store, data to be processed as well as programs which control the processing, are kept. By a program is understood the instructions which state how the processing is to be executed. Chapter 4 describes how a program may be written. A program must be present in the working store in order that it may be executed. Data being processed must also be present in working store. SOFTWARE When the computer is working, one machine instruction at a time is read from the working store and the instruction is executed. There may be several programs with associated data in the primary storage simultane- ously (figure 3.2). Then, it is said, the computer is multiprogrammed. F_i_g_u_r_e_ _3_._2_ PRIMARY STORE PROGRAM A DATA A PROGRAM B DATA B CONTROL The CPU is not alone in controlling the program as a PROGRAM control program exists and shares this function. Such a control program is called an operating system. \f F_i_g_u_r_e_ _3_._3_ PRIMARY STORE CONTROL PROGRAM PROGRAM A DATA A PROGRAM B DATA B As the control function is a continous process, the operating system must be permanently active in the primary store, as ap- posed to other programs, which are only active in the primary store in the limited time taken to execute the individual program. DATA When data is to be transferred between primary store TRANSFER and a peripheral unit a so-called zone buffer is used. On transfer from a peripheral unit to primary store data is placed in the zone buffer where it is available for processing. A zone buffer is thus a part of the primary store which contains data for a program. On transfer from primary store to a peripheral unit the data to be transferred is placed in a zone-buffer, from which the transfer may be made. F_i_g_u_r_e_ _3_._4_ PRIMARY STORE PROGRAM DATA ZONE \f All this activity is carried out partly because the primary store is usually very limited, allowing only room for the data being processed, and partly because all information existing in the primary store disappears when the computer is turned of, for example by an electricity cut. WORD The primary store is divided into a number of equally large parts, called words. A word is exactly the amount of primary store which can hold a machine instruction. MACHINE A machine instruction is an order which the computer INSTRUC- can interpret and execute. Therefore a program consists TIONS of a sequence of machine instructions and when the program is run the individual instructions are executed in order. Data may also be placed in the primary store. All data does not take up the same amount of space, and depending on the type of data to be stored it may be held in a half word, a word, or a double word. \f The following table shows the space required: WORD USE RANGE Half Integer min -2048 max 2047 Whole Integer min -8388608 max 8388607 Machine Instruction Double Integer min -140737488355328 max 140737488355327 Alpha numeric 6 characters M_m_m_ 616 P_p_p_ Real number min -10 M_m_m_ 616 P_p_p_ max 10 A character may be a letter, a digit, or one of the other symbols found on a typewriter keyboard. 3_._1_._3_ _ _ _ _ _B_a_c_k_i_n_g_ _S_t_o_r_e_ 3.1.3 Data as well as programs are stored on backing store. There are different types of backing store. A common characteristic for all types is that the data is written on a magnetic material, so that information is kept even though the computer is switched off. Thus information is only deleted when it is overwritten by new data. As the processing of data is carried out in the primary store there are many data transfers between the primary and backing store. Connection is made by a high speed cable so that least time possible is used on data transfers. \f 3_._1_._4_ _ _ _ _ _T_e_r_m_i_n_a_l_3.1.4 Terminals may be used for both input and output. Input is made using a normal typewriter keyboard. Output appears on paper or on a screen (display) depending on the terminal type. A terminal may be connected with a fixed cable or via the telephone network. Transfer speed is defined by terminal type and mode of connec- tion. 3_._1_._5_ _ _ _ _ _R_e_a_d_e_r_3.1.5 The computer may be equipped with both a paper tape and a card reader. Input via one of these units is usually made where large amounts of data are concerned. For example it could be data amendments punched on normal registering apparatus. F_i_g_u_r_e_ _3_._5_ There are several punch codes for both cards and paper tape. The tape shown in figure 3.5, is punched in flexowriter code. 3_._1_._6_ _ _ _ _ _P_u_n_c_h_3.1.6 Data and programs stored in the computer may be produced on paper tape using a paper tape punch. One of the various punch codes is used as desired. \f 3_._1_._7_ _ _ _ _ _L_i_n_e_ _P_r_i_n_t_e_r_ 3.1.7 A large amount of administrative data processing consists of printing out file information in various ways. The material to be output is usually extensive thus output to a terminal would be too time-consuming. A line at a time is output on a line printer and thus data is output at quite a good speed. 3_._2_ _ _ _ _ _ _ _S_o_f_t_w_a_r_e_ 3.2 Programs are called software. Software consists of both control program and the other utility programs delivered with the com- puter. Programs written by the user (application programs) are also called software. Section 3.2.1 deals with the basic principles involved in using the control program and thus in using the computer. A more de- tailed description is given in chapter 5 with the sole aim of showing how to use the computer to run the demonstration pro- grams. 3_._2_._1_ _ _ _ _ _T_h_e_ _O_p_e_r_a_t_i_n_g_ _S_y_s_t_e_m_ _B_O_S_S_3.2.1 The computer to be used to run the demonstration problems, is expected to be supplied with the BOSS operating system. BOSS at- tends to tasks in the computer which may be compared to those tasks, attended to by a librarian in a library. A librarian lends out books to borrowers with a library card. If there are several borrowers who wish to borrow the same book, the librarian decides in which order the book is to be lent out. When a loan has been made, and the book is not back on time, the li- brarian must take action and see that the book is returned. Apart from attending to these administrative functions, the librarian must also act in an advisory capacity where necessary. The led- ning of the computer resources is administered by the operating system, BOSS. \f The resources which may be borrowed are the various units shown in figure 3.1. If a program is to be run the various units must be borrowed when output or such like is to be carried out. BOSS has at its disposal a little file containing the names of the legitimate users of the computer, as well as a list of code- words which must be declared before permission is granted. BOSS decides in which order the jobs at the computer are to be execu- ted. If a user exceeds his run time BOSS takes action and imme- diately recalls all the resources lent out, which means effecti- vely that the run is terminated. Queries may also be made to BOSS concerning the activity of the computer. E_x_e_r_c_i_s_e_ _3_._1_ State some resources which are administered by the operating system. DATA The operating system also carries out many service TRANSFER functions. A very important function is handling all the data transfers between the primary store and the other units. As stated previously, the data to be output to a peripheral unit should be put in a zone buffer, thereafter the operating system deals with the transfer to the correct position. The various positions to which the data may be transferred are defined by name. When the position is to be found on backing store AREA the name refers to an area. BACKING A user may borrow part of the backing store. The users STORE share may consist of one or more areas which are individually named. \f F_i_g_u_r_e_ _3_._6_ USER A AREA 1AREA 2 FREE AREA AREA 3 AREA 4 USER B Figure 3.6 illustrates the utilisation of the backing store by two separate users, and it can be seen that there is free area also. AREA NAME A name can have a maximum of 11 characters. The characters may be letters or numbers. The first character must always be a letter. E_x_e_r_c_i_s_e_ _3_._2_ Which of the following names are valid? storagefile31 storagefile itemfile a2 7b a162: monkey face SEGMENT Areas can have different sizes. The size is given in segments, a segment contains 128 double words. BLOCK Transfer between the primary store and the backing store is made in blocks, these contain an integral number of segments. Block size is determined by the size of the zone buffer. \f As an integral number of whole words is transferred simultaneous- ly to an area, an area contains an interrupted string of double words. In certain cases the words are solely made up of charac- ters, thus the area contains a character string. DOCUMENT A string of double words is called a document. Documents are supplied with names, the same rules must be followed as for area names. E_x_a_m_p_l_e_ _3_._1_ A string of characters is output to the paper on the printer, and this is called a document. A paper tape consists of a character string, and this is called a document. Thus an area is also a document. E_x_e_r_c_i_s_e_ _3_._3_ Data is to be transferred to an area on backing store. Which of the following block sizes may be used? 128, 256, 24, 368, 512, 917. PROGRAM Areas may contain many different types of information. NAME Perhaps an area may contain an employee file or a pro- gram. Area reference is always made with the help of the area name. When a program is stored in the area, the area name is called the program name. \f 4_._ _ _ _ _ _ _ _ _P_R_O_G_R_A_M_M_I_N_G_ 4. The foundation is now laid for the solution of the printing pro- blem stated in chapter 2. It remains to state the problem solu- tion so that it may be executed by the computer. This can be done using the programming language ALGOL, and it would be natural at this point in the book to give a detailed description of the language. Such a language description is in the meantime rather complicated, and here the decision has been made to introduce those elements of the language as they occur in the solution of the problem. Using this method the book is less formal and thus less detailed, but it is done in the hope that the subject matter may be more easily understood. There are many details in the printout, shown in figure 2.1, which complicate the problem solving, so in the first case let us simplify the result required so that the item report should only give the item number and name as shown in fig. 4.1 F_i_g_u_r_e_ _4_._1_ 1 CPU 7 Core Store 17 Line Printer 1293 Paper tape Punch 2047 Paper tape Reader 3011 Terminal 3101 Disc Store 3300 Print Board PROGRAM The problem is now to make a set of instructions which can tell the computer how to act. Such a set of instruc- tions is called a program and it must, down to the smallest detail, describe the following: \f . The use of the primary store by the program . Course of action 4_._1_ _ _ _ _ _ _ _P_r_i_m_a_r_y_ _S_t_o_r_e_ _U_s_a_g_e_ 4.1 The data to be processed must be present in the primary store during the processing, thus the item file records must be read into the primary store. For this purpose a zonebuffer is required as stated in section 3.1.2. Space in the primary store must also be reserved for various working variables, such as field addres- ses (see section 2.2.1). Halfwords, words, double words or a consecutive string of any of these may be reserved for data storage. A reserved entity is localised by the name, and this name must be stated on reserva- tion. Fig. 4.2 shows part of the primary store where a halfword, a word, and a double word are reserved under the names A, B and C. F_i_g_u_r_e_ _4_._2_ A B C Data may be held in a reserved element of the primary store. The word, B, for example, is used to hold the number seven. The num- ber is put in B using the ALGOL statement: b:= 7; DECLARATION Reservation of primary store is stated in ALGOL by means of a declaration. \f E_x_._ _4_._1_ integer b; The name B is declared to be of type INTEGER, which means that a word is reserved under the name B. In a declaration it must be stated which element type is to be reserved, and under which name the element is to be identified. E_x_._ _4_._2_ boolean a; A half word is reserved under the name A. TYPE The special word which defines the element type is cal- DECLARA- led a type declarator. INTEGER and BOOLEAN are examples TOR of this. IDENTI- The name which identifies the reserved element is cal- FIER led an identifier. A and B are examples of valid names. VARIABLE A reserved element is called a variable as it may be assigned various values during the run of a program. The name is called the variable name. Several variables may be reserved in the same declara- tion. E_x_._ _4_._3_ long a,b; Two double words are reserved, and the two variables are given the names A and B respectively. \f It is worth noting that there is no assignment of values in con- nection with declarations, and before a variable is used it is normally necessary to give it an initial value, e.g. 0. This can be done for the variables declared in ex. 4.3 using the following ALGOL statement: a:= 0; b:= 0; SIMPLE Variables which may be held by a half word, a word, or VARIABLE a double word are called simple variables. BOOLEAN variables may be assigned logical values (see section 8.2), INTEGER and LONG variables may be assigned various integer values as shown in the following table. TYPE RANGE BOOLEAN TRUE FALSE INTEGER Min. -8388608 Max. 8388607 LONG Min. -140737488355328 Max. 140737488355327 FIELD As stated when describing records, the individual VARIABLE fields could only be addressed using a word address. Addresses of this type are held in field variables. E_x_._ _4_._4_ integer field nr; A field variable with the name NR is declared. \f A field variable declaration is similar to an ordinary declara- tion except that the word FIELD is inserted after the type de- clarator. The type declarator determines whether the field de- fined by the field variable consists of a halfword, a word, or a double word. The assignment of a value to a field variable is expressed in a way corresponding to that for a simple variable. E_x_._ _4_._5_ integer field no; no:= b; ZONE As previously mentioned a zone buffer is required for the input of records from the item file. A zone buffer is declared using the declarator ZONE. It must naturally be named and various parameters must be stated. E_x_._ _4_._6_ zone item (128,1,stderror); Declarator Name Specification Using the zone specification it is possible to tailor the zone buffer to its current use. In the specification, enclosed by brackets, 3 items of data, separated by commas, are given. The first parameter defines the size of the zone buffer given in double words. The second parameter states whether the zone buffer is to be devided into shares. The third parameter is the name of the error routine to be used if something unexpected happens. The error routine will then give an explanatory message. The zone declaration shown in ex. 4.6 will be the most suitable for use in connection with the problems in this book. \f FIELD A field in a record read into a zone buffer, is acces- REFERENCE sed by referring to both the zone and that field vari- able which defines the required field. The two names are separated by a full stop. E_x_._ _4_._7_ Item.no FIELD A record fills an integral number of words in the zone ADDRESS buffer. These words contain the record fields, and to facilitate reference to the individual fields all the half words in the record are numbered in ascending order starting with 1. The field address is now defined by the number of the last half word in the field. E_x_._ _4_._8_ RECORD IN ZONE ITEM 1 2 3 4 5 6 7 8 9 10 11 12 13 14 zone item (128,1,stderror); integer field no; no:= 6; ITEM.NO will then define the field consisting of half word 5 and half word 6. VARIABLE The item name cannot be contained by one double word thus several must be used. A consecutive set of double words is called a variable set, and to state that the field consists of several double words the word ARRAY is added in the declaration of the field variable which defines the field. \f E_x_ _4_._9_ long array field name; The individual elements in the variable set are numbered 1, 2, 3, etc. and reference may be made to the variable set as a whole or to a chosen element. E_x_._ _4_._1_0_ zone item (128,1, stderror); long array field name; ITEM.NAME refers to the array as a whole. ITEM.NAME (1) refers to the first element. ITEM.NAME (2) refers to the second element. ITEM.NAME (3) refers to the third element. The field address of an array is determined by the number of the half word which is placed before the first half word of the first element. E_x_._ _4_._1_1_ RECORD IN ZONE ITEM 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 zone item (128,1,stderror); long array field name; name:= 6; \f The half words 7, 8, 9, and 10 make up the element ITEM.NAME(1). In the printout program it is necessary to have a zone buffer for record input and a field variable as a pointer for the two fields to be printed out. The field types are described in the data list section 2.2.2, and the declarations necessary can be made as shown below; note that declarations are separated by a semicolon. zone item (128,1,stderror); integer field no; long array field name; Three areas are thus reserved in the working store. A zone buf- fer, consisting of 128 double words, and two field variables each consisting of a word. Figure 4.3 illustrates this. F_i_g_u_r_e_ _4_._3_ WORKING STORE NO NAME ITEM STANDARD The item report is to be output to a terminal, and a ZONE zone buffer is to be used in this connection. Usually both input and output are required, therefore a zone- buffer for each of these functions is declared automa- tically. A zone thus declared is called a standard IN zone. The standard zone, IN, is used for input, and the OUT standard zone, OUT, is for output. OUT is used for the output of the item report. \f STANDARD Most programs need various working variables and just as standard zones may be declared so may standard variables, these may be used without further difficulty. The working store now appears as shown in fig. 4.4. F_i_g_u_r_e_ _4_._4_ WORKING STORE PROGRAM- DECLARED VARIABLES NO NAME ITEM STANDARD VARIABLES STANDARD ZONES IN OUT 4_._2_ _ _ _ _ _ _ _D_e_s_c_r_i_p_t_i_o_n_ _o_f_ _t_h_e_ _C_o_u_r_s_e_ _o_f_ _A_c_t_i_o_n_ 4.2 An initial analysis of the problem clarifies the course of action. The following must be executed: . Read a record from the item file. . Output the item number and item name fields. \f The above actions must be executed for each record in the item file, the end record excepted. The process may be further illustrated by a graph (fig. 4.5). F_i_g_u_r_e_ _4_._5_ READ 1 INITIALISATION 2 PRINTOUT 3 4 TERMINATION GRAPH A graph consists of several nodes, which are connected by edges. LINE NODE The edges are finished with arrows which show the direction to be taken in the graph. E.g. in the graph, fig. 4.5, the edge may be followed from node 1 to node 2 but not vice versa. Nodes in a graph symbolise states, while edges symbolise actions (activities). \f NODE The nodes in the graph shown in fig. 4.5 symbolise the following states: 1. start 2. Ready for output 3. Ready for input 4. Stop EDGE Each edge in fig. 4.5 is supplied with an explanatory text which describes the symbolised action. The edges in fig. 4.5 symbolise the following actions: . Initialisation . Input of a record . Output of item number and item name. . Termination The course of action described by the graph may be further illustrated by a run through of the graph. GRAPH The initial state is the START state. From this state RUN an edge leads to a new node. The action symbolised by THROUGH this edge is called INITIALISATION, and this consists of accessing the item file and reading the first record If the first record is an end record, which is theore- tically possible, an edge leads from node (2) directly to the last node (4), and the course of action is terminated. A more interesting path is followed when the first record is an actual item record. An edge symbolising the output of the required data then leads to node (3). There is only one exit from node (3) the edge symbolising the input of a record, this returns to node (2). Depending on the record input, one of two possible edges exitting from node (2) is chosen. The loop is repeated as long as item records are input and output and input are executed for each time round the loop. Exit is made from the loop only when the end record is read. \f INPUT A record may be read from the item file on the backing store using the following ALGOL statement. invar (item); INVAR INVAR is the name of a subroutine which carries out the input, and ITEM is the name of the zone which is to be used for input. A subroutine is activated by stating the name and an associated parameter list enclosed in brackets. In the parameter list for a procedure, as a subroutine is usually called, information may be trans- ferred to the procedure, just as information may be returned by the procedure, using the parameters. The records which may be input using INVAR must have a defined construction, the first four halfwords are reserved for internal data to be used by INVAR. Fig. 4.6 shows this: F_i_g_u_r_e_ _4_._6_ INTERNAL PART USER PART The internal part consists of two word-length data items. The first word contains the length of the record as a number of halfwords. The second word contains internal control data called a CHECKSUM. Actual data information makes up the user part, and this can vary in size from record to record. The item file is constructed so that all records are of fixed length. The presence of the internal part explains why the first user field has the field address 6, - cf. the record description. \f The output of the required data must be supplemented with printed information, and every time a record is output to the printer the following must be carried out: 1. Make a line change. 2. Print the item number 3. Print space 4. Print the item name The following activation of the output procedure WRITE executes all that is required: write (out,"nl",1,item.no,"sp",2,item.name); Procedure name zone line-feed item number space item name WRITE The procedure WRITE is entered by stating the procedure name followed by a list of parameters enclosed by brac- kets. The parameter list specifies the zone to be used for output and the data which is to be output. The in- dividual data items in the parameter list are separated by comma, and they are output in the order in which they occur. OUT The first parameter must always be the name of the zone which is to be used. In this case it is the standard zone, OUT. "NL",1 The next parameter begins with a boolean constant. Boolean constant indicate that a certain character is to be output, and following parameter determines how many times that character is to be repeated. \f The output of the constant "NL" causes a new-line char- acter to be output, and as the following parameter is the digit one, only one new-line character is output. ITEM.NO This parameter refers to the field which contains the item number, and this is output. "SP",2 "SP" is a boolean constant, and the following parameter determines the number of times that character is to be output. The output of the constant "SP" results in the output of a space. Thus two space characters are out- put. ITEM.NAME This parameter refers to the field which contains the item name, and the name is output. Program statements are executed in the order in which they are written, and the writing of the two statements invar (item); write (out, "nl",1, item.no, "sp",2, item.name); just as many times as there are records in the item file would give one solution to the printing out problem. LOOP A more realistic solution is obtained by expressing the loop in the graph, fig. 4.5, in a WHILE construction, and the graph is thus converted to the following program sequence: invar(item); while item.no < 4000 do begin write (out, "nl",1, item.no, "sp",2, item.name); invar (item); end; \f In the first statement in this program sequence, the first record in the item file is read in. The next statement is a WHILE statement. A WHILE statement begins with the word WHILE, which is followed by a condition. The value of this condition may be TRUE or FALSE, dependent on the item number in the record last input being less than 4000 or not. When the condition is true the sequential operator DO indicates the next statement to be executed. In this case the next statement is a compound statement consisting of the two well-known statements enclosed by the statement bracket BEGIN END. After the compound statement is executed the condition is reexamined, and the cur- rent value determines whether the compound statement is to be executed again. When the condition is false exit is made from the WHILE statement and thus from the loop, and the follwing state- ment in the program is executed. As the end record has item number, 4000, it is clear that the program sequence is a direct transformation of the loop in the graph, fig 4.5, to ALGOL statements. E_x_e_r_c_i_s_e_ _4_._1_ Assume that the following records exist in the item file. 10 transistors 17 diodes 209 print cards 4000 end record Use the outlined program sequence for this item file and state in detail what occurs. A few details are still required to complete the output program. The zone ITEM has to be connected the area on the backing store where the item file is kept, and it must be released after use. The required initiation of field variables can be easily managed as shown in examples 4.8 and 4.10. \f OPEN A zone is connected to a stated area of the backing store by using the procedure OPEN. The zone ITEM may be connected to the area ITEMFILE, where the item file is assumed to exist, by the following activation of OPEN: open (item,4,<:itemfile:',0); Procedure name Zone Backing store type Area name Error statement The backing store type determines to which unit the zone is to be attached. For disc storage, the only type used for the problems in the book, 4 is stated. The error statement is used when error routine, defined in the zone declaration, is activated. If the standard error is to be used, a zero is given as parameter, this will be sufficient for the solution of the problems given in the book. CLOSE The procedure CLOSE terminates the used of a zone, and the connected area is released. The use of the zone ITEM may be terminated with the following statement: close (item, true); Procedure Zone Release The last parameter in the procedure call may be used in various ways, amongst others when a zone is connected to a magnetic tape, TRUE must always be used in the solution of problems in this book. The output program may now be put together using the completed parts, it must be noted that the individual declarations and statements must be separated by semicolons, and the whole program should be contained in the brackets BEGIN END. \f begin integer field no; long array field name; zone item (128,1,stderror); open (item,4,<:itemfile:',0); no: = 6; name: = 6; invar (item); while item.no <4000 do begin write (out,"nl",1,item.no, "sp",2,item.name); invar(item); end; close (item,true); end \f 5_._ _ _ _ _ _ _ _ _S_O_F_T_W_A_R_E_ 5. The last part of the programming effect, where the program is to be debugged using test runs, demands knowledge of the software. This chapter describes the use of the software with debugging in mind. The following must be done: 1. Get permission to use a terminal. 2. Type in the problem the computer is to execute. 3. Make the computer execute the program. NOTATION In the illustrating examples a special notation is used, amongst other things to show whether a line has been typed in by the terminal user or has been output by the computer. X shows that an ATTENTION signal is to be sent. -' indicates that the line is typed in. Note that a line is not processed before the complete line is typed in and terminated with a new line character; this cannot be seen in the examples. 5_._1_ _ _ _ _ _ _ _L_O_G_I_N_ _R_o_u_t_i_n_e_ 5.1 Permission to use a terminal is obtained after a conversation with BOSS. This dialogue is called the LOGIN routine, and this may run as shown in ex. 5.1 E_x_ _5_._1_ X att -' boss type user name and project number -' kc 1234 in: 1978.09.03 11.04 \f From ex 5.1 it is seen that the dialogue with the computer is initiated by sending an ATTENTION message. The message is answer- ed by the output ATT, the user then types BOSS and a new line character, the BOSS operating system then asks for identification; the user replies with a codeword consisting of a name and a num- ber. These data items are separated by a space character. BOSS shows acceptance of the codeword by outputting the time of day, and the terminal is at the disposal of the user. A so called JOBFILE is also reserved for the user where the fol- lowing lines, which are to describe the project, are stored. 5_._2_ _ _ _ _ _ _ _J_O_B_ 5.2 A defined project which the computer is asked to execute is cal- led a job. The job, which can manage the running of the output program, may be typed in to the JOBFILE as shown in ex. 5.2. \f E_x_._ _5_._2_ -' 10 u=algol -' 20 begin -' 30 integer field no; -' 40 long array field name; -' 50 zone item(128,1,stderror); -' 60 no:= 6; -' 70 name:= 6; -' 80 open(item,4,<:itemfile:',0); -' 90 invar(item); -' 100 while item.no < 4000 do -' 110 begin -' 120 write(out,"nl",1,item.no,"sp",2,item.name); -' 130 invar(item); -' 140 end; -' 150 close(item,true); -' 160 end -' 170 u -' 180 finis LINE In ex. 5.2 each line begins with a line number which is NUMBER separated from the contents by a space, lines typed in in this fashion are stored in the JOB FILE in ascending line number order. If any typing errors occur it is not a catastrophe, as by using the line number it is possi- ble to access the lines which are to be amended, or perhaps completely altered. The editing possibilities are described in section 5.5.4. FP Apart from the output program (lines 20-160), the COMMAND typed-in job contains various directions (control cards), which tell the computer which programs are to be activated during the job run. \f A directive is called an FP Command as a special pro- gram FP undertakes the interpretation and execution of these commands. There are 3 FP commands in the job. The first (line 10) states that the ALGOL compiler is to be acti- vated and is to compile the typed program to machine instruc- tions. It is further stated that the compiled program is to be stored under name U. The second FP command (line 170) is the name of the compiled program, and by giving this name it is stated that the compiled program is to be run. The third FP command is FINIS, and with this command the FINIS program is activated, this informs BOSS that the job is to be terminated. The three FP commands are executed in the order they are stored in the JOB FILE, and the job thus consists of compiling the out- put program, running the compiled program and stating that the job has no more requirements. FP commands are further described in section 5.6 5_._3_ _ _ _ _ _ _ _R_u_n_n_i_n_g_ _a_ _J_o_b_ 5.3 A job, described in the JOB FILE, is brought to execution by asking BOSS to run the job. Requests to BOSS are made by typing in various commands. GO The GO command request BOSS to execute a job. \f E_x_._ _5_._3_ -' go finis kc0 at 13.02 The GO command is acknowledged with a message stating the likely time for the run of the job. SYNTAX go FUNCTION When the GO command is used, the job described in the JOB- FILE is entered to be run. As there may be several jobs entered, the new job is just inserted in the queue of jobs waiting to be run. Following a well-defined strategy, BOSS chooses from the job queue those jobs which are to be run first. Thus the small jobs with short run times are usually run first. On job entry, an expected time for the job to be terminated is calcu- lated, and output to the terminal user. The terminal keyboard is then locked, and the terminal may not be used to run other jobs before the entered job is run. JOB NAME A job name is run under a job name made up of a user name and an index. The job name is output in the reply to the GO command. In ex. 5.4 the job name is KC0. Ex. 5.4 shows the complete terminal conversation. \f E_x_._ _5_._4_ X att -' boss type user name and project number -' kc 1234 in: 1978.09.03 11.04 -' 10 u=algol -' 20 begin -' 30 integer field no; -' 40 long array field name; -' 50 zone item(128,1,stderror); -' 60 no:= 6; -' 70 name:= 6; -' 80 open(item,4,<:itemfile:',0); -' 90 invar(item); -' 100 while item.no < 4000 do -' 110 begin -' 120 write(out,"nl",1,item.no,"sp",2,item.name); -' 130 invar(item); -' 140 end; -' 150 close(item,true); -' 160 end -' 170 u -' 180 finis -' go finis kc0 at 13.02 5_._4_ _ _ _ _ _ _ _R_u_n_ _A_n_a_l_y_s_i_s_ 5.4 The entered job (ex. 5.4) produces various messages during its run, these are in the following given explanatory comments. 1 : begin output from 15: end the ALGOL compiler algol end 25 \f 9 transistors Output from the item file. 11 diodes 17 terminals 111 curcuits 900 power supply 1234 disc store 2345 tape station 3456 magnetic tape end 18 Final output from the out- put program. end 2 sec job kc0 Output from BOSS log opdate 1978.09.03 12.59 '' The output from the ALGOL compiler relates that the compilation is completed without error, and the compiled program fills 25 segments of backing store. The ALGOL compiler is described in section 5.7. The output from the item file is poor as regards layout, but this will be improved later. The run of an ALGOL program is always terminated with the message END XX. The number after END relates how many times a program segment has been transferred from backing store to main store. This number may be less than the total number of segments in the program, as it is only those segments required which are read in. A job is always terminated with a message from BOSS stating the run time and termination time. '' informs that the terminal is free for further use. \f 5_._5_ _ _ _ _ _ _ _B_O_S_S_ _C_o_m_m_a_n_d_s_ 5.5 A BOSS command is a directive to BOSS concerning the execution of a certain action. Such a directive must be typed in from a termi- nal. The GO command is an example of a BOSS command. There are many BOSS commands which a terminal user may type in, and in the following section only a limited number are dealt with. After a job is entered from a terminal the keyboard may not nor- mally be used until the job is completed. Permision to do so may be obtained by sending an ATTENTION signal. Ex. 5.5 X '' -' kill The ATTENTION signal receives the reply '', this states that a BOSS command may be typed. The KILL command is then typed. Typing of BOSS commands can cause various error messages to be output. There are many reasons for these, but the most common are elementary spelling mistakes and the invalid use of a command. Appendix B gives a list of the error messages which may arise from the use of the BOSS commands given in this book. 5_._5_._1_ _ _ _ _ _J_O_B_ _I_n_t_e_r_r_u_p_t_i_o_n_ 5.5.1 KILL A job may be stopped using the KILL command. E_x_._ _5_._6_ X '' -' kill Permission to type a KILL command is obtained \f by sending an ATTENTION message. SYNTAX kill FUNCTION When the KILL command is typed at the terminal the job that is entered from that terminal to the job queue administered by BOSS, is stopped. 5_._5_._2_ _ _ _ _ _E_n_d_ _U_s_e_ _o_f_ _T_e_r_m_i_n_a_l_ 5.5.2 LOGOUT The LOGOUT command states that the terminal is no longer required. E_x_._ _5_._7_ -' logout logged in 3 min operations 5 The LOGOUT command is typed and receives the following line in reply. SYNTAX logout FUNCTION The use of the LOGOUT command gives the following result: 1. The removal of an entered job, if any 2. All LOGIN areas are removed. (see section 5.5.6.3) 3. An explanatory message concerning the time and the scope of the use of the terminal is output. When this is completed the use of the terminal is terminated, and a new session at the terminal must be initiated with the LOGIN routine. \f 5_._5_._3_ _ _ _ _ _A_s_s_i_g_n_m_e_n_t_ _o_f_ _L_i_n_e_ _N_u_m_b_e_r_s_ 5.5.3 AUTOLINE If the AUTOLINE command is used BOSS creates and outputs line numbers. This saves typing line numbers. E_x_._ _5_._8_ -' autoline 10 -' u=algol 20 -' begin 30 -' integer field no; 40 -' long array field name; 50 -' zone item(128,1,stderror); 60 -' no:= 6; 70 -' name:= 6; 80 -' open(item,4,<:itemfile:',0); 90 -' invar(item); 100 -' while item.no < 4000 do 110 -' begin 120 -' write(out,"nl",1,item.no,"sp",2,item.name); 130 -' invar(item); 140 -' end; 150 -' close(item,true); 160 -' end 170 -' u 180 -' finis 190 -' X SYNTAX autoline FUNCTION After the AUTOLINE command is typed each of the follo- wing lines is assigned with a line number. The lines are numbered 10, 20, 30..., etc. The line num- ber is output concurrently with the typing in, and the terminal user thus does not have to type the numbers. Assignment of line numbers is concluded when an ATTEN- TION message is sent. \f 5_._5_._4_ _ _ _ _ _E_d_i_t_i_n_g_ 5.5.4 It is nearly impossible to work at a terminal without making errors. Perhaps a word may be misspelt or a line forgotten. Various amendment facilities exist to correct such errors. 5_._5_._4_._1_ _ _ _D_e_l_e_t_i_o_n_ 5.5.4.1 A delete character may be used when an error is discovered while typing a line. BACKSPACE or RUBOUT deletes the last character (RUBOUT is eccoed as , BACKSPACE deletes the last character). A press on CTRL + E at the same time delets the whole line (CTRL + E is eccoed as ). E_x_._ _5_._9_ u=alf gol f is deleted. u=alf u=algol the line is deleted and rewritten. The delete symbol may be used several times in succession, and the characters in the line are successively deleted from right to left. E_x_._ _5_._1_0_ u=fortran algol fortran is deleted. 5_._5_._4_._2_ _ _ _A_m_e_n_d_m_e_n_t_ _C_o_m_m_a_n_d_s_ 5.5.4.2 It is possible . to insert . to delete . to modify lines in the JOB FILE. \f Each line in the JOB FILE is supplied with a line number. When typing, the line numbering may be chosen freely by the terminal user. The lines are stored in ascending line number order regard- less of the order in which they were typed. INSERT The typing of the job in example 5.2 consisted of inserting a set of lines into an empty JOB FILE. Thus new lines are inserted by typing the line number and the contents of the line, separated by a space. E_x_._ _5_._1_1_ 35 invar(item); If a line with the given line number already exists, the newest version of the line will replace the original line. E_x_e_r_c_i_s_e_ _5_._1_ Define the contents of the JOB FILE after the following input has been made: 10 p=algol 20 integer sum,a,b; 30 write(out,sum); 15 begin 40 end 10 u=algol list.yes 25 read(in,a,b); 26 sum:=a+b; Insert an empty line immediately after line 10. DELETE The typing of a line number alone causes that line to be deleted in the JOB FILE. \f E_x_._ _5_._1_2_ 40 MODIFY A line may be modified, and the following must then be stated: . the line number, . the characters (the graphical picture) which are to be replaced, . the new graphical picture to be inserted. The data must be separated by the same delimiter. Naturally the delimiter must not be found in either graphical picture. E_x_._ _5_._1_3_ 50 name: =6; 50/: =/:=/ The graphical picture >: => is replaced by >:=> in line 50. / is used as delimiter. The graphical picture first stated is searched for, from left to right. The first time it is met the correction is made, and the modification executed. DELIMITER A delimiter may be chosen freely with the following restrictions: 1. A space following immediatly after the line number causes the whole line to be inserted, thus a space may not be used as a delimiter. 2. The delimiter must not occur in the graphical pictures. / > " are given as examples of separators. \f E_x_e_r_c_i_s_e_ _5_._2_ The JOB FILE used in exercise 5.1 is to be altered so that the variable name A, whereever it occurs, is to be replaced with SALE. 5_._5_._5_ _ _ _ _ _P_r_i_n_t_i_n_g_ 5.5.5 The whole or part of the JOB FILE may be printed using various commands. 5_._5_._5_._1_ _ _ _V_e_r_i_f_y_ 5.5.5.1 The line last typed or modified is printed using the VERIFY com- mand. E_x_._ _5_._1_4_ verify A chosen line may be printed by adding the line number. E_x_._ _5_._1_5_ verify 10 A limited group of lines may be printed, by adding the number of lines to be output. E_x_._ _5_._1_6_ verify 10 4 line 10 plus the 3 following lines are output. 5_._5_._5_._2_ _ _ _L_i_s_t_ 5.5.5.2 The whole of the JOB FILE may be output using the LIST command. \f E_x_._ _5_._1_7_ list If a line number is added then the specified line plus all the lines with a greater line number will be output. E_x_._ _5_._1_8_ list 30 A group of lines may be printed out by stating the lower and upper limits for the group. E_x_._ _5_._1_9_ list 30 97 5_._5_._6_ _ _ _ _ _J_o_b_ _F_i_l_e_ _H_a_n_d_l_i_n_g_ 5.5.6 An area on the backing store may be reserved for the JOB FILE by using the GET command. The area is then called a BASIS FILE. The CLEAR command frees a BASIS FILE, the area then being returned to normal status. The contents of the JOB FILE may be copied to an area using the SAVE command. 5_._5_._6_._1_ _ _ _G_E_T_ 5.5.6.1 E_x_._ _5_._2_0_ get text The area TEXT is transferred to the JOB FILE. SYNTAX get <area name' \f GET An existing basis file, if any, is released, and the specified area is made a BASIS FILE, thus causing the contents to be transferred to the JOB FILE. The lines are numbered, 10, 20, 30 ..., etc. 5_._5_._6_._2_ _ _ _C_L_E_A_R_ 5.5.6.2 E_x_._ _5_._2_1_ clear The contents of the JOB FILE are erased, and a BASIS FILE, if it exists, is released. SYNTAX clear CLEAR The contents of the JOB FILE are erased and a BASIS FILE, if it exists, is released. 5_._5_._6_._3_ _ _ _S_A_V_E_ 5.5.6.3 E_x_._ _5_._2_2_ save rctext The JOB FILE is transferred to the area RCTEXT. SYNTAX save <area name' SAVE The contents of the JOB FILE are transferred to the backing store to an area with the specified name. If a LOGIN area with this name exists, the contents are transferred to this area. If not, a new LOGIN area with the name given is created, and the contents are trans- ferred. A LOGIN area is saved until the terminal user removes it, perhaps by using the LOGOUT command. When a LOGIN area is a BASIS FILE, the contents of the JOB\f FILE will be erased after transfer back to the BASIS FILE with the SAVE command. The last command in the series get rctext save rctext save rctext thus transfers an empty JOB FILE back to RCTEXT, and the original contents have disappeared. 5_._5_._7_ _ _ _ _ _M_e_s_s_a_g_e_s_ _f_r_o_m_ _B_O_S_S_ 5.5.7 The conversation with BOSS concerning terminal use, editing, JOB FILE handling and job control can give rise to various unexpected messages from BOSS. The reasons are many, but the most common are probably spelling mistakes and wrong use of BOSS commands. A selection of the messages output by BOSS masy be found in appendix B. 5_._5_._7_._1_ _ _ _N_O_ _R_O_O_M_ 5.5.7.1 The messages NO ROOM occurs when there is no capacity to make further amendments to a JOB FILE. To proceed the JOB FILE must be transferred to the backing store, and the area used converted to BASIS FILE. This capacity problem may be solved by using SAVE and GET commands, and further corrections may be made. The command which gave rise to the message has not been executed, and must thus be repeated. When the VERIFY command is used immediately after a GET command, the line number of the last line in the JOB FILE is output. If NO ROOM appears when typing, the VERIFY command thus ensures, in a simple way, the further input, as shown in the following: \f . . . -' 136 begin -' 137 integer no room -' save rcjob -' get rcjob -' verify 510 -' 510 integer . . . 5_._6_ _ _ _ _ _ _ _F_P_ _C_o_m_m_a_n_d_s_ 5.6 JOB requirements are expressed in JOB FILE with the aid of FP commands. A program is activated by an FP command, and at the same time parameters may be transferred to the program. E_x_._ _5_._2_3_ u=algol list.yes Call of the ALGOL compiler, accompanied by control parameters. E_x_._ _5_._2_4_ u u data p=algol txt list.yes bossline.yes Various FP commands. M_m_m_ 1 1 SYNTAX <name' = <programname' <parameter list' P_p_p_ 0 0 Names may consist of at most 11 characters (letters/digits). The first character must be a letter. \f FUNCTION The specified program is activated, and any control parameters are made available to the program. 5_._6_._1_ _ _ _ _ _M_e_s_s_a_g_e_ _f_r_o_m_ _F_P_ 5.6.1 FP commands are read and interpreted by the FILE PROCESSOR pro- gram, FP. When FP reads an erroneous FP command, one or more error messages are output, these are often accompained by an explanatory text, informing where the command in question was input. E_x_._ _5_._2_5_ *** FP SYNTAX TESTPROGRAM1 * READ FROM PRIMARY INPUT The first message states that there is a syntax error in the name TESTPROGRAM1, and the second states that the command was read on PRIMARY INPUT, i.e. JOB FILE. Appendix C contains some of the messages output by FP. 5_._7_ _ _ _ _ _ _ _A_L_G_O_L_ 5.7 COMPILER is the name of both the programming language and the ALGOL program which can translate an ALGOL text and compile a program in machine instructions. This section deals with the program ALGOL or the ALGOL compiler, as it is called. A program written in ALGOL cannot be run as it stands, as the computer can only execute machine code. Before it is run the program must be transformed into a series of machine instruc- tions. \f SYNTAX When the ALGOL compiler is working, a source text ERRORS composed of a series of letters and numbers, e.g. the output program, is read. Compilation can only be made correctly if the source text is written according to the defined rules. Syntax errors occur when these rules are broken, and under compilation any error is noted and a message output. An error message states when and where the error occurs as well the type of error. E_x_._ _5_._2_6_ Assume that line 70 in the output program is, by mistake, written thus: 70 name = 6 Compilation of the program will give the following error message: 6. LINE 6.1 DELIMITER When Where Error type When The compilation is executed with several passes, and the first number in the error message relates in which pass the error was discovered. Where The information consists of a line number followed by an operand number, which gives the position in the line. Under compilation each line is given a number, and it is this number which is used in the message. \f Error There are various error types. DELIMITER in ex. 5.26 type means that the delimiter = is placed incorrectly. It should have been :=. Appendix D contains a selection of the messages from the ALGOL compiler. LOGICAL Even if the compilation is completed successfully, ERRORS there may still be errors. These are the logical errors caused by a badly designed program. An incorrectly de- signed program can come to the stage where the run must be abandoned. An error message will be output stating why, and where in the program, the program was aban- doned. E_x_._ _5_._2_7_ 10 u=algol 20 begin 30 integer field no; 40 long array field name; 50 zone item(128,1,stderror); 60 no:= 6; 70 name:= 6; 90 invar(item); 100 while item.no < 4000 do 110 begin 120 write(out,"nl",1,item.no,"sp",2,item.name); 130 invar(item); 140 end; 150 close(item, true); 160 end 170 u 180 finis A run of the familiar job where line 80 is absentminded- ly omitted, will give the following error message. \f ZONE STATE 4 INVAR CALLED FROM LINE 6-7 It is obvious that the error is caused by the zone not being connected to the item file. Appendix E contains some of the messages output while the program is being run. 5_._7_._1_ _ _ _ _ _C_a_l_l_i_n_g_ _A_L_G_O_L_ 5.7.1 The ALGOL compiler may be activated in several ways, and thus it is possible to control the input as well as the output. E_x_._ _5_._2_8_ u=algol u=algol source object=algol source list.yes bossline.yes M_m_m_ 1 SYNTAX <object name'=algol <source name' P_p_p_ 0 M_m_m_ 1 1 list.yes bossline.yes P_p_p_ 0 0 The syntax given shows just a few of the possibilities for trans- ferring parameters which can influence execution. <object name' Defines the name of the compiled program. <source name' When this data is given, the ALGOL text is read from\f the area with the stated name. Where no name is given the ALGOL text must occur immediately after the ALGOL activation. LIST.YES When this parameter occurs the source text is output during the compilation. Each line starts with an as- signed line number thus facilitating the location of errors. BOSSLINE.YES This parameter causes the lines to be output with a supplementory line number which may be used when edi- ting with BOSS. 5_._8_ _ _ _ _ _ _ _I_l_l_u_s_t_r_a_t_i_v_e_ _R_u_n_ _E_x_a_m_p_l_e_s_ 5.8 Runs of the exercises in the book may be executed as shown in example 5.4. Though sometimes it may be easier to put the runs through in a different way. Many program tools exist, of which the following will be discussed: O Using the O program, the output data may be redirected to an area on the backing store. CONVERT Using the CONVERT program, an area may be output to the printer. SET An area is created using the SET program. In the example BEGIN ..... END defines an arbitrary ALGOL text. \f E_x_._ _5_._2_9_ Separation of the program text and FP commands. 10 begin 20 end save text clear 10 u=algol text line.yes bossline.yes 20 u 30 finis The ALGOL text is typed in and stored in the area TEXT. Then the contents of the JOB FILE are deleted, and various FP commands typed in. The ALGOL call states that the sourcetext is to be found in the area TEXT, and that output is to be made during the compilation so that each line is supplied with two line numbers. The first line number may be used for a subsegment editing using BOSS, while the second is used in connection with error messages from ALGOL. The separation of the ALGOL text and FP commands results in the first set of line numbers corresponding exactly with the line numbers assigned when the ALGOL text is transferred to the JOB FILE by the GET command. E_x_._ _5_._3_0_ It can be an advantage to save the FP commands on the backing store if several runs are to be made. 10 begih Type in the program. 20 end save text Save program. clear Delete JOB FILE. \f 10 u=algol text Type FP commands. 20 u 30 finis save command Save FP commands. go Book the job. . . . . . . Wait run results. get text Fetch ALGOL text. 10/begih/begin Correct ALGOL text. save text save edited text. get command Fetch FP commands. go Book job. E_x_._ _5_._3_1_ Using SET, O, and CONVERT it is possible to redirect output data from a job so that it is printed out on the printer. 10 outfile=set 200 An area of 200 segment is reserved for output. 20 o outfile Output is redirected to OUT- FILE 30 u=algol text list.yes 40 u 50 o c Output directed back again, thus terminating the use of OUTFILE 60 convert outfile OUTFILE output on the printer 70 finis The data redirected consists of output from ALGOL, any error messages from the running program as well as data output to the standard zone OUT. \f E_x_._ _5_._3_2_ Input which is read using the standard zone IN, is normally read from the JOB FILE. 10 u=algol text 20 u 30 1 2 40 3 4 50 finis The program u requires 4 numbers, and these are stated immediately after the call of the program. E_x_._ _5_._3_3_ The input of data using the standard zone IN can be re- directed by altering the call of the program. This is done by stating the name of the data area immediately after the program name. 10 1 2 Type input 20 3 4 save data Save in area DATA clear 10 u=algol text 20 u data Call of program so that input taken from DATA 30 finis \f 6_._ _ _ _ _ _ _ _ _A_L_G_O_L_ 6. The output program was written using the familiar characters found on a typewriter keyboard. Those characters which may appear in an ALGOL program are dealt with in this chapter, also the com- bination of characters into symbols, number constants, and names. The construction of declarations, expressions, and statements using the symbols, numbers, and names is also dealt with, but not exhaustively as a detailed explanation is given in the following chapters. This chapter ends with the last step in the language description, namely the construction of programs using statements and declarations. NOTATION The language description is simplified by using a special notation. Definitions are described with the aid of a so called defining equality sign ::=. <concept'::= <definition' In definitions the various possibilities are separated by vertical stroke. E_x_._ _6_._1_ <digit'::= 0 1 2 3 4 5 6 7 8 9 A digit is defined to be one of the symbols which ap- pear to the right of the defining equality sign. A choise between several possibilities may also be shown by sta- ting the possibilities in a column enclosed by brackets. E_x_._ _6_._2_ <integer' <number'::= <real number' A number is defined to be either integer or real. \f When an element may be repeated, it is defined by repetition statement on the brackets. E_x_._ _6_._3_ M_m_m_ 1 14 <integer'::= + <digit' P_p_p_ - U_U_U_ 0 1 The definition shows that an integer may be signed, and must consists of at least one digit and at most 14 digits. 6_._1_ _ _ _ _ _ _ _C_h_a_r_a_c_t_e_r_ _S_e_t_ 6.1 The following characters may be included in an ALGOL-program: a b c d e f g h i j k l m n o p q r s t u v w x y z æ ø å A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Æ Ø Å 0 1 2 3 4 5 6 7 8 9 = - * / < ' = . , > : ; ( ) <SP' <NL' <FF' - & ! " % ? \f Some symbols cannot be represented graphically, and a special notation is used to designate these characters. <SP' space. <NL' new line. <FF' form feed. The individual characters are separated by a vertical stroke and grouped as letters, digits, basic characters and graphic charac- ters. The characters are used to create indentifiers, numbers, basic symbols, strings, and to separate the various elements. 6_._2_ _ _ _ _ _ _ _I_d_e_n_t_i_f_i_e_r_s_ 6.2 In connection with the use of working storage it is necessary to declare indentifiers to define the working storage areas (see 4.1). Procedures (see 4.2) are also defined by names. Names in ALGOL must obey the following syntax: M_m_m_ N <letter' <name'::= <letter' <digit' P_p_p_ 0 The syntax definition shows that a name must begin with a letter, which may be followed by an arbitrary number of letters and digits in no definite order. \f E_x_._ _6_._4_ The first column consists of various valid names while the second column contains only invalid names. a 9 b2 2b abekat G=7 a99k vat-month paymentofwages payment of wages E_x_e_r_c_i_s_e_ _6_._1_ Find the errors in the invalid names in 6.4. The last name in the first column in ex. 6.4 is rather difficult to read unhappily so, as the advantage of having explanatory and easily read names cannot be disconnected. A name may not contain a space character but an underline character, _ , may be used. This character may be placed between any two characters in the name. E_x_._ _6_._5_ payment _of _wages _ serves only to help the legibility of a name, and has no significance from a programming viewpoint. When choosing a name it must be remembered that various character combinations are reserved for special purposes. A name is terminated by <SP', <NL', <FF', or one of the delimi- ters described in section 6.4 \f 6_._3_ _ _ _ _ _ _ _N_u_m_b_e_r_s_ A distinction is made between integers and reals. <integer' <number'::= <real' An integer must obey the following syntax. M_m_m_ 1 14 <integer'::= + <digit' P_p_p_ - 0 1 E_x_._ _6_._6_ +1 -1 +01 0987 88 17 9 -8 000 000 97 Ex. 6.6 shows that it is valid to separate digits with a space for better logibility. 6.3 A real number consists of a decimal number which may be followed by an exponent part. M_m_m_ 1 <real number'::= <decimal number' <exponent part' P_p_p_ 0 A decimal number must obey the following syntax: M_m_m_ 1 k 14-k <decimal number'::= + <digit' .<digit' P_p_p_ - 0 1 1 The exponent part states a power of 10, and the following syntax must be obeyed: M_m_m_ 1 3 <exponent part'::= > + <digit' P_p_p_ - 0 1 E_x_._ _6_._8_ M_M_m_ 2 P_P_p_ 5.7>2 represents the value 5.7* 10 = 570.0 \f 6_._4_ _ _ _ _ _ _ _B_a_s_i_c_ _S_y_m_b_o_l_s_ 6.4 A basic symbol may consist of a single character or of a group of characters. The basic symbols are divided into 4 groups: <letter' M_m_m_ <digit' <basic symbol'::= P_p_p_ <logical value' <delimiter' LETTER A letter is defined in exact agreement with the grouping of the character set in section 6.1. <letter'::= a b c d e f g h i j k l m n o p q r s t u v w x y z æ ø å A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Æ Ø Å By definition is meant that a letter may be one of the characters in the list on the right of the defining equality sign. DIGIT A digit is similarly defined in exact agreement with the character set grouping, thus: <digit'::= 0 1 2 3 4 5 6 7 8 9 Letters and digits are included in variables, amongst other things, as shown in section 6.2. As individual characters they do not normally have any significance. Single digit numbers and single letter indentifiers are the exception. LOGICAL The third group of basic symbols is the logical values. VALUE Logically a statement may have the value true or the value false. \f The relation >item.no < 4000> in the printout program could thus be true or false. A logical value is defined thus: <logical value'::= true false TRUE and FALSE represent the values true and false. A number of boolean constants may be used by writing individual characters. <boolean constant'::= "<character symbol'" DELMITER The fourth group of basic symbols is a motley selection which may be subdivided using the following definition: <operator' M_m_m_ <separator' <delimiter'::= P_p_p_ <parentheses' <declarator' OPERATOR In a common arithmetic expression such as 10 + 5*7 two operators exist, + and *. There is no doubt as to what the expression means, and that the value of the expression is 45. To be able to calculate the expression it is necessary to know the operations which the operators symbolise, as well as to know the order of operation. It is not insignificant if the addition is executed then the multiplication or vice versa. Operators for various uses exist in ALGOL. \f <arithmetic operator' <relational operator' <operator'::= <logical operator' <sequetial operator' ATITHMETIC Arithmetic expressions may be included in ALGOL OPERATOR programs, and the usual arithmetic operators may naturally be used. The denifition below shows the most common. <arithmetic operator'::= + - * ** / // mod +, - and / have their usual meaning. * multiplication sign ** to the power of // integer division mod the calcutation of the remainder on integer devision. E_x_._ _6_._9_ 7*5 = 35 10 ** 2 = 100 101 // 10 = 10 101 mod 10 = 1 The operators // and MOD may not be used in connection with real numbers. Arithmetic expressions in ALGOL programs are calculated using the same rules as normal arithmetic expressions. The operators have the following precedence. 1. ** 2. * / // mod 3. + - \f E_x_e_r_c_i_s_e_ _6_._2_ Calculate the value of the following expression: 7-8*10/2+3 RELATIO- The relational operator < has already been used in the NAL printout program. This operator was used to compare two OPERATOR numbers, namely the value of the field, ITEM.NO, and the constant 4000. The result of the comparison may be true or false. That is, a logical value, represented in ALGOL by TRUE or FALSE. <relational operators' ::= < <= = '= ' <' The operators have the following significance: < less than <= less than or equal to = equal to '= greater than or equal to ' greater than <' not equal to E_x_e_r_c_i_s_e_ _6_._3_ Put a cross in the correct column. RELATION TRUE FALSE 5 < 7 6 ' 80 7 <= 2 5 <' 5 9 '= 5 + 4 2 = 7 - 5 \f LOGICAL A logical operator may be used in a logical expression, OPERATOR that is an expression which takes the value TRUE or FALSE. A relation is an example of a logical expression. The definition below includes the 3 most common logical operators. <logical operator'::= -, and or E_x_._ _6_._1_0_ item.no ' 2000 and item.no < 3000 The logical expression has the value TRUE when the item number is greater than 2000 and less than 3000. The significance of the three operators is shown in the following diagram. p true true false false q true false true false NEGATION -, q false true false true CONJUNCTION p and q true false false false DISJUNCTION p or q true true true false Logical operators and expressions are often called boolean operators and expressions after the English mathematican, George Boole, who founded symbolic logic. SEQUEN- In the printout program DO was used to select the next TIAL statement: OPERATOR while item.no < 4000 do begin write(out,"nl",1,item.no,"sp",2,item.name); invar(item); end; \f An operator which selects the next statement or the next expression, is called s sequential operator. <sequential operator'::= if then else case of for do repeat goto All these operators are explained in detail in the following chapters. SEPARATOR In the printout program the individual declarations and statements are separated by semicolons, and the parameters in procedure calls are separated by commas. There are many different separators. <separator'::= , . > : = := ; while step until comment <FF' <NL' <SP' The last separators, those which do not have a graphic picture, differ from the others in that an arbitrary number of these se- parators may be used in those positions where such separators are allowed. This facility was used in the printout program to make the program legible by beginning several lines with spaces, and by inserting blank lines (see section 4.2). It is also valid to surround the separators , : ; := with an arbitrary number of spaces and line feeds. The usage of the various separators will be clarified in the order in which the necessity of using them occurs in the \f following chapters. BRACKETS In normal arithmetic expressions brackets may be used to alter the order of calculation. The same is possible in ALGOL programs. There are several different kinds of brackets in ALGOL, these are defined below: <brackets'::= begin end ( ) <: :' << ' <* *' BEGIN END is called a statement bracket and is used to bracket statements in a program. The statement brackets was used in the output program to create a compound statement, similarly the whole program must be enclosed in a statement bracket. () is used in expressions, declarations, procedure calls, and on reference to elements in an array. E_x_._ _6_._1_1_ (7 + 9)/3 zone item(128,1,stderror); invar.name(1); <: :' is solely used to enclose a text string. E.g. this could be the name of an area: open(item,4,<:itemfile:',0). << ' is used to enclose a layout. When printing, a layout string states the graphical picture required. This facility should be used in the output program. \f E_x_._ _6_._1_2_ <<dddd' In the layout string a d is given for each digit position required to be output. <* *' is used to enclose a comment which is directed only to someone reading the program. The characters thus enclosed have therefore no significance in relation to the program. E_x_._ _6_._1_3_ <*this is a meaningless comment*'. DECLARATOR Declarators are used in declarations. <declarator'::= boolean integer long real array field zone procedure Declarators are discussed in chapter 7. \f 6_._4_._1_ _ _ _ _ _C_o_m_p_o_u_n_d_ _S_y_m_b_o_l_s_ 6.4.1 The basic symbols in the following list are called compound. In an ALGOL program a compound symbol must always be separated from the previous and the following letters and digits. This can be done using <SP' <NL' or another delimiter which is not it self a compound symbol. The compound symbols may not be used as identi- fiers. Several of the symbols in the list will be discussed in more detail in the book, but all the symbols shown should be known to avoid invalid use of the names. abs external own add extract procedure algol false real and field repeat array for round begin goto shift boolean if step case integer string comment label switch do long then else message true end mod until entier of value extend or while zone \f E_x_e_r_c_i_s_e_ _6_._4_ Analyse the printout program and find all the brackets delimiters, operators and compound symbols. E_x_e_r_c_i_s_e_ _6_._5_ Find all the errors in the following version of the printout program. begin integer field no; long array field name: zone item(128,1,stderror), no:= 6; name:= 6; open(item,4<:itemfile:'0); invar(item); while item,no < 4000 do begin write (ont,"nl",2,item.no,"sp",2,item.name) invare (item); end; close(item,true): end; 6_._5_ _ _ _ _ _ _ _P_r_o_g_r_a_m_ _S_t_r_u_c_t_u_r_e_ 6.5 The rules as to how the characters from the character set may be combined to form indentifiers, numbers, and basic symbols were stated in the previous section. It remains to combine these en- tities into declarations and statements which can form a program. \f 6_._5_._1_ _ _ _ _ _D_e_c_l_a_r_a_t_i_o_n_s_ 6.5.1 There are various types of declarations. <type declaration' <array declaration' <declaration'::= <field declaration' <zone declaration' <procedure declaration' Declarations are separated from each other and from statements by using the delimiter semicolon. The syntax and use of declarations are discussed in detail in chapter 7. 6_._5_._2_ _ _ _ _ _S_t_a_t_e_m_e_n_t_s_ 6.5.2 Statements may be sub-divided thus: <unconditional statement' <statement'::= <conditional statement' <loop statement' The various statement types are covered in detail in the follow- ing chapters, the remainder of this chapters deals only with a few. <simple statement' <unconditional statement'::= <compound statement' <block' 6_._5_._2_._1_ _ _ _S_i_m_p_l_e_ _S_t_a_t_e_m_e_n_t_ 6.5.2.1 ASSIGN- An assignment statement is an example of a simple MENT statement. \f E_x_._ _6_._1_4_ no:= 6; A simple statement followed by the delimiter, semicolon. <assigment'::= <identifier':= <expression' FUNCTION To the right of the dynamic equality sign, as the delimiter := is called, an expression must be stated, and the value of this expression is assigned to the identifier stated on the left. PROCEDURE A procedure call is also an example of a simple state- CALL ment. E_x_._ _6_._1_5_ invar(item); A simple statement followed by delimiter, semicolon. <procedure call'::= M_m_m_ 1 <procedure identifier' (<parameter list') P_p_p_ 0 FUNCTION The procedure specified is activated, and using the parameter list it is possible to transfer data to and from the procedure. \f 6_._5_._2_._2_ _ _ _C_o_m_p_o_u_n_d_ _S_t_a_t_e_m_e_n_t_ 6.5.2.2 A Compound statement means one or more statements which are enclosed in statement brackets. E_x_._ _6_._1_6_ begin write(out, "nl", 1, item.no, "sp", 2, item.name); invar(item); end <compound statement'::= M_m_m_ N begin <statement'; <statement'; end P_p_p_ 0 The individual statements are separated by a semicolon. USE When several statements are to be executed, in connec- tion with a loop for example, it is necessary to define how many, and this is done by using a compound state- ment. RECURSIVE In the definition of a compound statement the concept STATEMENT appers on the right hand side, this may seen strange when definition of a statement (see 6.5.2.2) is remembered. A reduction of the definition gives the following: <statement' = begin <statement'; <statement'; end \f i T_A_B_L_E_ _O_F_ _C_O_N_T_E_N_T_S_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _P_A_G_E_ 1. INTRODUCTION ........................................... 1 2. INSTALLATION ........................................... 2 A_P_P_E_N_D_I_C_E_S_: A. REFERENCES ............................................. 3 B. FUNCTION KEYS .......................................... 4 \f ii \f 1_._ _ _ _ _ _ _ _ _I_N_T_R_O_D_U_C_T_I_O_N_ 1. CalcStar runs under the control of CP/M, which is assumed to be installed on your RC700/RC855 Microcomputer System. The CalcStar package you have received contains the following: - this manual "CALCSTAR for the RC700/RC855 Microcomputer System, Installation Guide". - MicroPro documentation of CalcStar: "CalcStar User's Guide" - One 8" diskette or one 5 1/4" diskette containing the CALCSTAR system. Do not write on your distribution diskette as it is your master copy, and serves as a last resort backup in case of grave errors. \f 2_._ _ _ _ _ _ _ _ _I_N_S_T_A_L_L_A_T_I_O_N_ 2. Start by making a copy of the original CalcStar distribution diskette, see ref. 1, backup, and continue in the following way: 1) Transfer all CalcStar files to your CP/M diskette by means of either PIP or TRANSFER 2) Call the "INSTCS" program which will carry out the installation of CalcStar 3) Answer to the installation questions as shown: First time installation of CalcStar (Y/N): N_ CALSTAR installation menu please enter selection (A/B) : A_ Installation menu A Please enter selection: <_n_o_>_ _<_c_r_>_ enter 33 for RC855 Work Station or 34 for RC855 Work Station with\f A_._ _ _ _ _ _ _ _ _R_E_F_E_R_E_N_C_E_S_ A. 1 RCSL No 42-i1995: CP/M for the RC700 Microcomputer System, User's Guide or RCSL No 42-i1687: RC855 Work Station, User's Guide. \f B_._ _ _ _ _ _ _ _ _F_U_N_C_T_I_O_N_ _K_E_Y_S_ B. K_E_Y_: F_U_N_C_T_I_O_N_: C_O_M_M_A_N_D_: -> GOTO @G <- NEXT ROW, FIRST COL @Z RUBOUT (RC702) DELETE CHAR LEFT DEL DEL CHAR (RC855) @ CURSOR UP @E CURSOR DOWN @X <- CURSOR LEFT @S -> CURSOR RIGHT @D \f i T_A_B_L_E_ _O_F_ _C_O_N_T_E_N_T_S_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _P_A_G_E_ 1. INTRODUCTION ........................................... 1 2. INSTALLATION ........................................... 2 3. KEYBOARD ............................................... 3 4. SCREEN CONTROL ......................................... 4 5. PRINTERS ............................................... 5 A_P_P_E_N_D_I_C_E_S_: A. REFERENCES ............................................. 7 B. INSTALLATION PROGRAM ................................... 8 \f ii \f F_ 1_._ _ _ _ _ _ _ _ _I_N_T_R_O_D_U_C_T_I_O_N_ 1. The present version of the WordStar 3.0 text processing system has been adapted specially for use on your ITT3290 Intelligent Terminal Work Station. WordStar runs under the control of the CP/M operating system. It is assumed that CP/M has been installed on your ITT3290 Intelligent Terminal Work Station and that you are familiar with the basic CP/M procedures. The WordStar package you have received contains the following ma- terials: - This manual: "WordStar for the ITT3290 Intelligent Terminal Work Station, Installation Guide". - MicroPro's documentation of WordStar including: "WordStar, General Information Manual" "WordStar, Reference Manual" "WordStar, Installation Manual". - A diskette containing the WordStar system. Do not write on the original distribution diskette as it is your master copy and last resort in case of errors. \f F_ 2_._ _ _ _ _ _ _ _ _I_N_S_T_A_L_L_A_T_I_O_N_ 2. Start by making a copy of the original WordStar distribution diskette - for details on how to do this, see ref. 1, BACKUP. After the copy has been made, proceed as follows: Transfer all WordStar files to a CP/M system diskette by means of CP/M command PIP or TRANSFER (see ref. 1). The file WS.COM is now ready for you to use with a standard matrix printer. In case you are not satisfied with the standard ITT 3290 WordStar adaption (WS.COM) please follow the instructions in appendix B in order to install a different adaption. !_W_A_R_N_I_N_G_!_ Due to a peculiarity in WordStar 3.0 the following sequence will bring the system down: R ; "run a program" command @U ; cancel command --- ; any normal command X ; exit command The remedy for this problem is to avoid the cancel command and to run a harmless program in place of the cancel command (e.g. STAT). \f F_ 3_._ _ _ _ _ _ _ _ _K_E_Y_B_O_A_R_D_ 3. The standard ITT 3290 WordStar 3.0 enables you to use the special function keys included on the ITT3290 keyboard. M_ K_e_y_: =_ _F_u_n_c_t_i_o_n_ =_ _C_o_m_m_a_n_d_ CLEAR = NOT USED = ERASE INP = DEL CHAR = @G ERASE EOF = NOT USED = PF1 = LINE UP = @Z PF2 = LINE DOWN = @W PF3 = SCREEN UP = @C PF4 = SCREEN DOWN = @R PF5 = INSERT LINE = @N PF6 = DELETE LINE = @Y PF7 = DELETE WORD RIGHT = @T PF8 = HELP MENU = @J PF9 = BLOCK MENU = @K PF10 = ON SCREEN MENU = @O PF11 = PRINT MENU = @P PF12 = QUICK MENU = @Q TEST REQ = NOT USED = PROC MODE = NOT USED = USM = NOT USED = CURSR SELECT = NOT USED = PRINT = PRINT = P RESET CURSR = POSITION BEFORE PREVIOUS COMMAND = @QP_ <- = DELETE CHAR LEFT = RUB ESC = ESC = ESC -> = WORD RIGHT = @F <- = WORD LEFT = @A <- = RETURN = RETURN RESET = STOP COMMAND = @U ENTER = RETURN = RETURN PA1/3 = FORMAT (ON SCREEN MENU) = @O PA2/4 = BLOCK MOVE = @KV_ -> = TAB = @I INS MODE = INSERT ON/OFF = @V DEL = BLOCK DELETE = @KY_ DUP = BLOCK COPY = @KC_ FIELD MARK = BLOCK MARKER DISPLAY/HIDE = @KH_ @ = CURSOR UP = @E = CURSOR DOWN = @X <- = CURSOR RIGHT = @S -> = CURSOR LEFT = @D P_ \f F_ 4_._ _ _ _ _ _ _ _ _S_C_R_E_E_N_ _C_O_N_T_R_O_L_ 4. The headings and menues of the standard system are displayed in the form of inverted and underlined text. For further information about attributes please see ref. 1, appendix B. The standard screen options can be changed by patching the sys- tem. For further information about patching please see ref. 2. \f F_ 5_._ _ _ _ _ _ _ _ _P_R_I_N_T_E_R_S_ 5. The WordStar system is provided with a set of printer options which make it possible to use almost any type of printer. You may choose the standard option (this is already done for you in WS.COM) by typing U in the printer menu during installation (as described in appendix B of this manual) If, on the other hand, you wish to choose an alternative printer option, then please note the following points: - The printer chosen may make special demands on the communi- cations protocol and/or the printer driver. Please check ref. 1 appendix F, ref. 2 chapter 7 and the technical specifications of the printer. - The following printers may, however, be used without chang- ing the printer driver or the communications protocol: 1) OKI 83A, Matrix Printer (RC867) 2) Qume Sprint 9 (RC868) 3) NEC Spinwriter 7710/772 Thimble Printer To ensure full utilization of the printer facilities, choose option U for OKI, F for Qume and G for NEC in the printer menu. If you choose options F or G, INSTALL will advise you to select a special communications protocol. Answer by typ- ing U. \f F_ \f F_ A_._ _ _ _ _ _ _ _ _R_E_F_E_R_E_N_C_E_S_ A. 1 RCSL No 42-i2134: ITT3290 Intelligent Terminal Work Station CP/M Operating System, User's Guide 2 WordStar, Installation Manual (by MicroPro) \f F_ B_._ _ _ _ _ _ _ _ _I_N_S_T_A_L_L_A_T_I_O_N_ _P_R_O_G_R_A_M_ B. Invoke the Installation Program by typing: A> I_N_S_T_A_L_L_ _<_c_r_>_ Once you have started INSTALL you should see the following question at the bottom of the display: DO YOU WANT A NORMAL FIRST-TIME INSTALLATION OF WORDSTAR? Answer by pressing the key marked Y. The display will change and at the bottom of the display you will see the text m_ OK (Y/N): p_ This is a question. Answer by pressing the key marked Y. At the bottom of the display you should now see the text: m_ PLEASE ENTER SELECTION (1 LETTER): p_ This is a menu. Respond by pressing the key marked U or the key for your required selection. There should now be a new question of type OK(Y/N) at the bottom of the display. This question is one of a series of questions and menues which will be displayed on the screen in succession, a new one appering each time you respond a question or menu. Each time you see a question of the type OK(Y/N) at the bottom of the display, press the key marked Y, and each time you see a menu at the bottom of the display press the key marked U or the key for your required selection, - just as you did above. After you have answered the last question there will be a number of display changes and then the first WordStar menu will appear. At the top of the menu you should see the text: m_ EDITING NO FILE p_ \f To make the function keys active, you have to exit the WordStar by pressing the key marked X. When the CP/M prompt appear, extend the keyboard function keys by entering the command as shown below. A> E_X_T_E_N_D_ _W_S_ _<_c_r_>_ where keyboard input is underlined and <cr> means pressing the return key. After the following print out: ITT KEYBOARD EXTENTION VERS.1.0 - 82.09.22 FUNCTION COMPLETE - KEYBOARD TABLES EXTENDED you have a full function key implementation as shown in chapter 3, Keyboard. \f F_ \f «eof»