1: int nofloat;
   2: int peekc;
   3: int obuf[259];
   4: int tabflg;
   5: int labno   1;
   6: 
   7: main(argc, argv)
   8: char **argv;
   9: {
  10: /*
  11: 	A1 -> A
  12: 	A2    B
  13: 	A     O
  14: 	B1    C
  15: 	B2    D
  16: 	BE    L
  17: 	BF    P
  18: 	C1    E
  19: 	C2    F
  20: 	F     G
  21: 	H     H
  22: 	R     I
  23: 	R1    J
  24: 	S     K
  25: 	I     M
  26: 	M     N
  27: 
  28: 		*	+1
  29: 		S	+2
  30: 		C	+4
  31: 		1	+8
  32: 
  33: 	z  -> 4
  34: 	c     10
  35: 	a     14
  36: 	e     20
  37: 	n     63
  38: 	*	+0100
  39: */
  40: 
  41:     auto c,snlflg,nlflg,t,smode,m,ssmode;
  42:     extern fin;
  43: 
  44:     smode = nlflg = snlflg = ssmode = 0;
  45:     if (argc>1)
  46:         if ((fin = open(argv[1], 0)) < 0) {
  47:             putchar('?\n');
  48:             return;
  49:         }
  50:     obuf[0] = 1;
  51:     if (argc>2)
  52:         if ((obuf[0] = creat(argv[2], 0666)) < 0) {
  53:             putchar('?\n');
  54:             return;
  55:         }
  56: loop:
  57:     c = getc();
  58:     if (c!='\n' && c!='\t') nlflg = 0;
  59:     if (ssmode!=0 && c!='%') {
  60:         ssmode = 0;
  61:         printf(".data\nL%d:<", labno++);
  62:     }
  63:     switch(c) {
  64: 
  65:     case '\0':
  66:         printf(".text; 0\n");
  67:         fflush(obuf);
  68:         return;
  69: 
  70:     case ':':
  71:         if (!smode)
  72:             printf("=.+2; 0"); else
  73:             putchar(':');
  74:         goto loop;
  75: 
  76:     case 'A':
  77:         if ((c=getc())=='1' || c=='2') {
  78:             putchar(c+'A'-'1');
  79:             goto loop;
  80:         }
  81:         putchar('O');
  82:         peekc = c;
  83:         goto loop;
  84: 
  85:     case 'B':
  86:         switch (getc()) {
  87: 
  88:         case '1':
  89:             putchar('C');
  90:             goto loop;
  91: 
  92:         case '2':
  93:             putchar('D');
  94:             goto loop;
  95: 
  96:         case 'E':
  97:             putchar('L');
  98:             goto loop;
  99: 
 100:         case 'F':
 101:             putchar('P');
 102:             goto loop;
 103:         }
 104:         putchar('?');
 105:         goto loop;
 106: 
 107:     case 'C':
 108:         putchar(getc()+'E'-'1');
 109:         goto loop;
 110: 
 111:     case 'F':
 112:         putchar('G');
 113:         goto subtre;
 114: 
 115:     case 'R':
 116:         if ((c=getc()) == '1')
 117:         putchar('J'); else {
 118:             putchar('I');
 119:             peekc = c;
 120:         }
 121:         goto loop;
 122: 
 123:     case 'H':
 124:         putchar('H');
 125:         goto subtre;
 126: 
 127:     case 'I':
 128:         putchar('M');
 129:         goto loop;
 130: 
 131:     case 'S':
 132:         putchar('K');
 133: subtre:
 134:         snlflg = 1;
 135:         t = 'A';
 136: l1:
 137:         switch (c=getc()) {
 138: 
 139:         case '*':
 140:             t++;
 141:             goto l1;
 142: 
 143:         case 'S':
 144:             t =+ 2;
 145:             goto l1;
 146: 
 147:         case 'C':
 148:             t =+ 4;
 149:             goto l1;
 150: 
 151:         case '1':
 152:             t =+ 8;
 153:             goto l1;
 154: 
 155:         case '2':
 156:             t =+ 16;
 157:             goto l1;
 158:         }
 159:         peekc = c;
 160:         putchar(t);
 161:         goto loop;
 162: 
 163:     case '#':
 164:         if(getc()=='1')
 165:             putchar('#'); else
 166:             putchar('"');
 167:         goto loop;
 168: 
 169:     case '%':
 170:         if (smode)
 171:             printf(".text;");
 172:         if (ssmode==0) {
 173:             if ((peekc=getc())=='[') {
 174:                 peekc = 0;
 175:                 printf(".data;");
 176:                 while((c=getc())!=']')
 177:                     putchar(c);
 178:                 getc();
 179:                 printf(";.text;");
 180:                 goto loop;
 181:             }
 182:         }
 183: loop1:
 184:         switch (c=getc()) {
 185: 
 186:         case ' ':
 187:         case '\t':
 188:             goto loop1;
 189:         case 'a':
 190:             m = 16;
 191:             t = flag();
 192:             goto pf;
 193: 
 194:         case ',':
 195:             putchar(';');
 196:             goto loop1;
 197: 
 198:         case 'i':
 199:             m = 12;
 200:             t = flag();
 201:             goto pf;
 202:         case 'z':
 203:             m = 4;
 204:             t = flag();
 205:             goto pf;
 206: 
 207:         case 'r':
 208:             m = 9;
 209:             t = flag();
 210:             goto pf;
 211: 
 212:         case '1':
 213:             m = 5;
 214:             t = flag();
 215:             goto pf;
 216: 
 217:         case 'c':
 218:             t = 0;
 219:             m = 8;
 220:             goto pf;
 221: 
 222:         case 'e':
 223:             t = flag();
 224:             m = 20;
 225:             goto pf;
 226: 
 227:         case 'n':
 228:             t = flag();
 229:             m = 63;
 230: pf:
 231:             if ((c=getc())=='*')
 232:                 m =+ 0100; else
 233:                 peekc = c;
 234:             printf(".byte %o,%o", m, t);
 235:             goto loop1;
 236:         case '[':
 237:             printf("L%d=", labno++);
 238:             while ((c=getc())!=']')
 239:                 putchar(c);
 240:             ssmode = 0;
 241:             smode = 0;
 242:             goto loop;
 243: 
 244:         case '\n':
 245:             printf("\nL%d\n", labno);
 246:             ssmode = 1;
 247:             nlflg = 1;
 248:             smode = 1;
 249:             goto loop;
 250:         }
 251:         putchar(c);
 252:         goto loop1;
 253: 
 254:     case '\t':
 255:         if (nlflg) {
 256:             nlflg = 0;
 257:             goto loop;
 258:         }
 259:         if (smode) {
 260:             tabflg++;
 261:             goto loop;
 262:         }
 263:         putchar('\t');
 264:         goto loop;
 265: 
 266:     case '\n':
 267:         if (!smode)  {
 268:             putchar('\n');
 269:             goto loop;
 270:         }
 271:         if (nlflg) {
 272:             nlflg = 0;
 273:             printf("\\0>\n.text\n");
 274:             smode = 0;
 275:             goto loop;
 276:         }
 277:         if (!snlflg)
 278:             printf("\\n");
 279:         snlflg = 0;
 280:         printf(">\n<");
 281:         nlflg = 1;
 282:         goto loop;
 283: 
 284:     case 'X':
 285:     case 'Y':
 286:     case 'T':
 287:         snlflg++;
 288:     }
 289:     putchar(c);
 290:     goto loop;
 291: }
 292: 
 293: getc() {
 294:     auto t, ifcnt;
 295: 
 296:     ifcnt = 0;
 297: gc:
 298:     if (peekc) {
 299:         t = peekc;
 300:         peekc = 0;
 301:     } else
 302:         t = getchar();
 303:     if (t==0)
 304:         return(0);
 305:     if (t=='{') {
 306:         ifcnt++;
 307:         t = getchar();
 308:     }
 309:     if (t=='}') {
 310:         t = getc();
 311:         if (--ifcnt==0)
 312:             if (t=='\n')
 313:                 t = getc();
 314:     }
 315:     if (ifcnt && nofloat)
 316:         goto gc;
 317:     return(t);
 318: }
 319: 
 320: flag() {
 321:     register c, f;
 322: 
 323:     f = 0;
 324: l1:
 325:     switch(c=getc()) {
 326: 
 327:     case 'w':
 328:         f = 1;
 329:         goto l1;
 330: 
 331:     case 'i':
 332:         f = 2;
 333:         goto l1;
 334: 
 335:     case 'b':
 336:         f = 3;
 337:         goto l1;
 338: 
 339:     case 'f':
 340:         f = 4;
 341:         goto l1;
 342: 
 343:     case 'd':
 344:         f = 5;
 345:         goto l1;
 346: 
 347:     case 's':
 348:         f = 6;
 349:         goto l1;
 350: 
 351:     case 'l':
 352:         f = 8;
 353:         goto l1;
 354: 
 355:     case 'p':
 356:         f =+ 16;
 357:         goto l1;
 358:     }
 359:     peekc = c;
 360:     return(f);
 361: }
 362: 
 363: putchar(c)
 364: {
 365:     if (tabflg) {
 366:         tabflg = 0;
 367:         printf(">;.byte %o;<", c+0200);
 368:     } else
 369:         putc(c, obuf);
 370: }

Defined functions

flag defined in line 320; used 7 times
getc defined in line 293; used 17 times
main defined in line 7; never used
putchar defined in line 363; used 27 times

Defined variables

labno defined in line 5; used 3 times
nofloat defined in line 1; used 1 times
obuf defined in line 3; used 4 times
peekc defined in line 2; used 15 times
tabflg defined in line 4; used 3 times
Last modified: 1975-07-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 820
Valid CSS Valid XHTML 1.0 Strict