📄 put.c
字号:
return ( oldlc ); }#ifdef DEBUG if (opt('k')) { printf("%5d\t%s", lc - HEADER_BYTES, cp+1); if (suboppr) printf(":%d", suboppr); if (string) printf("\t%s",string); if (n > 1) pchr('\t'); for (i=1; i<n; i++) printf("%d ", p[i]); pchr('\n'); }#endif if (op != NIL)# ifdef DEC11 word((op & 0377) | subop << 8);# else word(op << 8 | (subop & 0377));# endif DEC11 for (i=1; i<n; i++) word(p[i]); return (oldlc);}#endif OBJ/* * listnames outputs a list of enumerated type names which * can then be selected from to output a TSCAL * a pointer to the address in the code of the namelist * is kept in value[ NL_ELABEL ]. */listnames(ap) register struct nl *ap;{ struct nl *next;#ifdef OBJ register int oldlc;#endif register int len; register unsigned w; register char *strptr; if ( !CGENNING ) /* code is off - do nothing */ return(NIL); if (ap->class != TYPE) ap = ap->type; if (ap->value[ NL_ELABEL ] != 0) { /* the list already exists */ return( ap -> value[ NL_ELABEL ] ); }# ifdef OBJ oldlc = (int) lc; /* same problem as put */ (void) put(2, O_TRA, lc); ap->value[ NL_ELABEL ] = (int) lc;# endif OBJ# ifdef PC putprintf(" .data", 0); aligndot(A_STRUCT); ap -> value[ NL_ELABEL ] = (int) getlab(); (void) putlab((char *) ap -> value[ NL_ELABEL ] );# endif PC /* number of scalars */ next = ap->type; len = next->range[1]-next->range[0]+1;# ifdef OBJ (void) put(2, O_CASE2, len);# endif OBJ# ifdef PC putprintf( " .word %d" , 0 , len );# endif PC /* offsets of each scalar name */ len = (len+1)*sizeof(short);# ifdef OBJ (void) put(2, O_CASE2, len);# endif OBJ# ifdef PC putprintf( " .word %d" , 0 , len );# endif PC next = ap->chain; do { for(strptr = next->symbol; *strptr++; len++) continue; len++;# ifdef OBJ (void) put(2, O_CASE2, len);# endif OBJ# ifdef PC putprintf( " .word %d" , 0 , len );# endif PC } while (next = next->chain); /* list of scalar names */ strptr = getnext(ap, &next);# ifdef OBJ do {# ifdef DEC11 w = (unsigned) *strptr;# else w = *strptr << 8;# endif DEC11 if (!*strptr++) strptr = getnext(next, &next);# ifdef DEC11 w |= *strptr << 8;# else w |= (unsigned) *strptr;# endif DEC11 if (!*strptr++) strptr = getnext(next, &next); word((int) w); } while (next); /* jump over the mess */ patch((PTR_DCL) oldlc);# endif OBJ# ifdef PC while ( next ) { while ( *strptr ) { putprintf( " .byte 0%o" , 1 , *strptr++ ); for ( w = 2 ; ( w <= 8 ) && *strptr ; w ++ ) { putprintf( ",0%o" , 1 , *strptr++ ); } putprintf( "" , 0 ); } putprintf( " .byte 0" , 0 ); strptr = getnext( next , &next ); } putprintf( " .text" , 0 );# endif PC return( ap -> value[ NL_ELABEL ] );}char *getnext(next, new) struct nl *next, **new;{ if (next != NIL) { next = next->chain; *new = next; } if (next == NLNIL) return("");#ifdef OBJ if (opt('k') && CGENNING ) printf("%5d\t\t\"%s\"\n", lc-HEADER_BYTES, next->symbol);#endif OBJ return(next->symbol);}#ifdef OBJ/* * Putspace puts out a table * of nothing to leave space * for the case branch table e.g. */putspace(n) int n;{ register i; if ( !CGENNING ) /* * code disabled - do nothing */ return;#ifdef DEBUG if (opt('k')) printf("%5d\t.=.+%d\n", lc - HEADER_BYTES, n);#endif for (i = n; i > 0; i -= 2) word(0);}putstr(sptr, padding) char *sptr; int padding;{ register unsigned short w; register char *strptr = sptr; register int pad = padding; if ( !CGENNING ) /* * code disabled - do nothing */ return;#ifdef DEBUG if (opt('k')) printf("%5d\t\t\"%s\"\n", lc-HEADER_BYTES, strptr);#endif if (pad == 0) { do {# ifdef DEC11 w = (unsigned short) * strptr;# else w = (unsigned short)*strptr<<8;# endif DEC11 if (w)# ifdef DEC11 w |= *++strptr << 8;# else w |= *++strptr;# endif DEC11 word((int) w); } while (*strptr++); } else {# ifdef DEC11 do { w = (unsigned short) * strptr; if (w) { if (*++strptr) w |= *strptr << 8; else { w |= ' ' << 8; pad--; } word((int) w); } } while (*strptr++);# else do { w = (unsigned short)*strptr<<8; if (w) { if (*++strptr) w |= *strptr; else { w |= ' '; pad--; } word(w); } } while (*strptr++);# endif DEC11 while (pad > 1) {# ifdef DEC11 word(' ' | (' ' << 8));# else word((' ' << 8) | ' ');# endif DEC11 pad -= 2; } if (pad == 1)# ifdef DEC11 word(' ');# else word(' ' << 8);# endif DEC11 else word(0); }}#endif OBJ#ifndef PClenstr(sptr, padding) char *sptr; int padding;{ register int cnt; register char *strptr = sptr; cnt = padding; do { cnt++; } while (*strptr++); return((++cnt) & ~1);}#endif/* * Patch repairs the branch * at location loc to come * to the current location. * for PC, this puts down the label * and the branch just references that label. * lets here it for two pass assemblers. */patch(loc) PTR_DCL loc;{# ifdef OBJ patchfil(loc, (long)(lc-loc-2), 1);# endif OBJ# ifdef PC (void) putlab((char *) loc );# endif PC}#ifdef OBJpatch4(loc)PTR_DCL loc;{ patchfil(loc, (long)(lc - HEADER_BYTES), 2);}/* * Patchfil makes loc+2 have jmploc * as its contents. */patchfil(loc, jmploc, words) PTR_DCL loc; long jmploc; int words;{ register i; extern long lseek(); short val; if ( !CGENNING ) return; if (loc > (unsigned) lc) panic("patchfil");#ifdef DEBUG if (opt('k')) printf("\tpatch %u %D\n", loc - HEADER_BYTES, jmploc);#endif val = jmploc; do {# ifndef DEC11 if (words > 1) val = jmploc >> 16; else val = jmploc;# endif DEC11 i = ((unsigned) loc + 2 - ((unsigned) lc & ~01777))/2; if (i >= 0 && i < 1024) { obuf[i] = val; } else { (void) lseek(ofil, (long) loc+2, 0); write(ofil, (char *) (&val), 2); (void) lseek(ofil, (long) 0, 2); } loc += 2;# ifdef DEC11 val = jmploc >> 16;# endif DEC11 } while (--words);}/* * Put the word o into the code */word(o) int o;{ *obufp = o; obufp++; lc += 2; if (obufp >= obuf+512) pflush();}extern char *obj;/* * Flush the code buffer */pflush(){ register i; i = (obufp - ( ( short * ) obuf ) ) * 2; if (i != 0 && write(ofil, (char *) obuf, i) != i) perror(obj), pexit(DIED); obufp = obuf;}#endif OBJ/* * Getlab - returns the location counter. * included here for the eventual code generator. * for PC, thank you! */char *getlab(){# ifdef OBJ return (lc);# endif OBJ# ifdef PC static long lastlabel; return ( (char *) ++lastlabel );# endif PC}/* * Putlab - lay down a label. * for PC, just print the label name with a colon after it. */char *putlab(l) char *l;{# ifdef PC putprintf( PREFIXFORMAT , 1 , (int) LABELPREFIX , (int) l ); putprintf( ":" , 0 );# endif PC return (l);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -