Subject: /bin/as - major changes (#152 - part 1 of 2) Index: bin/as/* 2.11BSD Description: This is part 1 (of 2) of changes and improvements to the assembler. This description and the directions for applying the update are repeated in both parts of the update kit. The changes include: 1) Consolidation of the assembler source into 2 source files rather than 18 (some of which were empty/null!) files. 2) Elimination of 2 of the 3 /tmp files. Previously 'as' created 3 files in /tmp: a) /tmp/atm1aXXXXXX - the intermediate object file b) /tmp/atm2aXXXXXX - the forward/backward (fb) branch table c) /tmp/atm3aXXXXXX - the symbol table Only the first file is used now because the 'fb' and symbol tables are maintained in memory only. 3) Elimination of /lib/as2! /bin/as now contains _both_ phases of the assembler. There is no 'exec' of a second program now. Not having a second program also means that the symbol table does not need to be written out by /bin/as and then read by /lib/as2. 4) The filename '-' can be used to read input from the "stdin". 5) Support for the "string table" (a la 4.3BSD) object file format (long symbol names). The new assembler can produce _either_ the old "fixed 8" symbol table information or the new variable length "string table" format. The default is the _old style_ (obviously) but the choice of symbol table output format is a simple true/false (patchable via 'adb') flag. Repeat-By: By observation and experience. The organization of 'as' (items 1,2 and 3) has always left much to be desired. Number 4 is a nicety added at the last moment. Long symbol names (a cap of 32 characters is used to avoid running out of space) have been missing for long enough! With the assembler done only 'ld', 'ranlib', 'nlist(3)' and a few miscellaneous utilities need to be rewritten/modified. The changes to 'ld' are being sketched out on paper now. Time permitting the new symbol table format will be done on or before Christmas. Fix: MAKE SURE you have both parts 1 and 2 of this update kit! Part 1 (this part) includes the patches for the Makefile and 'as0.s' (the consolidated pass 0 and 1 phase of the assembler). ++++++++Description of changes+++++++++ The detailed directions for installing the assembler updates follow this description of what changes were made. I may have overlooked a couple of the smaller/cosmetic changes but those are obvious by looking at the sources. 1) All of the as1?.s files have been catenated into as0.s and the as2?.s files have been catenated into as2.s. 2) as0.s and as2.s have some of the same symbols, therefore all symbols must be _explicitly_ made global with the .globl, the old practice of using the '-' or '-g' option can not and must not be used. 3) The replicated initialization code in as2 has been removed. Because the symbol table is already in memory there is no need to read it in. Similarily the intermediate object file is already open, it merely needs to be rewound rather than reopened. 4) There is only _1_ Permanent Symbol Table (PST) now, the "duplicate" copies (one for /bin/as and another for /lib/as2) have been merged into a single table. In order to use a similar symbol table format for the PST and UST (User Symbol Table) the layout of the PST was altered - the strings are no longer embedded in the PST. A macro capability would have made this easier, but... 5) Symbol tables are extended by using either _realloc (in the case of the 'fb' table since it is never very large) or by linked blocks of memory created by _calloc. The old practice of simply calling _sbrk is not used (it meant that only the _last_ table could be expanded. Ugghh.) 6) The 'string' part of a UST entry is allocated separately from the value+flags data of a symbol. 7) A temporary file for the 'fb' table is no longer used. Instead a realloc()'d table is used. It should be noted that C files processed by /lib/c2 very _rarely_ have a 'fb' table longer than 0 bytes (because 'c2' is very good at rearranging branches). 8) Fairly large blocks of (helpful it is hoped) comments were included in the new sections of code. The tab'ing was made more uniform in other areas of the code. 9) The data and buffer declarations were consolidated at the end of each source file rather than being scattered thru the modules. 10) The hashtable is dynamically allocated rather than being statically declared. 11) Code was added in as2 to output either the old or new style of symbol table entry to the a.out file. If the global variable 'Newsym' is 0 the old style is output (this is the default) otherwise the new format is emitted. ++++++++End of Description of changes+++++++++ ---------------------start of installation instructions------------ Save the indicated portion of this file to /tmp/152. Do a similar thing to part 2 (patch #153) - saving the patch portion to /tmp/153. BACK UP THE CURRENT ASSEMBLER! Unless you're very trusting or very forgiving you will want to back up both the current executables for the assembler: tar cf safe_place.tar /bin/as /lib/as2 THEN: cd /usr/src/bin mv as as.old mkdir as chmod 755 as cd as cp ../as.old/Makefile Makefile cat ../as.old/as1?.s > as0.s cat ../as.old/as2?.s > as2.s patch < /tmp/152 patch < /tmp/153 make make install make clean make make install The double 'make' at the end makes sure that the new assembler can rebuild itself. If for any reason the patches do not apply cleanly or the assembler can not rebuild itself: tar -xpvf safe_place to restore the old versions. Then send me a mail item and I will send a complete dropin replacement for 'as'. ==============================cut here=============================== *** /usr/src/bin/as/Makefile.old Mon Jan 18 08:45:17 1993 --- /usr/src/bin/as/Makefile Wed Sep 1 19:27:05 1993 *************** *** 3,26 **** # AS= /bin/as ! ASFLAGS= - -V ! AS1SRC = as11.s as12.s as13.s as14.s as15.s as16.s as17.s as18.s as19.s ! AS2SRC = as21.s as22.s as23.s as24.s as25.s as26.s as27.s as28.s as29.s ! all: as as2 - as: ${AS1SRC} - ${AS} ${ASFLAGS} -o as1.o as1?.s - ld ${SEPFLAG} -o $@ as1.o -lc - - as2: ${AS2SRC} - ${AS} ${ASFLAGS} -o as2.o as2?.s - ld ${SEPFLAG} -o $@ as2.o -lc - install: all install -s as ${DESTDIR}/bin - install -s as2 ${DESTDIR}/lib clean: ! rm -f *.o a.out as as2 core errs --- 3,17 ---- # AS= /bin/as ! SEPFLAG= -i -X ! all: as ! as: as0.o as2.o ! ld ${SEPFLAG} -o $@ /lib/crt0.o as0.o as2.o -lc install: all install -s as ${DESTDIR}/bin clean: ! rm -f *.o a.out as core errs *** /usr/src/bin/as/as0.s.old Tue Sep 14 19:28:04 1993 --- /usr/src/bin/as/as0.s Wed Sep 1 19:44:55 1993 *************** *** 1,175 **** / / ! / PDP-11 assembler pass 0 ! .data ! .globl _environ / for the standard library ! _environ: 0 ! .text ! .globl _main ! _main: ! jmp start ! go: ! jsr pc,assem ! mov $1024.,-(sp) / write(pof, outbuf, 1024) ! mov $outbuf,-(sp) / movb pof,r0 ! mov pof,-(sp) / sys write; outbuf; 1024. ! jsr pc,_write / jes wrterr ! add $6,sp ! tst r0 ! jmi wrterr ! mov pof,-(sp) / close(pof) ! jsr pc,_close / movb pof,r0 ! / sys close ! mov fbfil,(sp) / close(fbfil) ! jsr pc,_close / movb fbfil,r0 ! tst (sp)+ / sys close ! tstb errflg ! bne aexit ! mov $a.tmp3,r5 ! jsr pc,fcreat ! mov r0,-(sp) / r0 = fcreat(a.tmp3) ! mov symend,-(sp) / write(r0, usymtab, symend-usymtab) ! sub $usymtab,(sp) / mov r0,r1 ! mov $usymtab,-(sp) / mov symend,0f ! mov r0,-(sp) / sub $usymtab,0f ! jsr pc,_write / sys indir; 9f ! tst r0 / jes wrterr ! jmi wrterr / .data ! add $6,sp /9: sys write; usymtab; 0:.. ! / .text ! / mov r1,r0 ! jsr pc,_close / close(r0) ! tst (sp)+ / sys close ! clr -(sp) / execl("/lib/as2", "as2", globfl, ovflag, ! mov $a.tmp3,-(sp) / "-o", outfp, a.tmp1, a.tmp2, a.tmp3, 0) ! mov $a.tmp2,-(sp) / sys exec; fpass2; 1f ! mov $a.tmp1,-(sp) / mov $fpass2,r0 ! / mov $"?\n,-(sp) ! mov outfp,-(sp) / jsr pc,filerr; tst (sp)+ ! mov $3f,-(sp) / { "-o" } ! mov $ovflag,-(sp) ! mov $globfl,-(sp) ! mov $2f,-(sp) / { "as2" } ! mov $1f,-(sp) / { "/lib/as2" } ! jsr pc,_execl ! ! mov $1f,r0 / { "/lib/as2" } ! mov $"?\n,-(sp) ! jsr pc,filerr tst (sp)+ ! aexit: ! mov $a.tmp1,-(sp) / unlink(a.tmp1) ! jsr pc,_unlink / sys unlink; a.tmp1 ! mov $a.tmp2,(sp) / unlink(a.tmp2) ! jsr pc,_unlink / sys unlink; a.tmp2 ! mov $a.tmp3,(sp) / unlink(a.tmp3) ! jsr pc,_unlink / sys unlink; a.tmp3 ! mov $3,(sp) / _exit(3) ! jsr pc,__exit / mov $3,r0 ! / sys exit ! .data ! 1: ! 2: ! 3: <-o\0> ! 4: ! globfl: unglob=.+1; <-\0\0> ! ovflag: ovloc=.+1; <-\0\0> ! .even ! outfp: 4b / { "a.out" } ! .text ! / filerr(fname::r0, err::2(sp)) ! / char *fname, *err; ! filerr: ! mov sp,r5 ! tst (r5)+ / point to error characters ! mov r1,-(sp) / protect r1 from library ! tst -(sp) / write(1, r0, strlen(r0)) ! mov r0,-(sp) mov $1,-(sp) ! clr r1 / { strlen(r0) } ! 1: ! tstb (r0)+ ! beq 2f ! inc r1 ! br 1b ! 2: ! mov r1,4(sp) ! jsr pc,_write ! add $6,sp ! mov $1,-(sp) / write(1, r5, *(r5+1) ? 2 : 1) ! tstb 1(r5) ! beq 3f ! mov $2,(sp) ! 3: ! mov r5,-(sp) mov $1,-(sp) ! jsr pc,_write ! add $6,sp ! mov (sp)+,r1 ! rts pc ! / fd = fcreat(fname::r5) { emulates mkstemp } ! / int fd; ! / char **fname; ! fcreat: ! mov r1,-(sp) / protect r1 from library ! 1: ! mov $outbuf,-(sp) / stat(r5, outbuf) ! mov r5,-(sp) ! jsr pc,_stat cmp (sp)+,(sp)+ ! tst r0 / does the file already exist? ! bmi 3f ! incb 9.(r5) / (yes) increment trailing letter ! cmpb 9.(r5),$'z / out of temporaries? ! blos 1b 2: ! mov r5,r0 / (yes) filerr(*r5, "?\n") ! mov $"?\n,-(sp) ! jsr pc,filerr ! mov $3,(sp) / _exit(3) ! jsr pc,__exit 3: ! mov $0444,-(sp) / creat(*r5, 0444) ! mov r5,-(sp) ! jsr pc,_creat ! cmp (sp)+,(sp)+ ! tst r0 ! bmi 2b ! mov (sp)+,r1 ! rts pc ! wrterr: ! mov $8f-9f, -(sp) / write(1, WRTMSG, strlen(WRTERR)) ! mov $9f,-(sp) / mov $1,r0 ! mov $1,-(sp) / sys write; 9f; 9f-8f jsr pc,_write add $6,sp ! incb errflg ! jbr aexit ! .data ! 9: ; 8: .even ! .text ! / ! / - / a2 -- pdp-11 assembler pass 1 - error: ! incb errflg mov r0,-(sp) mov r1,-(sp) mov r5,r0 --- 1,223 ---- + .globl _main, _write, _close, _execl, __exit, _creat, _brk + .globl _read, _signal, _stat, _open, _mkstemp, _calloc, _realloc + + .globl error, errore, errora, checkeos, pass1, aexit, argb + .globl overlaid, defund, a.outp, errflg, passno, filerr, outmod + .globl wrterr, argb, hshsiz, dot, dotdot, savdot, ch, outbuf + .globl line, savop, inbuf, fbptr, fbtbl, symnum, hshtab, symblk + .globl symleft, dotrel, symtab, fin, fout, curfb, nxtfb, ibufp + .globl ibufc, a.tmp1, usymtab, SYMENTSZ, SYMBLKSZ, PSTENTSZ + .globl obufp, Newsym, symbol,csv + + / This assembler supports _both_ the old style object files (with + / fixed 8 character symbols) and the new style (with a strings table). + / The variable 'Newsym' defined below specifies which format will be + / emitted, if the value is '0' the old style is output, if non-zero + / then the new 'string table' format is output. / + / The old style on disc symbol table entries looked like this: + / struct symbol + / { + / char name[8]; + / short type; + / short value; + / }; / + / The new style of on disc symbol table entry looks like: + / struct symbol + / { + / off_t offset_in_string_table; + / short type; + / short value; + / }; ! .data ! Newsym: 0 ! .text ! PSTENTSZ = 6. ! SYMENTSZ = 8. ! / User symbols and Permanent Symbol Table entries used to have the ! / same 12 byte format. Merging the two phases of the assembler, moving ! / the symbol name characters to an externally allocated heap and ! / using a non-contiguous user symbol table meant that the symbol number ! / could no longer be calculated by subtracting the base of the symbol ! / table and dividing by the size of an entry. What was done was to ! / expand the symbol table entry by another word and keep the symbol number ! / in that. The new internal symbol structure is: ! / ! / char *name; ! / u_short flags; ! / u_short value; ! / u_short number; ! SYMBLKSZ = 512. ! STRBLKSZ = 1024. ! hshsiz = 3001. ! / PDP-11 assembler ! _main: ! jsr r5,csv ! mov $1,-(sp) / signal(SIGINT, SIG_IGN) ! mov $2,-(sp) ! jsr pc,_signal ! cmp (sp)+,(sp)+ ! ror r0 ! bcs 1f ! mov $aexit,-(sp) / signal(SIGINT, aexit) ! mov $2,-(sp) ! jsr pc,_signal ! cmp (sp)+,(sp)+ ! 1: ! mov 4(r5),r0 / argc ! mov 6(r5),curarg / argv ! 9: ! dec r0 / argc-- ! add $2,curarg / argv++ ! 1: ! mov *curarg,r1 ! cmpb (r1),$'- ! bne 1f ! add $2,curarg / argv++ ! dec r0 / argc-- ! cmpb 1(r1),$'u ! beq 3f ! cmpb 1(r1), $'V ! bne 2f ! inc overlaid ! br 1b ! 2: ! tstb 1(r1) ! bne 2f ! 3: ! mov $40,defund ! br 1b ! 2: ! cmpb 1(r1),$'o ! bne 1f ! mov *curarg,a.outp ! br 9b ! 1: ! / The new object file format puts a ceiling of 32 characters on symbols. ! / If it is desired to raise this limit all that need be done is increase ! / the same ceiling in the C compiler and linker (ld). ! tst Newsym ! beq 1f ! movb $32.,Ncps ! 1: ! mov r0,nargs / # of remaining args ! mov $a.tmp1,-(sp) ! jsr pc,_mkstemp / fout = mkstemp(a.tmp1); tst (sp)+ ! mov r0,fout ! bmi oops ! / the symbol table is a single linked list of dynamically allocated ! / 'SYMBLKSZ' byte blocks. Allocate the first one now. ! mov $SYMBLKSZ+2,-(sp) / symblk = calloc(1, SYMBLKSZ+2) mov $1,-(sp) + jsr pc,_calloc + cmp (sp)+,(sp)+ + mov r0,symblk + mov r0,usymtab / pointer to first block + tst (r0)+ / skip link word + mov r0,symend / current end in block + mov $SYMBLKSZ,symleft / number of bytes left in block ! / The string portion of symbol table entries is now allocated dynamically. ! / We allocate the strings in 1kb chunks to cut down the number of times ! / the string table needs to be extended (besides, long variable names are ! / coming real soon now). ! / ! / NOTE: the string blocks are linked together for debugging purposes only, ! / nothing depends on the link. ! mov $STRBLKSZ+2,-(sp) mov $1,-(sp) ! jsr pc,_calloc / strblk = calloc(1, STRBLKSZ+2) ! / check for failure??? ! cmp (sp)+,(sp)+ ! mov r0,strblk / save pointer to string block ! tst (r0)+ / skip link word ! mov r0,strend / set available string pointer ! mov $STRBLKSZ,strleft / set amount left in block ! / the hash table is now dynamically allocated so that it can be ! / reused in pass 2 and re-alloced if necessary. ! mov $2,-(sp) / hshtab = calloc($hshsiz, sizeof(int)) ! mov $hshsiz,-(sp) ! jsr pc,_calloc cmp (sp)+,(sp)+ ! mov r0, hshtab ! ! mov $symtab,r1 ! 1: ! clr r3 ! mov (r1),r2 / pointer to PST symbol's string 2: ! movb (r2)+,r4 ! beq 2f ! add r4,r3 ! swab r3 ! br 2b ! 2: ! clr r2 ! div $hshsiz,r2 ! ashc $1,r2 ! add hshtab,r3 ! 4: ! sub r2,r3 ! cmp r3,hshtab ! bhi 3f ! add $2*hshsiz,r3 3: ! tst -(r3) ! bne 4b ! mov r1,(r3) ! add $PSTENTSZ,r1 ! cmp r1,$ebsymtab ! blo 1b ! / perform pass 0 processing ! jsr pc,pass0 ! ! / flush the intermediate object file ! mov $1024.,-(sp) / write(fout, outbuf, 1024) ! mov $outbuf,-(sp) ! mov fout,-(sp) jsr pc,_write add $6,sp ! tst errflg / any errors? ! beq 1f / yes - br ! jmp aexit ! 1: ! inc passno / go from -1 to 0 ! clr line / reset line number ! jmp pass1 / pass1 does both passes 1, 2, exit ! oops: ! mov $9f-8f,-(sp) / write(fileno(stderr),8f,strlen()) ! mov $8f,-(sp) ! mov $2,-(sp) ! jsr pc,_write ! mov $2,(sp) ! jsr pc,__exit ! .data ! 8: ! ! 9: ! .even ! .text error: ! tst passno / on pass1,2 ? ! bpl errorp2 ! inc errflg mov r0,-(sp) mov r1,-(sp) mov r5,r0 *************** *** 176,184 **** tst *curarg beq 1f mov r0,-(sp) ! mov *curarg,r0 clr *curarg - mov $'\n,-(sp) jsr pc,filerr tst (sp)+ mov (sp)+,r0 --- 224,231 ---- tst *curarg beq 1f mov r0,-(sp) ! mov *curarg,-(sp) clr *curarg jsr pc,filerr tst (sp)+ mov (sp)+,r0 *************** *** 185,193 **** 1: mov r2,-(sp) mov r3,-(sp) mov line,r3 ! movb r0,1f ! mov $1f+6,r0 mov $4,r1 2: clr r2 --- 232,280 ---- 1: mov r2,-(sp) mov r3,-(sp) + jsr pc,errcmn + mov (sp)+,r3 + mov (sp)+,r2 + mov (sp)+,r1 + mov (sp)+,r0 + rts pc + + errorp2: + mov pc,errflg + mov $666,outmod / make nonexecutable + mov r3,-(sp) + mov r2,-(sp) + mov r1,-(sp) + mov r0,-(sp) + + tst -(sp) / write(1, argb, strlen(argb)) + mov $argb,-(sp) + mov $1,-(sp) + mov $argb,r1 + clr r0 + 1: + tstb (r1)+ + beq 2f + inc r0 + br 1b + 2: + mov r0,4(sp) + jsr pc,_write + add $6,sp + + movb 12(sp),r0 + jsr pc,errcmn + mov (sp)+,r0 + mov (sp)+,r1 + mov (sp)+,r2 + mov (sp)+,r3 + mov (sp)+,(sp) + rts pc + + errcmn: mov line,r3 ! movb r0,9f ! mov $9f+6,r0 mov $4,r1 2: clr r2 *************** *** 197,219 **** mov r2,r3 sob r1,2b ! mov $7,-(sp) / write(1, 1f, 7) ! mov $1f,-(sp) / mov $1,r0 ! mov $1,-(sp) / sys write; 1f; 7 jsr pc,_write add $6,sp - - mov (sp)+,r3 - mov (sp)+,r2 - mov (sp)+,r1 - mov (sp)+,r0 rts pc .data ! 1: .even .text ! putw: tst ifflg beq 1f cmp r4,$'\n --- 284,302 ---- mov r2,r3 sob r1,2b ! mov $7,-(sp) / write(1, 9f, 7) ! mov $9f,-(sp) ! mov $1,-(sp) jsr pc,_write add $6,sp rts pc .data ! 9: .even .text ! ! p0putw: tst ifflg beq 1f cmp r4,$'\n *************** *** 225,265 **** blo 2f mov $outbuf,obufp ! mov r1,-(sp) / protect r1 from library ! mov $1024.,-(sp) / write(pof, outbuf, 1024) mov $outbuf,-(sp) ! mov pof,-(sp) jsr pc,_write add $6,sp mov (sp)+,r1 tst r0 ! jmi wrterr 2: rts pc - / - / ! / a3 -- pdp-11 assembler pass 1 ! assem: ! jsr pc,readop jsr pc,checkeos br 7f tst ifflg beq 3f cmp r4,$200 ! blos assem ! cmpb (r4),$21 /if bne 2f inc ifflg 2: ! cmpb (r4),$22 /endif ! bne assem dec ifflg ! br assem 3: mov r4,-(sp) ! jsr pc,readop cmp r4,$'= beq 4f cmp r4,$': --- 308,347 ---- blo 2f mov $outbuf,obufp ! mov r1,-(sp) / protect r1 from library ! mov $1024.,-(sp) / write(fout, outbuf, 1024) mov $outbuf,-(sp) ! mov fout,-(sp) jsr pc,_write add $6,sp mov (sp)+,r1 tst r0 ! bpl 2f ! jmp wrterr 2: rts pc ! / Pass 0. ! pass0: ! jsr pc,p0readop jsr pc,checkeos br 7f tst ifflg beq 3f cmp r4,$200 ! blos pass0 ! cmpb (r4),$21 /if bne 2f inc ifflg 2: ! cmpb (r4),$22 /endif ! bne pass0 dec ifflg ! br pass0 3: mov r4,-(sp) ! jsr pc,p0readop cmp r4,$'= beq 4f cmp r4,$': *************** *** 272,282 **** mov (sp)+,r4 cmp r4,$200 bhis 1f ! cmp r4,$1 / digit beq 3f mov $'x,r5 jsr pc,error ! br assem 1: bitb $37,(r4) beq 1f --- 354,364 ---- mov (sp)+,r4 cmp r4,$200 bhis 1f ! cmp r4,$1 / digit beq 3f mov $'x,r5 jsr pc,error ! br pass0 1: bitb $37,(r4) beq 1f *************** *** 285,291 **** 1: bisb dot-2,(r4) mov dot,2(r4) ! br assem 3: mov numval,r0 jsr pc,fbcheck --- 367,373 ---- 1: bisb dot-2,(r4) mov dot,2(r4) ! br pass0 3: mov numval,r0 jsr pc,fbcheck *************** *** 296,314 **** movb r0,nxtfb+1 mov dot,curfb(r0) ! mov r1,-(sp) / protect r1 from library ! mov $4,-(sp) / write(fbfil, nxtfb, 4) ! mov $nxtfb,-(sp) / movb fbfil,r0 ! mov fbfil,-(sp) / sys write; nxtfb; 4 ! jsr pc,_write / jes wrterr ! add $6,sp ! mov (sp)+,r1 ! tst r0 ! jmi wrterr ! ! br assem 4: ! jsr pc,readop jsr pc,expres mov (sp)+,r1 cmp r1,$200 --- 378,395 ---- movb r0,nxtfb+1 mov dot,curfb(r0) ! cmp fbfree,$4 / room for another fb entry? ! bge 5f / yes - br ! jsr pc,growfb / no - grow the table ! 5: ! sub $4,fbfree / four bytes less available ! mov nxtfb,*fbptr / store first word ! add $2,fbptr / advance to next ! mov nxtfb+2,*fbptr / store second word ! add $2,fbptr / point to next entry ! br pass0 4: ! jsr pc,p0readop jsr pc,expres mov (sp)+,r1 cmp r1,$200 *************** *** 338,348 **** movb $2,dotrel ealoop: cmp r4,$'; ! beq assem1 cmp r4,$'\n bne 1f inc line ! br assem1 1: cmp r4,$'\e bne 2f --- 419,429 ---- movb $2,dotrel ealoop: cmp r4,$'; ! beq 9f cmp r4,$'\n bne 1f inc line ! br 9f 1: cmp r4,$'\e bne 2f *************** *** 357,367 **** jsr pc,error 2: jsr pc,checkeos ! br assem1 ! jsr pc,readop br 2b ! assem1: ! jmp assem fbcheck: cmp r0,$9. --- 438,448 ---- jsr pc,error 2: jsr pc,checkeos ! br 9f ! jsr pc,p0readop br 2b ! 9: ! jmp pass0 fbcheck: cmp r0,$9. *************** *** 373,409 **** clr r0 rts pc ! checkeos: ! cmp r4,$'\n ! beq 1f ! cmp r4,$'; ! beq 1f ! cmp r4,$'\e ! beq 1f ! add $2,(sp) 1: rts pc - / - / ! / a4 -- pdp-11 assembler pass1 rname: mov r1,-(sp) mov r2,-(sp) mov r3,-(sp) ! mov $8,r5 ! mov $symbol+8.,r2 ! clr -(r2) ! clr -(r2) ! clr -(r2) ! clr -(r2) clr -(sp) clr -(sp) ! cmp r0,$'~ / symbol not for hash table ! bne 1f inc 2(sp) ! clrb ch 1: jsr pc,rch movb chartab(r0),r3 --- 454,503 ---- clr r0 rts pc ! / the 'fb' table never grows to be large. In fact all of the assemblies ! / of C compiler generated code which were processed by 'c2' never ! / produced a table larger than 0 bytes. So we 'realloc' because ! / this is not done enough to matter. ! ! growfb: ! mov r1,-(sp) / save r1 from library ! add $256.,fbtblsz / new size of fb table ! mov $256.,fbfree / number available now ! mov fbtblsz,-(sp) / fbtbl = realloc(fbtbl, fbtblsz); ! mov fbtbl,-(sp) ! bne 1f / extending table - br ! mov $1,(sp) / r0 = calloc(1, fbtblsz); ! jsr pc,_calloc ! br 2f 1: + jsr pc,_realloc + 2: + cmp (sp)+,(sp)+ + mov r0,fbtbl + bne 1f + iot / Can never happen (I hope) + 1: + add fbtblsz,r0 / fbptr starts 256 bytes from + sub $256.,r0 / end of new region + mov r0,fbptr + mov (sp)+,r1 / restore register rts pc ! / Symbol table lookup and hashtable maintenance. rname: mov r1,-(sp) mov r2,-(sp) mov r3,-(sp) ! movb Ncps,r5 / Max num of chars to accept ! mov $symbol,r2 ! clr (r2) clr -(sp) clr -(sp) ! cmp r0,$'~ / symbol not for hash table? ! bne 1f / no - br inc 2(sp) ! clr ch 1: jsr pc,rch movb chartab(r0),r3 *************** *** 415,420 **** --- 509,515 ---- movb r3,(r2)+ br 1b 1: + clrb (r2)+ / null terminate string movb r0,ch mov (sp)+,r1 clr r0 *************** *** 421,451 **** tst (sp)+ beq 1f mov symend,r4 ! br 4f 1: div $hshsiz,r0 ashc $1,r0 ! add $hshtab,r1 clr timesaround 1: sub r0,r1 ! cmp r1,$hshtab bhi 2f add $2*hshsiz,r1 tst timesaround beq 3f ! mov $8f-9f,-(sp) / write(1, ERRMSG, strlen(ERRMSG)) ! mov $9f,-(sp) / mov $1,r0 ! mov $1,-(sp) / sys write; 9f; 8f-9f jsr pc,_write add $6,sp - jmp aexit .data ! timesaround: ! .=.+2 ! 9: ; 8: .even .text 3: inc timesaround --- 516,548 ---- tst (sp)+ beq 1f mov symend,r4 ! br 4f / go insert into symtable (!hashtbl) 1: div $hshsiz,r0 ashc $1,r0 ! add hshtab,r1 clr timesaround 1: sub r0,r1 ! cmp r1,hshtab bhi 2f add $2*hshsiz,r1 tst timesaround beq 3f ! mov $8f-9f,-(sp) / write(fileno(stdout),9f,8f-9f); ! mov $9f,-(sp) ! mov $1,-(sp) jsr pc,_write add $6,sp jmp aexit + .data ! timesaround: 0 ! 9: ! ! 8: ! .even .text 3: inc timesaround *************** *** 453,516 **** mov $symbol,r2 mov -(r1),r4 beq 3f ! cmp (r2)+,(r4)+ ! bne 1b ! cmp (r2)+,(r4)+ ! bne 1b ! cmp (r2)+,(r4)+ ! bne 1b ! cmp (r2)+,(r4)+ ! bne 1b ! br 1f 3: mov symend,r4 mov r4,(r1) 4: ! mov $symbol,r2 ! mov r4,-(sp) ! add $20,r4 ! cmp r4,0f ! blos 4f ! add $512.,0f ! mov r1,-(sp) / protect r1 from library ! mov 0f,-(sp) / brk(0f) ! jsr pc,_brk / sys indir; 9f ! tst (sp)+ / .data ! mov (sp)+,r1 /9: sys sbreak; 0:end ! .data / .text ! 0: end ! .text ! 4: ! mov (sp)+,r4 ! mov (r2)+,(r4)+ ! mov (r2)+,(r4)+ ! mov (r2)+,(r4)+ ! mov (r2)+,(r4)+ ! clr (r4)+ ! clr (r4)+ mov r4,symend ! sub $4,r4 1: mov r4,-(sp) mov r4,r3 ! sub $8,r3 ! cmp r3,$usymtab ! blo 1f ! sub $usymtab,r3 ! clr r2 ! div $3,r2 ! mov r2,r4 ! add $4000,r4 / user symbol br 2f 1: sub $symtab,r3 clr r2 ! div $3,r2 mov r2,r4 add $1000,r4 / builtin symbol 2: ! jsr pc,putw mov (sp)+,r4 mov (sp)+,r3 mov (sp)+,r2 --- 550,614 ---- mov $symbol,r2 mov -(r1),r4 beq 3f ! mov (r4)+,r3 / ptr to symbol's name ! 9: ! cmpb (r2),(r3)+ ! bne 1b / not the right symbol - br ! tstb (r2)+ / at end of symbol? ! bne 9b / nope - keep looking ! br 1f / yep - br 3: mov symend,r4 + jsr pc,isroom / make sure there's room in block mov r4,(r1) 4: ! jsr pc,isroom / check for room in current block ! mov $symbol,r2 / length of string (including null) ! 8 : ! tstb (r2)+ ! bne 8b ! sub $symbol,r2 ! jsr pc,astring / allocate string space ! mov r0,(r4)+ / save string pointer in symtab entry ! mov $symbol,r1 ! 9: ! movb (r1)+,(r0)+ / copy symbol name to string block ! bne 9b ! sub $SYMENTSZ,symleft ! ! / each new symbol is assigned a unique one up number. This is done because ! / the user symbol table is no longer contiguous - the symbol number can ! / not be calculated by subtracting a base address and dividing by the ! / size of a symbol. ! ! clr (r4)+ / flags word ! clr (r4)+ / value word ! mov symnum,(r4)+ ! inc symnum mov r4,symend ! sub $6,r4 / point to flags word 1: mov r4,-(sp) mov r4,r3 ! tst -(r3) / back to beginning of entry ! cmp r3,$ebsymtab / Permanent Symbol Table(opcode, etc)? ! blo 1f / yes - br ! mov 6(r3),r4 / get symbol number ! add $4000,r4 / user symbol flag br 2f 1: + + / PST entries are PSTENTSZ bytes each because they do not have a 'symnum' + / entry associated with them. + sub $symtab,r3 clr r2 ! div $PSTENTSZ,r2 mov r2,r4 add $1000,r4 / builtin symbol 2: ! jsr pc,p0putw mov (sp)+,r4 mov (sp)+,r3 mov (sp)+,r2 *************** *** 518,523 **** --- 616,661 ---- tst (sp)+ rts pc + isroom: + cmp symleft,$SYMENTSZ / room for another symbol? + bge 1f / yes - br + mov r1,-(sp) / save from library + mov $SYMBLKSZ+2,-(sp) / size of sym block plus link word + mov $1,-(sp) / number of blocks to allocate + jsr pc,_calloc / calloc(1, SYMBLKSZ+2); + cmp (sp)+,(sp)+ + / check for failure? + mov r0,*symblk / link new block to old + mov r0,symblk / this is now the current block + tst (r0)+ / skip link word + mov $SYMBLKSZ,symleft / number of bytes available + mov r0,r4 / put where it's expected + mov (sp)+,r1 / restore saved register + 1: + rts pc / return + + / allocate room for a string, the length is in R2 and includes room for + / a terminating null byte. + + astring: + cmp r2,strleft / room in current block? + ble 1f / yes - go carve out a chunk + mov $STRBLKSZ+2,-(sp) + mov $1,-(sp) + jsr pc,_calloc / symblk = calloc(1,STRBLKSZ+2) + / check for failure? + cmp (sp)+,(sp)+ + mov r0,*strblk / update forward link between blocks + mov r0,strblk / update current string block pointer + tst (r0)+ / skip link word + mov r0,strend / current data pointer + mov $STRBLKSZ,strleft / amount of space left + 1: + mov strend,r0 / string address + add r2,strend / update current end point + sub r2,strleft / update amount of space left + rts pc + number: mov r2,-(sp) mov r3,-(sp) *************** *** 574,615 **** clrb ch rts pc 1: ! dec inbfcnt blt 2f ! movb *inbfp,r0 ! inc inbfp bic $!177,r0 beq 1b rts pc 2: mov fin,r0 ! beq 3f mov r1,-(sp) / protect r1 from library mov $1024.,-(sp) / read(fin, inbuf, 1024) ! mov $inbuf,-(sp) / sys read; inbuf;1024. ! mov r0,-(sp) / bcs 2f ! jsr pc,_read / tst r0 add $6,sp mov (sp)+,r1 tst r0 ! jmi 2f ! ! beq 2f ! mov r0,inbfcnt ! mov $inbuf,inbfp br 1b 2: - mov fin,r0 - clr fin - mov r1,-(sp) / protect r1 from library ! mov r0,-(sp) / close(r0) ! jsr pc,_close / sys close tst (sp)+ mov (sp)+,r1 3: ! decb nargs ! bgt 2f mov $'\e,r0 rts pc 2: --- 712,749 ---- clrb ch rts pc 1: ! dec ibufc blt 2f ! movb *ibufp,r0 ! inc ibufp bic $!177,r0 beq 1b rts pc 2: mov fin,r0 ! bmi 3f mov r1,-(sp) / protect r1 from library mov $1024.,-(sp) / read(fin, inbuf, 1024) ! mov $inbuf,-(sp) ! mov r0,-(sp) ! jsr pc,_read add $6,sp mov (sp)+,r1 tst r0 ! ble 2f ! mov r0,ibufc ! mov $inbuf,ibufp br 1b 2: mov r1,-(sp) / protect r1 from library ! mov fin,-(sp) / close(r0) ! jsr pc,_close tst (sp)+ + mov $-1,fin mov (sp)+,r1 3: ! dec nargs ! bge 2f mov $'\e,r0 rts pc 2: *************** *** 619,670 **** jsr pc,error jmp aexit 2: ! mov curarg,r0 ! tst (r0)+ ! mov r1,-(sp) / protect r1 from library clr -(sp) / open((r0), O_RDONLY, 0) ! clr -(sp) / mov (r0),0f ! mov (r0),-(sp) / mov r0,curarg ! mov r0,curarg / incb fileflg ! incb fileflg / sys indir; 9f ! jsr pc,_open / .data ! add $6,sp /9: sys open; 0:0; 0 ! mov (sp)+,r1 / .text ! tst r0 / bec 2f ! bpl 2f / mov 0b,r0 ! mov curarg,r0 ! mov (r0),r0 ! ! mov $"?\n,-(sp) jsr pc,filerr tst (sp)+ jmp aexit 2: - mov r0,fin mov $1,line mov r4,-(sp) mov r1,-(sp) mov $5,r4 ! jsr pc,putw mov *curarg,r1 2: movb (r1)+,r4 beq 2f ! jsr pc,putw br 2b 2: mov $-1,r4 ! jsr pc,putw mov (sp)+,r1 mov (sp)+,r4 br 1b - / - / ! / a5 -- pdp-11 assembler pass 1 ! ! readop: mov savop,r4 beq 1f clr savop --- 753,803 ---- jsr pc,error jmp aexit 2: ! / check for the filename argument of "-", this means to read 'stdin'. ! / Additional filenames are permitted and will be processed when EOF ! / is detected on stdin. ! mov *curarg,r0 ! cmpb (r0)+,$'- ! bne 5f / not the special case - br ! tstb (r0) / must be '-' by itself ! bne 5f ! clr fin / file descriptor is 0 for stdin ! br 2f ! 5: mov r1,-(sp) / protect r1 from library clr -(sp) / open((r0), O_RDONLY, 0) ! clr -(sp) ! mov *curarg,-(sp) ! jsr pc,_open ! add $6,sp ! mov (sp)+,r1 ! mov r0,fin ! bpl 2f ! mov *curarg,-(sp) jsr pc,filerr tst (sp)+ jmp aexit 2: mov $1,line mov r4,-(sp) mov r1,-(sp) mov $5,r4 ! jsr pc,p0putw mov *curarg,r1 2: movb (r1)+,r4 beq 2f ! jsr pc,p0putw br 2b 2: + add $2,curarg mov $-1,r4 ! jsr pc,p0putw mov (sp)+,r1 mov (sp)+,r4 br 1b ! p0readop: mov savop,r4 beq 1f clr savop *************** *** 671,682 **** rts pc 1: jsr pc,8f ! jsr pc,putw rts pc 8: jsr pc,rch - _readop: mov r0,r4 movb chartab(r0),r1 bgt rdname --- 804,814 ---- rts pc 1: jsr pc,8f ! jsr pc,p0putw rts pc 8: jsr pc,rch mov r0,r4 movb chartab(r0),r1 bgt rdname *************** *** 750,758 **** 1: mov r0,numval mov $1,r4 ! jsr pc,putw mov numval,r4 ! jsr pc,putw mov $1,r4 tst (sp)+ rts pc --- 882,890 ---- 1: mov r0,numval mov $1,r4 ! jsr pc,p0putw mov numval,r4 ! jsr pc,p0putw mov $1,r4 tst (sp)+ rts pc *************** *** 774,780 **** string: mov $'<,r4 ! jsr pc,putw clr numval 1: jsr pc,rsch --- 906,912 ---- string: mov $'<,r4 ! jsr pc,p0putw clr numval 1: jsr pc,rsch *************** *** 782,793 **** bne 1f mov r0,r4 bis $400,r4 ! jsr pc,putw ! inc numval br 1b 1: mov $-1,r4 ! jsr pc,putw mov $'<,r4 tst (sp)+ rts pc --- 914,925 ---- bne 1f mov r0,r4 bis $400,r4 ! jsr pc,p0putw ! inc numval br 1b 1: mov $-1,r4 ! jsr pc,p0putw mov $'<,r4 tst (sp)+ rts pc *************** *** 836,850 **** .byte 'p, 033 .byte 0, -1 .text - / - / - / a6 -- pdp-11 assembler pass 1 - opline: mov r4,r0 ! tst r0 ! blt 1f cmp r0,$200 bgt 1f cmp r0,$'< --- 968,977 ---- .byte 'p, 033 .byte 0, -1 .text opline: mov r4,r0 ! bmi 1f cmp r0,$200 bgt 1f cmp r0,$'< *************** *** 863,869 **** cmp r0,$36 bgt xpr mov r0,-(sp) ! jsr pc,readop mov (sp)+,r0 asl r0 jmp *1f-12(r0) --- 990,996 ---- cmp r0,$36 bgt xpr mov r0,-(sp) ! jsr pc,p0readop mov (sp)+,r0 asl r0 jmp *1f-12(r0) *************** *** 870,883 **** .data 1: ! opl13 / map fop freg,fdst to double opl6 opl7 opl10 opl11 ! opl13 / map fld/fst to double opl13 ! opl13 / map fop fsrc,freg to double opl15 opl16 opl17 --- 997,1010 ---- .data 1: ! opl13 / map fop freg,fdst to double opl6 opl7 opl10 opl11 ! opl13 / map fld/fst to double opl13 ! opl13 / map fop fsrc,freg to double opl15 opl16 opl17 *************** *** 889,895 **** opl25 opl26 opl27 ! opl13 / map mul s,r to double opl31 opl32 xpr --- 1016,1022 ---- opl25 opl26 opl27 ! opl13 / map mul s,r to double opl31 opl32 xpr *************** *** 898,910 **** opl36 .text ! / jbr ! opl35: mov $4,-(sp) br 1f ! / jeq, etc ! opl36: mov $6,-(sp) 1: jsr pc,expres --- 1025,1035 ---- opl36 .text ! opl35: / jbr mov $4,-(sp) br 1f ! opl36: / jeq, etc mov $6,-(sp) 1: jsr pc,expres *************** *** 919,927 **** add (sp)+,dot rts pc - /double opl13: ! opl7: jsr pc,addres op2: cmp r4,$', --- 1044,1051 ---- add (sp)+,dot rts pc opl13: ! opl7: /double jsr pc,addres op2: cmp r4,$', *************** *** 929,981 **** jsr pc,errora rts pc 1: ! jsr pc,readop ! opl15: / single operand jsr pc,addres add $2,dot rts pc ! opl31: / sob jsr pc,expres cmp r4,$', beq 1f jsr pc,errora 1: ! jsr pc,readop - /branch opl6: opl10: ! opl11: jsr pc,expres add $2,dot rts pc ! / .byte ! opl16: jsr pc,expres inc dot cmp r4,$', bne 1f ! jsr pc,readop br opl16 1: rts pc ! / < (.ascii) ! opl17: add numval,dot ! jsr pc,readop rts pc ! /.even ! opl20: inc dot bic $1,dot rts pc ! /.if ! opl21: jsr pc,expres tst r3 bne 1f --- 1053,1100 ---- jsr pc,errora rts pc 1: ! jsr pc,p0readop ! opl15: / single operand jsr pc,addres add $2,dot rts pc ! opl31: / sob jsr pc,expres cmp r4,$', beq 1f jsr pc,errora 1: ! jsr pc,p0readop opl6: opl10: ! opl11: /branch jsr pc,expres add $2,dot rts pc ! opl16: / .byte jsr pc,expres inc dot cmp r4,$', bne 1f ! jsr pc,p0readop br opl16 1: rts pc ! opl17: / < (.ascii) add numval,dot ! jsr pc,p0readop rts pc ! opl20: /.even inc dot bic $1,dot rts pc ! opl21: /.if jsr pc,expres tst r3 bne 1f *************** *** 985,1002 **** tst r2 bne opl22 inc ifflg ! opl22: /endif rts pc ! /.globl ! opl23: cmp r4,$200 blo 1f bisb $40,(r4) ! jsr pc,readop cmp r4,$', bne 1f ! jsr pc,readop br opl23 1: rts pc --- 1104,1120 ---- tst r2 bne opl22 inc ifflg ! opl22: /endif rts pc ! opl23: /.globl cmp r4,$200 blo 1f bisb $40,(r4) ! jsr pc,p0readop cmp r4,$', bne 1f ! jsr pc,p0readop br opl23 1: rts pc *************** *** 1013,1027 **** mov r0,dotrel rts pc ! / .common ! opl32: cmp r4,$200 blo 1f bis $40,(r4) ! jsr pc,readop cmp r4,$', bne 1f ! jsr pc,readop jsr pc,expres rts pc 1: --- 1131,1144 ---- mov r0,dotrel rts pc ! opl32: / .common cmp r4,$200 blo 1f bis $40,(r4) ! jsr pc,p0readop cmp r4,$', bne 1f ! jsr pc,p0readop jsr pc,expres rts pc 1: *************** *** 1042,1073 **** jsr pc,expres cmp r4,$'( bne 2f ! jsr pc,readop jsr pc,expres jsr pc,checkreg jsr pc,checkrp add $2,dot clr r0 rts pc 2: ! cmp r3,$24 / register type ! bne 1f jsr pc,checkreg clr r0 rts pc - 1: - add $2,dot - clr r0 - rts pc alp: ! jsr pc,readop jsr pc,expres jsr pc,checkrp jsr pc,checkreg cmp r4,$'+ bne 1f ! jsr pc,readop clr r0 rts pc 1: --- 1159,1187 ---- jsr pc,expres cmp r4,$'( bne 2f ! jsr pc,p0readop jsr pc,expres jsr pc,checkreg jsr pc,checkrp + 1: add $2,dot clr r0 rts pc 2: ! cmp r3,$24 / register type ! bne 1b jsr pc,checkreg clr r0 rts pc alp: ! jsr pc,p0readop jsr pc,expres jsr pc,checkrp jsr pc,checkreg cmp r4,$'+ bne 1f ! jsr pc,p0readop clr r0 rts pc 1: *************** *** 1075,1081 **** rts pc amin: ! jsr pc,readop cmp r4,$'( beq 1f mov r4,savop --- 1189,1195 ---- rts pc amin: ! jsr pc,p0readop cmp r4,$'( beq 1f mov r4,savop *************** *** 1082,1088 **** mov $'-,r4 br getx 1: ! jsr pc,readop jsr pc,expres jsr pc,checkrp jsr pc,checkreg --- 1196,1202 ---- mov $'-,r4 br getx 1: ! jsr pc,p0readop jsr pc,expres jsr pc,checkrp jsr pc,checkreg *************** *** 1090,1096 **** rts pc adoll: ! jsr pc,readop jsr pc,expres add $2,dot clr r0 --- 1204,1210 ---- rts pc adoll: ! jsr pc,p0readop jsr pc,expres add $2,dot clr r0 *************** *** 1097,1103 **** rts pc astar: ! jsr pc,readop cmp r4,$'* bne 1f mov $'*,r5 --- 1211,1217 ---- rts pc astar: ! jsr pc,p0readop cmp r4,$'* bne 1f mov $'*,r5 *************** *** 1136,1148 **** jsr pc,error rts pc 1: ! jsr pc,readop rts pc - / - / - / a7 -- pdp-11 assembler pass 1 - expres: mov r5,-(sp) mov $'+,-(sp) --- 1250,1258 ---- jsr pc,error rts pc 1: ! jsr pc,p0readop rts pc expres: mov r5,-(sp) mov $'+,-(sp) *************** *** 1151,1157 **** mov $1,r3 br 1f advanc: ! jsr pc,readop 1: mov r4,r0 tst r0 --- 1261,1267 ---- mov $1,r3 br 1f advanc: ! jsr pc,p0readop 1: mov r4,r0 tst r0 *************** *** 1230,1236 **** brack: mov r2,-(sp) mov r3,-(sp) ! jsr pc,readop jsr pc,expres cmp r4,$'] beq 1f --- 1340,1346 ---- brack: mov r2,-(sp) mov r3,-(sp) ! jsr pc,p0readop jsr pc,expres cmp r4,$'] beq 1f *************** *** 1370,1384 **** mov $1,r3 br 2f 1: - tst r5 clr r3 2: bis (sp)+,r3 rts pc - / - / - / a8 -- pdp-11 assembler pass 1 .data chartab: .byte -14,-14,-14,-14,-02,-14,-14,-14 --- 1480,1490 ---- *************** *** 1398,1452 **** .byte 160,161,162,163,164,165,166,167 .byte 170,171,172,-14,-26,-14,176,-14 ! namedone:.byte 0 ! a.tmp1: ! a.tmp2: ! a.tmp3: .even ! curfb: ! -1;-1;-1;-1;-1;-1;-1;-1;-1;-1 ! obufp: outbuf ! symend: usymtab ! ! .bss curfbr: .=.+10. savdot: .=.+6 ! bufcnt: .=.+2 ! hshsiz = 3001. ! hshtab: .=2*hshsiz+. ! wordf: .=.+1 ! fileflg:.=.+1 ! errflg: .=.+1 ! ch: .=.+1 ! .even ! pof: .=.+2 ! fin: .=.+2 ! fbfil: .=.+2 ! symbol: .=.+8. ! obufc: .=.+2 ! outbuf: .=.+1024. line: .=.+2 - inbfcnt:.=.+2 ifflg: .=.+2 - inbfp: .=.+2 nargs: .=.+2 curarg: .=.+2 opfound:.=.+2 savop: .=.+2 numval: .=.+2 ! nxtfb: .=.+4 ! usymtab:.=.+36. ! end: ! .text ! / ! / - / a9 -- pdp-11 assembler pass 1 - / key to types / 0 undefined ! / 1 absolute / 2 text / 3 data / 4 bss --- 1504,1550 ---- .byte 160,161,162,163,164,165,166,167 .byte 170,171,172,-14,-26,-14,176,-14 ! a.tmp1: ! Ncps: .byte 8. .even ! fin: -1 ! fout: -1 ! / The next two _must_ be adjacent! Not sure why, but then this whole ! / assembler is weird beyond belief. ! curfb: -1;-1;-1;-1;-1;-1;-1;-1;-1;-1 ! nxtfb: .=.+20. / first 4 used by pass0, all 20. by pass1+2 ! .bss curfbr: .=.+10. savdot: .=.+6 ! hshtab: .=.+2 / dynamically allocated ! ch: .=.+2 ! symnum: .=.+2 / symbol number ! symbol: .=.+32. / XXX ! .=.+2 / paranoia to make sure a null is present ! inbuf: .=.+1024. line: .=.+2 ifflg: .=.+2 nargs: .=.+2 curarg: .=.+2 opfound:.=.+2 savop: .=.+2 numval: .=.+2 ! fbtblsz:.=.+2 ! fbfree: .=.+2 ! fbptr: .=.+2 ! fbtbl: .=.+2 ! usymtab:.=.+2 / ptr to first block of symbols ! symleft:.=.+2 / bytes left in current symbol block ! symend: .=.+2 / ptr to next symbol space in block ! symblk: .=.+2 / ptr to beginning of current sym block ! strleft:.=.+2 / amount left in string block ! strend: .=.+2 / ptr to next available string byte ! strblk: .=.+2 / ptr to current string block link word / key to types / 0 undefined ! / 1 absolute (nop, reset, bpt, ...) / 2 text / 3 data / 4 bss *************** *** 1454,1460 **** / 6 branch / 7 jsr / 10 rts ! / 11 sys / 12 movf (=ldf,stf) / 13 double operand (mov) / 14 flop fsrc,freg (addf) --- 1552,1558 ---- / 6 branch / 7 jsr / 10 rts ! / 11 sys, trap / 12 movf (=ldf,stf) / 13 double operand (mov) / 14 flop fsrc,freg (addf) *************** *** 1478,1776 **** / 36 jeq, jne, etc .data symtab: ! / special variables ! <.\0\0\0\0\0\0\0>; dotrel:02; dot:000000 ! <..\0\0\0\0\0\0>; 01; dotdot:000000 / register ! ; 24;000000 ! ; 24;000001 ! ; 24;000002 ! ; 24;000003 ! ; 24;000004 ! ; 24;000005 ! ; 24;000006 ! ; 24;000007 / double operand ! ; 13;0010000 ! ; 13;0110000 ! ; 13;0020000 ! ; 13;0120000 ! ; 13;0030000 ! ; 13;0130000 ! ; 13;0040000 ! ; 13;0140000 ! ; 13;0050000 ! ; 13;0150000 ! ; 13;0060000 ! ; 13;0160000 / branch ! ; 06;0000400 ! ; 06;0001000 ! ; 06;0001400 ! ; 06;0002000 ! ; 06;0002400 ! ; 06;0003000 ! ; 06;0003400 ! ; 06;0100000 ! ; 06;0100400 ! ; 06;0101000 ! ; 06;0101400 ! ; 06;0102000 ! ; 06;0102400 ! ; 06;0103000 ! ; 06;0103000 ! ; 06;0103000 ! ; 06;0103400 ! ; 06;0103400 ! ; 06;0103400 / jump/branch type ! ; 35;0000400 ! ; 36;0001000 ! ; 36;0001400 ! ; 36;0002000 ! ; 36;0002400 ! ; 36;0003000 ! ; 36;0003400 ! ; 36;0100000 ! ; 36;0100400 ! ; 36;0101000 ! ; 36;0101400 ! ; 36;0102000 ! ; 36;0102400 ! ; 36;0103000 ! ; 36;0103000 ! ; 36;0103000 ! ; 36;0103400 ! ; 36;0103400 ! ; 36;0103400 / single operand ! ; 15;0005000 ! ; 15;0105000 ! ; 15;0005100 ! ; 15;0105100 ! ; 15;0005200 ! ; 15;0105200 ! ; 15;0005300 ! ; 15;0105300 ! ; 15;0005400 ! ; 15;0105400 ! ; 15;0005500 ! ; 15;0105500 ! ; 15;0005600 ! ; 15;0105600 ! ; 15;0005700 ! ; 15;0105700 ! ; 15;0006000 ! ; 15;0106000 ! ; 15;0006100 ! ; 15;0106100 ! ; 15;0006200 ! ; 15;0106200 ! ; 15;0006300 ! ; 15;0106300 ! ; 15;0000100 ! ; 15;0000300 ! ; 15;0006500 ! ; 15;0006600 ! ; 15;0106500 ! ; 15;0106600 ! ; 15;0170300 ! ; 15;0106700 ! ; 15;0106400 ! ; 15;0007000 ! ; 15;0007200 ! ; 15;0007300 / jsr ! ; 07;0004000 / rts ! ; 010;000200 / simple operand ! ; 011;104400 ! ; 011;000230 / flag-setting ! ; 01;0000240 ! ; 01;0000241 ! ; 01;0000242 ! ; 01;0000244 ! ; 01;0000250 ! ; 01;0000261 ! ; 01;0000262 ! ; 01;0000264 ! ; 01;0000270 ! ; 01;0000000 ! ; 01;0000001 ! ; 01;0000004 ! ; 01;0000005 ! ; 01;0000006 ! ; 01;0000007 / floating point ops ! ; 01;170000 ! ; 01;170001 ! ; 01;170011 ! ; 01;170002 ! ; 01;170012 ! ; 15;170400 ! ; 15;170700 ! ; 15;170600 ! ; 15;170500 ! ; 12;172400 ! ; 14;177000 ! ; 05;175400 ! ; 14;177400 ! ; 05;176000 ! ; 14;172000 ! ; 14;173000 ! ; 14;171000 ! ; 14;174400 ! ; 14;173400 ! ; 14;171400 ! ; 14;176400 ! ; 05;175000 ! ; 15;170100 ! ; 15;170200 ! ; 24;000000 ! ; 24;000001 ! ; 24;000002 ! ; 24;000003 ! ; 24;000004 ! ; 24;000005 ! / 11/45 operations ! ; 30;070000 ! ; 30;071000 ! ; 30;072000 ! ; 30;073000 ! ; 07;074000 ! ; 15;006700 ! ; 11;006400 ! ; 31;077000 ! / specials - <.byte\0\0\0>; 16;000000 - <.even\0\0\0>; 20;000000 - <.if\0\0\0\0\0>; 21;000000 - <.endif\0\0>; 22;000000 - <.globl\0\0>; 23;000000 - <.text\0\0\0>; 25;000000 - <.data\0\0\0>; 26;000000 - <.bss\0\0\0\0>; 27;000000 - <.comm\0\0\0>; 32;000000 - ebsymtab: .text - start: - mov $1,-(sp) / signal(SIGINT, SIG_IGN) - mov $2,-(sp) / sys signal; 2; 1 - jsr pc,_signal - cmp (sp)+,(sp)+ - - ror r0 - bcs 1f - - mov $aexit,-(sp) / signal(SIGINT, aexit) - mov $2,-(sp) / sys signal; 2; aexit - jsr pc,_signal - cmp (sp)+,(sp)+ - 1: - mov (sp)+,r0 - tst (sp)+ - 1: - mov (sp),r1 - cmpb (r1),$'- - bne 1f - tst (sp)+ - dec r0 - cmpb 1(r1),$'u - bne 2f - movb $'g,unglob - br 1b - 2: - cmpb 1(r1), $'V - bne 2f - movb $'V, ovloc - br 1b - 2: - tstb 1(r1) - bne 2f - movb $'g,unglob - br 1b - 2: - cmpb 1(r1),$'o - bne 1f - mov (sp),outfp - tst (sp)+ - dec r0 - br 1b - 1: - movb r0,nargs - tst -(sp) - mov sp,curarg - mov $a.tmp1,r5 - jsr pc,fcreat - mov r0,pof - mov $a.tmp2,r5 - jsr pc,fcreat - mov r0,fbfil - jsr pc,setup - jmp go - - setup: - mov $symtab,r1 - 1: - clr r3 - mov $8,r2 - mov r1,-(sp) - 2: - movb (r1)+,r4 - beq 2f - add r4,r3 - swab r3 - sob r2,2b - 2: - clr r2 - div $hshsiz,r2 - ashc $1,r2 - add $hshtab,r3 - 4: - sub r2,r3 - cmp r3,$hshtab - bhi 3f - add $2*hshsiz,r3 - 3: - tst -(r3) - bne 4b - mov (sp)+,r1 - mov r1,(r3) - add $12.,r1 - cmp r1,$ebsymtab - blo 1b - rts pc - - .data - inbuf: - . = inbuf+1024. --- 1576,1960 ---- / 36 jeq, jne, etc .data + / the format of PST entries was changed. rather than fixed 8 byte strings + / (often with many trailing nulls) a pointer to a null terminated string + / is now used. This saves quite a bit of space since most PST entries are + / only 3 or 4 characters long. we had to do this the hard way since there + / is no macro capability in the assembler and i'd chuck out the SDI [Span + / Dependent Instruction] stuff and use my own assembler before trying to + / add macros to this one. Symbols beginning with 'L' are used since the + / linker can be told to discard those. + symtab: ! / special symbols ! L1; dotrel: 02; dot: 0000000 ! L2; 01; dotdot: 0000000 / register ! L3; 24; 000000 ! L4; 24; 000001 ! L5; 24; 000002 ! L6; 24; 000003 ! L7; 24; 000004 ! L8; 24; 000005 ! L9; 24; 000006 ! L10; 24; 000007 / double operand ! L11; 13; 0010000 ! L12; 13; 0110000 ! L13; 13; 0020000 ! L14; 13; 0120000 ! L15; 13; 0030000 ! L16; 13; 0130000 ! L17; 13; 0040000 ! L18; 13; 0140000 ! L19; 13; 0050000 ! L20; 13; 0150000 ! L21; 13; 0060000 ! L22; 13; 0160000 / branch ! L23; 06; 0000400 ! L24; 06; 0001000 ! L25; 06; 0001400 ! L26; 06; 0002000 ! L27; 06; 0002400 ! L28; 06; 0003000 ! L29; 06; 0003400 ! L30; 06; 0100000 ! L31; 06; 0100400 ! L32; 06; 0101000 ! L33; 06; 0101400 ! L34; 06; 0102000 ! L35; 06; 0102400 ! L36; 06; 0103000 ! L37; 06; 0103000 ! L38; 06; 0103000 ! L39; 06; 0103400 ! L40; 06; 0103400 ! L41; 06; 0103400 / jump/branch type ! L42; 35; 0000400 ! L43; 36; 0001000 ! L44; 36; 0001400 ! L45; 36; 0002000 ! L46; 36; 0002400 ! L47; 36; 0003000 ! L48; 36; 0003400 ! L49; 36; 0100000 ! L50; 36; 0100400 ! L51; 36; 0101000 ! L52; 36; 0101400 ! L53; 36; 0102000 ! L54; 36; 0102400 ! L55; 36; 0103000 ! L56; 36; 0103000 ! L57; 36; 0103000 ! L58; 36; 0103400 ! L59; 36; 0103400 ! L60; 36; 0103400 / single operand ! L61; 15; 0005000 ! L62; 15; 0105000 ! L63; 15; 0005100 ! L64; 15; 0105100 ! L65; 15; 0005200 ! L66; 15; 0105200 ! L67; 15; 0005300 ! L68; 15; 0105300 ! L69; 15; 0005400 ! L70; 15; 0105400 ! L71; 15; 0005500 ! L72; 15; 0105500 ! L73; 15; 0005600 ! L74; 15; 0105600 ! L75; 15; 0005700 ! L76; 15; 0105700 ! L77; 15; 0006000 ! L78; 15; 0106000 ! L79; 15; 0006100 ! L80; 15; 0106100 ! L81; 15; 0006200 ! L82; 15; 0106200 ! L83; 15; 0006300 ! L84; 15; 0106300 ! L85; 15; 0000100 ! L86; 15; 0000300 ! L87; 15; 0006500 ! L88; 15; 0006600 ! L89; 15; 0106500 ! L90; 15; 0106600 ! L91; 15; 0170300 ! L92; 15; 0106700 ! L93; 15; 0106400 ! L94; 15; 0007000 ! L95; 15; 0007200 ! L96; 15; 0007300 / jsr ! L97; 07; 0004000 / rts ! L98; 010; 000200 / simple operand ! L99; 011; 104400 ! L102; 011; 000230 / flag-setting ! L103; 01; 0000240 ! L104; 01; 0000241 ! L105; 01; 0000242 ! L106; 01; 0000244 ! L107; 01; 0000250 ! L108; 01; 0000257 ! L109; 01; 0000261 ! L110; 01; 0000262 ! L111; 01; 0000264 ! L112; 01; 0000270 ! L113; 01; 0000277 ! L114; 01; 0000000 ! L115; 01; 0000001 ! L116; 01; 0000002 ! L117; 01; 0000003 ! L118; 01; 0000004 ! L119; 01; 0000005 ! L120; 01; 0000006 ! L121; 01; 0000007 / floating point ops ! L122; 01; 170000 ! L123; 01; 170001 ! L124; 01; 170011 ! L125; 01; 170002 ! L126; 01; 170012 ! L127; 15; 170400 ! L128; 15; 170700 ! L129; 15; 170600 ! L130; 15; 170500 ! L131; 12; 172400 ! L132; 14; 177000 ! L133; 05; 175400 ! L134; 14; 177400 ! L135; 05; 176000 ! L136; 14; 172000 ! L137; 14; 173000 ! L138; 14; 171000 ! L139; 14; 174400 ! L140; 14; 173400 ! L141; 14; 171400 ! L142; 14; 176400 ! L143; 05; 175000 ! L144; 15; 170100 ! L145; 15; 170200 ! L146; 24; 000000 ! L147; 24; 000001 ! L148; 24; 000002 ! L149; 24; 000003 ! L150; 24; 000004 ! L151; 24; 000005 ! L152; 30; 070000 ! L153; 30; 071000 ! L154; 30; 072000 ! L155; 30; 073000 ! L156; 07; 074000 ! L157; 15; 006700 ! L158; 11; 006400 ! L159; 31; 077000 ! / pseudo ops ! L160; 16; 000000 ! L161; 20; 000000 ! L162; 21; 000000 ! L163; 22; 000000 ! L164; 23; 000000 ! L165; 25; 000000 ! L166; 26; 000000 ! L167; 27; 000000 ! L168; 32; 000000 ebsymtab: + L1: <.\0> + L2: <..\0> + L3: + L4: + L5: + L6: + L7: + L8: + L9: + L10: + L11: + L12: + L13: + L14: + L15: + L16: + L17: + L18: + L19: + L20: + L21: + L22: + L23: + L24: + L25: + L26: + L27: + L28: + L29: + L30: + L31: + L32: + L33: + L34: + L35: + L36: + L37: + L38: + L39: + L40: + L41: + L42: + L43: + L44: + L45: + L46: + L47: + L48: + L49: + L50: + L51: + L52: + L53: + L54: + L55: + L56: + L57: + L58: + L59: + L60: + L61: + L62: + L63: + L64: + L65: + L66: + L67: + L68: + L69: + L70: + L71: + L72: + L73: + L74: + L75: + L76: + L77: + L78: + L79: + L80: + L81: + L82: + L83: + L84: + L85: + L86: + L87: + L88: + L89: + L90: + L91: + L92: + L93: + L94: + L95: + L96: + L97: + L98: + L99: + L102: + L103: + L104: + L105: + L106: + L107: + L108: + L109: + L110: + L111: + L112: + L113: + L114: + L115: + L116: + L117: + L118: + L119: + L120: + L121: + L122: + L123: + L124: + L125: + L126: + L127: + L128: + L129: + L130: + L131: + L132: + L133: + L134: + L135: + L136: + L137: + L138: + L139: + L140: + L141: + L142: + L143: + L144: + L145: + L146: + L147: + L148: + L149: + L150: + L151: + L152: + L153: + L154: + L155: + L156: + L157: + L158: + L159: + L160: <.byte\0> + L161: <.even\0> + L162: <.if\0> + L163: <.endif\0> + L164: <.globl\0> + L165: <.text\0> + L166: <.data\0> + L167: <.bss\0> + L168: <.comm\0> .text