>>37<<5552 >>37<>16<< >>37<<5552 44444 s>>37<<0 >>16<>12<< >>16<>16<< >>37<<242>>37<< >>37<<5552 >>17<<000>>17<< 11>>37<<11 >>37<>37<<55>>15<>13<<6 Introduction Certainly assembles source programs written in PDP-1 assembly language into object programs. The source language provides a convenient way of coding algorithms while giving the programmer complete control over the content of the object program. The source program may be read from the drum or the on-line typewriter. The object program may be written onto drum field 1 or punched onto paper tape. Note>>40<<. Sections identified with an asterisk (|x) may be omitted on a first reading. Certainly processes the source program twice. During pass 1 address tags and other symbols are defined, and constants and variables areas are allocated. During pass 2 the object program is produced. Macros, repeats, conditionals, and irps are expanded during both passes. A sample program written in Certainly assembler language is shown below. sum n=100 102/ a, law tab dap b dzm s b, lac adm s idx b sas c jmp b dsm tab, tab+n/ s, 0 c, lac tab+n start a The first non-blank line is the title, which is printed on the typewriter. The program ends with the start pseudo- instruction, or, if there is no start pseudo-instruction, with the end of the source program. A program may be divided into several consecutive sections, each with a title and start pseudo-instruction. This is useful when the input or output medium is changed between sections. >>13<<>>13<< The Source Language For clarity, the following symbols are assigned to the invisible characters when needed in examples of parts of source programs. carriage return (cr) tabulation (tab) The source program is considered to be a series of syllables and separators. A separator is one of the following characters - space, tab, cr, +, -, x, >>06<<, >>05<<, <, >, ~, =, comma, (, ), [, ], and slash. A syllable is a string of alphanumeric characters (digits, letters, and period) preceded and followed by separators. The most important object in the source language is the expression, which has a numerical value to be used as a storage word of the object program, location assignment, argument, etc. An expression is one or more terms separated by suitable combining operators. The following are some of the forms terms can take - A symbol is a syllable containing at least one letter. Symbols may be of arbitrary length, but are recognized by their first six characters. If a symbol is undefined, the expression in which it appears is undefined. If it is defined as a macro-instruction, pseudo-instruction, or function, special action is taken. The mnemonics for the PDP-1 machine instruc- tions are initially defined as shown in Appendix I. A number is a syllable which is a string of digits with an optional decimal point at the end. The value of a number is computed modulo 777777, except that 777777 is not changed to 0. If a number is immediately followed by a decimal point, then it is taken as decimal regardless of the current radix. The syllable consisting of a single point evaluates to the current location, which is the address at which the current instruction is to be assembled. A term consisting of upper case characters is a micro- program instruction (see memo PDP-35). The syllable must not contain case shifts. A double quote (") followed by an upper or lower case character is a term, which has the value of the 7-bit concise code of the character. The 7-bit concise code of a character is its concise code, plus 100 if the character is in upper case. >>13<>05<< means bitwise inclusive or >>06<< means bitwise and ~ means bitwise exclusive or x means integer multiply. In one's complement mode, multiplication is mod 777777. In two's complement mode, multiplication is mod 1000000. > means integer quotient. The argument on the left is divided by the argument on the right. Division by zero returns the original dividend. < means remainder of integer division. Division by zero returns zero. Operator priority Operations of the same priority are performed from left to right. Operations of different priorities are performed in the order given in the table below. unary + and - (executed first) < > >>06<< x ~ >>05<< binary + and - (executed last) >>13<<>>60<< Two consecutive operators are assumed to have zero between them. The following are some examples of expres- sions, giving the values (in octal) on the right. expression value, value, ones mode twos mode (if different from ones mode) 2 2 262143. 777777 262144. 1 -0 777777 0 2+3 5 2-3 777776 777777 2x3 6 400000x7 400003 400000 2>>05<<3 3 2>>06<<3 2 2~3 1 -5>>05<<1 777773 5<3 2 13>5 2 7-2>>05<<3 4 add 40 400040 cla>>05<>13<>06<>13<<>>76<< Uses of Expressions The meaning of an expression to Certainly is determined by the context in which it appears in the source program. The character immediately following the expression usually indicates its use. Storage word An expression terminated by a cr or tab is a storage word and is assembled into the object program. examples - jmp ret lac abc The 18 bit number which is the value of the expression is assigned a location in memory determined by the location counter in the assembler. After each word is stored, the location counter is advanced by one. A storage word may be an instruction, a constant, or data. A tab or cr not preceded by an expression, or preceded by arithmetic opera- tors only, with no syllables, does nothing. If a storage word is undefined on pass 2, the usw error message will be given. Location assignment An expression terminated by a slash is a location assignment. The current location is set to the value of the expression truncated to twelve bits. example - 100/ sza jmp 100 The above source program part will cause the instructions sza and jmp 100 to be assembled into locations 100 and 101 of the object program, respectively. An undefined location assignment will give the usl error message. >>13<< Address tag An expression followed by a comma is an address tag. If the tag is a single undefined symbol, that symbol will be defined to be equal to the current location. If it is a defined expression, it is compared with the current loca- tion, and a disagreement will cause an mdt error message to be printed. (Use of the same symbol as an address tag twice in one program is a common cause of this error.) If the tag is undefined but more complicated than a single symbol, it is ignored on pass 1 and a ust error is given on pass 2. example - a, dzm i tab+n SXXZ jmp a When the assembler defines a symbol as an address tag, if the comma is preceded by a centerdot, the symbol is defined in such a way that it will not be transmitted to ID. Note the opposite character of location assignments and address tags. A location assignment moves the value of an expression into the location counter, while a tag moves the location counter into the symbol which forms the tag. A sequence such as tab, tab+n/ is frequently used to reserve a block of registers for a table of data. In the above example, the length of the block is n, and tab is defined as the address of the first register in the block. >>13<<8 Formal symbol definition A symbol followed by an equals sign and an expression is defined to have the value of the expression if the expres- sion is defined. If the expression is not defined, no action is taken on pass 1, and the use error is given on pass 2. A formal symbol definition overrides any previous definition of the symbol, whether it was a numeric definition, an instruction mnemonic, a pseudo-instruction, macro, or func- tion. If an underbar precedes the equals sign, the symbol will be defined in such a way that it will not be transmitted to ID. examples - n=100 t=t+t smi>>40<<=spi i No storage word is generated by a formal symbol definition. Comments A slash, when not preceded by an expression, begins a comment. All characters are ignored up to the next carriage return. The location counter The location counter records the address at which the current storage word is to be assembled. It is set to zero at the beginning of each pass and is advanced by one after each storage word is assembled. Any attempt to assemble a word, constant, or variable into location 10000 will produce an rpm error. example - dzm i tab+n SXXZ jmp .-2 assembles into the same sequence of instructions as the example given in the section on address tags. >>13<<>>53<< Pseudo-instructions Pseudo-instructions are special commands to the assem- bler. They are usually used for generating certain types of data, controlling the assembly process, printing messages at assembly time, and defining macros and functions. Each pseudo-instruction has one or more names in the initial symbol table. Other symbols may be made to name pseudo- instructions by means of the equals pseudo-instruction. Certainly acts on a pseudo-instruction whenever it encoun- ters its name followed by any separator other than equals sign. Some of the descriptions below give names that are more than six characters long. Since symbols are recognized by their first six characters only, any pseudo-instruction name may be shortened to six characters (for example, charac instead of character). They may not be shortened further except for character and flexo, for which the alternate names char and flex are defined in the initial symbol table. Data Generating Pseudo-Instructions character and char The pseudo-instruction character (or its abbreviated form char) is used to generate a syllable containing the concise code for a given character. The name of the pseudo- instruction is followed by a separator, the letter l, m, or r, and then the character to be translated. The letter l, m, or r determines whether the following character is to be placed in the left, middle, or right six bits of the word, respectively. The other twelve bits are set to zero. If the character following the separator is not l, m, or r, that character itself is used, and is placed in the right six bits. The term generated by character may be used anywhere within an expression. examples - char ra = 000061 char mb = 006200 char lc = 630000 char d = 000064 >>13<>05<>05<>56<<20x50x50+31x50+31) squoze a = 13 The term generated by the squoze pseudo-instruction may be used anywhere within an expression. >>13<>32<< and generates a term which is the number of characters in the string. >>13<>13<>13<<>>37<< (|x) Printing Pseudo-instructions The three printing pseudo-instructions are used to print information on the typewriter at assembly time. The printout occurs during each pass unless a suitable conditional is used to prevent printing during one of the passes. printx The pseudo-instruction printx is followed by a character string in the same format as text, and prints that string. No carriage returns or other characters are added. example - print /This is /35/red/34/ / prints "This is (red shift)red(black shift) " at assembly time printo Printo is followed by an expression terminated by a carriage return. The expression is evaluated and printed in the current radix. No carriage returns or other characters are added. If the expression is undefined, the usn error message is given. printc Printc is followed by one or more expressions separated by commas and followed by a carriage return. The rightmost six bits of each expression are used as the concise code for the character to be printed. example - printc 61,62,63 prints "abc" >>13<>40<>13<>13<< Radix and Arithmetic Mode Control All numbers not followed by a decimal point are interpre- ted according to the current radix. All arithmetic is performed in the current arithmetic mode. At the beginning of each pass, the radix is set to octal and the arithmetic mode to ones. ones Ones sets the arithmetic mode to one's complement. twos Twos sets the arithmetic mode to two's complement. decimal Decimal sets the radix to decimal. octal Octal sets the radix to octal. These pseudo-instructions may be used anywhere within an expression, hence an expres- sion may be interpreted partly in decimal and partly in octal. (|x) radix Radix is followed by an expression and sets the radix to the value of that expression. The expression must be defined on both passes. The usx error is given if this is not the case. If the radix is greater than ten, illegal characters may be generated by the pseudo-instructions printo and spell. In this case, the icn error will occur. >>13<>40<>40<>13<<, Automatic Uariable and Array Allocation Certainly will automatically allocate one register of memory for a variable or temporary if the name of the variable appears with an overbar. The overbar may be anywhere within the name. Only one appearance of the name needs an overbar. The symbol will be defined to hav>>60<< a value of the address of the register which is allocated. A variable must have been previously undefined on pass 1. The mdv error will occur if this is not the case. dimension The dimension pseudo-instruction declares a symbol as an array or table to be automatically allocated. Dimension is followed by a series of array declarations separated by commas and terminated by a carriage return. Each declaration consists of the array name optionally followed by its length enclosed in parentheses. If the length specification is absent, the length is assumed to be 1. The length may be any expression, which must be defined on pass 1. The usd error will occur if the array size is not defined. Each array name will be defined as the value of the address of the first word of the array. An array name must have been previously undefined on pass 1. The mdd error will occur if this is not the case. example - dimension a(10),b(20),c(1),d declares a, b, c, and d as arrays of 10, 20, 1, and 1 words respectively. The declarations for c and d could have been accomplished by their appearance with an overbar in any expression. variables All variables and arrays are placed in a variables area, which the assembler constructs when it encounters the variables pseudo-instruction. This pseudo-instruction may be used up to 8 times in a program. Each variable or array is placed in the next variabk>>40<< area after the overbar or dimension pseudo-instruction that declares it. The program- mer should not make any assumptions about the order of variables and arrays within an area. The initial contents of variables and arrays are not assigned by the assembler. >>13<>56<>13<<6 repeat The pseudo-instruction repeat is used to make the assem- bler process part of the source program a specified number of times. The pseudo-instruction is followed by the cou>>40<>13<< The repeat range ends on the first carriage return not contained within brackets. These brackets are not to be confused with the brackets used for arithmetic grouping. They serve only to "hide" carriage returns and prevent them from ending the repe>>60<>13<<>>53<< Macro-instructions A macro-instruction is a user-defined "abbreviation" for a given string of characters. Macro-instructions are created by use of the define and terminate pseudo-instructions. Subsequent appearances of the macro-instruction name c>>60<>13<<4 another (definition) define clear a,b law a dap .+1 dzm idx .-1 sas (dzm a+b jmp .-3 terminate (call) clear tab,100 is treated as if it were law tab dap .+1 dzm idx .-1 sas (dzm tab+100 jmp .-3 define and terminate The pseudo-instruction define is followed by the name of the macro to be defined and then the list of "dummy symbols", separated by commas and terminated by a carriage return. The following text, up to the appearance of the pseudo-instruction terminate, become the definition. All appearances of dummy symbols within the definition are removed and marked as places where arguments are to be substituted when the macro is called. The actual definition begins with the character after the tab or carriage return that ends the dummy symbol list. It ends on and includes the separator before the terminate pseudo-instruction. In order to permit macro or function definitions within a macro, appearances of define, function (see below), and terminate are counted. The macro ends on the first terminate not paired with a define or function. If terminate is followed by a separator other than tab or carriage return, a symbol must follow. It is compared with the name of the macro being defined. A disagreement causes the mnd error. This is sometimes helpful in debugging complicated macros. >>13<