1: int word[16];
   2: char    gbuf[512];
   3: int fi;
   4: int conv;
   5: int base    010;
   6: int basem   01000;
   7: int max;
   8: int gidx;
   9: int gcnt;
  10: int eof;
  11: int addr[2];
  12: int from[2];
  13: int key;
  14: int flag;
  15: int nword   8;
  16: 
  17: main(argc, argv)
  18: char **argv;
  19: {
  20:     extern fout;
  21:     int f, k, w, i, a[2];
  22:     char *p;
  23: 
  24:     fout = dup(1);
  25:     argv++;
  26:     if(argc > 1) {
  27:         p = *argv;
  28:         if(*p == '-') {
  29:             while((i = *p++) != '\0') {
  30:                 switch(i) {
  31:                 case 'o':
  32:                     conv =| 001;
  33:                     f = 6;
  34:                     break;
  35:                 case 'd':
  36:                     conv =| 002;
  37:                     f = 5;
  38:                     break;
  39:                 case 'a':
  40:                     conv =| 004;
  41:                     f = 4;
  42:                     break;
  43:                 case 'h':
  44:                     conv =| 010;
  45:                     f = 4;
  46:                     break;
  47:                 case 'c':
  48:                     conv =| 020;
  49:                     f = 5;
  50:                     break;
  51:                 case 'b':
  52:                     conv =| 040;
  53:                     f = 7;
  54:                     break;
  55:                 }
  56:                 if(f > max)
  57:                     max = f;
  58:             }
  59:             argc--;
  60:             argv++;
  61:         }
  62:     }
  63:     if(!conv) {
  64:         max = 6;
  65:         conv = 1;
  66:     }
  67:     if(argc > 1)
  68:     if(**argv != '+') {
  69:         fi = open(*argv, 0);
  70:         if(fi < 0) {
  71:             printf("cannot open %s\n", *argv);
  72:             goto done;
  73:         }
  74:         argv++;
  75:         argc--;
  76:     }
  77:     if(argc > 1)
  78:         offset(*argv);
  79: 
  80: loop:
  81:     f = 1;
  82:     a[0] = addr[0];
  83:     a[1] = addr[1];
  84:     for(i=0; i<nword; i++) {
  85:         w = getw();
  86:         if(eof)
  87:             break;
  88:         word[i] = w;
  89:         if(i)
  90:             f =& w==k; else
  91:             k = w;
  92:     }
  93:     if(i)
  94:     if(f && !eof) {
  95:         if(!(flag && k==key)) {
  96:             dupl();
  97:             key = k;
  98:             from[0] = a[0];
  99:             from[1] = a[1];
 100:         }
 101:         flag =+ i;
 102:     } else {
 103:         dupl();
 104:         line(a, word, i);
 105:     }
 106:     if(!eof)
 107:         goto loop;
 108:     puta(addr);
 109:     putchar('\n');
 110: 
 111: done:
 112:     flush();
 113: }
 114: 
 115: dupl()
 116: {
 117: 
 118:     if(flag) {
 119:         flag = 0;
 120:         line(from, &key, 1);
 121:     }
 122: }
 123: 
 124: puta(a)
 125: int a[2];
 126: {
 127: 
 128:     putn(a[0], base, 4);
 129:     putn(a[1], base, 3);
 130:     putchar(' ');
 131: }
 132: 
 133: line(a, w, n)
 134: int w[];
 135: {
 136:     int i, f, c;
 137: 
 138:     f = 1;
 139:     for(c=1; c; c=+c) {
 140:         if((c&conv) == 0)
 141:             continue;
 142:         if(f) {
 143:             puta(a);
 144:             f = 0;
 145:         } else
 146:             for(i=0; i<8; i++)
 147:                 putchar(' ');
 148:         for(i=0; i<n; i++) {
 149:             putx(w[i], c);
 150:             putchar(i==n-1? '\n': ' ');
 151:         }
 152:     }
 153: }
 154: 
 155: putx(n, c)
 156: {
 157: 
 158:     switch(c) {
 159:     case 001:
 160:         pre(6);
 161:         putn(n, 8, 6);
 162:         break;
 163:     case 002:
 164:         pre(5);
 165:         putn(n, 10, 5);
 166:         break;
 167:     case 004:
 168:         pre(4);
 169:         putop(n);
 170:         break;
 171:     case 010:
 172:         pre(4);
 173:         putn(n, 16, 4);
 174:         break;
 175:     case 020:
 176:         pre(5);
 177:         putc(n);
 178:         putchar(' ');
 179:         putc(n>>8);
 180:         break;
 181:     case 040:
 182:         pre(7);
 183:         putn(n&0377, 8, 3);
 184:         putchar(' ');
 185:         putn((n>>8)&0377, 8, 3);
 186:         break;
 187:     }
 188: }
 189: 
 190: getw()
 191: {
 192:     int b1, b2;
 193: 
 194:     b1 = getc();
 195:     if(b1 == -1) {
 196:         eof = 1;
 197:         return(0);
 198:     }
 199:     b2 = getc();
 200:     if(b2 == -1)
 201:         b2 = 0;
 202:     return(b1|(b2<<8));
 203: }
 204: 
 205: getc()
 206: {
 207: 
 208:     if(gidx >= gcnt) {
 209:         gcnt = read(fi, gbuf, 512);
 210:         if(gcnt <= 0)
 211:             return(-1);
 212:         gidx = 0;
 213:     }
 214:     if(++addr[1] >= basem) {
 215:         addr[0]++;
 216:         addr[1] = 0;
 217:     }
 218:     return(gbuf[gidx++]&0377);
 219: }
 220: 
 221: putc(c)
 222: {
 223:     c =& 0377;
 224:     if(c>037 && c<0177 && c!='\\') {
 225:         putchar(' ');
 226:         putchar(c);
 227:         return;
 228:     }
 229:     putchar('\\');
 230:     switch(c) {
 231:     case '\0':
 232:         putchar('0');
 233:         break;
 234:     case '\n':
 235:         putchar('n');
 236:         break;
 237:     case '\\':
 238:         putchar('\\');
 239:         break;
 240:     case '\t':
 241:         putchar('t');
 242:         break;
 243:     default:
 244:         putchar('?');
 245:     }
 246: }
 247: 
 248: putn(n, b, c)
 249: {
 250: 
 251:     if(!c)
 252:         return;
 253:     putn(ldiv(0,n,b),b,c-1);
 254:     if((n=lrem(0,n,b)) > 9)
 255:         putchar(n-10+'a'); else
 256:         putchar(n+'0');
 257: }
 258: 
 259: pre(n)
 260: {
 261:     int i;
 262: 
 263:     for(i=n; i<max; i++)
 264:         putchar(' ');
 265: }
 266: 
 267: offset(s)
 268: char s[];
 269: {
 270:     char *p;
 271:     int a[2], d, i, j, b;
 272: 
 273:     p = s;
 274:     while(*p++);
 275:     i = p-s-1;
 276:     b = 0;
 277:     if(i > 0)
 278:         if(p[-2] == 'b') {
 279:             i--;
 280:             b++;
 281:             p--;
 282:         }
 283:     if(i > 0)
 284:         if(p[-2] == '.') {
 285:             i--;
 286:             base = 10;
 287:             basem = 1000;
 288:         }
 289:     a[0] = 0;
 290:     for(j=0; i-j>3; j++) {
 291:         d = s[j];
 292:         if(d>='0' && d<='9')
 293:             a[0] = a[0]*base + d-'0';
 294:     }
 295:     a[1] = 0;
 296:     for(; i-j>0; j++) {
 297:         d = s[j];
 298:         if(d>='0' && d<='9')
 299:             a[1] = a[1]*base + d-'0';
 300:     }
 301:     if(b) {
 302:         i = a[0]*basem+a[1];
 303:         a[0] = 0;
 304:         a[1] = 0;
 305:         while(i--) {
 306:             a[1] =+ 512;
 307:             while(a[1] >= basem) {
 308:                 a[1] =- basem;
 309:                 a[0]++;
 310:             }
 311:         }
 312:     }
 313:     i = 0;
 314:     while(a[0] > addr[0]+1) {
 315:         addr[1] =+ 512;
 316:         while(addr[1] >= basem) {
 317:             addr[1] =- basem;
 318:             addr[0]++;
 319:         }
 320:         i++;
 321:     }
 322:     seek(fi, i, 3);
 323:     while(a[0]!=addr[0] || a[1]!=addr[1])
 324:         if(getc() == -1)
 325:             break;
 326: }
 327: 
 328: putop(n)
 329: {
 330:     char *p;
 331:     int i, c;
 332: 
 333:     p = getop(n);
 334:     for(i=0; (c = *p++) != '\0'; i++)
 335:         putchar(c);
 336:     for(; i<4; i++)
 337:         putchar(' ');
 338: }
 339: 
 340: getop(n)
 341: {
 342: 
 343:     switch(n&0170000)
 344:     {
 345:     case 0000000:
 346:         switch(n&0177000)
 347:         {
 348:         case 0004000:
 349:             return("jsr");
 350: 
 351:         case 0077000:
 352:             return("sob");
 353:         }
 354:         switch(n&0177400)
 355:         {
 356:         case 0000400:
 357:             return("br");
 358: 
 359:         case 0001000:
 360:             return("bne");
 361: 
 362:         case 0001400:
 363:             return("beq");
 364: 
 365:         case 0002000:
 366:             return("bge");
 367: 
 368:         case 0002400:
 369:             return("blt");
 370: 
 371:         case 0003000:
 372:             return("bgt");
 373: 
 374:         case 0003400:
 375:             return("ble");
 376:         }
 377:         switch(n&0177700)
 378:         {
 379:         case 0000100:
 380:             return("jmp");
 381: 
 382:         case 0000300:
 383:             return("swab");
 384: 
 385:         case 0005000:
 386:             return("clr");
 387: 
 388:         case 0005100:
 389:             return("com");
 390: 
 391:         case 0005200:
 392:             return("inc");
 393: 
 394:         case 0005300:
 395:             return("dec");
 396: 
 397:         case 0005400:
 398:             return("neg");
 399: 
 400:         case 0005500:
 401:             return("adc");
 402: 
 403:         case 0005600:
 404:             return("sbc");
 405: 
 406:         case 0005700:
 407:             return("tst");
 408: 
 409:         case 0006000:
 410:             return("ror");
 411: 
 412:         case 0006100:
 413:             return("rol");
 414: 
 415:         case 0006200:
 416:             return("asr");
 417: 
 418:         case 0006300:
 419:             return("asl");
 420: 
 421:         case 0006400:
 422:             return("mark");
 423: 
 424:         case 0006500:
 425:             return("mfpi");
 426: 
 427:         case 0006600:
 428:             return("mtpi");
 429: 
 430:         case 0006700:
 431:             return("sxt");
 432:         }
 433:         switch(n&0177740)
 434:         {
 435:         case 0000240:
 436:             return("flag");
 437:         }
 438:         switch(n&0177770)
 439:         {
 440:         case 0000200:
 441:             return("rts");
 442: 
 443:         case 0000230:
 444:             return("spl");
 445:         }
 446:         switch(n&0177777)
 447:         {
 448:         case 0000000:
 449:             return("halt");
 450: 
 451:         case 0000001:
 452:             return("wait");
 453: 
 454:         case 0000002:
 455:             return("rti");
 456: 
 457:         case 0000003:
 458:             return("bpt");
 459: 
 460:         case 0000004:
 461:             return("iot");
 462: 
 463:         case 0000005:
 464:             return("rset");
 465: 
 466:         case 0000006:
 467:             return("rtt");
 468:         }
 469:         break;
 470: 
 471:     case 0010000:
 472:         return("mov ");
 473: 
 474:     case 0020000:
 475:         return("cmp");
 476: 
 477:     case 0030000:
 478:         return("bit");
 479: 
 480:     case 0040000:
 481:         return("bic");
 482: 
 483:     case 0050000:
 484:         return("bis");
 485: 
 486:     case 0060000:
 487:         return("add");
 488: 
 489:     case 0070000:
 490:         switch(n&0177000)
 491:         {
 492:         case 0070000:
 493:             return("mul");
 494: 
 495:         case 0071000:
 496:             return("div");
 497: 
 498:         case 0072000:
 499:             return("ash");
 500: 
 501:         case 0073000:
 502:             return("ashc");
 503: 
 504:         case 0074000:
 505:             return("xor");
 506:         }
 507:         break;
 508: 
 509:     case 0100000:
 510:         switch(n&0177400)
 511:         {
 512:         case 0100000:
 513:             return("bpl");
 514: 
 515:         case 0100400:
 516:             return("bmi");
 517: 
 518:         case 0101000:
 519:             return("bhi");
 520: 
 521:         case 0101400:
 522:             return("blos");
 523: 
 524:         case 0102000:
 525:             return("bvc");
 526: 
 527:         case 0102400:
 528:             return("bvs");
 529: 
 530:         case 0103000:
 531:             return("bhis");
 532: 
 533:         case 0103400:
 534:             return("blo");
 535: 
 536:         case 0104000:
 537:             return("emt");
 538: 
 539:         case 0104400:
 540:             return("sys");
 541:         }
 542:         switch(n&0177700)
 543:         {
 544:         case 0105000:
 545:             return("clrb");
 546: 
 547:         case 0105100:
 548:             return("comb");
 549: 
 550:         case 0105200:
 551:             return("incb");
 552: 
 553:         case 0105300:
 554:             return("decb");
 555: 
 556:         case 0105400:
 557:             return("negb");
 558: 
 559:         case 0105500:
 560:             return("adcb");
 561: 
 562:         case 0105600:
 563:             return("sbcb");
 564: 
 565:         case 0105700:
 566:             return("tstb");
 567: 
 568:         case 0106000:
 569:             return("rorb");
 570: 
 571:         case 0106100:
 572:             return("rolb");
 573: 
 574:         case 0106200:
 575:             return("asrb");
 576: 
 577:         case 0106300:
 578:             return("aslb");
 579: 
 580:         case 0106500:
 581:             return("mfpd");
 582: 
 583:         case 0106600:
 584:             return("mfpd");
 585:         }
 586:         break;
 587: 
 588:     case 0110000:
 589:         return("movb");
 590: 
 591:     case 0120000:
 592:         return("cmpb");
 593: 
 594:     case 0130000:
 595:         return("bitb");
 596: 
 597:     case 0140000:
 598:         return("bicb");
 599: 
 600:     case 0150000:
 601:         return("bisb");
 602: 
 603:     case 0160000:
 604:         return("sub");
 605: 
 606:     case 0170000:
 607:         switch(n&01777000)
 608:         {
 609:         case 0:0;
 610:         }
 611:         break;
 612:     }
 613:     return("???");
 614: }

Defined functions

dupl defined in line 115; used 2 times
getc defined in line 205; used 3 times
getop defined in line 340; used 1 times
getw defined in line 190; used 1 times
  • in line 85
line defined in line 133; used 2 times
main defined in line 17; never used
offset defined in line 267; used 1 times
  • in line 78
pre defined in line 259; used 6 times
puta defined in line 124; used 2 times
putc defined in line 221; used 2 times
putn defined in line 248; used 8 times
putop defined in line 328; used 1 times
putx defined in line 155; used 1 times

Defined variables

addr defined in line 11; used 13 times
base defined in line 5; used 5 times
basem defined in line 6; used 7 times
conv defined in line 4; used 9 times
eof defined in line 10; used 4 times
fi defined in line 3; used 4 times
flag defined in line 14; used 4 times
from defined in line 12; used 3 times
gbuf defined in line 2; used 2 times
gcnt defined in line 9; used 3 times
gidx defined in line 8; used 3 times
key defined in line 13; used 3 times
max defined in line 7; used 4 times
nword defined in line 15; used 1 times
  • in line 84
word defined in line 1; used 2 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1365
Valid CSS Valid XHTML 1.0 Strict