|
|
1.1 ! root 1: #include <stdio.h> ! 2: ! 3: #include "Xoptab.h" ! 4: ! 5: #include "Xoptab.c" ! 6: ! 7: #define swab ! 8: ! 9: main() ! 10: { ! 11: register struct optab *op; ! 12: ! 13: for (op = optab; op->opname; op++) { ! 14: if (op->size == BWL) ! 15: putbwl(op); ! 16: else ! 17: putopt(op); ! 18: } ! 19: } ! 20: ! 21: putbwl(op) ! 22: register struct optab *op; ! 23: { ! 24: char *orig; ! 25: char new[20]; ! 26: ! 27: orig = op->opname; ! 28: op->opname = new; ! 29: sprintf(new, "%s.b", orig); ! 30: /* size field in opcode == 0 */ ! 31: op->size = B; ! 32: putopt(op); ! 33: sprintf(new, "%s.w", orig); ! 34: op->opcode |= 0100; /* size == 01 */ ! 35: op->size = W; ! 36: putopt(op); ! 37: sprintf(new, "%s.l", orig); ! 38: op->opcode &=~ 0100; ! 39: op->opcode |= 0200; /* size == 03 */ ! 40: op->size = L; ! 41: putopt(op); ! 42: } ! 43: ! 44: /* ! 45: * struct optab { ! 46: * unsigned short opcode; ! 47: * unsigned short mask; ! 48: * unsigned short op2; ! 49: * unsigned short mk2; ! 50: * char *opname; ! 51: * char flags; ! 52: * char nrand; ! 53: * short rand[MAXRAND]; ! 54: * }; ! 55: */ ! 56: ! 57: putopt(op) ! 58: register struct optab *op; ! 59: { ! 60: register int n; ! 61: long mask; ! 62: char *mkrand(); ! 63: long mkmask(); ! 64: ! 65: printf("{ "); ! 66: printf("0x%04x, ", swab(op->opcode)); /* opcode */ ! 67: mask = mkmask(op); ! 68: printf("0x%04x, ", swab((int)mask&0xffff)); /* mask */ ! 69: if ((((int)mask & 0xffff) & op->opcode) != op->opcode) ! 70: fprintf(stderr, "awful mask %s\n", op->opname); ! 71: if ((op->iflag & I2W) == 0) ! 72: printf("0x0000, 0x0000, "); /* op2 mk2 */ ! 73: else { ! 74: mask = (mask >> 16) & 0xffff; ! 75: printf("0x%04x, ", swab(op->op2code)); /* op2 */ ! 76: printf("0x%04x, ", swab((int)mask)); /* mk2 */ ! 77: if (((int)mask & op->op2code) != op->op2code) ! 78: fprintf(stderr, "awful 2mask %s\n", op->opname); ! 79: } ! 80: printf("\"%s\", ", op->opname); /* name */ ! 81: switch (op->size) { ! 82: case B: ! 83: printf("B"); ! 84: break; ! 85: ! 86: case W: ! 87: printf("W"); ! 88: break; ! 89: ! 90: case L: ! 91: printf("L"); ! 92: break; ! 93: ! 94: default: ! 95: fprintf(stderr, "bad size %s\n", op->opname); ! 96: printf("GOK "); ! 97: case 0: ! 98: printf("NZ"); ! 99: break; ! 100: } ! 101: if (op->iflag & I2W) ! 102: printf("|I2W"); ! 103: printf(", "); /* flags */ ! 104: n = nrand(op); ! 105: printf("%d", n); /* nrand */ ! 106: if (n > 0) ! 107: printf(", %s", mkrand(op->addr1, op->a1disp)); ! 108: if (n > 1) ! 109: printf(", %s", mkrand(op->addr2, op->a2disp)); ! 110: if (n > 2) ! 111: printf(", %s", mkrand(op->addr3, op->a3disp)); ! 112: if (n > 3) ! 113: printf(", %s", mkrand(op->addr4, op->a4disp)); ! 114: printf(" },\n"); ! 115: } ! 116: ! 117: static long opmask[] = { ! 118: 0, /* DIG 0 ignore this address */ ! 119: 0x0000003f, /* DEA 1 E.A. to low order 6 bits */ ! 120: 0x00000007, /* DRG 2 register to low order 3 bits */ ! 121: 0x00000e00, /* DRGL 3 register to bits 11-9 */ ! 122: 0x000000ff, /* DBR 4 branch offset (short) */ ! 123: 0x000000ff, /* DMQ 5 move-quick 8-bit value */ ! 124: 0x00000e00, /* DAQ 6 add-quick 3-bit value in 11-9 */ ! 125: 0, /* DIM 7 Immediate value, according to size */ ! 126: 0x00000fc0, /* DEAM 8 E.A. to bits 11-6 as in move */ ! 127: 0, /* DBCC 9 branch address as in "dbcc" */ ! 128: 0, /* DIMH 10 Immediate forced to be 1 word */ ! 129: 0x00070000, /* D2L 11 register to bits 0-2 of next word */ ! 130: 0x70000000, /* D2H 12 register to bits 12-14 of next word */ ! 131: 0x001f0000, /* DBL 13 qty in bits 0-5 of next word */ ! 132: 0x07c00000, /* DBH 14 qty in bits 6-11 of next word */ ! 133: 0, /* DCR 15 control reg a bit combination in 0-11 */ ! 134: }; ! 135: ! 136: long ! 137: mkmask(op) ! 138: register struct optab *op; ! 139: { ! 140: register long x; ! 141: ! 142: x = opmask[op->a1disp]|opmask[op->a2disp]|opmask[op->a3disp]|opmask[op->a4disp]; ! 143: return (~x); ! 144: } ! 145: ! 146: int ! 147: nrand(op) ! 148: register struct optab *op; ! 149: { ! 150: ! 151: if (op->addr1 == 0) ! 152: return (0); ! 153: if (op->addr2 == 0) ! 154: return (1); ! 155: if (op->addr3 == 0) ! 156: return (2); ! 157: if (op->addr4 == 0) ! 158: return (3); ! 159: return (4); ! 160: } ! 161: ! 162: char * ! 163: mkrand(addr, disp) ! 164: int addr, disp; ! 165: { ! 166: char *regmode(); ! 167: ! 168: switch (addr) { ! 169: case AIMM+O: ! 170: return ("DIM|AONE"); ! 171: ! 172: case AREG+C: ! 173: return ("DSREG|C"); ! 174: ! 175: case AREG+SR: ! 176: return ("DSREG|SR"); ! 177: ! 178: case AREG+U: ! 179: return ("DSREG|U"); ! 180: } ! 181: switch (disp) { ! 182: case DIG: ! 183: fprintf(stderr, "unaccounted DIG\n"); ! 184: return ("DIG"); ! 185: ! 186: case DEA: ! 187: return ("DEA"); ! 188: ! 189: case DRG: ! 190: return (regmode(addr, "DRG")); ! 191: ! 192: case DRGL: ! 193: return (regmode(addr, "DRGL")); ! 194: ! 195: case DBR: ! 196: return ("DBR"); ! 197: ! 198: case DMQ: ! 199: return ("DMQ"); ! 200: ! 201: case DAQ: ! 202: return ("DAQ"); ! 203: ! 204: case DIM: ! 205: switch (addr) { ! 206: case AIMM: ! 207: return ("DIM"); ! 208: ! 209: case AIMM+O: ! 210: return ("DIM|AONE"); ! 211: ! 212: case AIMM+H: ! 213: return ("DIM|AWORD"); ! 214: } ! 215: fprintf(stderr, "unknown DIM\n"); ! 216: return ("GOK DIM"); ! 217: ! 218: case DEAM: ! 219: return ("DEAM"); ! 220: ! 221: case DBCC: ! 222: return ("DBCC"); ! 223: ! 224: case DIMH: ! 225: return ("DIM|AWORD"); ! 226: ! 227: case D2L: ! 228: return (regmode(addr, "D2L")); ! 229: ! 230: case D2H: ! 231: return (regmode(addr, "D2H")); ! 232: ! 233: case DBL: ! 234: return ("DBL"); ! 235: ! 236: case DBH: ! 237: return ("DBH"); ! 238: ! 239: case DCR: ! 240: return ("DCR"); ! 241: ! 242: default: ! 243: fprintf(stderr, "GOK rand\n"); ! 244: return ("GOK"); ! 245: } ! 246: } ! 247: ! 248: #ifndef swab ! 249: int ! 250: swab(s) ! 251: int s; ! 252: { ! 253: ! 254: return (((s >> 8) & 0xff) | ((s << 8) & 0xff00)); ! 255: } ! 256: #endif ! 257: ! 258: char * ! 259: regmode(addr, rb) ! 260: int addr; ! 261: char *rb; ! 262: { ! 263: static char buf[10]; ! 264: char *mod; ! 265: ! 266: if (addr == ADEC) ! 267: mod = "ADEC"; ! 268: else if (addr == AINC) ! 269: mod = "AINC"; ! 270: else if (addr == AREG + A) ! 271: mod = "AAREG"; ! 272: else if (addr == AREG + D) ! 273: mod = "ADREG"; ! 274: else { ! 275: fprintf(stderr, "awful regmode\n"); ! 276: mod = "GOK"; ! 277: } ! 278: sprintf(buf, "%s|%s", rb, mod); ! 279: return (buf); ! 280: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.