6/15/72 AS (I) NAME as -- assembler SYNOPSIS as [ - ] name ... 1 DESCRIPTION as assembles the concatenation of name , .... as 1 is based on the DEC-provided assembler PAL-11R [1], although it was coded locally. Therefore, only the differences will be recorded. If the optional first argument - is used, all un- defined symbols in the assembly are treated as global. Character changes are: for use @ * # $ ; / In as, the character ";" is a logical new line; several operations may appear on one line if sep- arated by ";". Several new expression operators have been provided: \> right shift (logical) \< left shift * multiplication \/ division % remainder (no longer means "register") ! one's complement [] parentheses for grouping ^ result has value of left, type of right For example location 0 (relocatable) can be writ- ten "0^."; another way to denote register 2 is "2^r0". All of the preceding operators are binary; if a left operand is missing, it is taken to be 0. The "!" operator adds its left operand to the one's complement of its right operand. There is a conditional assembly operation code different from that of PAL-11R (whose condition- als are not provided): .if expression ... .endif If the expression evaluates to non-zero, the sec- tion of code between the ".if" and the ".endif" is assembled; otherwise it is ignored. ".if"s may be nested. Temporary labels like those introduced by Knuth [2] may be employed. A temporary label is de- fined as follows: n: where n is a digit 0 ... 9. Symbols of the form "nf" refer to the first label "n:" following the use of the symbol; those of the form "nb" refer to the last "n:". The same "n" may be used many times. Labels of this form are less taxing both on the imagination of the programmer and on the symbol table space of the assembler. The PAL-11R opcodes ".word", ".eot" and ".end" are redundant and are omitted. The symbols r0 ... r5 fr0 ... fr5 (floating-point registers) sp pc ac mq div mul lsh ash nor csw .. are predefined with appropriate values. The sym- bol "csw" refers to the console switches. ".." is the relocation constant and is added to each relocatable reference. On a PDP-11 with reloca- tion hardware, its value is 0; on most systems without protection, its value is 40000(8). The new opcode "sys" is used to specify system calls. Names for system calls are predefined. See section (II). The opcodes "bes" (branch on error set) and "bec" (branch on error clear) are defined to test the error status bit set on return from system calls. Strings of characters may be assembled in a way more convenient than PAL-11's ".ascii" operation (which is, therefore, omitted). Strings are in- cluded between the string quotes "<" and ">": <here is a string> Escape sequences exist to enter non graphic and other difficult characters. These sequences are also effective in single and double character constants introduced by single (') and double (") quotes respectively. use for \n newline (012) \0 NULL (000) \> > \t TAB (011) \a ACK (006) \r CR (015) \p ESC (033) \\ \ (134) as provides a primitive segmentation facility. There are three segments: text, data and bss. The text segment is ordinarily used for code. The data segment is provided for initialized but variable data. The bss segment cannot be ini- tialized, but symbols may be defined to lie within this segment. In the future, it is ex- pected that the text segment will be write- protected and sharable. Assembly begins in the text segment. The pseudo-operations .text .data .bss cause the assembler to switch to the text, data, or bss segment respectively. Segmentation is useful at present for two reasons: Non- initialized tables and variables, if placed in the bss segment, occupy no space in the output file. Also, alternative use of the text and data segments provides a primitive dual location- counter feature. In the output file, all text-segment information comes first, followed by all data-segment infor- mation, and finally bss information. Within each segment, information appears in the order writ- ten. Note: since nothing explicit can be assembled into the bss segment, the usual appearance of this segment is in the following style: .bss var1: .=.+2 tab1: .=.+100. ... That is, space is reserved but nothing explicit is placed in it. As is evident from the example, it is legal to assign to the location counter ".". It is also permissible in segments other than ".bss". The restriction is made, however, that the value so assigned must be defined in the first pass and it must be a value associated with the same segment as ".". The pseudo-op .comm symbol,expression makes symbol an undefined global symbol, and places the value of the expression in the value field of the symbol's definition. Thus the above declaration is equivalent to .globl symbol symbol = expression ^ symbol The treatment of such a symbol by the loader ld(I) is as follows: If another routine in the same load defines the symbol to be an ordinary text, data, bss, or absolute symbol, that defini- tion takes precedence and the symbol acts like a normal undefined external. If however no other routine defines the symbol, the loader defines it as an external bss-segment symbol and reserves n bytes after its location, where n is the value of the expression in the .comm operation. Thus ".comm x,100" effectively declares x to be a com- mon region 100 bytes long. Note: all such decla- rations for the same symbol in various routines should request the same amount of space. The binary output of the assembler is placed on the file "a.out" in the current directory. a.out also contains the symbol table from the assembly and relocation bits. The output of the assembler is executable immediately if the assembly was error-free and if there were no unresolved exter- nal references. The link editor ld may be used to combine several assembly outputs and resolve global symbols. The assembler does not produce a listing of the source program. This is not a serious drawback; the debugger db discussed below is sufficiently powerful to render a printed octal translation of the source unnecessary. On the last pages of this section is a list of all the assembler's built-in symbols. In the case of instructions, the addressing modes are as follows: src, dst source, destination r general register fsrc,fdst floating source, destination fr floating register exp expression The names of certain 11/45 opcodes are different from those in the 11/45 manual; some were changed to avoid conflict with EAE register names, others to draw analogies with existing 11/20 instruc- tions. FILES /etc/as2 pass 2 of the assembler /tmp/atm1? temporary /tmp/atm2? temporary /tmp/atm3? temporary a.out object SEE ALSO ld(I), nm(I), sh(I), un(I), db(I), a.out(V), fptrap(III), [1] PAL-11R Assembler; DEC-11-ASDB- D, [2] Knuth, The Art of Computer Programming, Vol. I; Fundamental Algorithms. DIAGNOSTICS When an input file cannot be read, its name fol- lowed by a question mark is typed and assembly ceases. When syntactic or semantic errors occur, a single-character diagnostic is typed out to- gether with the line number and the file name in which it occurred. Errors in pass 1 cause can- cellation of pass 2. The possible errors are: ) parentheses error ] parentheses error < String not terminated properly * Indirection ("*") used illegally . Illegal assignment to "." A error in Address B Branch instruction is odd or too remote E error in Expression F error in local ("F" or "b") type symbol G Garbage (unknown) character I End of file inside an If M Multiply defined symbol as label O Odd-- word quantity assembled at odd address P Phase error-- "." different in pass 1 and 2 R Relocation error U Undefined symbol X syntaX error BUGS Symbol table overflow is not checked. If "." is moved backwards by an odd number of bytes, relocation bits are corrupted. OWNER dmr Special variables: . .. Register: r0 r1 r2 r3 r4 r5 sp pc fr0 fr1 fr2 fr3 fr4 fr5 Eae & switches: csw div ac mq mul sc sr nor lsh ash System calls: exit fork read write open close wait creat link unlink exec chdir time makdir chmod chown break stat seek tell mount umount setuid getuid stime quit intr fstat cemt mdate stty gtty ilgins hog Double operand: mov src,dst movb " cmp " cmpb " bit " bitb " bic " bicb " bis " bisb " add " sub " Branch: br bne beq bge blt bgt ble bpl bmi bhi blos bvc bvs bhis bec (= bcc) bcc blo bcs bes (= bcs) clr dst clrb " com " comb " inc " incb " dec " decb " neg " negb " adc " adcb " sbc " sbcb " ror " rorb " rol " rolb " asr " asrb " asl " aslb " jmp " swab " tst src tstb src Miscellaneous: jsr r,dst rts r sys exp (= trap) Flag-setting: clc clv clz cln sec sev sez sen Floating point ops: cfcc setf setd seti setl clrf fdst negf fdst absf fdst tstf fsrc movf fsrc,fr (= ldf) movf fr,fdst (= stf) movif src,fr (= ldcif) movfi fr,dst (= stcfi) movof fsrc,fr (= ldcdf) movfo fr,fdst (= stcfd) addf fsrc,fr subf fsrc,fr mulf fsrc,fr divf fsrc,fr cmpf fsrc,fr modf fsrc,fr 11/45 operations als src,r (= ash) alsc src,r (= ashc) mpy src,r (= mul) dvd src,r (= div) xor src,r sxt dst mark exp sob r,src Specials .byte .even .if .endif .globl .text .data .bss .comm