1: #if !defined(lint) && defined(DOSCCS)
   2: static  char    sccsid[] = "@(#)opset.c 2.7 (2.11BSD) 2000/2/28";
   3: #endif
   4: 
   5: #include "defs.h"
   6: 
   7:     char    *errflg;
   8:     long    dot;
   9:     int dotinc;
  10:     long    var[];
  11:     MAP     datmap;
  12: 
  13: #undef  SINGLE
  14: 
  15: /* instruction printing */
  16: 
  17: #define DOUBLE  0
  18: #define DOUBLW  1
  19: #define SINGLE  2
  20: #define SINGLW  3
  21: #define REVERS  4
  22: #define BRANCH  5
  23: #define NOADDR  6
  24: #define DFAULT  7
  25: #define TRAP    8
  26: #define SYS     9
  27: #define SOB     10
  28: #define JMP     11
  29: #define JSR     12
  30: 
  31: struct optab {
  32:     int     mask;
  33:     int     val;
  34:     int     itype;
  35:     char    *iname;
  36: } optab[] = {
  37:     0107777, 0010000, DOUBLE, "mov",
  38:     0107777, 0020000, DOUBLE, "cmp",
  39:     0107777, 0030000, DOUBLE, "bit",
  40:     0107777, 0040000, DOUBLE, "bic",
  41:     0107777, 0050000, DOUBLE, "bis",
  42:     0007777, 0060000, DOUBLW, "add",
  43:     0007777, 0160000, DOUBLW, "sub",
  44:     0100077, 0005000, SINGLE, "clr",
  45:     0100077, 0005100, SINGLE, "com",
  46:     0100077, 0005200, SINGLE, "inc",
  47:     0100077, 0005300, SINGLE, "dec",
  48:     0100077, 0005400, SINGLE, "neg",
  49:     0100077, 0005500, SINGLE, "adc",
  50:     0100077, 0005600, SINGLE, "sbc",
  51:     0100077, 0005700, SINGLE, "tst",
  52:     0100077, 0006000, SINGLE, "ror",
  53:     0100077, 0006100, SINGLE, "rol",
  54:     0100077, 0006200, SINGLE, "asr",
  55:     0100077, 0006300, SINGLE, "asl",
  56:     0000077, 0000100, JMP,    "jmp",
  57:     0000077, 0000300, SINGLE, "swab",
  58:     0000077, 0170100, SINGLW, "ldfps",
  59:     0000077, 0170200, SINGLW, "stfps",
  60:     0000077, 0170300, SINGLW, "stst",
  61:     0000077, 0170400, SINGLW, "clrf",
  62:     0000077, 0170500, SINGLW, "tstf",
  63:     0000077, 0170600, SINGLW, "absf",
  64:     0000077, 0170700, SINGLW, "negf",
  65:     0000077, 0006700, SINGLW, "sxt",
  66:     0000077, 0006600, SINGLW, "mtpi",
  67:     0000077, 0106600, SINGLW, "mtpd",
  68:     0000077, 0006500, SINGLW, "mfpi",
  69:     0000077, 0106500, SINGLW, "mfpd",
  70:     0000077, 0106700, SINGLW, "mfps",
  71:     0000077, 0106400, SINGLW, "mtps",
  72:     0000777, 0070000, REVERS, "mul",
  73:     0000777, 0071000, REVERS, "div",
  74:     0000777, 0072000, REVERS, "ash",
  75:     0000777, 0073000, REVERS, "ashc",
  76:     LOBYTE,  0000400, BRANCH, "br",
  77:     LOBYTE,  0001000, BRANCH, "bne",
  78:     LOBYTE,  0001400, BRANCH, "beq",
  79:     LOBYTE,  0002000, BRANCH, "bge",
  80:     LOBYTE,  0002400, BRANCH, "blt",
  81:     LOBYTE,  0003000, BRANCH, "bgt",
  82:     LOBYTE,  0003400, BRANCH, "ble",
  83:     LOBYTE,  0100000, BRANCH, "bpl",
  84:     LOBYTE,  0100400, BRANCH, "bmi",
  85:     LOBYTE,  0101000, BRANCH, "bhi",
  86:     LOBYTE,  0101400, BRANCH, "blos",
  87:     LOBYTE,  0102000, BRANCH, "bvc",
  88:     LOBYTE,  0102400, BRANCH, "bvs",
  89:     LOBYTE,  0103000, BRANCH, "bcc",
  90:     LOBYTE,  0103400, BRANCH, "bcs",
  91:     0000000, 0000000, NOADDR, "halt",
  92:     0000000, 0000001, NOADDR, "wait",
  93:     0000000, 0000002, NOADDR, "rti",
  94:     0000000, 0000003, NOADDR, "bpt",
  95:     0000000, 0000004, NOADDR, "iot",
  96:     0000000, 0000005, NOADDR, "reset",
  97:     0000000, 0000006, NOADDR, "rtt",
  98:     LOBYTE,  0171000, REVERS, "mulf",
  99:     LOBYTE,  0171400, REVERS, "modf",
 100:     LOBYTE,  0172000, REVERS, "addf",
 101:     LOBYTE,  0172400, REVERS, "movf",
 102:     LOBYTE,  0173000, REVERS, "subf",
 103:     LOBYTE,  0173400, REVERS, "cmpf",
 104:     LOBYTE,  0174000, DOUBLW, "movf",
 105:     LOBYTE,  0174400, REVERS, "divf",
 106:     LOBYTE,  0175000, DOUBLW, "movei",
 107:     LOBYTE,  0175400, DOUBLW, "movfi",
 108:     LOBYTE,  0176000, DOUBLW, "movfo",
 109:     LOBYTE,  0176400, REVERS, "movie",
 110:     LOBYTE,  0177000, REVERS, "movif",
 111:     LOBYTE,  0177400, REVERS, "movof",
 112:     0000000, 0170000, NOADDR, "cfcc",
 113:     0000000, 0170001, NOADDR, "setf",
 114:     0000000, 0170002, NOADDR, "seti",
 115:     0000000, 0170011, NOADDR, "setd",
 116:     0000000, 0170012, NOADDR, "setl",
 117:     0000000, 0000007, NOADDR, "mfpt",
 118:     0000077, 0007000, JMP, "csm",
 119:     0000077, 0007300, SINGLW, "wrtlck",
 120:     0000077, 0007200, SINGLW, "tstset",
 121:     0000777, 0004000, JSR,    "jsr",
 122:     0000777, 0074000, DOUBLE, "xor",
 123:     0000007, 0000200, SINGLE, "rts",
 124:     0000017, 0000240, DFAULT, "cflg",
 125:     0000017, 0000260, DFAULT, "sflg",
 126:     LOBYTE,  0104000, TRAP,   "emt",
 127:     LOBYTE,  0104400, SYS,    "sys",
 128:     0000077, 0006400, TRAP,   "mark",
 129:     0000777, 0077000, SOB,    "sob",
 130:     0000007, 0000230, DFAULT,   "spl",
 131:     0177777, 0000000, DFAULT, "<illegal op>",
 132: };
 133: 
 134: char *systab[] = {
 135:     "indir",        /* 0 - indir*/
 136:     "exit",
 137:     "fork",
 138:     "read",
 139:     "write",
 140:     "open",
 141:     "close",
 142:     "wait4",
 143:     NULL,           /* 8 - unused */
 144:     "link",
 145:     "unlink",       /* 10 */
 146:     "execv",
 147:     "chdir",
 148:     "fchdir",
 149:     "mknod",
 150:     "chmod",
 151:     "chown",
 152:     "chflags",
 153:     "fchflags",
 154:     "lseek",
 155:     "getpid",       /* 20 */
 156:     "mount",
 157:     "umount",
 158:     "__sysctl",
 159:     "getuid",
 160:     "geteuid",      /* 25 */
 161:     "ptrace",
 162:     "getppid",
 163:     NULL,           /* 28 - unused */
 164:     NULL,           /* 29 - unused */
 165:     NULL,           /* 30 - unused */
 166:     "sigaction",        /* 31 - sigaction */
 167:     "sigprocmask",      /* 32 - sigprocmask */
 168:     "access",
 169:     "sigpending",       /* 34 - sigpending */
 170:     "sigaltstack",      /* 35 - sigaltstack */
 171:     "sync",
 172:     "kill",
 173:     "stat",
 174:     "_getlogin",        /* 39 - _getlogin */
 175:     "lstat",
 176:     "dup",
 177:     "pipe",
 178:     "setlogin",     /* 43 - unused */
 179:     "profil",
 180:     "setuid",       /* 45 - setuid */
 181:     "seteuid",      /* 46 - seteuid */
 182:     "getgid",
 183:     "getegid",
 184:     "setgid",       /* 49 - setgid */
 185:     "setegid",      /* 50 - setegid */
 186:     "acct",
 187:     "phys",
 188:     "lock",
 189:     "ioctl",
 190:     "reboot",
 191:     NULL,           /* 56 - unused */
 192:     "symlink",
 193:     "readlink",
 194:     "execve",
 195:     "umask",
 196:     "chroot",
 197:     "fstat",
 198:     NULL,           /* 63 - unused */
 199:     NULL,           /* 64 - unused */
 200:     "pselect",      /* 65 - pselect */
 201:     "vfork",
 202:     NULL,           /* 67 - unused */
 203:     NULL,           /* 68 - unused */
 204:     "sbrk",
 205:     NULL,           /* 70 - unused */
 206:     NULL,           /* 71 - unused */
 207:     NULL,           /* 72 - unused */
 208:     NULL,           /* 73 - unused */
 209:     NULL,           /* 74 - unused */
 210:     NULL,           /* 75 - unused */
 211:     "vhangup",
 212:     NULL,           /* 77 - unused */
 213:     NULL,           /* 78 - unused */
 214:     "getgroups",
 215:     "setgroups",
 216:     "getpgrp",
 217:     "setpgrp",
 218:     "setitimer",
 219:     NULL,           /* 84 - unused */
 220:     NULL,           /* 85 - unused */
 221:     "getitimer",
 222:     NULL,           /* 87 - unused */
 223:     NULL,           /* 88 - unused */
 224:     "getdtablesize",
 225:     "dup2",
 226:     NULL,           /* 91 - unused */
 227:     "fcntl",
 228:     "select",
 229:     NULL,           /* 94 - unused */
 230:     "fsync",
 231:     "setpriority",
 232:     "socket",
 233:     "connect",
 234:     "accept",
 235:     "getpriority",
 236:     "send",
 237:     "recv",         /* 102 - recv */
 238:     "sigreturn",
 239:     "bind",
 240:     "setsockopt",
 241:     "listen",
 242:     "sigsuspend",       /* 107 - sigsuspend */
 243:     NULL,           /* 108 - unused */
 244:     NULL,           /* 109 - unused */
 245:     NULL,           /* 110 - unused */
 246:     NULL,           /* 111 - unused */
 247:     "old sigstack",     /* 112 - sigstack COMPAT-43 for zork */
 248:     "recvmsg",
 249:     "sendmsg",
 250:     NULL,           /* 115 - unused */
 251:     "gettimeofday",
 252:     "getrusage",
 253:     "getsockopt",
 254:     NULL,           /* 119 - unused */
 255:     "readv",
 256:     "writev",
 257:     "settimeofday",
 258:     "fchown",
 259:     "fchmod",
 260:     "recvfrom",
 261:     NULL,           /* 126 - unused */
 262:     NULL,           /* 127 - unused */
 263:     "rename",
 264:     "truncate",
 265:     "ftruncate",
 266:     "flock",
 267:     NULL,           /* 132 - unused */
 268:     "sendto",
 269:     "shutdown",
 270:     "socketpair",
 271:     "mkdir",
 272:     "rmdir",
 273:     "utimes",
 274:     NULL,           /* 139 - unused */
 275:     "adjtime",
 276:     "getpeername",
 277:     NULL,           /* 142 - unused */
 278:     NULL,           /* 143 - unused */
 279:     "getrlimit",
 280:     "setrlimit",
 281:     "killpg",
 282:     NULL,           /* 147 - unused */
 283:     "setquota",
 284:     "quota",
 285:     "getsockname",
 286:     /*
 287: 	 * 2.11BSD special calls
 288: 	 */
 289:     NULL,           /* 151 - unused */
 290:     "nostk",
 291:     "fetchi",
 292:     "ucall",
 293:     "fperr",
 294: };
 295: 
 296: #define NUMSYSCALLS (sizeof (systab) / sizeof (char *))
 297: 
 298: char    *regname[] = { "r0", "r1", "r2", "r3", "r4", "r5", "sp", "pc"};
 299: 
 300:     u_int   type, space, incp;
 301: 
 302: printins(idsp,ins)
 303:     register int ins;
 304: {
 305:     int byte;
 306:     register struct optab *p;
 307: 
 308:     type=DSYM; space=idsp; incp=2;
 309:     FOR p=optab;; p++
 310:     DO      IF (ins & ~p->mask) == p->val
 311:         THEN    break;
 312:         FI
 313:     OD
 314:     printf(p->iname);
 315:     byte=ins&0100000;
 316:     ins &= p->mask;
 317: 
 318:     switch (p->itype) {
 319: 
 320:         case JMP:
 321:         type=ISYM;
 322: 
 323:         case SINGLE:
 324:         IF byte THEN printc('b'); FI
 325:         case SINGLW:
 326:         paddr("%8t",ins);
 327:         break;
 328: 
 329:         case REVERS:
 330:         doubl(ins&077,(ins>>6)&07);
 331:         break;
 332: 
 333:         case JSR:
 334:         type=ISYM;
 335: 
 336:         case DOUBLE:
 337:         IF byte THEN printc('b'); FI
 338:         case DOUBLW:
 339:         doubl(ins>>6,ins);
 340: 
 341:         case NOADDR:
 342:         break;
 343: 
 344:         case SOB:
 345:         paddr("%8t",(ins>>6)&07);
 346:         branch(",",-(ins&077));
 347:         break;
 348: 
 349:         case BRANCH:
 350:         branch("%8t",ins);
 351:         break;
 352: 
 353:         case SYS:
 354:         if (ins < NUMSYSCALLS && systab[ins])
 355:             printf("%8t%s", systab[ins]);
 356:         else
 357:             printf("%8t%d", ins);
 358:         break;
 359: 
 360:         case TRAP:
 361:         case DFAULT:
 362:         default:
 363:         printf("%8t%o", ins);
 364:     }
 365:     dotinc=incp;
 366: }
 367: 
 368: doubl(a,b)
 369: {
 370:     paddr("%8t",a); paddr(",",b);
 371: }
 372: 
 373: branch(s,ins)
 374:     char    *s;
 375:     register int ins;
 376: {
 377:     printf(s);
 378:     IF ins&0200 THEN ins |= 0177400; FI
 379:     ins = shorten(dot) + (ins<<1) + 2;
 380:     psymoff(leng(ins),ISYM,"");
 381: }
 382: 
 383: paddr(s, a)
 384:     char    *s;
 385:     register int a;
 386: {
 387:     register int r;
 388: 
 389:     var[2]=var[1];
 390:     r = a&07; a &= 070;
 391: 
 392:     printf(s);
 393:     IF r==7 ANDF a&020
 394:     THEN IF a&010 THEN printc('*'); FI
 395:          IF a&040
 396:          THEN IF space==NSP
 397:           THEN printc('?');
 398:           ELSE  var[1]=chkget(inkdot(incp),space) + shorten(inkdot(incp+2));
 399:                psymoff(var[1],(a&010?DSYM:type),"");
 400:           FI
 401:          ELSE printc('$');
 402:           IF space==NSP
 403:           THEN printc('?');
 404:           ELSE var[1]=chkget(inkdot(incp), space);
 405:             psymoff(var[1], (a&010?type:NSYM), "");
 406:           FI
 407:          FI
 408:          incp += 2;
 409:          return;
 410:     FI
 411:     r = (int)regname[r];
 412:     switch (a) {
 413:         /* r */
 414:         case 000:
 415:         printf(r);
 416:         return;
 417: 
 418:         /* (r) */
 419:         case 010:
 420:         printf("(%s)", r);
 421:         return;
 422: 
 423:         /* *(r)+ */
 424:         case 030:
 425:         printc('*');
 426: 
 427:         /* (r)+ */
 428:         case 020:
 429:         printf("(%s)+", r);
 430:         return;
 431: 
 432:         /* *-(r) */
 433:         case 050:
 434:         printc('*');
 435: 
 436:         /* -(r) */
 437:         case 040:
 438:         printf("-(%s)", r);
 439:         return;
 440: 
 441:         /* *x(r) */
 442:         case 070:
 443:         printc('*');
 444: 
 445:         /* x(r) */
 446:         case 060:
 447:         IF space==NSP
 448:         THEN printc('?');
 449:         ELSE    var[1]=chkget(inkdot(incp), space);
 450:             psymoff(var[1], (a==070?type:NSYM), "");
 451:         FI
 452:         incp += 2;
 453:         printf("(%s)", r);
 454:         return;
 455:     }
 456: }

Defined functions

branch defined in line 373; used 2 times
doubl defined in line 368; used 2 times
paddr defined in line 383; used 4 times
printins defined in line 302; used 2 times

Defined variables

datmap defined in line 11; never used
dot defined in line 8; used 1 times
dotinc defined in line 9; used 1 times
errflg defined in line 7; never used
incp defined in line 300; used 8 times
optab defined in line 36; used 1 times
regname defined in line 298; used 1 times
sccsid defined in line 2; never used
space defined in line 300; used 7 times
systab defined in line 134; used 3 times
type defined in line 300; used 6 times
var defined in line 10; used 8 times

Defined struct's

optab defined in line 31; used 2 times
  • in line 306(2)

Defined macros

BRANCH defined in line 22; used 15 times
DFAULT defined in line 24; used 4 times
DOUBLE defined in line 17; used 6 times
DOUBLW defined in line 18; used 6 times
JMP defined in line 28; used 2 times
JSR defined in line 29; used 1 times
NOADDR defined in line 23; used 13 times
NUMSYSCALLS defined in line 296; used 1 times
REVERS defined in line 21; used 14 times
SINGLE defined in line 19; used 15 times
SINGLW defined in line 20; used 16 times
SOB defined in line 27; used 1 times
SYS defined in line 26; used 1 times
TRAP defined in line 25; used 2 times
Last modified: 2000-02-29
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 959
Valid CSS Valid XHTML 1.0 Strict