Annotation of researchv8dc/cmd/PDP11/11as/as14.c, revision 1.1

1.1     ! root        1: /* a4 -- pdp-11 assembler pass1 */
        !             2: #include "as1.h"
        !             3: extern char end[];
        !             4: char *brkend = end;
        !             5: extern struct symtab *hshtab[HSHSIZ];
        !             6: extern struct symtab symtab[];
        !             7: extern int noputw;
        !             8: 
        !             9: struct expr *
        !            10: rname(t)
        !            11: {
        !            12:        register int i;
        !            13:        register char *cp1,*cp2;
        !            14:        struct symtab *sp,**hp;
        !            15:        int around;
        !            16:        int h=0,flags=0;
        !            17: 
        !            18:        for (cp1=symbol+NCPS,i=NCPS; --i>=0; ) *--cp1=0;
        !            19:        i=NCPS;
        !            20:        if (t=='~') {ch=0; flags=1;}    /* symbol not for hash table */
        !            21:        for (;;) {
        !            22:                if (chartab[t=rch()]<=0) break;
        !            23:                h+=t; h=((h&0377)<<8)|((h>>8)&0377);
        !            24:                if (--i>=0) *cp1++=t;
        !            25:        }
        !            26:        ch=t;
        !            27:        if (flags) {sp=symend++; goto f4;}
        !            28:        hp=hshtab+((long)(unsigned short)h)%HSHSIZ;
        !            29:        h=((long)(unsigned short)h)/HSHSIZ;
        !            30:        around=0;
        !            31:        for (;;) {
        !            32:                if ((hp-=h)<=hshtab) {
        !            33:                        hp+=HSHSIZ;
        !            34:                        if (around) {fprintf(stderr,"as: symbol table overflow\n"); aexit();}
        !            35:                        around++;
        !            36:                }
        !            37:                cp1=symbol;
        !            38:                if ((sp= *--hp)!=0) {
        !            39:                        cp2=sp->name;
        !            40:                        if (*cp1++!=*cp2++ || *cp1++!=*cp2++ || *cp1++!=*cp2++ || *cp1++!=*cp2++ ||
        !            41:                            *cp1++!=*cp2++ || *cp1++!=*cp2++ || *cp1++!=*cp2++ || *cp1++!=*cp2++)
        !            42:                                continue;
        !            43:                        break;
        !            44:                }
        !            45:                *hp=sp=symend++;
        !            46:        f4:
        !            47:                cp2=sp->name; cp1=symbol;
        !            48:                if (cp2>=brkend) {
        !            49:                        register char *s;
        !            50:                        if (-1==(int)(s=sbrk(512))) {error('M'); aexit();}
        !            51:                        brkend=s+512-sizeof(*sp);
        !            52:                }
        !            53:                for (i=NCPS; --i>=0; ) *cp2++= *cp1++;
        !            54:                sp->sval.typ=0; sp->sval.val=0;
        !            55:                break;
        !            56:        }
        !            57:        if (sp>=usymtab)
        !            58:                putw(USYM+(sp-usymtab));
        !            59:        else
        !            60:                putw(BSYM+(sp-symtab));
        !            61:        noputw=1;
        !            62:        return(&sp->sval);
        !            63: }
        !            64: 
        !            65: int fbflag;
        !            66: 
        !            67: number()
        !            68: {
        !            69:        register int t;
        !            70:        register short dec=0,oct=0;
        !            71: 
        !            72:        fbflag=0;
        !            73:        for (;;) {
        !            74:                t=rch();
        !            75:                if (t<'0' || t>'9') break;
        !            76:                dec=(dec*10)+t-'0'; oct=(oct<<3)+t-'0';
        !            77:        }
        !            78:        if (t=='b' || t=='f') {
        !            79:                register int i;
        !            80:                fbflag=1;
        !            81:                i=fbcheck(dec)+'a';
        !            82:                if (t=='f') i+=10;
        !            83:                return(i);
        !            84:        }
        !            85:        if (t=='.')
        !            86:                {ch=0; return(dec);}
        !            87:        else
        !            88:                {ch=t; return(oct);}
        !            89: }
        !            90: 
        !            91: rch()
        !            92: {
        !            93:        register int t;
        !            94:        register char *cp;
        !            95: 
        !            96:        for (;;) {
        !            97:                if (t=ch) {ch=0; return(t);}
        !            98:                if ((t=getchar())!=EOF) return(t);
        !            99:                fclose(stdin);
        !           100:                if (--nargs<=0) return('\004');
        !           101:                if (ifflg) {error('i'); aexit();}
        !           102:                if (NULL==freopen(*++curarg,"r",stdin)) {filerr(*curarg,"?\n"); aexit();}
        !           103:                line=1;
        !           104:                putw(5); cp= *curarg; while (t= *cp++) putw(t); putw(-1);
        !           105:        }
        !           106: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.