LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN 510.8^ no .3fc|-366 cop 2. '^X^^ZZrt^ri^ this material is re- ^ ''^i^-'^ i Va withe "7' ° '^' ^'^'''y f'-^'" Potest Dot;:tX:d''^^^^^^^ 'he University "" """^ ^""l' '" -l.n.U.al ,„„ To renew cell Telephone Center, 333-8400 Ll61_O-1096 Digitized by the Internet Archive in 2013 http://archive.org/details/macroassemblerfo364grot ^ Report No. 364 December 1, 1969 A MACRO-ASSEMBLER FOR ILLIAC IV by David Michael Grothe "" iAWnHTI THE OF Tri£ UNII/LiiJJil UMUliilJiS DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN URBANA, ILLII Report No. 364 A MACRO- ASSEMBLER FOR ILLIAC IV* David Michael Grothe December 1, 19^9 Department of Computer Science University of Illinois at Urt ana- Champaign Urhana, Illinois 618OI ■X- This work was supported in part by the Advanced Research Projects Agency as administered by the Rome Air Development Center imder Contract No. USAF 30(602)-4lH and submitted in partial fulfillment of the requirements for the degree of Master of Science in Computer Science, September I969. 11 ABSTRACT This report describes the ILLIAC IV macro assembly language (ask) and the ILLIAC IV macro assembler. ASK is a free field assembly language vith conditional assembly features and in-line text -substitution macros. Ill ACKNOWLEDCMENT The author wishes to express his gratitude to N. Saville without whose encouragement (and arguments) the ILLIAC IV macro assembler would not have achieved its present and proposed states. The author also wishes to thank Professor R. S. Northcote for his support and encouragement in this project. Also, the author is indebted to the ILLIAC IV project for providing the opportunity to create this assembler. Finally, the author would like to thank Mrs. Kay Flessner and Mrs. Patricia Douglas for the typing of this manuscript. Iv TABLE OF COIWENTS Page 1. ILLIAC IV ARCHITECTUEE AM) ADDRESSING 1 1.1 ILLIAC rv Architecture 1 1.1.1 Processors 1 1.1.2 Memory 1 1.2 Assembly-Time Arithmetic 3 1.2.1 Three Modes of Arithmetic: Syllable, Word._, Row .... 3 1.2.2 Arithmetic Expressions 6 1.2.3 Relocatable Arithmetic 7 1.2.U External References 12 1.3 Boimdary Considerations I3 2. OPERATING SYSTEM ENVIRONMENT I6 3. THE ASK LANGUAGE I8 3.1 General Format of Input to ASK I8 3.2 Syntactic and Semantic Description of ASK I8 3.2.1 ASK Control Statements I8 3.2.2 Basic Elements of the Language 23 3.2.2.1 Characters and Identifiers 23 3.2.2.2 Symbols 23 3.2.2.3 Numbers 2k 3.2.3 Structure of an ASK Program 26 3.2.i+ ASK Statements 27 3.2.5 Register Designators and Operand Fields for CU Instructions 28 3.2.6 Register Designators and Operand Fields for PE Instructions 33 V Page 3.2.7 Operand Fields for Mode -Setting Instructions 38 3.2.8 ASK Pseudo Operations ko 3.2.8.1 EQU Pseudo i+0 3.2.8.2 SYL Pseudo hi 3.2.8.3 WDS Pseudo k2 3.2.8.U BLK Pseudo ^3 3.2.8.5 FILL Pseudo hk 3.2.8.6 SET Pseudo kk 3.2.8.7 DATA Pseudo ^5 3.2.8.8 ORG Pseudo kG 3.2.8.9 CHWS Pseudo ^7 3.2.8.10 LOCAL Pseudo ^7 3.2.8.11 GLOBAL Pseudo h8 3.2.8.12 DEFINE Pseudo ^8 EXTENSIONS TO ASK - THE MACRO ASSEMBLER 50 U.l Definitions of the Tasks of Each Pass 50 U.1.1 Pass I 50 4.1.2 Pass II 51 U. 1.2.1 Implementation of Pass II -- K-Machine .... 52 4.2 Assembly-Time Assignment Statements 55 U.3 Allocation Counters 56 h.k Lexicographical Level at Assembly-Time 59 U.5 Defines, Pseudo-Strachey Macros 60 4.6 Conditional Assembly 6I 4.6.1 Conditional Statements 64 4.6.2 Iterative Statements 67 4.6.2.1 WHILE - DO 67 vi Page U.6.2.2 DO - UMTL 69 U.6.3 Conditional Expressions 7I k.G.h Listing Control 72 k.f Errors - Termination of the Assembly 76 5. SIBMARY 77 APPENDIX A. EXPANSION OF THE META-LINGUISTIC TEKM . . 78 B. COMPLETE DESCRIPTION OF THE K-MACHIWE 87 LIST OF REFERENCES 104 Vll LIST OF FIGURES Figure Page 1. Each Square Represents a Processor, 65 Total 2 2. PE Memory As Seen By (a) Instruction Counter, (b) CU Address Registers, (c) PE Address Logic k Relationship Between Pass I and Pass II 53 Relationship of Pass I and Pass II for Conditional Constructs 63 Skeletal K-Machine Code for Conditional Expressions 66 Skeletal K-Machine Code Generated for WHILE Statement .... 68 Skeletal K-Machine Code Generated for DO Statement 70 Code Generated for Conditional Expressions 73 Vlll PREFACE This paper deals vrith the design and implementation of a macro- assembler for ILLIAC IV. Chapter 1 discusses the features of the ILLIAC IV hardware which pose assembler design problems, such as addressing and alignment of program and data. Chapter 2 discusses briefly the operating system environment of the assembly program. Chapter 3 defines the ASK language as it exists at the time of writ- ing. Chapter h treats the macro, and conditional assembly features of ASK and discusses their implementation. I 1. ILLIAC IV ARCHITECTUEE AND ADDRESSING 1.1 ILLIAC IV Architecture* 1.1.1 Processors ILLIAC rv separates the functions of controlling the hardware and process- ing of "data manipulating" instructions into two logically distinct^ but interacting, machines. A control unit (CU) exists which is itself programmable. It has its own repertoire of instructions which enable it to control both itself and the re- mainder of the hardware. The hardware external to itself, which the CU controls, is an array of sixty-four processing elements (PE's). The FE's execute instruc- tions, passed to them by the CU, in lockstep. Figure 1 illustrates this rela- tionship pictorially. ASK (Assembler System-K) must assemble, into a single stream of instructions, instructions for both these machines. 1.1.2 Memory Both the CU and the PE's have associated memory. The CU contains an as- sortment of control registers (Instiruction Coiinter, Interrupt Register, etc.), data registers (sixty-four 6U-bit temporary storage registers and four 6^-bit Index/ Utility Registers) . Each of these registers is assigned a fixed location in CU-Mem- ory. That these registers are addressed by the hardware as CU-Memory locations sug- gests that ASK provide for symbolic addressing of CU-Memory (ASK does in fact provide this facility). Each PE has associated with it a memory stack of its own (20^ 64-bit words) . A PE may address only its own memory stack, but the entire array of PE-Memory may be ad- dressed by the CU (6k times 20^8 = 2 ' 64-bit words). Program is stored in PE- Memory and is fetched into the CU for execution. defined in detail in The ILLIAC IV computer is described by Barnes, et. al. in [5] and " ■ "■ in [3J. cu i 1 P^O P%3 . Figure 1. Each Square Represents a Processor, 65 Total. The addressability of PE -Memory presents a problem for symbolic assembly: The instruction coiinter addresses FE-Memory as if it were a string 18 of 2 32-bit syllables; the CU index registers may address FE-Memory as if it 17 were 2 6^4— bit words; and since all PE's receive the same address from the CU, except for PE indexing, the PE's address PE-Memory as if it were 2 U096-bit words (U096 (= 6U times 6^+) is regarded as the word size since sixty-four PE's each fetch a 6U-bit word from each PE memory simultaneously). (See Figure 2.) The problem arises from the possibility of a single symbolic address being used in all three contexts. Since it is desirable that the symbol denote a unique location in PE-Memory, a definition of assembly-time arithmetic (address arith- metic) must be chosen which satisfies this requirement. 1.2 Assembly-Time Arithmetic 1.2.1 Ihree Modes of Arithmetic; Syllable, Word, Row ASK evaluates arithmetic expressions using one of three modes of arithmetic, depending upon context. Syllable arithmetic operates on a PE sym- bol as if it symbolizes the PE memory address of a 32 -bit instruction syllable; word arithmetic operates on a PE symbol as if it symbolizes the PE memory address of a 64-bit word; row arithmetic operates on a PE symbol as if it symbolizes the EE memory stack address of an entire row of 6U-bit words across a quadrant. Since the same PE symbol may, at different times, appear in all three contexts, it would not be meaningful to use the same value for the symbol in each of the three modes of arithmetic. For instance, a PE symbol PLACE which has the value 23 would repre- sent three entirely different memory locations if the nimiber 23 were used as a Section 3.2.2 gives a syntactic description of . 32 BITS *- 218.27 2^8.27,1 • • • 2l«-2 2l«-l • • • • 1 1 • 126 127 (a) 2^7-61, . 2l^-l 1 • • • • • • 1 63 1 (b) Figure 2. PE Memory As Seen By (a) Instruction Counter, (b) CU Address Registers, (c) PE Address Logic. syllable address, word address, and row address. In order to avoid this am- biguity, ASK considers the value of a PE symbol to be divided into three fields for purposes of evaluating arithmetic expressions. i SYLLABLE FIELD- -WORD FIELD- ; •ROW FIELD- 17 BITS 6 BITS 1 BIT 1 SYLLABLE BIT -WORD BITS -ROW BITS The above diagram represents the value of a PE symbol as it is in- terpreted by ASK. Syllable arithmetic operates on the syllable field; word arithmetic operates on the word field; row arithmetic operates on the row field. The interpretation of a numeric value depends upon how that value was specified in the source text : 1) The value of a PE symbol is interpreted as specified in the preceding paragraph. 2) The value of a CU symbol or a numeric constant is interpreted as designating the same field as the mode *See Section 3.2.2 for a definition of the syntactic item Examples : of arithmetic being performed on it. For example, the numeric constant 23 designates syllable, word and row 23 in syllable, word and row arithmetic, respectively. Suppose the PE symbol A has the value 67 10 I 00000000000000000 I 100001 rr t t ■Row field- -Word field- -Syllable field- Syllable Arithmetic Word Arithmetic Row Arithmetic A+2 = 69 A+2 = 33 A+2 = 2 1.2.2 Arithmetic Expressions Assembly -time arithmetic expressions will now be defined syntactically and semantically: Syntax : : := | | : := | : := + | - : := X ] / : := | ;= () || || ABS () | RELOC () | SLA () | WDA () | RWA () : := @@ ::= * ::= (one or more consecutive blank characters] Semantics : An arithmetic expression denotes a sequence of arithmetic operations to be performed (at assembly time) on certain specified quantities. The op- erations allowed are: addition, subtraction, multiplication, integer division and exponentiation (raised to the power of). Evaluation is performed in 2k- bit two's complement arithmetic. ABS specifies that the result of the evaluation of the arithmetic expression is to be made absolute (no matter what the relocatability of the expression turns out to be). RELOC acts the same as ABS only the value is made relocatable. SLA indicates that the parenthesized expression is to be evaluated using syllable arithmetic. WDA indicates that the parenthesized expression is to be evaluated using word arithmetic. RWA indicates that the parenthesized expression is to be evaluated using row arithmetic. Examples 1 (3) X + 3 PLACEINMEMORY + Y/2*(X-1) + 2 X N 1.2.3 Relocatable Arithmetic During the assembly of any particular code segment, it may not be known where in PE memory the object code will actually be loaded. Therefore, ASK must make provision as it emits "object" code, for the placement of that 8 code at an "arbitrary" place in PE memory. An "object" code file with that property is known as a relocatable code file. The assembly proceeds as if the code were to be loaded at PE memory location zero. At load time, however, the code may be loaded at PE memory address R. Therefore, if a PE symbol symbolizes location m at assembly time, it must symbolize location R+m at load time. Re- locatable arithmetic takes the term R into accoimt during the evaluation of arithmetic expressions. In the following analyses : Let R and R stand for PE symbols which symbolize some PE memory address which may be relocated. Let A and A stand for either an integer or a symbol which sym- s s bolizes a PE memory address which may not be relocated. Henceforth a quantity of one of these two types shall be referred to as an absolute quantity. Let m and n stand for the numbers associated with the symbols, and R stand for the starting PE memory address of the code at load time. ADDITION Three cases: (1) R^ + R^^ = (R+m) + (R+n) = 2R + (m+n) This result is valid only for intermediate results. An expression which evaluates to a relocation amount greater than R is invalid and is flagged as such at assembly time. (2) R + A = (R+m) + (n) = R + (m+n) ■''Section I.3 places some restrictions on how arbitrary "arbitrary" can be. 9 This result is valid \inder all circumstances which allow a relocatable expres- sion. The assembly time result is (m+n) as a relocatable quantity. (3) Ag + A^ = m + n This result is the number (m+n) which is absolute (not relocatable) and as such is valid under any circumstances which allow absolute quantities. SUBTRACTION Fo\ir cases: (1) R - R = (R+m) - (R+n) = (R-R) + (m-n) = m - n The result of subtracting two relocatable quantities is an absolute quantity. (2) Rg - ^3 = (R+m) -n = R + (m-n) The result of subtracting an absolute quantity from a relocatable one is a relocatable quantity (m-n) . (3) Ag - R^ = n - (R=m) = (n-m) - R This result produces a negative relocation amount which is Invalid. (h) A - A = m-n ^ ' s s The result of subtracting one absolute quantity from another one is their difference (m-n), which is also absolute. 10 MULTIPLICATION Three cases (1) R X R = (R+m) X (R+n) o S 2 = R +RXm + RXn + mXn Multiplication of two relocatable quantities is invalid \inder all circumstances, (2) R X A = (R+m) X n =(r X n) + (m X n) s s Multiplication of a relocatable quantity and an absolute quantity is invalid under all circumstances. (3) A X A = m X n ^^ s s The only valid multiplication is that of two absolute quantities. INTEGER DIVISION (All address arithmetic is integer arithmetic) Four cases : (1) R / R = (R+m) / (R+n) = R / (R+n) + m / (R+n) s s Division of one relocatable quantity by another is invalid under all circim- stances. (2) Rg / A^ = (R+m) / n = R/n + m/n Division of a relocatable quantity by an absolute quantity is invalid under all circumstances. (3) A / R = n / (R+m) Division of an absolute quantity by a relocatable quantity is invalid under all circiomstances. 11 (U) Ag / Ag = m/n The only valid division is that of two absolute quantities. EXPONENTIATION Exponentiation is multiplicative in nature and obeys the same rules as multiplication. The only valid construct is: A * A = m s s Summary The valid constructs in relocatable arithmetic are R + R Valid only as an intermediate result. s s R + A Relocatable, s s A + A Absolute, s s R - R Absolute, s s R - A Relocatable, s s A X A Absolute, s s A / A Absolute. s ' s A * A Absolute, s s An arithmetic expression is correct, with respect to relocatability, if the final result contains either the term 1 X R (as in R ) or X R (as in ^ s A ) . A further contextual restriction may be applied where only an absolute or only a relocatable result is valid. Examples of Relocatable Arithmetic : Let a symbol which begins with the letter "R" be understood to be relocatable, and one which begins with the letter "A" be understood to be absolute. 12 KX + RY - RA Relocatable. RX - (AY f RA) Absolute. (RY - RX)/2 Absolute. RX + RY Invalid. 2 X RX Invalid. RX/2 Invalid. 1.2.^ External References An address expression may make use of a symbol whose definition is external to the assembly in which it appears. This facility allows the pos- sibility of total separation of code and data in PE memory, since a data area can be "declared" via a single (or collection of) ASK progratn(s) consisting entirely of data-loading and/ or storage reservation pseudo instructions. These data areas may then be addressed by another ASK program consisting en- tirely of executable code. The fact that the value of an external symbol is not known at assembly-tme leads to the necessity that certain restrictions must be placed on the use of such symbols : (1) An external symbol may not appear in any expression whose result determines, in any way, the size of the program, i.e., storage reservation pseudo operations. (2) An external symbol may not appear as a factor in an expres- sion in conjunction with a multiplicative operator. (3) An external symbol may appear as a term in an expression in conjunction with an additive operator only if the other terms of the expression (considering the external symbol as having value 0, Absolute) comprise an absolute expres- sion. (h) (From (3)) At most one external symbol may appear in a single expression. Thus, an external symbol or expression represents a base in PE-Memory (unknown at assembly-time) + a value known absolutely at assembly-time. 13 A symbol is declared as external to ASK via the following pseudo- declarations : : := EXTERML : := | , : := The user may indicate to ASK that a symbol which is defined within this assembly is to be made visible externally. A symbol so defined may cor- respond to the same symbol declared EXTEEHML in another assembly and, if it does correspond, give the EXTEEINAL symbol a definition at load time. Such symbols are termed Entry Symbols in ASK and are defined as such by way of the following syntax (an extension of the syntax for given in Section 3.2.U) : : := | [ENTRY] 1.3 Boundary Considerations A good portion of the art of programming the ILLIAC IV lies in the structuring of the data to be operated on. In particular, in order to take advantage of certain functional characteristics of the hardware, it is sometimes convenient -- and sometimes necessary -- that code or data be placed at some specific address with respect to some address whose value is a multiple of some particular power of two. For example : a) There exists an instruction which fetches eight words of data from PE-Memory to CU-Memory. This instruction demands that the data be on an eight -word bounday. b) The JUMP instruction requires that the syllable to be Jtmiped to lie on a single-word boundary. Ik c) PE instructions, unless modified by the PE index ■ registers, fetch data from the same PE-Memory address, implying that the data should be placed beginning on a sixty-four -word boundary (or 128 or 256, depending upon the configuration) . The above suggests the need for a facility which allows a PE Symbol to be assigned a value, v, such that v = w modulo t, where t is a power of two. If t is determined implicitly from w, i.e., the smallest power of two greater than or equal to w, then w determines the congruence class V = {v I V = w modulo t} . Accordingly, ASK provides a facility through which the Allocation Counter (the assembly-time image of the Instruction Counter) may be advanced to the nearest v such that v € V, given w. This allows code or data to be placed at any of these convenient boundaries. This, however, is not in itself sufficient for, although the address V may appear at assembly time to satisfy the constraints, it is not neces- sarily known whether the actual run-time address will or not. The solution to this problem is that the ILLIAC IV loader is informed of the existence of such constraints. The manner in which the loader is informed of these matters is crucial. Suppose, for instance, that ASK simply provided the loader with the constant w at each occurrence of such an address adjustment. Were this the case, the loading address of a code segment possibly varying from rim to run, the loaded code segment could be considerably larger (or smaller) than it was thought to be at assembly time, invalidating many relocatable addresses A second, acceptable, approach is this: For every code segment (assembly) there exists a number T which represents the largest t. for that segment. If the loading address (L) is such that L = modulo T, then for all v. such that v. = w. modulo t., ' 1 111' it follows that L + v. = w. modulo t.. That is to say, the actual memory 111 15 satisfies the constraints imposed upon it at assembly time, and no adjustment must be performed except prior to determining L. Hence, the code segment re- mains the same size as it was thought to be at assembly time, and all relocat- able addresses are valid. The latter approach to the "Boundary Problem" was the one selected for implementation. (See Section 3'2.8.5 - FILL Pseudo) . 16 2. OPERA.TING SYSTEM ENVIRONMENT "Die Welt ist alles, was der Fall ist." -- Ludwig Wittgenstein, 1. ASK must interface to (at least) three separate, but connected, operating systems. The first of these is 0S4, the ILLIAC IV resident operating system. ASK does not itself run under the auspices of 0S4, but the code which it emits, when loaded into ILLIAC IV and executed, does. At the time of this writing, OS^ is in its first, infantile state. The conventions established by this operating system are minimal and, to some extent, arbitrary. It is envisioned that, in the future, OSU will expand as more user facilities are necessitated by the needs of an increasingly large and (hopefully) diverse world of users. ASK must provide for the interface to this operating system, taking into account the fact that the system itself is likely to change. The only assump- tion that ASK can make is that the language for communicating with 0S4 is de- fined, namely ILLIAC IV machine language. ASK will provide this interface not via special constructs in its own language but, rather, by way of macros written by the operating system group, known to ASK as macros and thus avail- able to the user. This approach (the "System Macro" approach) obviates the necessity of changing ASK itself as OSU changes; the only necessary change is to the definitions of the "System Macros" which are input to ASK. The second operating system that ASK must interface to is the B65OO Resident ILLIAC IV Operating System (this operating system has no offi- cial name at this time, but will herein be called BRIOS). The design of this operating system makes this interface simple almost to the point of non- existence. To ERIOS, ASK is just a B65OO program which it runs at appropriate times. The interface to BRIOS consists mainly of not interfering with it, specifically by not initiating any other B65OO jobs whose supervision belongs 17 to BRIOS. The only other possible interface to BRIOS is the returning of a condition code to indicate the degree of success of the assembly. The third operating system which ASK interacts with is the B65OO MCP. The consciousness of the MCP affects little other than the manner in which ASK itself is coded. Although these considerations are important, they will not be discussed here. There is a fourth system to which ASK must interface very closely, although it is not an operating system^ that is, the ILLIAC IV Collector/ Loader system. The closeness of this interface very nearly binds the two systems into a single \init. Any change to one system which affects this inter- face covild conceivably imply extensive modifications to the other. The reader is referred to [l] which defines this interface in detail. 18 3- THE ASK LANGUAGE This section defines the ASK language in detail. The description is taken, in part, from [2], a reference manual for ASK. A familiarity with ILLIAC IV and its instruction set [3] is assumed for total comprehension of this section. 3-1 General Format of Input to ASK ASK accepts as input punched cards or card images from any source available to the B5500 (B65OO) system. The information in card (image) columns I-72, inclusive, is considered by ASK to be statements or portions thereof in the ASK language. Columns 73-80 are available to the user for sequencing or identification piirposes except when ASK is performing a merge assembly from two sources, in which case the information in columns 73-80 are used by the selection criterion to determine the next card to be scanned (see Section 3*2.1 ASK Control Statements). An arbitrary number of blank spaces may separate any two syntactic quantities and, with the following exceptions, card (image) boundaries are ignored: a) Neither an identifier nor a number may be split across a card boundary or contain embedded blanks. b) A "$"-sign in column one followed by one or more spaces will cause the card to be interpreted as the beginning of an ASK control statement. 3.2 Syntactic and Semantic Description of ASK 3.2.1 ASK Control Statements Control statements direct the assembler to take some action, usually with respect to file handling. A control statement may appear anywhere in an 19 ASK program, allowing assembly -time options to be manipiolated in accordance with the desires of the user. The following is a syntactic and semantic description of ASK control statements : Syntax : := $ : := | : := | | |