Annotation of researchv10no/cmd/PDP11/11as/as22.c, revision 1.1

1.1     ! root        1: /* a2 -- pdp-11 assembler pass 2 */
        !             2: #include "as2.h"
        !             3: 
        !             4: struct expr *xsymbol;
        !             5: 
        !             6: outw(typ,val)
        !             7: register int typ;
        !             8: {
        !             9:        register int pcrel;
        !            10: 
        !            11:        if (*dotrel==T_BSS) {error('x'); return;}
        !            12:        if (*dot&1) {error('o'); outb(0,val); return;}
        !            13:        *dot+=2;
        !            14:        if (passno==0) return;
        !            15:        pcrel=typ&PCREL; typ&=~PCREL;
        !            16:        if (typ==T_EXTERN) {/* external references */
        !            17:                outmod=0666;    /* non executable */
        !            18:                typ=((xsymbol-usymtab)<<3)|4;   /* external relocation */
        !            19:        } else {
        !            20:                if ((typ&=~T_EXTERN)>=R_EXTERN) {
        !            21:                        if (typ==T_ESTTXT || typ==T_ESTDAT) error('r');
        !            22:                        typ=T_ABS;
        !            23:                }
        !            24:                if (typ>=T_TEXT && typ<=T_BSS) {
        !            25:                        if (pcrel==0) val+= *dotdot;
        !            26:                } else if (pcrel) val-= *dotdot;
        !            27:                if (--typ<0) typ=0;
        !            28:        }
        !            29:        typ<<=1;
        !            30:        if (pcrel) typ|=1;
        !            31:        putw(val,txtf); tseek[*dotrel-T_TEXT]+=2;
        !            32:        putw(typ,relf); rseek[*dotrel-T_TEXT]+=2;
        !            33: }
        !            34: 
        !            35: outb(typ,val)
        !            36: {
        !            37:        if (*dotrel==T_BSS) {error('x'); return;}
        !            38:        if ((unsigned)typ>T_ABS) error('r');
        !            39:        if (passno!=0) {
        !            40:                if (1!=fwrite(&val,1,1,txtf)) wrterr();
        !            41:                tseek[*dotrel-T_TEXT]++;
        !            42:                if (!(*dot&1)) {/* relocate immediately, so we don't forget */
        !            43:                        val=0; if (1!=fwrite(&val,2,1,relf)) wrterr();
        !            44:                        rseek[*dotrel-T_TEXT]+=2;
        !            45:                }
        !            46:        }
        !            47:        (*dot)++;
        !            48: }
        !            49: 
        !            50: char argb[20];
        !            51: 
        !            52: error(t)
        !            53: {
        !            54:        ++errflg; outmod=0666;
        !            55:        fprintf(stderr,"%s%c %.4d\n",argb,t,line);
        !            56:        argb[0]='\0';
        !            57: }

unix.superglobalmegacorp.com

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