Digital PDFs
Documents
Guest
Register
Log In
DEC-08-CMAA-D
December 1969
75 pages
Original
2.8MB
view
download
Document:
MACRO-8
Programming Manual
Order Number:
DEC-08-CMAA-D
Revision:
Pages:
75
Original Filename:
https://svn.so-much-stuff.com/svn/trunk/pdp8/src/dec/dec-08-cma/dec-08-cmab-d.pdf
OCR Text
MACRO-8 PROGRAMMER’S REFERENCE MANUAL FOR THE PDP-8 FAMILY COMPUTERS For additionaI copies order No. DEC—O8—CMAB-D from Program Equipment Corporation, Maynard, Mass. DIGITAL EQUIPMENT CORPORATION Library, Digital Price 0 $3.00 MAYNARD, MASSACHUSETTS Ist Printing October 1965 2nd Printing November 1966 3rd Printing October 1967 4th Printing January 1969 5th Printing (Rev) November 1969 Your attention is invited to the last two pages of this The Reader's Comments page, when filled in manual and returned, is beneficial to both you and DEC. All . comments received are considered when documenting subsequent manuals, and when assistance is required, knowledgeable DEC representative will contact you. a The Software Information page offers you a means of keeping up-to—date with DEC's software . Copyright©1965, 1966, 1967, 1969 by Digital Equipment Corporation The following are trademarks of Digital ment Equip— Corporation, Maynard, Massachusetts: DEC PDP FLIP CHIP FOCAL COMPUTER LAB DIGITAL CONTENTS PART I BASIC INFORMATION Page CHAPTER I INTRODUCTION l—l CHAPTER 2 THE BINARY SYSTEM 2-l CHAPTER 3 THE PDP—8 INSTRUCTION SET 3—l 3.I Instructions 3-l 3. I .l Memory Reference Instructions 3-I 3. I .2 Augmented Instructions 3-3 3. I .3 Input-Output Transfer Instruction 3-3 3.I 4 Operate Instruction 3—4 3.2 The Organization of Memory 3-6 3.3 Complement Arithmetic 3-8 3 .3 .1 Addition 3—9 3 .3 .2 Subtraction 3-9 ORGANIZATION 4-I 4. I Programming Steps 4-l 4.2 Coding 4—2 4 3 Comments 4—4 4.4 Address Tags 4-5 CHAPTER 4 . 4.4.l 4—6 Symbolic Addressing 4.5 Storage Techniques 4-6 4.6 Optimum Use 4—7 4.7 Subroutines 4—9 PART 2 THE MACRO LANGUAGE CHAPTER 5 MACRO-8 PROGRAMMING LANGUAGE 5-I 5.l Function 5-l 5.2 Compatibility 5-l CO NTE NTS (Cont) Page Characters l mmmmmmmmmmm-h-Ah-pnwww minow I #QN .1 Links CHAPTER 6 —l Letters 5—2 Digits 5-2 Punctuation Characters 5—2 Ignored Characters 5—3 Coding Practices 5-4 Coding Structure 5—5 Elements 5-5 Integers 5-5 Symbols 5—5 Expressions 5-7 Special Symbols 5—10 Current Address Indicator 5—10 Origin Setting 5—10 Literals 5-H Single Character Text Facility 5-12 PSEUDO-INSTRUCTIO NS Functions Current Location Counter 0~0~0~O~0\O~0~0~O~0~0~~00MO~U101014>0N Extended Memory Radix Control Numbers —I Double Precision Integers N Floating Point Constants CHAPTER 7 Text Facility End of Program End of Tape Alterations to the Symbol Table MACROS 7. I Function 7.2 Defining CONTENTS (Cont) Page Restrictions 7.3 CHAPTER 8 8 . ERROR DIAGNOSTICS I Format 8 2 Error Messages CHAPTER 9 OPERATING INSTRUCTIONS . 9. I Assembler Output 9.2 Versions 9 3 Procedures 9.4 Symbol Table ModifiCation . APPENDIX I MACRO-8 SYMBOL TABLE APPENDIX 2 ASCII CHARACTER SET ILLUSTRATIONS I 3—] Memory Reference Instruction Format 3-2 IOT Instruction Format 3-3 Group I Operate Microinstruction Format 3—4 Group 2 Operate Microinstruction Format 4—] Flow Chart of Program to Calculate Sum of Integers 4—2 Program Example TABLES 2—I First Sixteen Integers in Three Number Systems 3-] Memory Reference Instructions 3—2 Group I Operate Microinstructions 3—3 Group 2 Operate Microinstructions 3—4 Effective Address Calculation 3-5 One's and Two's Complement Representations 9—] Switch Options 3—2 PREFACE This manual is directed both to the new user of programming systems and the expe— rienced programmer. Part I presents basic information on programming techniques and an introduction to assembler concepts. language. Part II details the MACRO—8 assembler The experienced programmer will find in Part II all the information necessary for the use of MACRO-8. DEC offers four symbolic assemblers for use on PDP-8 Family computers, a. as PAL III Symbolic Assembler, the basic 4K assembly system. follows: It is a two-pass assembler with an'optional third pass which produces an octal/ symbolic assembly program listing, and is highly recommended for the computer with 4K words of core memory. It is an excellent assembly language for the less experienced programmer yet powerful enough to satisfy the needs of the advanced programmer. b. MACRO—8 Symbolic Assembler, essentially PAL III with the following additional features: user-defined macros, double precision integers, floating—point constants, arithmetic and Boolean operators, literals, text facilities, and automatic off-page linkage generation. It is recommended for the computer with 4K words of core memory when any of the additional features listed above are desired. c. PAL—D Symbolic Assembler, essentially MACRO—8 excluding macros. It is used only in the PDP-8/I Disk Monitor System and requires 4K words of core memory. d. 8K SABR Symbolic Assembler, to use with a primarily for experienced programmers computer that has 8K to 32K words of core memory. It differs from the preceding assemblers in its operating procedures, character set, pseudo—ops, execution of the assembled program, and especially in its assembled output (relocatable binary code). It is assumed that the reader is familiar with assembly language programming. For an elementary ap- proach to this type of programming, we recommend DEC's publication, Introduction To Programming (specify publication C-l8), available from the Program Library (address on Title page). PART BASIC 1 INFORMATION CHAPTER 1 INTRODUCHON In describing the solution oF the Following equation, y=mx+b one can say, "First, multiply the quantity x by m. To this product, add the quantity b. The result is the value oF y.” The same problem can be solved on an adding machine in the Following steps: 1 . Clear the keyboard and registers. 2. Enter the value oF m and press the ADD key. 3. Enter the value oF x and press the keys which initiate the multiplication. 4. Enter the value oF b and press the ADD key. The result, appearing in the totalizing register, is the value oF y. This sequence oF steps can be thought oF as a program For the solution ot the problem on an adding machine. In similar Fashion, the steps can be written out For a solution to be perFormed by a digital computer. In- stead oF pressing buttons and keys, the programmer writes a sequence oF instructions to perForm operations on data stored in the computer. Such a sequence (For a hypothetical computer) might appear as Follows: clear add m multiply x add b deposit y The variables m, x, and b represent quantities stored in the computer; the variable y represents a storage register. The operations are carried out in a register called the accumulator, abbreviated AC. instruction clears the AC. The next adds the quantity m into the AC. The third instruction multiplies the contents 0F the AC by the quantity x, and the Fourth adds the quantity b to the result. contents oF The First Finally, the the AC are deposited into a storage register designated by the symbol y. To be useFul to a computer, the instructions 0F 0 written program must be translated into a sequence oF numeric codes, each oF which represents a specific computer operation. 1—] To do such translating by hand trom instructions to binary numbers would be tedious and to perform lengthy. Computer programs have been written the translating task, interpreting the written program and producing from it a second program which can be executed directly by the computer. These translators are called assemblers because they assemble from a source program written by the user, a working program instruction by instruction . This output From the assembler is called an obiect, or binary program. MACRO-8 is an assembler designed to accept input in the Form of a sequence of symbolic instructions representing the operations capable of being executed on the PDP—8. which may then be placed in the computer and executed. It produces a binary program tape The next chapter explains a Few basics of the binary numbering system; succeeding chapters deal in more detail with the MACRO-8 assembly program. PART TH E MACRO 2 LANG UAG E CHAPTER THE BINARY 2 SYSTEM Every item of information stored in or processed by a digital computer is encoded as a binary number. Consequently, the user should become familiar with the binary system and be able to convert numbers from binary to decimal representation and back, using the octal system as an intermediate. as the programmer gains more experience, he will find himself using the decimal system less and "thinking in octal” more. This is a useful habit to cultivate. Table 2-I gives the first I6 integers (and 0) as they are represented in the decimal, number systems. Note that in the decimal system there are ten different symbols, used to represent any number. or binary, and octal digits, 0-9 which are In the binary system there are two, 0 and l; in the octal system, The number of digits required in 0—7. is Eventually, a given system is called the radix. eight, Therefore, the decimal radix I0; the octal radix is 8, and the binary radix is 2. A subscript is used to identify the radix of the sys- tem in and which the number is represented. IIOIOI2 a Thus, 4196 I0 indicates a decimal number, 25478 an octal number, binary number. TABLE 2—I FIRST SIXTEEN INTEGERS IN THREE NUMBER SYSTEMS Decimal Octal Binary 000 9 II IOOI IO I2 IOIO 2 00] OIO II I3 IOII Decimal Octal Binary O 0 I I 2 3 3 Oil I2 I4 IIOO 4 4 I00 I3 I5 HOT 5 5 IOI I4 I6 IIIO 6 6 IIO I5 I7 IIII 7 7 III I6 20 IOOOO 8 I0 1000 All numbering systems using radices involve positional notation; that is, each successive digit position to the left represents the next higher power of the radix. For example, the decimal number expressed algebraically as 4xI03+IxI02+9xIOI +6xl00 2—I 4I9610 may be which when calculated becomes 4x1000+lxlOO+9xlO+6xl=4l96 lO . Positionally, this appears as 102 TO] 100 1000 l00 l0 l (Radix to its respective powers) 4 l 9 6 (Units required of each value) 103 (Positioned radix) Likewise, the octal number 25478 can be expressed as 2 x 83 + 5 x 82 + 4 x 81 + 7 x 8 0 . In all systems the integral and Fractional parts of a number are separated by a radix point. the system in use, this may be a decimal point, octal point, or Depending on binary point. As can be seen from the table, four binary digit positions are required to represent the decimal up to 9. are The octal integers up to 7 require only three binary positions; furthermore, exactly three positions needed. octal digits. In other words, three binary digit positions are necessary and sufficient to represent the eight This fact makes binary—to-octal and octal-to—binary conversions quite simple. Example: Binary—to-Octal Conversion The binary integer 1011100110102 can integers be converted to its octal equivalent as follows: 1. Divide the binary digits into groups of three, starting from the right l0l HO OH 010 2. Substitute for each group its octal equivalent 5 3. 6 3 2 The result is the octal number 56328 To perform the reverse conversion, substitute the binary equivalent of each octal 4751 47518 =100Hi lOl 00] =1001111010012 digit To convert an octal fraction, group by threes in each direction away from the radix point 11101010100012 =1 HO iOl 2243.5578 = 010 0T0 TOO Oll . OTO 01(0) =165.228 lOl l0l lll . = OTOOTOTOOOT l .lOllOllll2 Example: Decimal-to-Binary Conversion The "remainder method” may be used to convert a decimal number to a binary number. The decimal number may be converted as follows: NN N00" 00 U1 \IOJ N—d NN Q N :l CO 01 (binary radix)—>2 N \O \lO ‘— (remainders) O b 1011100110102 Notice that this method simply involves halving the number to be converted and noting the remainder after each division. Example: Decimal—to-Octal Conversion The remainder method may also be used for octal conversions. 2970 The decimal number ——I 0 would be converted as follows: (octal radix)—98 T2970 2-3 prewar.» 4—— (remainders) 56328 In one sense, the conversion of a number From one representation to another is a way of encoding the number; the octal integer 778 can be encoded as the binary integer llllll a binary code to any symbol, such as a letter of the alphabet. . Similarly, one can assign The table in Appendix B shows the binary codes assigned to all the characters of the Model ASR-33 Teletype. A programmer may invent a symbolic name to refer to the location of a given word in the computer mem- These symbolic names, or tags, are assembled together with the instruction mnemonic into a binary ory. number which indicates the memory location of the word, the instruction code, and the address of the data . The association of binary code and symbol is the basis of a programming language . A programmer learns the symbols for the computer's repertoire of operations and the rules for arranging a sequence of symbolic instructions in a useful Format. paper tape. An assembly program accepts this source program sequence of binary numbers, on an He prepares a symbolic program for input on a medium such as punched input and translates it into an equivalent producing a program which is usable directly by the computer by placing it output medium, which again may be punched tape. be read into the computer and executed. This binary, or object program tape may then CHAPTER THE 3.] PDP-8 3 INSTRUCTION SET INSTRUCTIONS Every PDP-8 operation is specified by a unique combination of l's and 0's stored in the twelve bits of one memory register. Such an instruction word can be one of two types: memory reference instructions per- form operations which require access to the information stored in a memory register; augmented instructions do not refer to memory cells. The operation code of an instruction is contained in bits 0, l, and 2 of the word. Since three binary digits correspond to one octal digit, it is apparent that there can be no more than eight operation codes, corre— sponding to the octal digits 0—7. Codes 0-5 are reserved for memory reference instructions. Operation codes 6 and 7 are for augmented instructions. These two types of instructions are defined, and the instruc- tions described, in the following sections. The following special symbols are used in the instruction lists below. Definition Mel C(A) The contents of register A C(A) 3» C(B) The contents of register A replace the contents of register B Y The address or location of any memory register Yl The ith bit of register Y Y]_4 Bits l-4, inclusive, of register Y C(AO__5) => C(Y6_] 1) The contents of bits 0-5 of register A replace the contents of bits 6-] l of register Y. not affected The contents of A are . lnclusive OR O>< 3.1 .1 AND > (Boolean) The l's complement of the contents of register A Memory Reference Instructions Word format of memory reference instructions is shown in Figure 3-l , and the instructions are explained in Table 3-l . 3-1 MEMORY PAGE OPERATION CODES 0-5 1 3 2 5 6 7 LW_J TABLE 3-I Mnemonic Octal Time Symbol Code (psec) AND Y 3.0 10 9 ‘II V ADDRESS INDIRECT ADDRESSING Figure 3—l 8 Memory Reference Instruction Format MEMORY REFERENCE INSTRUCTIONS Operation Logical AND. The AND operation is performed between the C(Y) and the C(AC). The result is left in the AC, C(AC) are lost. The C(Y) are unchanged. Corresponding bits are compared independently. This in— struction, often called extract or mask, can be considered => /\ as a bit-by—bit multiplication. and the original C(Yl) C(ACi) C(ACi) Example TAD Y 3.0 C(ACi) original C(Yl) 0 O O I I O I I Two's complement add. —'OO The C(Y) are added to the C(AC) in 2's complement arithmetic and the original final C(ACi) . The result is left in the AC C(AC) are lost. The C(Y) are unchanged. If there is a carry from AC0, the link is complemented. This feature is useful in multiple precision arithmetic . C(Y) + C(AC) => C(AC) ISZ Y 3.0 Index and skip if zero. The C(Y) are incremented by one in 2's complement arithmetic. If the resultant C(Y) the next instruction is skipped. 0, If the resultant C(Y) 75 0, the program proceeds to the next instruction. are = The C(AC) unaffected. C(Y) + 1 => C(Y) lf result 0, C(PC) + l => C(PC) = DCA Y 3.0 Deposit and clear AC. The C(AC) are deposited in core memory location Y and the AC is then cleared. The previous C(Y) are lost. C(AC) => C(Y), then 0 => C(AC) TABLE 3-] MEMORY REFERENCE INSTRUCTIONS Mnemonic Octal Time Symbol Code (psec) JMS Y 4 3.0 (continued) 0 pera t'Ion Jump to subroutine. The C(PC) are deposited in core mem— ory location Y. Y + I The next instruction is taken from location . C(PC) + I => C(Y) Y + I => C(PC) JMP Y 5 I .5 Jump to Y. The next instruction is taken from core mem— ory location Y. Y => C(PC) 3. I .2 Augmented Instructions There are two classes of augmented instructions, or instructions which do not reference core memory. They are the input-output transfer (IOT) which has an operation code of 6, and the operate (OPR), which Bits 3 through II within these instructions function as an extension of the has an operation code of 7. operation code and can be microprogrammed to perform several operations with one instruction. Augmented instructions are 3.1 .3 I-cycle instructions requiring I .5 psec for execution . Input-Output Transfer Instruction Microinstructions of the input-output transfer (IOT) instruction effect information transfers between the arithmetic and control element and aninput—output device via the input—output control element. format of the IOT instruction is shown in Figure 3-2. Bits 3 through 8 are used to select the and bits 9 through II enable generation of I/O pulses during event times 4, The I/O device; 2, and I, respectively. Operations performed by IOT microinstructions are explained in Chapter 4 of the PDP-8 Users Handbook. GENERATES AN IOP 4 PULSE AT EVENT TIME 5 IF A I OPERATION C D GENERATES AN IOP I PULSE AT EVENT TIMEI IF A 1 W4 DEVICE SELECTION Figure 3-2 IOT Instruction Format 3-3 GENERATES AN IOP 2 PULSE AT EVENT TIME 2 A 1 3.1.4 Operate Instruction The operate instruction consists of two groups of microinstructions. Group I is principally for clear, complement, rotate, and increment operations and is designated by the presence of a 0 in bit 3. Group 2 is used principally for checking the contents of the accumulator and link and continuing to or skipping the next instruction A l in bit 3 and a 0 in bit ll based on the check. designate a Group 2 microinstruction. Group I operate microinstruction Format is shown in Figure 3-3, and the microinstructions are listed in the table below. Any logical combination of bits within this group can be combined into one microinstruction. For example, it is possible to assign l's to bits 5, 6, and II; but it is not logical to assign l's to bit 8 and 9 simultaneously since they specify conflicting operations. If RAL, RAR, RTL, or RTR is specified, lAC may not be specified, and conversely. OPERATION CODE 7 CLA ROTATE 1 POSITION IF A O. 2 POSITIONS IF A I ROTATE AC AND L RIGHT CMA WF—LflF—gfif‘k‘fi O | 2 3 CONTAINS A 0 TO SPECIFY GROUPI Figure 3-3 TABLE 3—2 4 5 6 CLL 7 8 CML 9 IO ROTATE 41 IAC LEFT Group I Operate Microinstruction Format GROUP I OPERATE MICROINSTRUCTIONS Mnemonic Octal Event Symbol Code Time CLA 7200 1 O pera f.Ion Clear AC . 0 => C(AC) CLL 7l00 l Clear L. 0 => C(L) CMA 7040 l Complement AC. The C(AC) are set to the T's complement of C(AC). C(AC) => C(AC) CML 7020 l Complement L. C(L) => C(L) RAR 70l0 2 Rotate AC and L right. rotated right one place C(AC.) => C(AC. + 1) ):> C(L)l C(L) =l>I C(ACO) C(Ac' The C(AC) and the C(L) are . TABLE 3-2 GROUP I OPERATE MICROINSTRUCTIONS Mnemonic Octal Event Symbol Code Time RAL 7004 2 (continued) 0 per at'Ion Rotate AC and L left. The C(AC) and the C(L) are rotated left one place. C(ACi) => C(Aci => _ ]) C(L) C(ACO) C(L) => C(ACH) 70I2 RTR Rotate two places to the right. 2 Equivalent to two successive RAR operations. 7006 RTL 2 Rotate fwo places to the left. Equivalent to two successive RAL operations. 700i IAC 2 Index AC. The C(AC) are incremented by one in 2's complement arithmetic. C(AC) +1 $ C(AC) 7000 NOP . Causes a I .5 psec program delay. format is shown in Figure 3-4, and the microinstructions are listed in Group 2 operate microinstruction the table below. No operation — Any logical combination of bits within this group can be composed in one microinstruction. REVERSE OPERATION CODE 7 0 CLA 2 1 3 4 CONTAINS A 1 TO SPECIFY GROUP 2 Figure 3-4 SKIP SENSING OF BITS 5,6,7 SZA 5 6 7 SNL SMA 8 HLT 9 H 10 OSR CONTAINS A 0 TO SPECIFY GROUP 2 Group 2 Operate Microinstruction Format If skips are combined in a single instruction, the inclusive OR of the conditions determines the skip. For example, if I's are designated in bits 6 and 7 (SZA and SNL), the next instruction is skipped if either C(AC) = 0, or C(L) = I, or both . If two reverse sense skip instructions are combined (bit 8 is set), the logical AND of the conditions determines the skip. For example, if I's are designated in bits 6, 7, and 8 (SNA and SZL), the next instruction is skipped if C(AC) 7’é 0 and C(L) from to = 0. The CLA microinstruction Group I can be combined with Group 2 commands. This command occurs at event time 2 with respect the event times listed in the following table. 3—5 GROUP 2 OPERATE MICROINSTRUCTIONS TABLE 3—3 Mnemonic Octal Event Symbol Code Time CLA 7600 2 , O peratlon Clear AC. 0 => C(AC) SPA 7510 1 Skip on positive AC. If the C(AC) is a positive number, the next instruction is skipped. :r C(ACO) 0, then C(PC) + 1 => C(PC) = SMA 7500 1 Skip on minus AC. If the C(AC) is a negative num— ber, the next instruction is skipped. 'I , then C(PC) + 1 => C(PC) If C(ACO) = SNA 7450 l Skip on non-zero AC. If C(AC) 75 0, then C(PC) +1 => C(PC) SZA 7440 1 Skip on zero AC. If C(AC) 0, then C(PC) +1 => C(PC) = SZL 7430 1 Skip on zero L. If C(L) O, the next instruction is skipped. If C(L) 0, the C(PC) + 1 => C(PC) = = SNL 7420 1 Skip on non-zero L. If C(L) =1, then C(PC) +i => C(PC) SKP 74l0 1 Skip, unconditional. The next instruction is skipped. C(PC) + 1 => C(PC) OSR 7404 2 OR with switch register. (May be combined with CLA.) C(SR) V C(AC) => C(AC) HLT 7402 2 Halt. Stops the program. If this instruction is com— bined with others in the CPR 2 group, the computer stops immediately after completion of the cycle in process. 3.2 THE ORGANIZATION OF MEMORY A PDP—8 memory field can be likened to a book. The 4,096 words of the memory field correspond to the lines of text, and if we divide the memory into segments of l28 words each, we have an analogy to a 32-page book in which each page contains 128 lines. The memory field is in fact segmented in this fashion, and the analogy to a book is affirmed by the fact that each of the l28—word blocks is called a page. to allow direct reference to all be provided. Because the PDP—8 instruction word is not long enough of the registers in a memory field, a special type of address reference must This can be illustrated by pursuing our book analogy a little bit farther. 3-6 Suppose that one is reading a text, and taking notes in the margins of each page. some of the notes will refer to other parts of the page, or to information on One can expect that other pages. if one of the notes refers to a line of text on the same page, write only the line number. For convenience, If the note re— fers to a line on some other page, write the page number followed by the number of the line on that page. Alternatively, of course, it is possible to begin on the first page and number all the lines of the book con— secutively, and refer to them by these numbers alone. In similar fashion, a given word of memory may be referred to by its page address; that is, its address within a page, or by its absolute address, which designates its position in the whole of memory. analogy ends Here the . A PDP-8 memory field is organized as follows: the 4,096 words are arranged sequentially, with absolute 77778. The field is divided into 32 pages numbered from 0-378. Each page tains I28 registers, with page addresses of O-I778. As Figure 3-I shows, the address field of memory field of to memory reference instruction contains 7 bits, which is iust enough to allow 2008 addresses of 0 through con- a a locations. access If bit 4 of the instruction contains a l, the address field of the instruction refers to one of the addresses on the current page, that is, the page in which the instruction is stored. If bit 4 contains a O, the reference is to an address on page 0. The state of bit 3 of the instruction determines what is done with the contents of the memory register specified by bits 4—I I . If this bit is 0, the contents of the cell addressed by the instruction are taken as the operand, and the operation is completed. effective address of the instruction. are In this case, the address specified by the instruction is the If, however, bit 3 contains a I, the contents of the cell addressed treated, not as the operand, but as the I2—bit absolute address of the register containing the operand. In other words, the cell addressed contains the effective address of the instruction. ory reference instruction can indirectly address any register in the memory field, In this way, a mem- regardless of which page it is on. Thus, there are four ways, depending on the states of bits 3 and 4 of a memory reference instruction, in which the effective address may be obtained. TABLE 3-4 Bit 3 Bit 4 O O EFFECTIVE ADDRESS CALCULATION Effective Address The operand is in page 0 at the address specified by bits 5 through I I O I . The operand is in the current page at the address specified by bits 5 through I I 3—7 . TABLE 3—4 EFFECTIVE ADDRESS CALCULATION Effective Address Bit 4 Bit 3 (continued) The absolute address of the operand is taken from the contents of the location in page 0 designated by bits 5 through II . The absolute address of the operand is taken from the contents of the location in the current page designated by bits 5 through II. 3.3 COMPLEMENT ARITHMETIC In the PDP-8, as in other machines utilizing complementation techniques, negative numbers are repre- sented as the complement of positive numbers, and subtraction is achieved by complement addition. Representation of negative values in 2's complement arithmetic is slightly different from that in I's com— plement arithmetic . The I's complement of a number is the complement of the absolute positive value; that is, all I's are re— placed by 0's and all 0's are replaced by I's. plement of the positive value plus one The 2's complement of a number is equal to the I's com- . In I's complement arithmetic a carry from the sign bit (most significant bit) is added to the least significant bit in an end-around carry. In 2's complement arithmetic a carry from the sign bit complements the link (a carry would set the link to I if it were properly cleared before the operation), and there is no' end—around carry . A I's complement representation of a negative number is always one less than the 2's complement representation of the same number. Differences between I's and 2's complement representations are indicated in the following table. TABLE 3-5 ONE'S AND TWO'S COMPLEMENT REPRESENTATIONS Number One's Complement Two's Complement +5 OOOOOOOOOI OI 000000000I OI +4 000000000 I 00 000000000 I 00 + 3 00000000001 I 0000000000I I +2 0000000000 I 0 0000000000 I 0 + I 00000000000I 00000000000I + 0 000000000000 000000000000 —0 IIIIIIIIIIII Nonexistent —I IIIIIIIIIIIO IIIIIIIIIIII 3-8 TABLE 3—5 ONE'S AND TWO'S COMPLEMENT REPRESENTATIONS (continued) Number One's Complement Two's Complement -2 HHHHHOT HHHTHHO —3 HHHHHOO THHHTHOT —4 THHHHOH 111111111100 -5 HHHTHOTO THHHHOH Note that in 2's complement there is only one representation for the number which has the value zero, while in T's complement there are two representations. Note also that complementation does not interfere with sign notation in either T's or 2's complement arithmetic; bit 0 remains a O for positive numbers and a i for negative numbers. PDP—8 arithmetic operations (as exemplified by the TAD instruction) are carried out in 2's complement. This means that the operands involved in the arithmetic must be in correct 2's complement representation. The 2‘s complement of any number is formed by taking the T's complement, and adding T to it. The two operate class instructions, CMA and IAC, may be combined into a single instruction to perform the opera— tion of taking a 2'5 complement. Because the operation is often required, the mnemonic CIA is given to the combined instruction. 3 3. T . Addition The addition of a number contained in a core memory location and the number contained in the accumu- lator is performed directly by using the TAD Y instruction, assuming that the binary point is in the same position and that both numbers are properly represented in 2's complement arithmetic. Addition can be performed without regard for the sign of either the augend or the addend. Overflow is possible, in which case the result will have an incorrect sign, carry from bit 0 will 3.3.2 although the eleven least significant bits will be correct. complement the link bit. Subtraction Subtraction is performed by complementing the subtrahend and adding the minuend. As in addition, if both numbers are represented by their 2's complement, subtraction can be performed without regard for the signs of either number. 3—9 A CHAPTER 4 ORGANIZATION 4.1 PROGRAMMING STEPS The rules for writing a program can best be introduced by tracing the steps from the statement of a problem to the n completed routine. Consider, for-example, this problem definition: "compute the sum of the first integers. " The problem may also be stated as: s=n+ After defining the problem, a the problem, should be made. (n—l)+ (n-2)+ (n-3)+ ...+3+2+l flow chart, that is, a block diagram of the general steps to the solution of It might look something like Figure 4-1. moment, consider the second, third, and fourth boxes. perform the main computation of the sum. sum. Ignoring the first box for the The operations specified in these three boxes Box 2 specifies the actual arithmetic of computing the partial Box 3 is a counter, which counts the number of partial additions that have been made. Box 4 is a decision point; if the count indicates that the sum is complete, the program goes on to box 5; if it is not complete, the program returns to the beginning of the main computation. This sort of continuous recycling through a section of program is called a loop. 1 CLEAR TEMPORARY REGISTERS AND INITIALIZE 2 CALCULATE PARHAL sum 3 DECREMENT INDEX N0 4 YES 5 Figure 4-] HALT Flow Chart of Program to Calculate Sum of Integers The first box in this chart specifies the operations which prepare the program for operation different data each every program written will be used more than once, with 4—1 . Since nearly time, it is necessary at the start of the routine to clear out old results from previous use of the program so that one can start fresh with new data, in the same way that one clears the keyboard and registers of an adding machine before starting a new calculation. ln programming terms, this preparation is called initializing. Besides indicating the general sequence of operations, the flow chart also gives an idea of storage require- ments. Space will be needed not only for the instructions which perform the computation, but also for the One register will be needed to hold the partial sum accumulated through re- data used by the routine. peated additions; this register will naturally hold the correct total when the calculation is finished. Another cell is needed for the index, which is the counter specified in box 3 of the flow chart. one register is necessary to hold the number n, which determines the limit of the computation. The program, then, must supply two types of information. First, it must include the executable instructions, data, and temporary registers which will occupy memory cells when the program is executed. must Finally, include a certain amount of information for the MACRO Assembler itself, and extent of the program in memory. to establish Second, it the locations These assembler directives are called pseudo-instructions; they are included in the program along with the executable instructions. A pseudo-instruction is rather like a proofreader's mark on a manuscript; the mark provides information to the editor, but does not itself cause additional text to appear in the printed book. Similarly, a pseudo-instruction provides information to the Assembler, but does not itself cause any coding to be inserted into the obiect program. 4.2 CODING First one must decide where the program is to be stored. Now to write the program. This word is called the m, necessary only to establish the location of the first register of the program. and can be designated in two ways. to To do this, it is The most common way is to designate the page in which the program is be stored; the origin is automatically set at the first register (page address 0) in that page. Thus, to put the routine in page 2, the pseudo-instruction, PAGE, would be used as follows: PAGE 2 The program would then begin in location 0 of page 2. To set the origin to any register other than the first one in a page, the absolute address of the starting location must be specified. This is done by using the special character “9:" . To place the origin at loca- tion 2T0, the coding would be: *210 In establishing the origin, an index within the Assembler, called the current location counter (CLC), has been set equal to the absolute address of the origin. For example, the use of PAGE 2 would set the CLC 4—2 to a value of 400, which is the absolute address of the first register in page 2. the CLC to be set to a value of 2T0. Likewise, *210 causes ln programming terms the CLC points to the origin; such an index is called a pointer. The coding for the program may now be written. First three registers for the three items of data must be Usually, data storage is set aside by placing a O in each register, thus allocating a cell. reserved. The coding looks like this: PAGE 2 O O 0 Since the origin has been set at location 400, the three data cells occupy locations 400, 40l , and 402 (page addresses 0, l, and 2, respectively). Next, write the coding for the computation. PAGE 2 O O 0 CLA DCA 400 TAD 40] DCA 402 TAD 400 TAD 402 DCA 400 STA TAD 402 SZA JMP 406 HLT $ The program now occupies locations 400-4l6 (O-lé on page 2). The special character $ indicates to the Assembler that it is a complete program and that nothing else is to follow. This program is now complete, and can be assembled into a working routine. The coding, however, is rather stark, and not very useful to another programmer, should he wish to discover what the program does. Of course, he could Figure out the function of the routine by going through it step by step with pencil 4-3 and paper, but if this program were much a longer, this task would be tedious and impractical. Comments, method of explaining the Functions of the program, make the work immediately useful to someone else. 4.3 COMMENTS Comments are included in a PDP—8 program in a simple way. our program. Consider the three data storage locations of A comment would identify each register's function immediately; they might appear as: /PART|AL SUM AND FINAL TOTAL /INTEGER N /INDEX 0 0' The slash preceding each comment is the character which identifies a comment field. All information on that line following the slash is considered to be a comment, and is ignored by the Assembler. and neatness, a For clarity tab has been inserted between the instruction and the comment. Since a slash identifies all the subsequent information on a line as a comment, for a title by placing the slash in the first space after the left margin. one full line can be used With a title, the program might look like this: /|NTE GER SUMMATION ROUTINE PAGE 2 /PARTIAL SUM AND FINAL TOTAL 0 Now, an immediate identification of what the program is to be used for is included in the listing. More comments explain the workings of the program: /|NTEGER SUMMATION ROUTlNE PAGE 2 o 0 0 /PART|AL SUM AND FINAL TOTAL /|NTEGER N /INDEX CLA DCA 400 /ZERO TO SUM TAD 401 DCA 402 TAD 400 /SET INDEX /MAIN LOOP TAD 402 DCA 400 STA /DECREMENT INDEX 4—4 TAD 402 /IS IT 0? /NO: KEEP GOING /YES: HALT SZA JMP 406 HLT $ Now it is a little easier to understand the program, but some limitations remain. lar place in the computer's memory; to put it in some other addresses would be necessary. It is tied to one particu- location, recoding the entire routine with new Nor are these octal page addresses much help in keeping track of program flow; even in a short routine such as this, it is necessary to do some counting to find out what location the instruction STA is in, for example. -4.4 A simple, meaningful way of identifying storage addresses is needed. ADDRESS TAGS As described above, a symbol is assigned to each of the PDP-8 instruction codes. mer can Similarly, the program- assign a'symbol to any one of the storage addresses in the computer memory. routine under discussion contains three important registers: For instance, the the beginning of data storage, the beginning of the program sequence, and the beginning of the main loop. Each one of these locations can be labelled with a symbolic tag, in the following way: /INTE GER SUMMATION ROUTINE PAGE 2 /PART|AL SUM AND FINAL TOTAL /INTEGER N /INDEX DATA, 0 0 0 BEGIN, CLA DCA 400 /ZERO TO SUM TAD 40I Go, DCA 402 TAD 400 /SET INDEX /MAIN LOOP TAD 402 DCA 400 STA /DECREMENT INDEX TAD 402 SZA JMP 406 HLT /IS IT 0? /NO: KEEP GOING /YES; HALT $ Three reference points have been established. Note that the tags are roughly mnemonic, thus offering an additional measure of program identification and clarification. been defined. In programming terms, three symbols have In this case, each symbol has a value that is equal to the absolute address of the register in which the associated item (data word or instruction) is stored. of BEGIN, 403; of GO, 406. 4-5 Thus, the value of the symbol DATA is 400; '4.4.l Symbolic Addressing Locating sections of a program has been simplified, but full advantage of address tags has not yet been taken. The instruction addresses themselves are still tied to the absolute addresses of the program. ever, since How- each tag has a numeric value corresponding to an address, a tag may also be used as a symbol in the address part of an instruction. For example, the absolute address 402 is clearly equivalent to the expression, BEGIN—l (BEGIN=403; 403-l=402). Similarly, the address 4ll is equivalent to GO+3. Replacing absolute addresses with symbolic expressions, the program will look like this: /INTE GER SUMMATION ROUTINE PAGE 2 /PARTIAL SUM AND FINAL TOTAL /lNTEGER N /INDEX DATA, 0 0 0 BEGIN, CLA DCA DATA /ZERO TO SUM TAD DATA+I GO, DCA DATA+2 TAD DATA /SET INDEX /MA|N LOOP TAD DATA+2 DCA DATA STA /DECREMENT INDEX TAD DATA+2 SZA JMP GO HLT /IS IT 0? /NO: KEEP GOING /YES: HALT $ This program that is easily readable, includes a running commentary for explaining its functions, and carries its own symbolic references that further assist in understanding and keeping track of the routine. Moreover, the routine has been freed from a specific place in memory by the use of symbolic addresses. To change the location of the program, it is necessary only to change the origin setting by the PAGE pseudo-instructions 4.5 . STORAGE TECHNIQUES The program above will function but it may be improved. One of its drawbacks is the fact that wherever the program is stored, the data must be stored right along with it. When space is at a premium, as it often is, it would be desirable to put all of the data in a fixed place, and let the working parts of the program be arranged as necessary. In the PDP-8, data that is used by several parts of a program is often stored in page 0. If each of the three data words in the program is given a name, page 0 addresses can be assigned to them. 4-6 Call the first word TOTAL, the second INDEX, and the third N . In effect, the data words have been labeled with address tags, but since the names can be used in symbolic eXpressions (for instance, in address), programmers usually refer to them as variables. If the variables are assigned to page 0 and the an instruction instruction address in the program changed to match, the coding will look like this: /| NTE GER SUMMATION ROUTINE *20 TOTAL, 0 INDEX, 0 0 N, /THESE REGISTERS ARE /NOW ON PAGE 0 PAGE 2 BEGIN, CLA DCA TOTAL /ZERO TO SUM TAD N GO, DCA INDEX TAD TOTAL /SET INDEX /MAIN LOOP TAD INDEX DCA TOTAL STA /DECREMENT INDEX TAD INDEX SZA JMP GO HLT /IS IT 0? /NO: KEEP GOING /YES: HALT $ When the program is loaded, the three items of data (having been assigned addresses on page 0) will be stored in page 0. A large step toward our goal of a refined, useful routine has been taken; i.e., a program which may be placed anywhere in memory and is easily understood and interpreted by someone other than the author, because of liberal comments and symbolic addressing. 4.6 OPTIMUM USE It remains only to relate this sequence of coding to the context in which it is likely to operate. Obviously the summation program is useless in core by itself, waiting for an integer summation to be carried out. Since the example has served its purpose in illustrating how a complete program can be written, all the coding except the minimum necessary for the actual computation will be removed, leaving this (the ellipsis always indicates the presence of unspecified coding): 4—7 BEGIN, CLA DCA TOTAL /ZERO TO SUM TAD N GO, DCA INDEX TAD TOTAL /SET INDEX /MAIN LOOP TAD INDEX DCA TOTAL /DECREMENT INDEX STA TAD INDEX /IS IT 0? /NO: KEEP GOING /YES: HALT SZA JMP GO HLT This sequence can now be placed within a larger program wherever it may be needed. example of a long program which uses this routine two times. Figure 4-2 is an Whenever the summation routine occurs, it is preceded by an instruction which takes the value of N from the AC and places it on the proper loca- tion in data storage . One other change is also necessary. The address tag GO has been eliminated from all but the first occurrence in the coding sequence; it is obvious that one symbol cannot be defined with more than one value, or there would be confusion as to which of the values was meant at any one time. As a result, it is necessary to eliminate the reference to GO in the JMP instruction at the end of the sequence . Notice that the instruction, DCA INDEX always remains exactly seven locations ahead of the JMP in- struction, regardless of where the routine is stored. to the a Evidently, an address expression which could refer location of DCA INDEX relative to the location of the JMP instruction is needed. In other words, construction is desired that will perform the same function as the following but without having to define the symbol HERE: DCA INDEX TAD INDEX HERE, JMP HERE-2 Remembering that the current location counter always "points" to the location of the instruction currently being assembled, it becomes apparent that what is desired is a symbol which, whenever it is used, M takes the value of the CLC . In MACRO-8, this symbol is the period, " ." . Whenever this character is encountered in an address expression, the value of the CLC is substituted for it. In the example in Figure 4-2 it is used in the address of the JMP instruction wherever it appears in the routine. the necessity of having to define a new set of symbols each time the routine is used is avoided. In this way, PAGE 10 BEGIN, DCA N DCA TOTAL TAD N /IN|T|AL|ZAT|ON ' GO, DCA INDEX TAD TOTAL TAD INDEX DCA TOTAL /SET INDEX /MA|N LOOP - /INCREMENT INDEX STA TAD INDEX _ /Is IT 0? /NO: KEEP GOING /YES: ALL DONE SZA JMP GO DCA N DCA TOTAL TAD N DCA INDEX TAD TOTAL INDEX TOTAL TAD DCA - /SET INDEX /MAIN LOOP /DECREMENT INDEX STA TAD INDEX /IS IT 0? /NO: KEEP GOING /YES: ALL DONE SZA JMP .-7 Figure 4-2 4.7 /INITIALIZATION Program Example SUBROUTINES Now the program example is useful, but one more difficulty must be overcome. An examination of Figure 2-4 will make this problem obvious: If the routine is used very many times, an extremely large amount of storage space will be used simply in repetitions of the same coding sequence the general aim of writing a concise, efficient program. . This counteracts If the routine could be written only once, placed in a separate section of memory and called into operation each time it was needed, the whole procedure would be more efficient. 4—9 A program that may be used in this manner is called a subroutine. It is a sequence of coding with the fol lowing properties: I. It is self-contained, that is, it can be assembled by itself without having to be part of a larger program. logically separate from other coding sequences. 2. It occupies its own section of memory, 3. It performs only one task. 4. It is called into operation only by another program, and when it has finished its Each subroutine has a definite purpose. task, it returns to that program. It can be called any number of times, and upon com- pletion always returns control to the point from which it was last called. 5 a . When necessary, it uses data supplied by the calling program, and returns results to place accessible by that program . When a subroutine is written, four requirements which are implied by the last two properties listed above must be fullfilled: Q The data must be accessible by the subroutine 0— The results must be accessible by the calling program. 0 There must be a way of calling the subroutine into operation d. There must be a way of returning control to the calling program .. . . The problem of data transmission has been solved by placing the three data storage registers in page 0, thereby making them accessible to any program or subroutine in memory. return is not quite so obvious. The transfer and control of First, restore the symbolic tags to the subroutine as well as the title and other pseudo-instructions to make it a self-contained program giving: /|NTE GER SUMMATION SUBROUTINE PAGE 2 INTSUM, DCA N DCA TOTAL /SAVE INPUT IN C(AC) /ZERO TO SUM TAD N GO, DCA INDEX TAD TOTAL /SET INDEX /MA|N LOOP TAD INDEX DCA TOTAL STA /DECREMENT INDEX TAD INDEX /IS IT 0? /NO: CONTINUE /YES SZA JMP GO At a first glance, it could seem easy to eliminate the problem of transferring control to the subroutine. A JMP INTSUM in the calling program every time the subroutine was called would provide the path what happens at the end of the calculation? The subroutine has no way of knowing where to return. . But The subroutine cannot merely halt as this violates requirement d above. The solution lies in the use of the JMS instruction. Remembering from Chapter 2 when the JMS instruction is executed, the contents of the program counter are saved in the location addressed by the instruction, and control is transferred to the register immediately following the one addressed. contains the address of the next instruction following the JMS is available . Thus, a register which This can be used to return to the proper point in the calling program when the subroutine has finished its computation. Rearrange the first part of our subroutine as follows: /lNTE GER SUMMATION ROUTINE PAGE 2 INTSUM, 0 DCA N DCA TOTAL /SAVE PC HERE /SAVE INPUT NUMBER /ZERO TO SUM TAD N GO, DCA INDEX /SET INDEX Now, whenever the instruction JMS INTSUM is used, the contents of the program counter are stored in the location tagged with the name INTSUM and the computer continues operation with the instruction imme- diately following which is the first instruction of the subroutine. Now that the subroutine has been called, a means to exit from it must be provided. stores the program counter which JMS "points" to the instruction following the JMS . The JMS instruction After the execution of a INTSUM, the register INTSUM contains the contents of the program counter at the time the JMS was executed. return to This can be used as an effective address (See Chapter 3 the point of call. , the ”Organization of Memory") to To do this, the subroutine may be terminated with a JMP instruction which references the register INTSUM as an indirect address as follows: 4—H /INTEGER SUMMATION SUBROUTINE PAGE 2 /SAVE PC HERE /SAVE INPUT NUMBER INTSUM, o DCA N JMP I The character INTSUM mas; is used to signify indirect addressing. EXIT SUBROUTINE In use here it means, ”Jump to the register whose address is contained in the register tagged INTSUM." The complete subroutine is shown below: (not including the page 0 definition of the variables). /INTE GER SUMMATION SUBROUTINE PAGE 2 INTSUM, O DCA N DCA TOTAL /SAVE PC HERE /SAVE INPUT NUMBER /ZERO TO SUM TAD N GO, DCA INDEX TAD TOTAL /SET INDEX /MAIN LOOP TAD INDEX DCA TOTAL STA /DECREMENT INDEX TAD INDEX SZA JMP GO JMP I INTSUM /IS IT 0? /NO: CONTINUE /YES: ALL DONE The reader is referred to the PDP-8 Library for other examples of subroutine calling techniques. The MACRO—8 Programming Language may now be discussed in detail. CHAPTER MACRO-8 5.I 5 PROGRAMMING LANGUAGE FUNCTION The MACRO-8 Symbolic Assembler accepts source programs written in symbolic language and translates them into binary form. MACRO-8 produces an ‘obiect program tape (binary), a symbol table defining memory locations (for use with 5. 2 DDT), an octal/symbolic assembly listing, and useful diagnostic messages. COMPATIBILITY MACRO—8 is compatible with PAL III, but has the Following additional features: User-Defined Macro's Groups of computer instructions required for the the solution of a specific problem can be defined instruction by the user. as a macro Double Precision Integers Positive or negative double precision integers are allotted two consecutive core locations. Floating Point Constants The format and rules for defining these constants are compatible with the format used by the PDP—8 Floating Point Package (See Digital-8—5—S). Operators . Symbols and integers may be combined with a number of operators. Literals + Addition & Boolean AND f Subtraction '. Boolean Inclusive OR Symbolic or integer literals (constants) are auto— matical ly assigned Text Facility . There are text facilities for single characters and blocks of text. Link Generation Links are automatically generated for out of page references 5—l . To incorporate these new features, it was necessary to decrease the size of the symbol table and because of this, programs that were originally coded to be assembled by PAL III might have too many symbols to be assembled by MACRO-8. If Switch Register switches 10 and H are set to "l " during assembly (See Table 9—1) MACRO—8's external(user) symbol table will be extended. 5.3 CHARACTERS Programs in the MACRO-8 language are written using characters from the ASCII character set. The following characters are used: 5.3.l Letters ABCD...XYZ 5.3.2 Digits 1234567890 5.3.3 Punctuation Characters Since a number of characters are invisible (i .e . , nonprinting), the Following notation is used to represent them in the examples: space w M ) tab carriage return The Following characters are used to specify operations to be performed upon symbols or numbers: Character Hie 1—! space Combine symbols or numbers- + plus Combine symbols or numbers (add) minus Combine symbols or numbers (subtract) ' exclamation point Combine symbols or numbers (OR) ) carriage return Terminate line ._.>l tab Combine symbols or numbers or format source - tape 5-2 comma Assign symbolic address equals Define parameters ; semicolon Terminate coding line $ dollar sign End of pass * asterisk Set location counter . point Has value equal to current location counter / slash Indicates start of a comment & ampersand Combine symbols or numbers (AND) quote Generate ASCll constant ( ) parentheses Define literal on current page [ ] brackets Define page 0 literal < > angle brackets Define a macro , = " 5 3 4 . . Ignored Characters Form-feed End of a logical page of a source program (see Symbolic Editor) Blank tape Used for leader/trailer Rubouts Used for deleting characters Code 200 Used for leader/trailer Line-feed Follows carriage-return All other characters are illegal when not in a comment or a TEXT field, and cause the error message lC to be printed. The form-feed is used at the end of a page of program for editing purposes. The functions of leader and trailer are self-explanatory. This may be either blank tape or code 200. Tabulations are usually used in the body of a program to provide a neat page for printing; they can separate fields from one another, as between an instruction and an associated comment. For example, a line could be written as: GO, TAD TOTAL/MAIN LOOP) but it is far easier to read if tabs are inserted: GO, —->i TAD TOTAL —>| /MA|N (the characters —§l and Either ; J are LOOP) nonprinting) (semicolon) or the combination carriage-return/line-feed may be used as line terminators. The semicolon is considered identical to carriage-return/line-feed except that it will not terminate a comment. 5-3 Example: /THIS lS A COMMENT TAD A TAD ; B) The entire expression up to the carriage return is considered a comment. neat appearance for As was noted previously, the tabulation is used as a formatting device to provide a Use of the semicolon allows the programmer to place several lines of coding the printed program listing. on a to rotate single line. If, for example, he wishes to write a sequence of instructions the C(AC) and C(L) six places to the right, it might look like: RTR) RTR) RTR) .- He may place all three instructions as a single line by substituting the control character ";" for the line terminator RTR; ”) RTR; " (carriage return). (semicolon) The above sequence of instructions may be rewritten as: RTR‘) This type of format is particularly useful when setting aside a section of data storage for a list. For ex- ample, a l2-word list could be reserved by: LIST, 5.3.5 0; O; 0; O; O; 0‘) O; O; 0; O; 0; 0‘) Coding Practices A neat printout (or program listing, as it is usually called) makes subsequent editing, debugging, and interpretation much easier than if the coding were laid out in a haphazard fashion. listed below are in general use, and will result in a readable, orderly listing. a program to produce A title comment begins at the left hand margin. 2. Pseudo-instructions may begin at the left margin; often, one tab stop to line up with the executable instructions. 3. Address tags begin at the left margin tabulation (See Digital-8—21—U for listings of this form.) l. a The coding practices . however, they are indented They are separated from succeeding fields by . 4. Instruction fields, whether or not they are preceded by a tag field, one tab stop. 5—4 are indented 5. A comment is separated from the preceding field by a tabulation, unless it occupies the whole line, in which case it usually begins at the left margin. CODING STRUCTURE 5.4 and restrictions applicable Following is the hierarchy of assembler language components with definitions to each level. 5.4.l Elements Any group of letters, digits, and punctuation characters which represents binary values less than 2 l2 . IS an element. 5.4.2 Integers Any sequence of numbers delimited by punctuation characters forms a number. Example: 1 l2 4372 The radix control pseudo-instructions indicate to the Assembler the radix to be used in number tation. The pseudo-instruction DEClMAL indicates that all numbers are to be interpre- interpreted as decimal until the next occurrence of the pseudo-instruction OCTAL. The pseudo-instruction OCTAL indicates that all numbers are to be occurrence of the pseudo-instruction DEClMAL. interpreted as octal until the next The radix is initially set to octal and remains octal un— less otherwise specified. 5.4.3 Symbols A symbol is a string of one or more alphanumeric characters delimited by a punctuation character. are Symbols composed according to the following rules: l . The characters must be either alphabetic (A-Z) or numeric (0—9) . 2. The first character must be alphabetic. 3. Only the first six characters of any symbol are meaningful; the remainder, if any, are ignored. 4. A symbol is terminated by any nonalphanumeric character. The MACRO Assembler has, in its permanent symbol table, definitions of the symbols for all PDP-8 operation codes, operate commands, and many lOT commands (see Appendix A for a complete list). 5—5 These may be used without prior definition by the user. Example: is a symbol whose value of 4000 is taken from the operation code JMS definitions. is a user—created symbol. A When used as a symbolic address tag, its value is the address of the instruction it tags. Assembler This value is assigned by the . Note that because of rule 3, a symbol such as INTEGER, for instance, would be interpreted as lNTEGE since the seventh letter is ignored. If symbols of more than six characters are used, the programmer should be careful to avoid the error of defining two apparently different symbols whose first six characters are, in fact, identical. For example, the two symbols, GEORGE] and GEORGEZ, differ only in the seventh character, so that the Assembler would treat them as being the same symbol, GEORGE It is not necessary to define a symbol before it is used in an expression. end of PASS l, however. . They must be defined before the Thus, one may refer to a number of registers by their address tags, and then define the symbols later. Parameter Assignments 5.4.3.1 A symbol may be assigned a value by means of a parameter assignment statement which looks like an alge- braic statement. The single symbol to the left of the equal sign is assigned the value of the expression on the right. No space(s) or tab(s) may appear between the single symbol to the left of the equal sign and the equal sign Examples: . A = 6 EXIT C = = JMP I 0 A + B All symbols to the right of an ”=" sign must be already defined. The symbol to the left of the "=" sign and its associated value is stored in the Assembler's symbol table. The use of the "=" does not increment the current location counter. Assembler itself rather than a part of the output binary. 5.4.3.2 A symbol may be defined by the user in one of three ways: . By use of a parameter assignment. Example: DISMIS = JMP RESTOR 5—6 rather, an instruction to the The equal sign may be used to redefine a symbol. Symbol Definition i It is, 2. As a macro name. Example: DEFINE LOAD A < CLA TAD A > 3. a By use of the comma. When a symbol is terminated by a comma, it is assigned value equal to the current location counter. Example: /SET CLC TO 100 *100 TAG, CLA B, A, 0 JMPA DCAB The symbol I'TAG" is assigned a value of OlOO, the symbol "B" a value of 0102, and the symbol ”A" a value of 0103. 5.4.4 Expressions All elements, i.e., symbols and numbers (exclusive of pseudo-instruction symbols, macro names, and double precision or Floating point constants) may be combined with certain operators to form expressions. These opera tors are: + This signifies 2's complement addition (modulo plus 409610). — This signifies 2's complement subtraction (modulo minus 409610). 1 exclamation point This signifies Boolean inclusive OR (union). & ampersand This signifies Boolean AND (intersection). ~—-I space Space is interpreted in context. It may signify inclusive OR or act as a field delimiter. Symbols and integers may be combined with any of the above operators. ated from left to right; no grouping of terms is permitted. Value Value Value . A symbolic expression is evalu— Example: A _B_ A+ B A-B A 1 B E 0002 0003 0005 7777 0003 0002 0007 0005 0014 0002 0007 0005 0700 0007 0707 067] 0707 0000 5-7 The MACRO-8 Assembler makes a distinction between the types of symbols it is processing. are These types l) permanent symbols, 2) user defined symbols, and 3) macro names. The character "space" is inter— preted written in the context of the expression. If a space is used to delimit two or more permanent sym- bols, space signifies inclusive OR. Example: CLA is a permanent symbol whose value is 7200. CMA is a permanent symbol whose value is 7040. The expression: CLA has a value of 7240. CMA .__. If the symbol following the space is a user defined symbol, space acts as an address field delimiter. Example: *2117 CLA A, JMP .._J A "A" is a user defined symbol whose value is 2] T7. The expression JMP L_. A is evaluated as follows: The seven address bits of A are taken, i.e.: A 010 00100] HT 1001 iii The remaining five bits of A are tested to see if they are 0‘s (page 0 reference); if they are not, the current page bit is set. 000 Oil 001 ill The operation code is ORed into the expression: 10] 000 000 Address A 000 Oil 00] ill Oil 001 ill JMP JMP or, written more 5317 A 101 concisely: 000 In addition to the above outlined tests, the page bits of the address field are compared with the page bits of the current location counter. If the page bits of the address field are nonzero and do not equal the page bits of the current location counter, an If the reference out-of—page reference is being attempted. is to an address not on the page where the instruction will be located, the Assembler will set the indirect bit (bit 3) and an indirect address linkage will be generated on the current memory page. page reference is already an indirect one, the error diagnostic II PASS 2. case If the out—of- (Illegal Indirect) will be typed on When the link is generated, the LG (Link Generated) message will be typed on PASS 2. In the of several out—of—page references to the same address, the link will be generated only once, but the LG message will be printed each time. Example: *2117 CLA A, *2600 JMP ._. A The space preceding the user defined symbol "A" acts as an address field delimiter. The Assembler will recognize that the register tagged "A" is not on the current page (in this case 2600-2777) and will generate a link to it as follows: in location 2600 the Assembler will place the word 5777 which is JMP I 2777 in address 2777 (the last location on the current page), the word 2I I7 (the actual address of ”A”) will be placed. The address field of a memory reference instruction may be any valid expression. Example: A=270 * 200 TAD A—20 would produce, in location 200, the word OOI OIO I01 000 or 1250 (TAD 250) Although the Assembler will recognize and generate an indirect address linkage when necessary, the programmer may indicate an explicit indirect address by using the special between the operation code and the address field. . This must be The Assembler cannot generate a link for an instruction that is already specified as being an indirect reference. II symbol I'I'l (Illegal Indirect). 5-9 In this case, the Assembler will type the message 5 5 . SPECIAL SYM BO LS The period, asterisk, left parenthesis and quote have special usage which is adhered to universally in PDP—8 assembler programs. 5.5. 1 Current Address Indicator The single character period (.) has, at all times, a value equal to the value of the current location It may be used as any integer or symbol counter. (except to the left of an equal sign). Example: *200 JMP .+2 ls equivalent to JMP 202. * . 300 +2400 would produce, in register 0300, the quantity 2700. *2200 CALL=J MS I . 0027 Since the second line, CALL=JMP | . , does not increment the current location counter, 0027 would be placed in register 2200 and CALL would be placed in the symbol table with an associated value of 100 110 000 000 or 4600. 5.5.2 Origin Setting The origin (current location counter) is reset by use of the special character asterisk (*). location counter is set to the value of the expression following the 0200. All symbols to the right of "*" must "*” . The current The origin is initially set to already have been defined. Example: If D has the value 250 then *D+lO will set the location counter to 0260. To simplify page handling, the pseudo—instruction PAGE may be used. the origin is reset to the first location of the next page. When ”PAGE" is encountered, A page number may be specified by a legal expression Following the page pseudo-instruction. Example: * at this 270 point, either * 400 PA GE or PAGE 2 will reset the origin to 0400. 5.5.3 Literals Since the symbolic expressions which appear in the address part of an instruction usually refer to the loca— tions of registers containing the quantities being operated upon, the programmer must explicitly reserve the registers holding his constants. The MACRO-8 language provides a means for using a constant directly. Suppose, for example, that the programmer has an index which is incremented by two. One way of coding this operation would be as follows: cLA TAD INDEX TAD C2 DCA INDEX C2, 2 Using a literal, this would become CLA TAD INDEX TAD (2) DCA INDEX The left parenthesis is a signal to the Assembler that the expression following is to be evaluated and as- signed a register in the constants table of the current page. This is the same table in which the indirect address linkages are stored. In the above example, the quantity 2 is stored in a register in a list begin- ning at the top of the memory page (page address 177), and the instruction in which it appears is encoded 5-H with an address referring to that address. A literal is assigned to storage the first time it is encountered; subsequent references will be to the same register If the programmer wishes to assign literals to . page 0 rather than the current page, he may use square brackets, "E" and "J “, in place of the parentheses. However, in both cases, the right of closing member may be omitted. TAD AND The Following examples are acceptable: (777) UMP) Note that in the second example, the instruction AND [JMP has the same effect as AND [5000. Literals may be nested. For example: *200 TAD (TAD (30 will generate 0200 l 376 0376 l 377 0377 0030 This type of nesting may be carried to as many levels as desired. at page address W7 and extending toward page address 0. page 0). Literals are stored on each page starting (Only 12710 or 1778 literals may be placed on If a literal is generated for a nonzero page and then the origin is set to another page, the current page literal buffer is punched out (during PASS 2). If the origin is then reset to the previously used page, the same literal will be generated if used again. 5.5.4 Single Character Text Facility If a single character is preceded by a double quote, the 8—bit value of the ASCII code for the character is inserted instead of taking the letter as a symbol. CLA TAD ("A will place the constant 030] in the accumulator. Example: CHAPTER 6 PSEUDO-INSTRUCTIONS 6.1 FUNCTIONS The pseudo-instructions are directions to the Assembler to perform certain tasks or to interpret subsequent coding in a certain way. By themselves pseudo-instructions do not generate coding or (in general) effect the current location counter. The functions of each pseudo-instruction are described in this chapter. CURRENT LOCATION COUNTER 6.2 PAGE This pseudo-instruction is used to set the current location counter. PAGE n This will reset the current location counter to the first address of page n, where n is an integer, a previously defined symbol, or a symbolic expression. Examples: PAGE 2 will set the CLC to 0400 PAGE 6 will set the CLC to 1400 When used without an argument, PAGE will reset the CLC to the first location on the PAGE next succeeding page. Thus, if a program is being assembled into page l and the pro- grammer wishes to begin the next segment on page 2, he need only insert the instruction PAGE, as pseudo- follows: JMP . —7 PAGE CLA The current location counter may be explicitly set by use of the asterisk. 6.3 EXTENDED MEMORY On PDP—8's equipped with more than one FIELD n memory bank, the pseudo—instruction may be used where n is an integer, a previously defined symbol, or a symbolic expression within the range 03n57. This pseudo—instruction causes a word of the form ll XXX 000 where OOOSXXX 5 ill 6-1 to be punched on the binary tape during PASS 2. This word is interpreted by the Extended Memory Binary Loaders (see Digital‘8-2A-U; Digital-8—ZB—U). 6.4 RADIX CONTROL Normally, all integers used in a program are taken as octal numbers. If, however, the programmer wishes numbers treated as decimal, he may use the pseudo-instructions: to have certain When this pseudo-instruction occurs, all integers encountered in subsequent coding will DECIMAL be taken as decimal until the occurrence of the pseudo-instruction which will reset the radix to its original OCTAL (octal) base. NUMBERS 6.5 The types of numbers allowed are integers (See Chapter 5), double precision integers, and double pre— cision floating point numbers. 6.5.] Double Precision Integers Double precision integers may be positive or negative (2's complement) according to their sign but may not be combined with operators. not disturbed. They are always taken as decimal radix although the current radixis Each double precision integer is allotted two consecutive registers with the sign indicated by bit 0 of the first word. The double precision integer mode is entered through the use of pseudo-instruction DUBL and all numbers encountered will be taken as double precision integers until an alphabetic character is encountered. Each number is terminated by the carriage return (d ) or *400‘) 679467) 44) DUBL _3) TAG, CLA) would produce 0400 0245 0401 705 3 0402 0000 0403 0054 6-2 the semicolon (;) or by a comment. Example: 0404 7777 0405 7775 0406 7200 and the symbol ”TAG” would have a value equal to 0406. 6.5.2 Floating Point Constants Double precision floating point constants may be positive or negative according to their sign but may not Decimal radix is assumed but the current radix is not altered. be combined with operators. point constants are each assigned three registers and are stored in normalized form . Floating (See Digital—8-5—S for a description of floating point arithmetic.) The double precision floating point mode is entered through use of the pseudo-instruction FLTG. All numbers encountered after the use of FLTG will be taken as double precision Floating point constants until the occurrence of an alphabetic character otherthan E . The general input format of a floating point number is iddd ddddEidd - where the d's are decimal digits. Any character which is not legally part of the above format (except rubouts) terminates input of the number. Example: Produces *400 FLTG +509 . 32E-02) -62 97E . i TAG2, . 00E 04) -2) CLA) 0400 0003 040] 2427 0402 6670 0403 0024 0404 0405 5462 0740 0406 7772 0407 2436 041 0 5574 041 i 7200 and the symbol ”TAG2" would be assigned a value of 0411 6.6 . TEXT FACILITY There is a text facility for single characters and text strings. mode (double quote), see Chapter 5. For a description of the single character .A string of text may be entered by giving the pseudo-instruction TEXT followed by a space, a delimiting character, a string of text, and repeating the same delimiting character. Example: ATEXTA TEXT The character codes are stored two to a register in ASCII code that has been trimmed to six bits. lowing the last character, a 6—bit zero is inserted as a stop code. Fol- The above statement would produce: 2405 3024 0000 /B0 B/ TEXT L4 would produce 0217 0200 The TEXT pseudo—op could also be used'as part of a calling sequence to a subroutine: JMS MESS a. TEXT / / or b. JMS MESS NOWDS ADDMESS ADDMESS, TEXT / - /NO WDS IN MESSAGE /ADDRESS OF MESSAGE / Note that while the TEXT pseudo—instruction causes characters to be stored in a trimmed code, the use of the single-character control code (") causes characters to be stored as a Full 8—bit ASCII code. 6.7 END OF PROGRAM The special symbol ”35" indicates the end of a program. nates the PASS. When the Assembler encounters the "$" it termi— 6.8 END OF TAPE When several tapes are to be assembled together, each, except the last (which ends in "$"), should have its last symbol the pseudo—instruction PAUSE. This causes the MACRO—8 Assembler to stop processing as and halt the computer. After placing a new tape in the reader, assembly can be continued by depressing CONTINUE. 6.9 ALTERATIONS TO THE SYMBOL TABLE There are two pseudo—instructions that may be used to alter the permanent symbol table (during PASS 1): EXPUNGE EX PUNGE the entire symbol FIXTAB FIX the symbol TABle. table, except for the pseudo-instructions. All symbols that are currently in the symbol table are fixed. Example: CLSF = 6141 FIXTAB would define CLSF as a permanent symbol. EX PUNGE TAD=lOOO FIXTAB would place the symbol TAD in the assembler's permanent symbol table. been expunged All other symbols would have . To append the following card reader IOT's to the symbol table, the programmer generates an ASCII tape of: RCSF=663I RCSP=667I RCRD=6674 FIXTAB PAUSE The ASCII tape is then read into core ahead of the symbolic program tape during pass I. The PAUSE pseudo-op stops assembly, and the Loader waits for the programmer to put the symbolic program tape into the tape reader and press CONTinue. CHAPTER 7 MACROS 7.1 FUNCTION When writing a program, it often happens that certain coding sequences are used several times with iust If so, it is convenient if the entire sequence can be generated by a single state- the arguments changed. ment. To do this, the coding sequence is defined with dummy arguments as a macro. A single statement referringto the macro by name, along with a list of real arguments, will generate the correct sequence in line with the rest of the coding. 7.2 DEFINING The macro name must be defined before it is used. The macro is defined by means of the pseudo-instruction DEFINE followed by the macro's name and a list of dummy arguments. For example: A macro to move the contents of register A to register B and also leave the result in the accumulator, would be coded as follows: DEFINE H MOVE DUMMYI' H M DUMMY2 <CLA TAD DUMMYI DCA DUMMY2 TAD DUMMY2> The actual choice of symbols used as dummy arguments is arbitrary; however, not be defined or they may referenced prior to the macro definition. The above definition of the macro MOVE is identical to the following: DEFINE E_. <CLA;TAD MOVE H ARGI; ARGIEE ARGZ DCA ARGZ; TAD ARG2> The actual definition of the macro is enclosed in angle brackets. When a macro name is processed by the assembler, the real arguments will replace the dummy arguments. For example: Assuming that the macro MOVE has been defined as above, *400 A,0 B, -6 0400 0000 0401 7772 MOVE _. A, B $ 0402 7200 0403 0404 0405 3201 l 201 l 200 A macro need not have any arguments: NOTE: sequence of coding to rotate the C(AC) and C(L) six places to the left might be encoded as a macro For example, a by means of DEFINE.“ ROTL 6 <RTL; RTL; RTL> The entire macro definition is placed in the Macro Table, two characters per word, with a dummy argument value replacing the symbolic name. Example: DEFINE LOAD.“ A a <CLA TAD A> is stored, in the Macro Table, |CL|A)| TA| D... roughly as follows: l77oo|>ool where the vertical lines indicate successive l2—bit words. are not stored Comments and line-feeds . The macro definition can consist of any valid coding except for TEXT or 7.3 " type statements. RESTRICTIONS l . Macros cannot be nested; i.e. , another macro name or definition cannot appear in a macro definition and cannot be brought in as an argument at reference time. ” type statements cannot appear in a macro definition. 2. TEXT or 3. Arguments cannot be: 4. a. Macro name b. TEXT pseudo—instruction or ‘' special character The symbols used as dummy arguments must not have been previously defined or referenced . 5. A macro may not be redefined. DEFINE LOOP“ A H <TAD A DCA B TAD COUNT ISZ B JMP .-2> H Example: B The symbol "COUNT" is not a dummy argument but an actual symbol. A macro is referenced by giving the macro name, by commas. macro a space, and then the list of real arguments, separated There must be at least as many arguments in the macro reference as in the corresponding definition. When a macro is referenced, its definition is found, expanded, and the real arguments replace the dummy arguments. LOOP a The expanded macro is then processed in the normal fashion. X, Y2 is equivalent to: TAD X DCA Y2 TAD COUNT ISZ JMP Y2 . NOTE: —2 The macro table shares the available space (60410 registers) with the symbol table. Thus the programmer must be aware of the amount of room required by his macros and the fact that each symbol occupies four words of memory. Also, the arguments of a macro call are temporarily stored in this buffer space while the macro is being expanded. CHAPTER ERROR 8.] 8 DIAGNOSTICS FO RMAT The format of the error messages is: ADDRESS ERROR CODE Where ERROR CODE is a 2-character code which specifies the type of error, and ADDRESS is either the absolute octal address where the error occurred or the address of the error relative to the last symbolic tag (if there was one) on this page . Assembly will continue or may be continued after all errors except SE (Symbol Table Exceeded). the Assembler will halt and may not be restarted. error occurs, 8. 2 ERROR MESSAGES PE If an SE Current, Non-Zero Page Exceeded An attempt was made to i. override a literal with an instruction or 2. override an instruction with a literal. This can be corrected by ZE a. decreasing the number of literals on the page b. decreasing the number of instructions on the page Zero Page Exceeded Same as PE only with reference to page 0 Illegal Redefinition of a Symbol An attempt was made to give a previously defined symbol a new value not via the "=" . The symbol was not redefined. (This is similar to the Duplicate Tag diagnostic of PAL Ill). illegal Character 1 . # % ' : ? @\ were processed neither in a comment nor a TEXT field. The character is ignored and the assembly continued. A non-valid character was processed 2. . The computer will halt with the illegal character displayed in the accumulator. Assembly may be continued by putting the desired character in the SWITCH REGISTER and depressing CONTINUE . Illegal Equals An equal A + TAD A + B sign was used in the wrong context. Examples: = = B (The expression to the left of the equal sign is not a single symbol) C Illegal Indirect An out of page reference was made, and a link could not be generated because the indirect bit was already set. Example: *200 TAD A | PAGE LG CLL CMA A, Link Generated Not an error —— a link was generated for an out of page reference at this address. *200 Generated Binary A TAD . Example: . 0200 I 777 0377 0400 0400 7I 40 PA GE A, SE CMA, CLL Symbol Table Exceeded The Symbol Table overlaps the Macro Table or vice versa. be continued Assembly is halted and cannot . Illegal Format in a Macro Definition The expression after the DEFINE pseudo-instruction does not comply with the macro definition, position, or structural rules. Example: A macro name is referenced before the macro definition. 8—2 US Undefined Symbol A symbol has been processed during PASS 2 that was not defined by the end of PASS 1 MP . Missing Parameter in a Macro Call An argument, called For by the macro definition, is missing. Example: MAC DEFINE < TAD CIA DCA MAC BE A B A B > SUM Two MACRO-8 internal tables have overlapped . This situation can usually be corrected by de— creasing the number of current page literals used prior to this point on the page . If the error persists, please contact the Small Computer Systems Programming Group at Digital Equipment Corporation for assistance . 8-3 CHAPTER OPERATING 9.1 9 INSTRUCTIONS ASSEMBLER OUTPUT MACRO—8 is a 2—pass assembler with an optional third pass which produces an octal/symbolic assembly listing. During the first pass, MACRO-8 processes the source tape and places all symbol definitions and macro definitions in its symbol table and macro table, respectively. During the second pass, MACRO-8 processes the source tape and punches the Binary Format Tape. At the end of PASS 2, MACRO-8 prints the Symbol Table (it is also punched if the 33-ASR PUNCH is turned on). read by DDT (See Digital-8—4—S) . This punched table may be The third pass provides a listing of the generated octal code and the original source language. 9.2 VERSIONS There are two versions of MACRO-8 which differ with respect to their use of input/output equipment: the low speed version uses the 33-ASR Reader for all input and the 33—ASR Punch for all output; the high speed version uses the Type 750 Photoelectric Reader for all input, the Type 75 High Speed Punch for binary output, and the 33—ASR Punch for printable output such as error printouts, symbol table punching and listing, and third pass assembly listing. NOTE: In the high speed version of MACRO—8, the Type 75 Punch may be used as the printable output device by changing the contents of location 0004 from 2600 to 0600. This is useful for long third pass listings, since the punched It is advised that output from the 75 Punch can be subsequently listed off-line. this change not be made until pass 3, so that pass l and pass 2 error messages will come out on the 33-ASR. 9.3 PROCEDURES 1. Load MACRO—8 with the Binary Loader (See Digital—8—2-U). 2. Put the source tape in the reader. 3. Set the SWITCH REGISTER to 0200. 4. Depress LOAD ADDRESS 5. Set switch options (See Table 9—l) 6. Depress START 7. Turn on the 33-ASR reader (if using the low speed version). . . . 9—] 8. When MACRO-8 stops reading (after processing a PAUSE statement), next tape in the reader and depress CONTINUE been processed . place the Repeat this step until all tapes have . 9. When MACRO-8 encounters the terminating character, dollar sign (35), it performs one of the following sets of events depending upon what pass has iust been completed. Proper operator intervention is then required. Pass Just Completed l Events Operator Intervention Turn on 33—ASR punch (in high speed Set up for PASS 2 MACRO—8, symbol table is output via 33—ASR). Put source tape in reader, and proceed from Step 2 of the oper— ating procedures, above. 2 (a) If PASS 3 is desired: (In the high speed version of MACRO-8, Terminate current assembly; punch out page 0 constants, the contents of register 0004 could be altered at this point to change output devices). Go to step 2 of the operating checksum and trailer code on binary tape; print and punch rubout, the alphanumerically ordered symbol table, an EOT procedures, above. code, a rubout, and trailer code; Set up for PASS l . (b) If PASS 3 not desired: Turn off 33-ASR punch, put next program Go to to be assembled in the reader. step 2 of the operating procedures, above. 3 Terminate assembly listing: Set up for PASS l Turn off 33-ASR punch; put next program to be assembled in the reader; . hit CONTINUE to enter PASS 1. TABLE 9-l SWITCH OPTIONS Switch Up None Result MACRO-8 will enter the next pass as defined in the preceding table. example: For if the previous assembly was terminated during or at the end of PASS restarting MACRO-8 with no switches up would cause PASS 2 to be entered. MACRO-8 initially starts at PASS 1 . Restore symbol table to only the permanent symbols and enter PASS 1 Enter PASS 2 . . 1, TABLE 9—] SWITCH OPTIONS (continued) Switch Up Result Enter PASS l without erasing any previously defined symbols. Enter PASS 3. During PASS 3, MACRO-8 outputs an octal/symbolic listing of the assembled program. If this pass is terminated before completion, either switch options 0 or 2 may be used to return to PASS l for subsequent assemblies. MACRO-8 will output as much of the source statement (symbolic) as its internal storage capacity will allow. Because of the internal operations during the processing of macro statements, the symbolic output may be meaningless. The double precision integer and double precision Floating point processors 10 are deleted and may be used for storage of user defined symbols. creases the size of the symbol table by 6410 symbols. The macro processor and the number processors (above) are deleted and may be ll used for storage of user defined symbols. table by 125 NOTE: to This in- Switches l0 and ll are This increases the size of the symbol l0 symbols. sensed whenever PASS l is entered. MACRO-8 would have to be reloaded handle subsequent programs that use macros, double precision integers, or floating point numbers. The Binary Format Tape produced during PASS 2 may be loaded by the Binary Loader. When the loading is completed, the accumulator should contain zero which indicates that it has loaded correctly. The PASS 3 output is of the following format: AAAA NNNN (Symbolic) CR/LF Where AAAA is the absolute octal address and NNNN is the generated code. of phase with the octal . Example: *200 TAD (l 0200 T377 020] 3776 DCA A 0376 4000 *4000 0377 0001 4000 0000 A, 0 Literals are somewhat out SYMBOL TABLE MODIFICATION 9.4 Because of the small amount of core macro (60410 registers) remaining to be used for programmer symbols and the table, the following suggestions are offered which may allow a particular installation or individual to conserve on table space . By use of the pseudo-ops EXPUNGE and FIXTAB, unnecessary instruction mnemonics can be removed from the symbol table thus making more space available for programmer defined symbols and macros. This also decreases assembly time as the never used instruction symbols are not involved in the symbol table searches. The most often used instruction mnemonics should be assembled first, the special characters and pseudo-instructions. so that they will be in core next to This is desirable because the symbol search routine starts searching at the top of the table and works down. At an installation that does not have a piece of optional equipment available, the corresponding instruction set can be removed. A symbolic tape beginning with EXPUNGE, containing all necessary instruction mne- monics, and ending with FIXTAB and the 35 sign could be assembled (only PASS l prior to any other assemblies. is needed) by MACRO-8 Example: EXPUNGE AND=OOOO TAD=I 000 C LA=7200 FIXTAB $ (The pseudo-op PAUSE could also be used with this tape, the first of a multiple tape assembly.) 9—4 APPENDIX I MACRO—8 SYMBOL TABLE /MEMORY REFERENCE INSTRUCTIONS KCC=6D32 AND=DOOO KRS=6O34 TAD=IOOD KRB=6O36 Isz=2DOO ITELETYPE DCA=30OD TSF=6®41 JM5=ADOD TCF=6D42 JMP=SDDD TPC=6O44 IOT=OOOD TLS=6®46 0PR=TDOO /FLOATING /MICROINSTRUCTIONS EEXT=ODOO POINT CLL=71DO EMPY=OOOO CMA=7O4D EDIV=4OOO CML=TD2O EOET=5OOD RAR=7DID PPUT=OOOD RTR=7D12 PNOR=7DOD RAL=7Z®4 IOSCILLOSCOPE RTL=7DO6 /DISPLAY IAC=TOOI DCX=6$51 5MA=75OO DXL=6O53 SZA=744O DCY=6O61 SPA=751O DYL=6®63 SNA=7450 DIx=6DSA SNL=742® D1Y=6D64 52L=743D DXS=6057 SKP=TAIO DY5=6D67 05R=74O4 DSE=6O71 HLT=7402 DCF=6072 /COMBINED MICROINSTRUCTIONS /INCREMENTAL LAS=76$4 PLSE=65D1 STA=724D PLCE=65O2 STL=7120 PLPU=6SOA GLK=72D4 PLPR=6511 /PROGRAM I NTERRUPT PLOTTER PLDD=6514 IOF=6002 PLUD=6522 DIGITAL TO PLPL=6521 CONVERTER PLPD=6524 ADC=6@@4 SPEED PEREORATED TAPE READER /LINE PRINTER RSE=6O11 LCF=6652 RRB=6O12 LPR=6655 LSF=6661 REC=6O14 SPEED PEREORATED TAPE PUNCH LCB=6662 PSE=6D21 LLD=6664 PCE=6O22 /CARD PPC=6D24 CRSF=6632 PLS=6O26 ITELETYPE KSF=6®31 PRECISION PLDU=6512 ION=6®®1 /HIGH AND DLB=6O74 CIA=7041 /HIGH COMMANDS PSUB=2ODO CLA=72OO /ANALOG INTERPRETIVE EADD=1OOO * NOP=7DOD TELEPRINTER/PUNCH READER CERS=6634 KEYBOARD/READER CRRB=6671 CRSA=6672 AI-l AND CONTROL CRT CR§E=6674 /CARD MMLC=6766 PUNCH MMML=6766 CONTROL CPSF=6631 IMEMORY CPCF=6641 SMP=61®1 CPSE=6642 CMP=61®2 /TYPE CPLB=6644 /AUTOMATIC MAGNETIC TAPE CONTROL PA RITY 138/139 MSCR=67®1 ADSF=6531 MCD=67®2 ADCV=6532 MTS=67®6 ADRB=6534 MSUR=6711 ADCC=6S41 MNC=6712 ADSC=6542 MTC=6716 ADIC=6S44 MAGNETIC MSWF=6721 ISERIAL MDWF=6722 DRCR;6603 MCWF=6722 DRCW=6605 MEWF=6722 DRCF=6611 MIWF=6722 DREF=6612 MSEF=6731 DRTS=6615 MDEF=6732 DRSE=6621 MCED=6732 DRSC=6622 MEEF=6732 DRCN=6624 MIEF=6732 IEXTENDED MTRS=6734 MUY=7405 MCC=6741 DVI=7407 MRWC=6742 NMI=7411 MRCA=6744 SHL=7413 MCA=6745 ASR=7415 /COMBINED INSTRUCTIONS MQL=7421 MMMF=67S7 SCA=7441 MULTIPLY-DIVIDE ARITHMETIC MQA=7501 CAM=6101 /MAGNETIC LAR=6104 TIFM=67Q7 LMO=6102 TSRD=6716 RDA=6112 TSWR=6716 MUL=6111 TSDF=6721 DIV=6121 TSSR=6722 SZO=6114 SAF=6124 RDM=6122 FSST=6724 /MICROTAPE TAPE SYSTEM TSRS=6734 TWRT=6731 INSTRUCTIONS DRUM LSR=7417 MMMM=67S7 /AUTOMATIC ANALOG TO DIGITAL /CONVERTER TCTI=6732 MMLS=67SI MMLM=6752 RDF=6214 MMLF=6754 RIF=6224 MMSF=6761 RMF=6244 /MEMORY MMCF=6772 RIB=6234 MMSC=6771 CDF=6201 MMRS=6774 CIF=62Q2 MMCC=6762 A1-2 EXTENSION SYSTEM ELEMENT APPE NDIX 2 ASCII CHARACTER SET These characters may be used in symbols. Character 8-Bit From 6-Bit From 01 S 323 23 02 T 324 24 303 03 U 325 25 D 304 04 V 326 26 E 305 05 W 327 27 F 306 06 X 330 30 G 307 07 Y 331 31 H 310 10 Z 332 32 I 311 11 0 260 60 J 312 12 1 261 61 K 313 13 2 262 62 L 263 63 4 264 64 N 316 5 265 65 O 317 6 266 66 P 320 14 15 16 17 20 3 M 314 315 7 267 67 Q 321 21 8 270 70 R 322 22 9 271 71 Character 8—Bit From 6-Bit From A 301 B 302 C These characters are special. Character 8-Bit From 6—Bit From 1 41 42 $ 241 242 243 244 % 245 8: 246 ' 247 ( ) 250 * 252 45 46 47 50 51 52 53 " # + , 251 253 Meaning Inclusive OR Character pseudo-instruction Illegal outside of (TEXT) or (") or comment 43 44 End of PASS Illegal outside of (TEXT) or (") or comment Logical AND Illegal outside of (TEXT) or (") or comment Define literal Teminate literal Set origin 2'5 complement addition 254 54 Define symbol 255 55 256 56 2'5 complement subtraction Has value of CLC / 257 57 Start of comment - 272 72 Illegal outside of (TEXT) or (") or comment - . A2—1 Character 8-Bit From 6-Bit From A" 273 274 73 74 Start macro definition 275 276 75 Define Parameter 76 End macro definition 277 77 300 00 Illegal outside of (TEXT) or (") or comment Illegal outside of (TEXT) or (") or comment 333 33 Define page 0 literal 334 34 Illegal outside of (TEXT) or (") or comment 335 35 End page 0 literal 336 36 337 37 Illegal Illegal ll ~>‘—‘/I-1@.°V 1* Meaning Terminate expression Li ne -feed 212 Used For Formatting (ignored) Return 2 I5 Terminate line Space 240 377 Address delimiter or inclusive OR Ru bout Form—feed 2 I4 Blank 000 Code 200 200 Ignored Ignored Ignored Ignored A2—2 INDEX A Binary—to—octal conversions, 2—2 Bits, 3-3, 3—7 Absolute address, 3—7, 3—8, 4-2, 4-3, 4-5, 4-6, 9—3 Absolute positive value, 3-8 Accumulator, 3-4, 9—3 Addend, 3-9 Addition, 3-9 Bit zero, 3—9 Block diagram, 4—] Boolean AND, 5—7 Boolean inclusive OR, 5-7 Brackets, 5—I I , 5—12 Address field delimiter, 5—9 C Address part of instruction, 4—6 Address tags, 4-5, 4-6, 5-4 Carriage return, 5-2, 5-3, 6—2 AND, 3-2, 3—5, 5-7, 5—12 Carry, 3-8, 3—9 Angle brackets, 7—1 Cell, 4—3 Argument, missing, 8-3 Character code storage, 6—4 Arithmetic operations, 3—9 Character string, 5—5 ASCII character set, 5—2, A2—I Characters, 5—2 ASCII code, 5—I2 Characters, special, A2-I ASR—33 Teletype binary codes, 2-4 CIA, 3—9 Assembler pseudo—instructions, 4-2 CLA (clear AC), 3-4, 3-5, 3—6 Assembly, 4-3 CLC (current location counter), 4-2 Assembly listing, 5—I, 9-1 CLL (clear L), 3—4 Asterisk, 5—IO, 6—I CMA (complement AC), 3—4, 3-9 Augend, 3—9 CML (complement L), 3—4 Augmented instructions, 3-l, 3-3 Coding practices, 5-4 Comma, 5—7 Comments, 4—4, 5—3, 5-4, 6—2, 7-2 BE (overlapped MACRO—8 internal tables), 8-3 Binary codes, ASR—33 Teletype, 2—4 Binary Format tape, 9—] Binary integers, 2'-I Binary Loader, 9-1, 9-3 Binary point, 3—9 Binary program tape, I-2 Comment field, 4—4 Complement, 3-9 Complement arithmetic, 3-8 Constants table, 5-II CONTINUE, 6—5, 9—2 Count, 4-] Counter, 4—2 INDEX (Cont) Current address indicator, 5-IO Encoding, 2—4 Current location counter, End of tape, 6-5 4—2, 5—9, 6-1 Current Non—Zero Page Exceeded, 8—1 Equal sign, 5—6 Current page, 3—7, 5—11 Error code, 8—] Current page bit, 5-8 Error diagnostic II, 5-9 Current radix, 6—2, 6-3 Error diagnostics, 8—1 Error message format, 8-] D Error message IC, 5—3 Error messages, 8—] Data cells, 4—3 Data storage registers, 4—10 Event times, 3—3, 3—5 Expression, 4—6, 5—6, 5—7 DCA, 3-2 EXPUNGE, 6—5, 9—4 DECIMAL, 6—2 Extended memory, 6-] Decimal integers, 2-1 DECIMAL pseudo—instruction, 5-5 Extended memory binary loaders, 6—2 Decimal—to-binary conversion, 2—3 Decimal-to-octal conversion, 2—3 DEFINE, 7-] FIELD n, 6-l Definition of macro, 7—l FIXTAB (fix symbol table), 6—5, 9—4 Definition of macro name, 7—] Floating point constant registers, 6—3 Deposit and clear AC, 3—2 Floating point constants, 5—1, 6-3 Diagnostic messages, 5—] Floating point constants normalized, 6-3 Dollar Sign ($), 4-3, Floating point input format, 6-3 6-4, 9-2, 9—4 Double precision Floating point, 6—2 FLTG (floating point pseudo-instruction), 6-3 Double precision floating point constants, 6-3 Flow chart, 4—l Double precision integers, 5-1, 6-2 Form—feed, 5-3 Dummy arguments, 7-l G Dummy argument symbol, 7-] Group I operate microinstructions, 3—4 Group 2 operate microinstructions, 3-4, 3—5, 3—6 E, 6-3 H Effective address, 3—7 Elements, 5—5, 5-7 Halt, 6-5 INDEX HLT (halt), 3—5, 3-6 (Cont) Intersection, 5—7 1/0 device, 3—3 1/0 pulses, 3-3 IOT instruction format, 3-3 I, 4—12 IAC (index AC), 3-4, 3—9 IC (illegal character), 8-I ID (illegal redefinition of symbol), 8-] IOT instructions, 3—3 IOT microinstruction operations, 3—3 ISZ (index and skip if zero), 3—2 IE (illegal equals), 8-2 Ignored characters, 5—3 II (illegal indirect), 5—9, 8-2 JMP, 3—3 Illegal characters, 5—3 JMP I, 5—9 Illegal equals, 8—2 JMP instruction, 4-H Illegal format, 8-2 JMS (jump to subroutine), 3-3 Illegal indirect, 5—9, 8—2 JMS instruction, 4-H IM (illegal format), 8—2 Inclusive OR, 3-5, 5—8 Inclusive OR (space), 5-8 Incrementing location counter, 5-6 Index, 4—2, 4—3 3—7, 4-1], 4—12 Indirect address linkage, 5-9, 5-” Indirect bit, 5-9 Initializing, Leader, 5—3 Least significant bits, 3-9 Index and skip if zero, 3-2 Indirect address, Labelled locations, 4-5 LG (link generated) message, 5—9, 8—2 Line—feeds, 7-2 Line terminators, 5—3 4-2 Link, 3-4, 3-8, 5-9 Input, I—2 Link generation, 5-], 5—9, 8-2 Input—output transfer instructions, 3-3 Instruction address, 4—6 Instruction Fields, 5-4 Instruction operation code, 3—] Instructions, 3-3 Listing, 5-4 List storage, 5—4 Literal buffer, 5—12 Literal regeneration, 5—l2 Literal storage, 5-H, 5-12 Integers, 5-5, 6-2 Integers, decimal, Left parenthesis, 5-“ Literals, 5-I, 5-H, 9—3 binary, and octal, 2-] Logical AND, 3-2, 3-5 INDEX (Cont) Location counter, 5—7 Module, 5-7 Locations labelled, 4—5 MP (missing parameter), 8—3 Loop, 4—] N M Negative numbers, 3-8 MACRO Assembler, 4—2 Nested literals, 5-12 MACRO-8 Programming Language, 5-l Nonprinting characters, 5-2 MACRO—8 symbol table, Al-l Nonzero page literal, 5-12 MACRO-8 versions, 9—] Numbers, 6-2 Macro definition, 7-] Macro definition storage, 7—2 Macro expansion, 7-3 Macro instruction, 5-l Macro name, 5-7, 5—8 Macro name definition, 7—l Macro nesting, 7-2 Macro redefinition, 7-3 Macro referencing, 7—3 Macro restrictions, 7—2 Macro table, 7-2, 9—4 Macro table storage, 7-3 Macros, 7-] Memory field, 3-6, 3—7 Memory field page, 3—6 Memory field Words, 3—6 Memory organization, 3—6 Memory reference instructions (MRI), 3-], 5-9 Memory register, 3-] Microprogramming, 3—3 Minuend, 3—9 Missing parameter, 8-3 Mnemonic, 2-4 Obiect program, 2—4 Obiect program tape, 5-l OCTAL, 6—2 Octal fraction conversion, 2—3 Octal integers, 2—l Octal page addresses, 4-5 OCTAL pseudo—instruction, 5—5 Octal-to-binary conversions, 2—2 l—cycle instructions, 3—3 l's complement, 3—8, 3—9 Operand, 3—7 Operate instructions, 3—3, 3—4 Operating instructions, 9—] Operation code, 3—3, 3-4 Operation code, instruction, 3-] Operation characters, 5-2 Operator intervention, 9—2 Operators, 5-1, 5—7, 5-10, 6-2, 6—3 OPR, 3—3 Optimum use, 4-7 Organization of memory, 3-6 INDEX (Cont) Origin, 4—2, 4—3 Programmer symbols, 9—4 Origin reset, 5-l0 Programming language, 2—4 Origin setting, 5-10 Pseudo—instruction, 4-2, 4—10, 5—4, 6-'l OSR, 3—5 Pseudo-instruction PAGE, 5—10 OST, 3-6 Punctuation characters, 5—2 I Out-of—page reference, 5—9 Q Overflow, 3—9 Quote, 5-12, 6—3, 6—4, 7—2 Page, 3—7 PAGE, 4-2, 6—] Radix, 2-1 Page address, 3—7 Radix control, 6-2 Page bits, 5—9 Radix point, PAGE n, 6—] Radix pseudo—instructions, 5-5 PAGE pseudo-instruction, 5—l0 Page zero, 3—7, 4—6, 4-10, 4—12, 2-2, 2-3 RAL (rotate AC and L left), 3—4 5-H, 5-12 Page zero addresses, 4—6 Parameter assignment statement, 5—6 PASS 1, 5—6, 6—5, 9—], 9-2, 9—4 PASS 2, 5—9, 5—12, 6-2, 9—l, 9—2 PASS 3, 9—1, 9—3 PASS 3 format, 9-3 PAUSE pseudo—instruction, 6-5, 9—2, 9-4 PE (Current, Non—Zero page Exceeded), 8-] RAR (rotate AC and L right), 3—4 Recycling, 4—] Redefinition of symbol, 5-6 Registers, 3—6, 3—7, 4-2, 4-3, 4-5 Relative location, 4—8 Reverse skip sensing, 3-5 ROTATE AC and L, 3-4 RTL (rotate left), 3—4 RTR (rotate right), 3-4 Period, 4—8, 5-10 Permanent symbols, 5-8 Permanent symbol table, 5-5, 6—5 Pointer, 4—3, 4—11 Points, 4-“ Positional notation, 2—] Positive numbers, 3—8 Program (Location) Counter, 4-2, 4—11 SE (symbol table exceeded), 8—2 Semicolon, 5-3, 5—4, 6-2 Sign, 6-2 Sign bit, 3—8 Sign notation, 3—9 Single character mode, 6-3 (Cont) INDEX Single character text facility, 5-12 Symbol rules, 5-5 Skipping, 3—4 Symbol table, 5-1, 5-6, 9—] Skips, 3-5 Symbol table alterations, 6—5 SKP (skip unconditional), 3-6 Symbol table exceeded, 8—2 Slash, 4-4 Symbol table modification, 9—4 SMA (skip on minus AC), 3-5, 3—6 Symbol table punching, 9—] SNA (skip on non—zero AC), 3-6 Symbol value, 4—5 SNL (skip on non—zero L), 3-6 Symbolic addressing, 4-6 Source programs, 2-4, 5-] Symbolic expression, 5-H Source tape, 9-] Symbolic expression evaluation, 5-7 ' SPA (skip on positive AC), 3—6 Symbolic name, 2-4 Space address field delimiter, 5—8 Symbolic program, 2-4 Space interpretation, 5-7, 5-8 Symbolic tag, 4—5, 4-10 Space, 5—6 SZA (skip on zero AC), 3-5, 3—6 Special characters, A2-l SZL (skip on zero L), 3—6 Special symbol (dollar sign), 4-3, 6—4, 9—2, 9—4 Special symbols (text), 3—] Storage for list, 5-4 Storage requirements, 4—2 Storage techniques, 4—6 Stored literals, 5-12 Subroutine properties, 4-10 Subroutine requirements, 4—10 Subroutines, 4-9, 4-10 Subscript, 2-] Tabulations, 5-3, 5—4 TAD instruction, 3-2, 3-8, 3—9 Tags, 2-4 TEXT pseudo-instruction, 6-4, 7—2 Text facility, 3-9 Subtrahend, 3-9 Switch options, 9-2 Switch register, 9—] 5—1, 6—3 TEXT field, 5-3 Text strings, Subtraction, 3-8, Symbol, 4—5, Tab, 4-4, 5—6 6—3, 6—4 Title, 4-4, 5—4 Trailer, 5—3 Transferring control, 4-H Two's complement add, 3-2, 3—8, 3—9, 6-2 5—5 Symbol and integer combination, 5-7 U Symbol definition, 5-5, 5-6 Symbol redefinition, 5—6 Undefined symbol, 8—3 INDEX Union, 5-7 US (undefined symbol), 8-3 User defined symbols, 5—8 V Value zero, 3—9 Variables, 4—7, 4-12 W Words, 3-7 Z ZE (zero page exceeded), 8—] (Con’r) PDP-8/I READER’S COMMENTS MAC RO-8 DEC—O8-CMAB—D . Digital Equipment Corporation maintains a continuous effort to improve the quality and usefulness of its publications. To do this effectively we need user feedback your critical evaluation of this manual. . — . Please comment on this manual’s completeness, accuracy, organization, usability, and readability. - i Did you find errors in this manual? _ How can this manual be improved? ' DEC also strives to keep its customers informed of current DEC software and publications. Thus, the following perioddistributed publications are available upon request. Please check the appropriate boxes for a current issue of the ically ; publication(s) desired. : ' D Software Manual Update, a quarterly collection of revisions to current software manuals. [3 User‘s Bookshelf, a bibliography of current software manuals. C] Program Library Price List, a list of currently available software programs and manuals. Please describe your position. . ’ . Name Organization Street Department City State Zip or Country ......................................................................................... ............................................................................ Fold Herc Do Not Tear — Fold Here and S[ap]e FIRST CLASS PERMIT NO. 33 MAYNARD, MASS. BUSINESS REPLY MAIL NO POSTAGE STAMP NECESSARY IF MAILED IN THE UNITED STATES Postage will be paid by: magnlEn Digital Equipment Corporation Software Information Services 146 Main Street, Bldg. 3-5 Maynard, Massachusetts 01754
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies