Annotation of researchv10no/cmd/lcomp/bundled, revision 1.1.1.1

1.1       root        1: # To unbundle, sh this file
                      2: echo 3binstr.c 1>&2
                      3: sed 's/.//' >3binstr.c <<'//GO.SYSIN DD 3binstr.c'
                      4: -From research!whuxld!bjb Thu Mar  8 13:23 EST 1984*
                      5: -To: research!seki!pjw
                      6: -
                      7: -/*
                      8: - *    static char *ID_opsout = "@(#) ops.out: 1.5 4/26/83";
                      9: - */
                     10: -{"mcomb",     IS25|INSTRB,    DYAOP1-256,     8,      0x8bL},
                     11: -{"mcomh",     IS25|INSTRH,    DYAOP1-256,     8,      0x8aL},
                     12: -{"mcomw",     IS25|INSTRW,    DYAOP1-256,     8,      0x88L},
                     13: -{"movzbh",    IS25|INSTRBH,   DYAOP7-256,     8,      0x87L},
                     14: -{"movzbw",    IS25|INSTRBW,   DYAOP7-256,     8,      0x87L},
                     15: -{"movzhw",    IS25|INSTRHW,   DYAOP7-256,     8,      0x86L},
                     16: -{"pushzb",    IS25|INSTRB,    PUSHOP1-256,    8,      0x87L},
                     17: -{"pushzh",    IS25|INSTRHW,   PUSHOP1-256,    8,      0x84L},
                     18: -{"movaw",     IS25|INSTRW,    DYAOP2-256,     8,      0x4L},
                     19: -{"pushaw",    IS25|INSTRW,    MONOP2-256,     8,      0xe0L},
                     20: -{"andb2",     IS25|INSTRB,    DYAOP1-256,     8,      0xbbL},
                     21: -{"andh2",     IS25|INSTRH,    DYAOP1-256,     8,      0xbaL},
                     22: -{"andw2",     IS25|INSTRW,    DYAOP1-256,     8,      0xb8L},
                     23: -{"andb3",     IS25|INSTRB,    TRIOP1-256,     8,      0xfbL},
                     24: -{"andh3",     IS25|INSTRH,    TRIOP1-256,     8,      0xfaL},
                     25: -{"andw3",     IS25|INSTRW,    TRIOP1-256,     8,      0xf8L},
                     26: -{"orb2",      IS25|INSTRB,    DYAOP1-256,     8,      0xb3L},
                     27: -{"orh2",      IS25|INSTRH,    DYAOP1-256,     8,      0xb2L},
                     28: -{"orw2",      IS25|INSTRW,    DYAOP1-256,     8,      0xb0L},
                     29: -{"orb3",      IS25|INSTRB,    TRIOP1-256,     8,      0xf3L},
                     30: -{"orh3",      IS25|INSTRH,    TRIOP1-256,     8,      0xf2L},
                     31: -{"orw3",      IS25|INSTRW,    TRIOP1-256,     8,      0xf0L},
                     32: -{"xorb2",     IS25|INSTRB,    DYAOP1-256,     8,      0xb7L},
                     33: -{"xorh2",     IS25|INSTRH,    DYAOP1-256,     8,      0xb6L},
                     34: -{"xorw2",     IS25|INSTRW,    DYAOP1-256,     8,      0xb4L},
                     35: -{"xorb3",     IS25|INSTRB,    TRIOP1-256,     8,      0xf7L},
                     36: -{"xorh3",     IS25|INSTRH,    TRIOP1-256,     8,      0xf6L},
                     37: -{"xorw3",     IS25|INSTRW,    TRIOP1-256,     8,      0xf4L},
                     38: -{"bitb",      IS25|INSTRB,    CMPOP2-256,     8,      0x3bL},
                     39: -{"bith",      IS25|INSTRH,    CMPOP2-256,     8,      0x3aL},
                     40: -{"bitw",      IS25|INSTRW,    CMPOP2-256,     8,      0x38L},
                     41: -{"llsw2",     IS25|INSTRW,    DYAOP3-256,     16,     0xd0L},
                     42: -{"llsw3",     IS25|INSTRW,    SHFTOP1-256,    16,     0xd0L},
                     43: -{"lrsw2",     IS25|INSTRBW,   DYAOP3-256,     16,     0xd4L},
                     44: -{"lrsw3",     IS25|INSTRBW,   SHFTOP1-256,    16,     0xd4L},
                     45: -{"movb",      IS25|INSTRB,    DYAOP4-256,     16,     0x8387L},
                     46: -{"movh",      IS25|INSTRH,    DYAOP4-256,     16,     0x8286L},
                     47: -{"movw",      IS25|INSTRW,    DYAOP4-256,     16,     0x8084L},
                     48: -{"movbbh",    IS25|INSTRBH,   DYAOP5-256,     16,     0x87E7L},
                     49: -{"movbbw",    IS25|INSTRBW,   DYAOP5-256,     16,     0x87E7L},
                     50: -{"movbhw",    IS25|INSTRHW,   DYAOP5-256,     8,      0x86L},
                     51: -{"movthb",    IS25|INSTRHB,   DYAOP5-256,     8,      0x86L},
                     52: -{"movtwb",    IS25|INSTRWB,   DYAOP5-256,     8,      0x84L},
                     53: -{"movtwh",    IS25|INSTRWH,   DYAOP5-256,     8,      0x84L},
                     54: -{"mnegh",     IS25|INSTRH,    DYAOP1-256,     8,      0x8eL},
                     55: -{"mnegw",     IS25|INSTRW,    DYAOP1-256,     8,      0x8cL},
                     56: -{"pushbb",    IS25|INSTRBW,   PUSHOP1-256,    8,      0x87L},
                     57: -{"pushbh",    IS25|INSTRH,    PUSHOP1-256,    8,      0x86L},
                     58: -{"pushw",     IS25|INSTRW,    MONOP1-256,     8,      0xa0L},
                     59: -{"addb2",     IS25|INSTRB,    DYAOP6-256,     16,     0x939fL},
                     60: -{"addh2",     IS25|INSTRH,    DYAOP6-256,     16,     0x929eL},
                     61: -{"addw2",     IS25|INSTRW,    DYAOP6-256,     16,     0x909cL},
                     62: -{"addb3",     IS25|INSTRB,    TRIOP1-256,     8,      0xdfL},
                     63: -{"addh3",     IS25|INSTRH,    TRIOP1-256,     8,      0xdeL},
                     64: -{"addw3",     IS25|INSTRW,    TRIOP1-256,     8,      0xdcL},
                     65: -{"subb2",     IS25|INSTRB,    DYAOP6-256,     16,     0x97bfL},
                     66: -{"subh2",     IS25|INSTRH,    DYAOP6-256,     16,     0x96beL},
                     67: -{"subw2",     IS25|INSTRW,    DYAOP6-256,     16,     0x94bcL},
                     68: -{"subb3",     IS25|INSTRB,    TRIOP1-256,     8,      0xffL},
                     69: -{"subh3",     IS25|INSTRH,    TRIOP1-256,     8,      0xfeL},
                     70: -{"subw3",     IS25|INSTRW,    TRIOP1-256,     8,      0xfcL},
                     71: -{"mulw2",     IS25|INSTRW,    DYAOP1-256,     8,      0xa8L},
                     72: -{"umulw2",    IS25|INSTRW,    DYAOP8-256,     8,      0xa8L},
                     73: -{"mulw3",     IS25|INSTRW,    TRIOP1-256,     8,      0xe8L},
                     74: -{"umulw3",    IS25|INSTRW,    TRIOP2-256,     8,      0xe8L},
                     75: -{"divw2",     IS25|INSTRW,    DYAOP1-256,     8,      0xacL},
                     76: -{"udivw2",    IS25|INSTRW,    DYAOP8-256,     8,      0xacL},
                     77: -{"divw3",     IS25|INSTRW,    TRIOP1-256,     8,      0xecL},
                     78: -{"udivw3",    IS25|INSTRW,    TRIOP2-256,     8,      0xecL},
                     79: -{"modw2",     IS25|INSTRW,    DYAOP1-256,     8,      0xa4L},
                     80: -{"umodw2",    IS25|INSTRW,    DYAOP8-256,     8,      0xa4L},
                     81: -{"modw3",     IS25|INSTRW,    TRIOP1-256,     8,      0xe4L},
                     82: -{"umodw3",    IS25|INSTRW,    TRIOP2-256,     8,      0xe4L},
                     83: -#if   FLOAT
                     84: -{"fadds2",    INSTRW,         FPDYAOP1-256,   8,      0x31L},
                     85: -{"fsubs2",    INSTRW,         FPDYAOP1-256,   8,      0x41L},
                     86: -{"fmuls2",    INSTRW,         FPDYAOP1-256,   8,      0x51L},
                     87: -{"fdivs2",    INSTRW,         FPDYAOP1-256,   8,      0x61L},
                     88: -{"movhs",     INSTRHW,                FPDYAOP2-256,   8,      0x71L},
                     89: -{"movws",     INSTRW,         FPDYAOP2-256,   8,      0x81L},
                     90: -{"movss",     INSTRW,         FPDYAOP1-256,   8,      0x91L},
                     91: -{"movsd",     INSTRW,         FPDYAOP1-256,   8,      0xa1L},
                     92: -{"movsh",     INSTRW,         FPDYAOP1-256,   8,      0xb1L},
                     93: -{"movtsh",    INSTRW,         FPDYAOP1-256,   8,      0xc1L},
                     94: -{"movsw",     INSTRW,         FPDYAOP1-256,   8,      0xd1L},
                     95: -{"movtsw",    INSTRW,         FPDYAOP1-256,   8,      0xe1L},
                     96: -{"fcmps",     INSTRW,         FPCMPOP1-256,   8,      0xf1L},
                     97: -{"faddd2",    INSTRD,         FPDYAOP1-256,   8,      0x35L},
                     98: -{"fsubd2",    INSTRD,         FPDYAOP1-256,   8,      0x45L},
                     99: -{"fmuld2",    INSTRD,         FPDYAOP1-256,   8,      0x55L},
                    100: -{"fdivd2",    INSTRD,         FPDYAOP1-256,   8,      0x65L},
                    101: -{"movhd",     INSTRH,         FPDYAOP2-256,   8,      0x75L},
                    102: -{"movwd",     INSTRW,         FPDYAOP2-256,   8,      0x85L},
                    103: -{"movds",     INSTRD,         FPDYAOP1-256,   8,      0x95L},
                    104: -{"movdd",     INSTRD,         FPDYAOP1-256,   8,      0xa5L},
                    105: -{"movdh",     INSTRD,         FPDYAOP1-256,   8,      0xb5},
                    106: -{"movtdh",    INSTRD,         FPDYAOP1-256,   8,      0xc5},
                    107: -{"movdw",     INSTRD,         FPDYAOP1-256,   8,      0xd5L},
                    108: -{"movtdw",    INSTRD,         FPDYAOP1-256,   8,      0xe5L},
                    109: -{"fcmpd",     INSTRD,         FPCMPOP1-256,   8,      0xf5L},
                    110: -{"fadds3",    INSTRW,         FPTRIOP1-256,   8,      0x39L},
                    111: -{"fsubs3",    INSTRW,         FPTRIOP1-256,   8,      0x49L},
                    112: -{"fmuls3",    INSTRW,         FPTRIOP1-256,   8,      0x59L},
                    113: -{"fdivs3",    INSTRW,         FPTRIOP1-256,   8,      0x69L},
                    114: -{"faddd3",    INSTRD,         FPTRIOP1-256,   8,      0x79L},
                    115: -{"fsubd3",    INSTRD,         FPTRIOP1-256,   8,      0x89L},
                    116: -{"fmuld3",    INSTRD,         FPTRIOP1-256,   8,      0x99L},
                    117: -{"fdivd3",    INSTRD,         FPTRIOP1-256,   8,      0xa9L},
                    118: -#endif
                    119: -{"alsw2",     IS25|INSTRBW,   DYAOP3-256,     16,     0xc0L},
                    120: -{"alsw3",     IS25|INSTRBW,   SHFTOP1-256,    16,     0xc0L},
                    121: -{"arsw2",     IS25|INSTRW,    DYAOP3-256,     16,     0xc4L},
                    122: -{"arsw3",     IS25|INSTRW,    SHFTOP1-256,    16,     0xc4L},
                    123: -{"cmpb",      IS25|INSTRB,    CMPOP1-256,     16,     0x2b3fL},
                    124: -{"cmph",      IS25|INSTRH,    CMPOP1-256,     16,     0x2a3eL},
                    125: -{"cmpw",      IS25|INSTRW,    CMPOP1-256,     16,     0x283cL},
                    126: -{"jbc",               IS25|INSTRW,    JMBOP1-256,     8,      0x38L},
                    127: -{"jbs",               IS25|INSTRW,    JMBOP1-256,     8,      0x38L},
                    128: -{"rsb",               IS25|INSTRW,    ZEROP1-256,     8,      0x78L},
                    129: -{"acjl",      IS25|INSTRW,    LOOPOP1-256,    24,     0xb83c4bL},
                    130: -{"acjlu",     IS25|INSTRW,    LOOPOP1-256,    24,     0xb83c5bL},
                    131: -{"acjle",     IS25|INSTRW,    LOOPOP1-256,    24,     0xb83c4fL},
                    132: -{"acjleu",    IS25|INSTRW,    LOOPOP1-256,    24,     0xb83c5fL},
                    133: -{"atjnzb",    IS25|INSTRW,    LOOPOP2-256,    8,      0x2bL},
                    134: -{"atjnzh",    IS25|INSTRW,    LOOPOP2-256,    8,      0x2aL},
                    135: -{"atjnzw",    IS25|INSTRW,    LOOPOP2-256,    8,      0x28L},
                    136: -{"movblb",    IS25|INSTRB,    BLOCKOP-256,    8,      0x87L},
                    137: -{"movblh",    IS25|INSTRH,    BLOCKOP-256,    8,      0x86L},
                    138: -{"movblw",    IS25|INSTRW,    ZEROP1-256,     16,     0x3019L},
                    139: -{"call",      IS25|INSTRW,    CALOP1-256,     8,      0x2cL},
                    140: -{"save",      IS25|INSTRW,    SAVOP1-256,     8,      0x10L},
                    141: -{"ret",               IS25|INSTRW,    RETOP1-256,     16,     0x0818L},
                    142: -{"insv",      IS25|INSTRW,    FLDOP1-256,     8,      0xc8L},
                    143: -{"extzv",     IS25|INSTRW,    FLDOP2-256,     8,      0xccL},
                    144: -{"jz",                IS25|INSTRW,    JMPOP1-256,     16,     0x777fL},
                    145: -{"jnz",               IS25|INSTRW,    JMPOP1-256,     16,     0x7f77L},
                    146: -{"jpos",      IS25|INSTRW,    JMPOP1-256,     16,     0x4f47L},
                    147: -{"jnpos",     IS25|INSTRW,    JMPOP1-256,     16,     0x474fL},
                    148: -{"jneg",      IS25|INSTRW,    JMPOP1-256,     16,     0x434bL},
                    149: -{"jnneg",     IS25|INSTRW,    JMPOP1-256,     16,     0x4b43L},
                    150: -{"je",                IS25|INSTRW,    JMPOP1-256,     16,     0x777fL},
                    151: -{"jne",               IS25|INSTRW,    JMPOP1-256,     16,     0x7f77L},
                    152: -{"jl",                IS25|INSTRW,    JMPOP1-256,     16,     0x434bL},
                    153: -{"jle",               IS25|INSTRW,    JMPOP1-256,     16,     0x474fL},
                    154: -{"jg",                IS25|INSTRW,    JMPOP1-256,     16,     0x4f47L},
                    155: -{"jge",               IS25|INSTRW,    JMPOP1-256,     16,     0x4b43L},
                    156: -{"jlu",               IS25|INSTRW,    JMPOP1-256,     16,     0x535bL},
                    157: -{"jleu",      IS25|INSTRW,    JMPOP1-256,     16,     0x575fL},
                    158: -{"jgu",               IS25|INSTRW,    JMPOP1-256,     16,     0x5f57L},
                    159: -{"jgeu",      IS25|INSTRW,    JMPOP1-256,     16,     0x5b53L},
                    160: -{"jmp",               IS25|INSTRW,    JMPOP1-256,     8,      0x7bL},
                    161: -{"jsb",               IS25|INSTRW,    JSBOP1-256,     16,     0x3437L},
                    162: -{"BEB",               INSTRB,         JMPOP1-256,     8,      0x7fL},
                    163: -{"BNEB",      INSTRB,         JMPOP1-256,     8,      0x77L},
                    164: -{"BLB",               INSTRB,         JMPOP1-256,     8,      0x4bL},
                    165: -{"BLEB",      INSTRB,         JMPOP1-256,     8,      0x4fL},
                    166: -{"BGB",               INSTRB,         JMPOP1-256,     8,      0x47L},
                    167: -{"BGEB",      INSTRB,         JMPOP1-256,     8,      0x43L},
                    168: -{"BLUB",      INSTRB,         JMPOP1-256,     8,      0x5bL},
                    169: -{"BLEUB",     INSTRB,         JMPOP1-256,     8,      0x5fL},
                    170: -{"BGUB",      INSTRB,         JMPOP1-256,     8,      0x57L},
                    171: -{"BGEUB",     INSTRB,         JMPOP1-256,     8,      0x53L},
                    172: -{"BRB",               INSTRB,         JMPOP1-256,     8,      0x7bL},
                    173: -{"BSBB",      INSTRB,         BSBOP1-256,     8,      0x37L},
                    174: -{"BEH",               INSTRH,         JMPOP1-256,     8,      0x7eL},
                    175: -{"BNEH",      INSTRH,         JMPOP1-256,     8,      0x76L},
                    176: -{"BLH",               INSTRH,         JMPOP1-256,     8,      0x4aL},
                    177: -{"BLEH",      INSTRH,         JMPOP1-256,     8,      0x4eL},
                    178: -{"BGH",               INSTRH,         JMPOP1-256,     8,      0x46L},
                    179: -{"BGEH",      INSTRH,         JMPOP1-256,     8,      0x42L},
                    180: -{"BLUH",      INSTRH,         JMPOP1-256,     8,      0x5aL},
                    181: -{"BLEUH",     INSTRH,         JMPOP1-256,     8,      0x5eL},
                    182: -{"BGUH",      INSTRH,         JMPOP1-256,     8,      0x56L},
                    183: -{"BGEUH",     INSTRH,         JMPOP1-256,     8,      0x52L},
                    184: -{"BRH",               INSTRH,         JMPOP1-256,     8,      0x7aL},
                    185: -{"BSBH",      INSTRH,         BSBOP1-256,     8,      0x36L},
                    186: -{"CALL",      INSTRW,         CALOP2-256,     8,      0x2cL},
                    187: -{"SAVE",      INSTRW,         SAVOP2-256,     8,      0x10L},
                    188: -{"RESTORE",   INSTRW,         SAVOP2-256,     8,      0x18L},
                    189: -{"RET",               INSTRW,         ZEROP1-256,     8,      0x08L},
                    190: -{"GATE",      INSTRW,         ZEROP1-256,     16,     0x3061L},
                    191: -{"RETG",      INSTRW,         ZEROP1-256,     16,     0x3045L},
                    192: -{"CALLPS",    INSTRW,         ZEROP1-256,     16,     0x30acL},
                    193: -{"RETPS",     INSTRW,         ZEROP1-256,     16,     0x30c8L},
                    194: -{"MVERNO",    INSTRW,         ZEROP1-256,     16,     0x3009L}, /* 12 */
                    195: -{"DISVJMP",   INSTRW,         ZEROP1-256,     16,     0x3013L},
                    196: -{"ENBVJMP",   INSTRW,         ZEROP1-256,     16,     0x300dL},
                    197: -{"STREND",    INSTRW,         ZEROP1-256,     16,     0x301fL},
                    198: -{"STRCPY",    INSTRW,         ZEROP1-256,     16,     0x3035L},
                    199: -{"SLFTST",    INSTRW,         ZEROP1-256,     16,     0x303cL},
                    200: -{"WAIT",      INSTRW,         ZEROP1-256,     8,      0x2fL},
                    201: -{"BPT",               INSTRW,         ZEROP1-256,     8,      0x2eL},
                    202: -{"SWAPWI",    INSTRW,         MONOP1-256,     8,      0x1cL},
                    203: -{"SWAPHI",    INSTRH,         MONOP1-256,     8,      0x1eL},
                    204: -{"SWAPBI",    INSTRB,         MONOP1-256,     8,      0x1fL},
                    205: -{"POPW",      INSTRW,         MONOP3-256,     8,      0x20L},
                    206: -{"TSTW",      INSTRW,         MONOP1-256,     8,      0x28L},
                    207: -{"TSTH",      INSTRH,         MONOP1-256,     8,      0x2aL},
                    208: -{"TSTB",      INSTRB,         MONOP1-256,     8,      0x2bL},
                    209: -{"RGEQ",      INSTRW,         ZEROP1-256,     8,      0x40L},
                    210: -{"RGEQU",     INSTRW,         ZEROP1-256,     8,      0x50L},
                    211: -{"RGTR",      INSTRW,         ZEROP1-256,     8,      0x44L},
                    212: -{"RLSS",      INSTRW,         ZEROP1-256,     8,      0x48L},
                    213: -{"RLSSU",     INSTRW,         ZEROP1-256,     8,      0x58L},
                    214: -{"RLEQ",      INSTRW,         ZEROP1-256,     8,      0x4cL},
                    215: -{"RCC",               INSTRW,         ZEROP1-256,     8,      0x50L},
                    216: -{"RGTRU",     INSTRW,         ZEROP1-256,     8,      0x54L},
                    217: -{"RCS",               INSTRW,         ZEROP1-256,     8,      0x58L},
                    218: -{"RLEQU",     INSTRW,         ZEROP1-256,     8,      0x5cL},
                    219: -{"RVC",               INSTRW,         ZEROP1-256,     8,      0x60L},
                    220: -{"BVCH",      INSTRH,         JMPOP1-256,     8,      0x62L},
                    221: -{"BVCB",      INSTRB,         JMPOP1-256,     8,      0x63L},
                    222: -{"RVS",               INSTRW,         ZEROP1-256,     8,      0x68L},
                    223: -{"BVSH",      INSTRH,         JMPOP1-256,     8,      0x6aL},
                    224: -{"BVSB",      INSTRB,         JMPOP1-256,     8,      0x6bL},
                    225: -{"BCCB",      INSTRB,         JMPOP1-256,     8,      0x53L},
                    226: -{"BCSB",      INSTRB,         JMPOP1-256,     8,      0x5bL},
                    227: -{"BCCH",      INSTRH,         JMPOP1-256,     8,      0x52L},
                    228: -{"BCSH",      INSTRH,         JMPOP1-256,     8,      0x5aL},
                    229: -{"BEQLBX",    INSTRB,         JMPOP1-256,     8,      0x6fL},
                    230: -{"BEQLHX",    INSTRH,         JMPOP1-256,     8,      0x6eL},
                    231: -{"BNEQBX",    INSTRB,         JMPOP1-256,     8,      0x67L},
                    232: -{"BNEQHX",    INSTRH,         JMPOP1-256,     8,      0x66L},
                    233: -{"JMP",               INSTRW,         JMPOP1-256,     8,      0x24L},
                    234: -{"JSB",               INSTRW,         JSBOP2-256,     8,      0x34L},
                    235: -{"RNEQ",      INSTRW,         ZEROP1-256,     8,      0x74L},
                    236: -{"RNEQU",     INSTRW,         ZEROP1-256,     8,      0x64L},
                    237: -{"NOP",               INSTRW,         ZEROP1-256,     8,      0x70L},
                    238: -{"NOP3",      INSTRW,         ZEROP1-256,     24,     0x720000L},
                    239: -{"NOP2",      INSTRW,         ZEROP1-256,     16,     0x7300L},
                    240: -{"REQL",      INSTRW,         ZEROP1-256,     8,      0x7cL},
                    241: -{"REQLU",     INSTRW,         ZEROP1-256,     8,      0x6cL},
                    242: -{"CLRW",      INSTRW,         MONOP1-256,     8,      0x80L},
                    243: -{"CLRH",      INSTRH,         MONOP1-256,     8,      0x82L},
                    244: -{"CLRB",      INSTRB,         MONOP1-256,     8,      0x83L},
                    245: -{"MNEGB",     INSTRB,         DYAOP1-256,     8,      0x8fL},
                    246: -{"INCW",      INSTRW,         MONOP1-256,     8,      0x90L},
                    247: -{"INCH",      INSTRH,         MONOP1-256,     8,      0x92L},
                    248: -{"INCB",      INSTRB,         MONOP1-256,     8,      0x93L},
                    249: -{"DECW",      INSTRW,         MONOP1-256,     8,      0x94L},
                    250: -{"DECH",      INSTRH,         MONOP1-256,     8,      0x96L},
                    251: -{"DECB",      INSTRB,         MONOP1-256,     8,      0x97L},
                    252: -{"MODH2",     INSTRH,         DYAOP1-256,     8,      0xa6L},
                    253: -{"MODB2",     INSTRB,         DYAOP1-256,     8,      0xa7L},
                    254: -{"MULH2",     INSTRH,         DYAOP1-256,     8,      0xaaL},
                    255: -{"MULB2",     INSTRB,         DYAOP1-256,     8,      0xabL},
                    256: -{"DIVH2",     INSTRH,         DYAOP1-256,     8,      0xaeL},
                    257: -{"DIVB2",     INSTRB,         DYAOP1-256,     8,      0xafL},
                    258: -{"ALSW3",     INSTRW,         TRIOP1-256,     8,      0xc0L},
                    259: -{"ARSW3",     INSTRW,         TRIOP1-256,     8,      0xc4L},
                    260: -{"ARSH3",     INSTRH,         TRIOP1-256,     8,      0xc6L},
                    261: -{"ARSB3",     INSTRB,         TRIOP1-256,     8,      0xc7L},
                    262: -{"LLSW3",     INSTRW,         TRIOP1-256,     8,      0xd0L},
                    263: -{"LLSH3",     INSTRH,         TRIOP1-256,     8,      0xd2L},
                    264: -{"LLSB3",     INSTRB,         TRIOP1-256,     8,      0xd3L},
                    265: -{"LRSW3",     INSTRW,         TRIOP1-256,     8,      0xd4L},
                    266: -{"ROTW",      INSTRW,         TRIOP1-256,     8,      0xd8L},
                    267: -{"MODH3",     INSTRH,         TRIOP1-256,     8,      0xe6L},
                    268: -{"MODB3",     INSTRB,         TRIOP1-256,     8,      0xe7L},
                    269: -{"MULH3",     INSTRH,         TRIOP1-256,     8,      0xeaL},
                    270: -{"MULB3",     INSTRB,         TRIOP1-256,     8,      0xebL},
                    271: -{"DIVH3",     INSTRH,         TRIOP1-256,     8,      0xeeL},
                    272: -{"DIVB3",     INSTRB,         TRIOP1-256,     8,      0xefL},
                    273: -{"MCOMB",     INSTRB,         DYAOP1-256,     8,      0x8bL},
                    274: -{"MCOMH",     INSTRH,         DYAOP1-256,     8,      0x8aL},
                    275: -{"MCOMW",     INSTRW,         DYAOP1-256,     8,      0x88L},
                    276: -{"MOVTRW",    INSTRW,         DYAOP2-256,     8,      0xcL},
                    277: -{"MOVAW",     INSTRW,         DYAOP2-256,     8,      0x4L},
                    278: -{"PUSHAW",    INSTRW,         MONOP2-256,     8,      0xe0L},
                    279: -{"ANDB2",     INSTRB,         DYAOP1-256,     8,      0xbbL},
                    280: -{"ANDH2",     INSTRH,         DYAOP1-256,     8,      0xbaL},
                    281: -{"ANDW2",     INSTRW,         DYAOP1-256,     8,      0xb8L},
                    282: -{"ANDB3",     INSTRB,         TRIOP1-256,     8,      0xfbL},
                    283: -{"ANDH3",     INSTRH,         TRIOP1-256,     8,      0xfaL},
                    284: -{"ANDW3",     INSTRW,         TRIOP1-256,     8,      0xf8L},
                    285: -{"ORB2",      INSTRB,         DYAOP1-256,     8,      0xb3L},
                    286: -{"ORH2",      INSTRH,         DYAOP1-256,     8,      0xb2L},
                    287: -{"ORW2",      INSTRW,         DYAOP1-256,     8,      0xb0L},
                    288: -{"ORB3",      INSTRB,         TRIOP1-256,     8,      0xf3L},
                    289: -{"ORH3",      INSTRH,         TRIOP1-256,     8,      0xf2L},
                    290: -{"ORW3",      INSTRW,         TRIOP1-256,     8,      0xf0L},
                    291: -{"XORB2",     INSTRB,         DYAOP1-256,     8,      0xb7L},
                    292: -{"XORH2",     INSTRH,         DYAOP1-256,     8,      0xb6L},
                    293: -{"XORW2",     INSTRW,         DYAOP1-256,     8,      0xb4L},
                    294: -{"XORB3",     INSTRB,         TRIOP1-256,     8,      0xf7L},
                    295: -{"XORH3",     INSTRH,         TRIOP1-256,     8,      0xf6L},
                    296: -{"XORW3",     INSTRW,         TRIOP1-256,     8,      0xf4L},
                    297: -{"BITB",      INSTRB,         CMPOP2-256,     8,      0x3bL},
                    298: -{"BITH",      INSTRH,         CMPOP2-256,     8,      0x3aL},
                    299: -{"BITW",      INSTRW,         CMPOP2-256,     8,      0x38L},
                    300: -{"MOVB",      INSTRB,         DYAOP4-256,     8,      0x87L},
                    301: -{"MOVH",      INSTRH,         DYAOP4-256,     8,      0x86L},
                    302: -{"MOVW",      INSTRW,         DYAOP4-256,     8,      0x84L},
                    303: -{"MNEGH",     INSTRH,         DYAOP1-256,     8,      0x8eL},
                    304: -{"MNEGW",     INSTRW,         DYAOP1-256,     8,      0x8cL},
                    305: -{"PUSHW",     INSTRW,         MONOP1-256,     8,      0xa0L},
                    306: -{"ADDB2",     INSTRB,         DYAOP6-256,     8,      0x9fL},
                    307: -{"ADDH2",     INSTRH,         DYAOP6-256,     8,      0x9eL},
                    308: -{"ADDW2",     INSTRW,         DYAOP6-256,     8,      0x9cL},
                    309: -{"ADDB3",     INSTRB,         TRIOP1-256,     8,      0xdfL},
                    310: -{"ADDH3",     INSTRH,         TRIOP1-256,     8,      0xdeL},
                    311: -{"ADDW3",     INSTRW,         TRIOP1-256,     8,      0xdcL},
                    312: -{"SUBB2",     INSTRB,         DYAOP6-256,     8,      0xbfL},
                    313: -{"SUBH2",     INSTRH,         DYAOP6-256,     8,      0xbeL},
                    314: -{"SUBW2",     INSTRW,         DYAOP6-256,     8,      0xbcL},
                    315: -{"SUBB3",     INSTRB,         TRIOP1-256,     8,      0xffL},
                    316: -{"SUBH3",     INSTRH,         TRIOP1-256,     8,      0xfeL},
                    317: -{"SUBW3",     INSTRW,         TRIOP1-256,     8,      0xfcL},
                    318: -{"MULW2",     INSTRW,         DYAOP1-256,     8,      0xa8L},
                    319: -{"MULW3",     INSTRW,         TRIOP1-256,     8,      0xe8L},
                    320: -{"DIVW2",     INSTRW,         DYAOP1-256,     8,      0xacL},
                    321: -{"DIVW3",     INSTRW,         TRIOP1-256,     8,      0xecL},
                    322: -{"MODW2",     INSTRW,         DYAOP1-256,     8,      0xa4L},
                    323: -{"MODW3",     INSTRW,         TRIOP1-256,     8,      0xe4L},
                    324: -{"CMPB",      INSTRB,         CMPOP1-256,     8,      0x3fL},
                    325: -{"CMPH",      INSTRH,         CMPOP1-256,     8,      0x3eL},
                    326: -{"CMPW",      INSTRW,         CMPOP1-256,     8,      0x3cL},
                    327: -{"RSB",               INSTRW,         ZEROP1-256,     8,      0x78L},
                    328: -{"MOVBLW",    INSTRW,         ZEROP1-256,     16,     0x3019L},
                    329: -{"INSFW",     INSTRW,         FLDOP4-256,     8,      0xc8L},
                    330: -{"INSFH",     INSTRH,         FLDOP4-256,     8,      0xcaL},
                    331: -{"INSFB",     INSTRB,         FLDOP4-256,     8,      0xcbL},
                    332: -{"EXTFW",     INSTRW,         FLDOP4-256,     8,      0xccL},
                    333: -{"EXTFH",     INSTRH,         FLDOP4-256,     8,      0xceL},
                    334: -{"EXTFB",     INSTRB,         FLDOP4-256,     8,      0xcfL},
                    335: -{"EXTOP",     INSTRX,         SIMOP-256,      8,      0x14L},
                    336: -{"getsm",     INSTRX,         ZEROP1-256,     8,      0x1L},
                    337: -{"putsm",     INSTRX,         ZEROP1-256,     8,      0x11L},
                    338: -{"ungetsm",   INSTRX,         ZEROP1-256,     8,      0x21L},
                    339: -{"r0",                DUMMY,          REGISTER-256,   4,      0x0L},
                    340: -{"r1",                DUMMY,          REGISTER-256,   4,      0x1L},
                    341: -{"r2",                DUMMY,          REGISTER-256,   4,      0x2L},
                    342: -{"r3",                DUMMY,          REGISTER-256,   4,      0x3L},
                    343: -{"r4",                DUMMY,          REGISTER-256,   4,      0x4L},
                    344: -{"r5",                DUMMY,          REGISTER-256,   4,      0x5L},
                    345: -{"r6",                DUMMY,          REGISTER-256,   4,      0x6L},
                    346: -{"r7",                DUMMY,          REGISTER-256,   4,      0x7L},
                    347: -{"r8",                DUMMY,          REGISTER-256,   4,      0x8L},
                    348: -{"fp",                DUMMY,          REGISTER-256,   4,      0x9L},
                    349: -{"ap",                DUMMY,          REGISTER-256,   4,      0xaL},
                    350: -{"psw",               DUMMY,          REGISTER-256,   4,      0xbL},
                    351: -{"sp",                DUMMY,          REGISTER-256,   4,      0xcL},
                    352: -{"pcbp",      DUMMY,          REGISTER-256,   4,      0xdL},
                    353: -{"isp",               DUMMY,          REGISTER-256,   4,      0xeL},
                    354: -{".globl",    PSEUDO,         PSGLOBAL-256,   0,      0x0L},
                    355: -{".comm",     PSEUDO,         PSCOMM-256,     0,      0x0L},
                    356: -{".set",      PSEUDO,         PSSET-256,      0,      0x0L},
                    357: -{".zero",     PSEUDO,         PSZERO-256,     0,      0x0L},
                    358: -{".bss",      BSS,            PSBSS-256,      0,      0x0L},
                    359: -{".file",     PSEUDO,         PSFILE-256,     0,      0x0L},
                    360: -{".align",    PSEUDO,         PSALIGN-256,    0,      0x0L},
                    361: -{".byte",     PSEUDO,         PSBYTE-256,     0,      0x0L},
                    362: -{".half",     PSEUDO,         PSHALF-256,     0,      0x0L},
                    363: -{".word",     PSEUDO,         PSWORD-256,     0,      0x0L},
                    364: -#if   FLOAT
                    365: -{".float",    PSEUDO,         PSFLOAT-256,    0,      0x0L},
                    366: -{".double",   PSEUDO,         PSDOUBLE-256,   0,      0x0L},
                    367: -#endif
                    368: -{".def",      PSEUDO,         PSDEF-256,      0,      0x0L},
                    369: -{".val",      PSEUDO,         PSVAL-256,      0,      0x0L},
                    370: -{".scl",      PSEUDO,         PSSCL-256,      0,      0x0L},
                    371: -{".type",     PSEUDO,         PSTYPE-256,     0,      0x0L},
                    372: -{".tag",      PSEUDO,         PSTAG-256,      0,      0x0L},
                    373: -{".line",     PSEUDO,         PSLINE-256,     0,      0x0L},
                    374: -{".size",     PSEUDO,         PSSIZE-256,     0,      0x0L},
                    375: -{".dim",      PSEUDO,         PSDIM-256,      0,      0x0L},
                    376: -{".endef",    PSEUDO,         PSENDEF-256,    0,      0x0L},
                    377: -{".ln",               PSEUDO,         PSLN-256,       0,      0x0L},
                    378: -{".text",     TXT,            SECTIONN-256,   0,      0x0L},
                    379: -{".data",     DAT,            SECTIONN-256,   0,      0x0L},
                    380: -{"sbyte",     DUMMY,          EXPTYPE-256,    8,      0x7L},
                    381: -{"ubyte",     DUMMY,          EXPTYPE-256,    8,      0x3L},
                    382: -{"byte",      DUMMY,          EXPTYPE-256,    8,      0x7L},
                    383: -{"shalf",     DUMMY,          EXPTYPE-256,    8,      0x6L},
                    384: -{"half",      DUMMY,          EXPTYPE-256,    8,      0x6L},
                    385: -{"uhalf",     DUMMY,          EXPTYPE-256,    8,      0x2L},
                    386: -{"sword",     DUMMY,          EXPTYPE-256,    8,      0x4L},
                    387: -{"word",      DUMMY,          EXPTYPE-256,    8,      0x4L},
                    388: -{"uword",     DUMMY,          EXPTYPE-256,    8,      0x0L},
                    389: -
                    390: //GO.SYSIN DD 3binstr.c
                    391: echo 5bb.c 1>&2
                    392: sed 's/.//' >5bb.c <<'//GO.SYSIN DD 5bb.c'
                    393: -#define unsafe 1      /* pretend killing all but C is as good as killing
                    394: -                       * all condition codes */
                    395: -#ifdef unsafe
                    396: -#define E     (C|K)
                    397: -#else
                    398: -#define E     K
                    399: -#endif
                    400: -#include "stdio.h"
                    401: -#include "instr.c"
                    402: -#include "ctype.h"
                    403: -struct inst *index[128];
                    404: -
                    405: -#define SBBLK 1       /* looking for the start of a basic block */
                    406: -#define SINST 2       /* thinking about generating a tally */
                    407: -#define SPRO  3       /* thinking about generating prolog code */
                    408: -#define SMAYBE        4       /* seen _, thinking about SPRO */
                    409: -
                    410: -#define MAXLA 5       /* max no. of lines that can be read for lookahead */
                    411: -
                    412: -FILE *outs, *fd, *outl;       /* outs goes to assembler, outl is for listing */
                    413: -extern FILE *popen();
                    414: -char line[256], fname[256];   /* file names must fit in fname */
                    415: -
                    416: -char labuf[5][256];           /* look ahead needed for 5.0 stab entries */
                    417: -int lastla, lookahead;
                    418: -char begfcn[] = "     .def    .bf";   /* 5.0 stab entry */
                    419: -
                    420: -int lineno, lastline;
                    421: -int base=0;
                    422: -
                    423: -int cnt;
                    424: -int state = SBBLK;
                    425: -char *ptr, *curarg;
                    426: -char curdir[256];
                    427: -
                    428: -main(argc, argv)
                    429: -char **argv;
                    430: -{     int i;
                    431: -      if(argc <= 1) {
                    432: -              fprintf(stderr, "no files given\n");
                    433: -              exit(1);
                    434: -      }
                    435: -      for(i = 0; insts[i].iname; i++)
                    436: -              ;
                    437: -      for(; i >= 0; i--)
                    438: -              index[insts[i].iname[0]] = insts + i;
                    439: -      fd = popen("pwd", "r");
                    440: -      for(i = 0; i < sizeof(curdir) && !feof(fd); i++)
                    441: -              curdir[i] = getc(fd);
                    442: -      curdir[i-2] = 0;        /* thisdir\n */
                    443: -      fclose(fd);
                    444: -      for(i = 1; i < argc; i++) {
                    445: -              if(setfd(argv[i]))      /* fix fd, outs, outl */
                    446: -                      doarg();        /* do the work */
                    447: -      }
                    448: -      exit(0);
                    449: -}
                    450: -
                    451: -setfd(s)
                    452: -char *s;
                    453: -{     char outnams[24], outnaml[24];
                    454: -      fname[0] = 0;
                    455: -      cnt = 3;
                    456: -      if(fd != NULL)
                    457: -              fclose(fd);
                    458: -      if(outs != NULL)
                    459: -              fclose(outs);
                    460: -      if(outl != NULL)
                    461: -              fclose(outl);
                    462: -      sprintf(outnams, "X%s", s);
                    463: -      sprintf(outnaml, "%sL", s);
                    464: -      lastline = lineno = 0;
                    465: -      fd = fopen(s, "r");
                    466: -      if(fd == NULL) {
                    467: -              perror(s);
                    468: -              return(0);
                    469: -      }
                    470: -      outs = fopen(outnams, "w");
                    471: -      if(outs == NULL) {
                    472: -              perror(outnams);
                    473: -              return(0);
                    474: -      }
                    475: -      outl = fopen(outnaml, "w");
                    476: -      if(outl == NULL) {
                    477: -              perror(outnaml);
                    478: -              return(0);
                    479: -      }
                    480: -      curarg = s;
                    481: -      return(1);
                    482: -}
                    483: -
                    484: -doarg()
                    485: -{     struct inst *x, *firstword();
                    486: -
                    487: -      state = SBBLK;
                    488: -      lookahead = 0;          /* empty buffer */
                    489: -      lastla = 0;
                    490: -      for(;;) {
                    491: -              if (lookahead != lastla){
                    492: -                      strcpy(line,labuf[ (lookahead++) % MAXLA ] );
                    493: -                      if (lookahead == lastla) lookahead = lastla = 0;
                    494: -              }
                    495: -              else
                    496: -                      (void) fgets(line, sizeof(line), fd);
                    497: -              if(feof(fd))
                    498: -                      break;
                    499: -              for(ptr = line; isspace(*ptr); *ptr++)
                    500: -                      ;
                    501: -              if(*ptr == 0 || *ptr == '#')
                    502: -                      continue;
                    503: -              testlabel();
                    504: -              /* deal with symbol table info */
                    505: -              if(*ptr == '.') {
                    506: -                      stab();
                    507: -                      fprintf(outs, " %s", ptr);
                    508: -                      continue;
                    509: -              }
                    510: -              if(*ptr == 0 || *ptr == '\n')
                    511: -                      continue;
                    512: -              x = firstword();
                    513: -              if(x == 0){
                    514: -                      printf("unknown inst: %s\n",ptr);
                    515: -                      continue;
                    516: -              }
                    517: -#ifdef u3b
                    518: -              if ((state == SMAYBE) && !strncmp(ptr,"save",4)){
                    519: -                      state = SPRO;
                    520: -                      getlnum();      /* 5.0 true line # */
                    521: -              }
                    522: -#endif
                    523: -              if(state == SPRO)
                    524: -                      prolog(x);
                    525: -              if(state == SINST)
                    526: -                      tally(x);
                    527: -              if(state == SBBLK && (x->type & JUMP))
                    528: -                      state = SINST;
                    529: -              outinstr();
                    530: -              if(x->type & BYTE)
                    531: -                      fixinstr(x);
                    532: -              fprintf(outs, " %s", ptr);
                    533: -      }
                    534: -      finish();
                    535: -}
                    536: -
                    537: -
                    538: -getlnum(){    /* get true line number from 5.0 sdb info */
                    539: -      char *la;
                    540: -      int l;
                    541: -
                    542: -      /* get true line number by looking ahead */
                    543: -      /* this is necessary for 5.0 sdb output  */
                    544: -      do
                    545: -              (void) fgets(labuf[l = ((lastla++)%MAXLA)], sizeof(line), fd);
                    546: -      while (!feof(fd) && strncmp(begfcn, labuf[l],
                    547: -                      9) && (lookahead != (lastla)%MAXLA ));
                    548: -      if ( strncmp(begfcn, labuf[l], 9) ) 
                    549: -              return;         /* bad input  or not 5.0 */
                    550: -      la = labuf[l];
                    551: -      while ( *la != '\0' ){
                    552: -              while ( *la != ';' && *la != '\0') la++;
                    553: -              if ( *la == ';' ) la++;
                    554: -              while ( isspace(*la) ) la++;
                    555: -              if ( !strncmp(la, ".line" , 5) ){
                    556: -                      lineno = base = atoi( la + 5 );
                    557: -                      return;
                    558: -              }
                    559: -      }
                    560: -}
                    561: -
                    562: -
                    563: -/* unbelievable variability in sdb info */
                    564: -stab()
                    565: -{     char buf[128];
                    566: -      int i, j, k;
                    567: -
                    568: -#ifndef u3b
                    569: -      if(state == SMAYBE && strncmp(ptr, ".word", 5) == 0) {
                    570: -              state = SPRO;
                    571: -              getlnum();
                    572: -              return;
                    573: -      }
                    574: -#endif
                    575: -
                    576: -      if((i = *(ptr + 1)) != 's' && i != 'f' && i != 'l')
                    577: -              return;
                    578: -      /* real compiler output */
                    579: -      if(sscanf(ptr, ".stabs \"%[^\"]\", %o", buf, &i) == 2 && i == 0144)
                    580: -              strcat(fname, buf);
                    581: -      else if(sscanf(ptr, ".stabd %o,%o,%o", &i, &j, &k) == 3 && i == 0104)
                    582: -              lineno = k;
                    583: -      /* pwb 3.0 */
                    584: -      else if(sscanf(ptr, ".stab %[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%d",
                    585: -              buf, buf+2, buf+4, buf+6, buf+8, buf+10, buf+12, buf+14, &i)
                    586: -              == 9 && i == 144) {
                    587: -                      for(i = k = 0; buf[i] ; i++)
                    588: -                              if(buf[i] == '\'')
                    589: -                                      buf[k++] = buf[++i];
                    590: -                      buf[k] = 0;
                    591: -                      strcat(fname, buf);
                    592: -              }
                    593: -      else if(sscanf(ptr, ".stab %[0,]%d,%d,%d", buf,&i, &j, &k) == 4
                    594: -              && i == 104)
                    595: -              lineno = k;
                    596: -      /* pwb 5.0 */
                    597: -      else if(sscanf(ptr," .file \"%[^\"]\"", buf) == 1)
                    598: -              strcat(fname, buf);
                    599: -      else if(sscanf(ptr, " .ln %d",&k) == 1)
                    600: -              lineno = k + base - 1;
                    601: -}
                    602: -
                    603: -testlabel()
                    604: -{     char *p;
                    605: -      int i;
                    606: -
                    607: -for(;;){
                    608: -      for(p = ptr; *p; p++) {
                    609: -              if(*p == ':')
                    610: -                      break;
                    611: -              if(!isalnum(*p) && *p != '_' && *p != '.')
                    612: -                      return;
                    613: -      }
                    614: -      if(*p == 0)
                    615: -              return;
                    616: -      *p++ = 0;       /* that is overwriting the : */
                    617: -      fprintf(outs, "%s:\n", ptr);
                    618: -      if (lineno != lastline){
                    619: -              for (i=lastline+1; i < lineno ; i++)    /* allign label with right inst */
                    620: -                      fprintf(outl, "0 %s: %d\n", fname, i);
                    621: -              lastline = lineno - 1;
                    622: -      }
                    623: -      fprintf(outl, "%d %s:\n", 4*(cnt - 1), ptr);
                    624: -#ifdef u3b
                    625: -      if(*ptr != '.')
                    626: -#else
                    627: -      if(*ptr == '_' )
                    628: -#endif
                    629: -              state = SMAYBE;
                    630: -      else
                    631: -              if(state != SPRO)
                    632: -                      state = SINST;
                    633: -      for(ptr = p; isspace(*ptr); ptr++)
                    634: -              ;
                    635: -      }       /* L68:L70: ... */
                    636: -}
                    637: -
                    638: -struct inst *
                    639: -firstword()
                    640: -{     char buf[sizeof(line)], *p, *q;
                    641: -      struct inst *x;
                    642: -      for(p = buf, q = ptr; isalnum(*q); )
                    643: -              *p++ = *q++;
                    644: -      if(p == buf)
                    645: -              return((struct inst *)0);
                    646: -      *p = 0;
                    647: -      for(x = index[buf[0]]; x && x->iname[0] == buf[0]; x++)
                    648: -              if(strcmp(buf, x->iname) == 0)
                    649: -                      return(x);
                    650: -      return(0);
                    651: -}
                    652: -
                    653: -outinstr()
                    654: -{     int i;
                    655: -      for(i = lastline + 1; i < lineno; i++)
                    656: -              fprintf(outl, "0 %s: %d\n", fname, i);
                    657: -      if (lastline != lineno){
                    658: -              fprintf(outl, "%d %s: %d\n", 4*(cnt - 1), fname, lineno);
                    659: -              lastline = lineno;
                    660: -      }
                    661: -      fprintf(outl, "%d       %s", 4*(cnt - 1), ptr);
                    662: -}
                    663: -
                    664: -#ifdef u3b
                    665: -
                    666: -/* 3b code  ***********************************/
                    667: -tally(x)
                    668: -struct inst *x;
                    669: -{
                    670: -      if(x->type & E)
                    671: -              fprintf(outs, " addw2 &1,locprof+%d\n", 4*cnt++);
                    672: -      else {
                    673: -              fprintf(outs, " stsm &1,savecc\n");
                    674: -              fprintf(outs, " gcc %%r0\n");
                    675: -              fprintf(outs, " addw2 &1,locprof+%d\n", 4*cnt++);
                    676: -              fprintf(outs, " scc %%r0\n");
                    677: -              fprintf(outs, " lsm &1,savecc\n");
                    678: -      }
                    679: -      state = SBBLK;
                    680: -}
                    681: -
                    682: -prolog(x)     /* no liveness test, presumes can't get here by jump */
                    683: -struct inst *x;
                    684: -{     int i;
                    685: -      fprintf(outs, " .data\n");
                    686: -      fprintf(outs, " .globl proFptr\n");     /* the global chain */
                    687: -      fprintf(outs, " .globl savecc\n");
                    688: -      fprintf(outs, " .text\n");
                    689: -      fprintf(outs, " cmpw &0,locprof+4\n");
                    690: -      fprintf(outs, " jne L%da\n", i = cnt);
                    691: -      fprintf(outs, " movw proFptr,locprof+4\n");
                    692: -      fprintf(outs, " movaw locprof,proFptr\n");
                    693: -      fprintf(outs, "L%da: addw2 &1,locprof+%d\n", i, 4*cnt++);
                    694: -      state = SBBLK;
                    695: -}
                    696: -
                    697: -finish()
                    698: -{     int i;
                    699: -      fprintf(outs, " .data\n");
                    700: -      fprintf(outs, " .align  4\n");
                    701: -      fprintf(outs, "locprof:\n");
                    702: -      fprintf(outs, " .word   %d\n", cnt);
                    703: -      fprintf(outs, " .word 0\n");
                    704: -      fprintf(outs, " .word L%db\n", cnt);
                    705: -      fprintf(outs, " .zero %d\n", 4 * cnt);
                    706: -      fprintf(outs, "L%db: .byte ", cnt);
                    707: -      for(i = 0; curdir[i]; i++)
                    708: -              fprintf(outs, " 0x%x,", curdir[i]);
                    709: -      fprintf(outs, " 0x%x\n", '/');
                    710: -      fprintf(outs, " .byte ");
                    711: -      if(fname[0])
                    712: -              for(i = 0; fname[i]; i++)
                    713: -                      fprintf(outs, " 0x%x,", fname[i]);
                    714: -      else
                    715: -              for(i = 0; curarg[i]; i++)
                    716: -                      fprintf(outs, " 0x%x,", curarg[i]);
                    717: -      fprintf(outs, "0\n");
                    718: -}
                    719: -
                    720: -#else
                    721: -
                    722: -/*  Vax code  **************************/
                    723: -tally(x)
                    724: -struct inst *x;
                    725: -{
                    726: -      if(x->type & E)
                    727: -              fprintf(outs, " incl locprof+%d\n", 4*cnt++);
                    728: -      else {
                    729: -              fprintf(outs, " movpsl -(sp)\n");
                    730: -              fprintf(outs, " incl locprof+%d\n", 4*cnt++);
                    731: -              fprintf(outs, " movw (sp)+,(sp)\n");
                    732: -              fprintf(outs, " bicpsw $0xff\n");
                    733: -              fprintf(outs, " bispsw (sp)+\n");
                    734: -              /* thanks to kirk mckusick */
                    735: -      }
                    736: -      state = SBBLK;
                    737: -}
                    738: -
                    739: -
                    740: -prolog(x)     /* no liveness test, presumes can't get here by jump */
                    741: -struct inst *x;
                    742: -{     int i;
                    743: -      fprintf(outs, " .data\n");
                    744: -      fprintf(outs, " .comm _proFptr,4\n");   /* the global chain */
                    745: -      fprintf(outs, " .text\n");
                    746: -      /*if(!(x->type & E))
                    747: -              fprintf(outs, " movpsl -(sp)\n");*/
                    748: -      fprintf(outs, " tstl locprof+4\n");
                    749: -      fprintf(outs, " bneq L%da\n", i = cnt);
                    750: -      fprintf(outs, " movl _proFptr,locprof+4\n");
                    751: -      fprintf(outs, " moval locprof,_proFptr\n");
                    752: -      fprintf(outs, "L%da: incl locprof+%d\n", i, 4*cnt++);
                    753: -      /*if(!(x->type & E)) {
                    754: -              fprintf(outs, " movw (sp)+,(sp)\n");
                    755: -              fprintf(outs, " bicpsw $0xff\n");
                    756: -              fprintf(outs, " bispsw (sp)+\n");
                    757: -      }*/
                    758: -      state = SBBLK;
                    759: -}
                    760: -
                    761: -finish()
                    762: -{     int i;
                    763: -      fprintf(outs, " .data\n");
                    764: -      fprintf(outs, "locprof: .long %d\n", cnt);
                    765: -      fprintf(outs, " .long 0\n");
                    766: -      fprintf(outs, " .long L%db\n", cnt);
                    767: -      fprintf(outs, " .space %d\n", 4 * cnt);
                    768: -      fprintf(outs, "L%db: .byte ", cnt);
                    769: -      for(i = 0; curdir[i]; i++)
                    770: -              fprintf(outs, "0x%x,", curdir[i]);
                    771: -      fprintf(outs, "0x%x\n", '/');
                    772: -      fprintf(outs, " .byte ");
                    773: -      if(fname[0])
                    774: -              for(i = 0; fname[i]; i++)
                    775: -                      fprintf(outs, "0x%x,", fname[i]);
                    776: -      else
                    777: -              for(i = 0; curarg[i]; i++)
                    778: -                      fprintf(outs, "0x%x,", curarg[i]);
                    779: -      fprintf(outs, "0\n");
                    780: -}
                    781: -
                    782: -#endif
                    783: -
                    784: -
                    785: -fixinstr(x)
                    786: -struct inst *x;
                    787: -{
                    788: -#ifndef u3b
                    789: -      if(x->iname[0] == 'b')
                    790: -              *ptr = 'j';     /* let assembler worry about branches */
                    791: -      /* this is where the code for aob and sob goes */
                    792: -#endif
                    793: -}
                    794: -
                    795: -
                    796: -
                    797: -
                    798: -
                    799: //GO.SYSIN DD 5bb.c
                    800: echo 68k-instr.c 1>&2
                    801: sed 's/.//' >68k-instr.c <<'//GO.SYSIN DD 68k-instr.c'
                    802: -#define K     1       /* kills all condition codes */
                    803: -#define JUMP  2       /* ends a basic block */
                    804: -#define BYTE  4       /* target is byte offset */
                    805: -#define C     8       /* kills all condition codes but for C bit*/
                    806: -/* if((p->type & EXPAND) && p->iname[0] == 'b') replace first char with j */
                    807: -/* aob and sob get replaced by two instructions */
                    808: -
                    809: -struct inst {
                    810: -      char *iname;
                    811: -      short type;
                    812: -} insts[] = {
                    813: -{ "abcd", K},
                    814: -{ "add", K},
                    815: -{ "addx", K},
                    816: -{ "and", K},
                    817: -{ "asl", K},
                    818: -{ "asr", K},
                    819: -{ "bcc", 0},
                    820: -{ "bchg", 0},
                    821: -{ "bclr", 0},
                    822: -{ "bcs", 0},
                    823: -{ "beq", 0},
                    824: -{ "bge", 0},
                    825: -{ "bgt", 0},
                    826: -{ "bhi", 0},
                    827: -{ "bhs", 0},
                    828: -{ "ble", 0},
                    829: -{ "blo", 0},
                    830: -{ "bls", 0},
                    831: -{ "blt", 0},
                    832: -{ "bmi", 0},
                    833: -{ "bne", 0},
                    834: -{ "bpl", 0},
                    835: -{ "br", 0},
                    836: -{ "bra", 0},
                    837: -{ "bset", 0},
                    838: -{ "bsr", 0},
                    839: -{ "btst", 0},
                    840: -{ "bvc", 0},
                    841: -{ "bvs", 0},
                    842: -{ "chk", K},
                    843: -{ "clr", K},
                    844: -{ "cmp", K},
                    845: -{ "dbcc", 0},
                    846: -{ "dbcs", 0},
                    847: -{ "dbeq", 0},
                    848: -{ "dbge", 0},
                    849: -{ "dbgt", 0},
                    850: -{ "dbhi", 0},
                    851: -{ "dbhs", 0},
                    852: -{ "dble", 0},
                    853: -{ "dblo", 0},
                    854: -{ "dbls", 0},
                    855: -{ "dblt", 0},
                    856: -{ "dbmi", 0},
                    857: -{ "dbne", 0},
                    858: -{ "dbpl", 0},
                    859: -{ "dbr", 0},
                    860: -{ "dbra", 0},
                    861: -{ "dbvc", 0},
                    862: -{ "dbvs", 0},
                    863: -{ "divs", K},
                    864: -{ "divu", K},
                    865: -{ "eor", K},
                    866: -{ "exg", 0},
                    867: -{ "ext", K},
                    868: -{ "jmp", 0},
                    869: -{ "jsr", 0},
                    870: -{ "lea", 0},
                    871: -{ "link", 0},
                    872: -{ "lsl", K},
                    873: -{ "lsr", K},
                    874: -{ "mov", K},
                    875: -{ "movea", 0},
                    876: -{ "movm", 0},
                    877: -{ "muls", K},
                    878: -{ "mulu", K},
                    879: -{ "nbcd", K},
                    880: -{ "neg", K},
                    881: -{ "negx", K},
                    882: -{ "nop", 0},
                    883: -{ "not", K},
                    884: -{ "or", K},
                    885: -{ "pea", 0},
                    886: -{ "reset", 0},
                    887: -{ "rol", K},
                    888: -{ "ror", K},
                    889: -{ "roxl", K},
                    890: -{ "roxr", K},
                    891: -{ "rte", K},
                    892: -{ "rtr", K},
                    893: -{ "rts", 0},
                    894: -{ "sbcd", K},
                    895: -{ "scc", 0},
                    896: -{ "scs", 0},
                    897: -{ "seq", 0},
                    898: -{ "sf", 0},
                    899: -{ "sge", 0},
                    900: -{ "sgt", 0},
                    901: -{ "shi", 0},
                    902: -{ "shs", 0},
                    903: -{ "sle", 0},
                    904: -{ "slo", 0},
                    905: -{ "sls", 0},
                    906: -{ "slt", 0},
                    907: -{ "smi", 0},
                    908: -{ "sne", 0},
                    909: -{ "spl", 0},
                    910: -{ "st", 0},
                    911: -{ "stop", K},
                    912: -{ "sub", K},
                    913: -{ "suba", 0},
                    914: -{ "subx", K},
                    915: -{ "svc", 0},
                    916: -{ "svs", 0},
                    917: -{ "swap", K},
                    918: -{ "tas", K},
                    919: -{ "trap", 0},
                    920: -{ "trapv", 0},
                    921: -{ "tst", K},
                    922: -{ "unlk", 0},
                    923: -{ 0, 0},
                    924: -};
                    925: //GO.SYSIN DD 68k-instr.c
                    926: echo README 1>&2
                    927: sed 's/.//' >README <<'//GO.SYSIN DD README'
                    928: -There's no makefile.  Compile bb.c (or 5bb.c if you've unix V) and put
                    929: -the output in bb.  fix the shell scripts lcomp, lcc.  good luck. [instr.c is
                    930: -included in bb.c, so doesn't get compiled.
                    931: -cc -c nexit.c -o nexit.o; cc -o lprint lprint.c, and that's it]
                    932: -.
                    933: //GO.SYSIN DD README
                    934: echo bb.c 1>&2
                    935: sed 's/.//' >bb.c <<'//GO.SYSIN DD bb.c'
                    936: -#define unsafe 1      /* pretend killing all but C is as good as killing
                    937: -                       * all condition codes */
                    938: -#ifdef unsafe
                    939: -#define E     (C|K)
                    940: -#else
                    941: -#define E     K
                    942: -#endif
                    943: -#include "stdio.h"
                    944: -#include "instr.c"
                    945: -#include "ctype.h"
                    946: -struct inst *index[128];
                    947: -
                    948: -#define SBBLK 1       /* looking for the start of a basic block */
                    949: -#define SINST 2       /* thinking about generating a tally */
                    950: -#define SPRO  3       /* thinking about generating prolog code */
                    951: -#define SMAYBE        4       /* seen _, thinking about SPRO */
                    952: -
                    953: -FILE *outs, *fd, *outl;       /* outs goes to assembler, outl is for listing */
                    954: -extern FILE *popen();
                    955: -char line[256], fname[256];   /* file names must fit in fname */
                    956: -char curfunc[256];
                    957: -int lineno, lastline;
                    958: -int cnt;
                    959: -int state = SBBLK;
                    960: -char *ptr, *curarg;
                    961: -char curdir[256];
                    962: -
                    963: -main(argc, argv)
                    964: -char **argv;
                    965: -{     int i;
                    966: -      if(argc <= 1) {
                    967: -              fprintf(stderr, "no files given\n");
                    968: -              exit(1);
                    969: -      }
                    970: -      for(i = 0; insts[i].iname; i++)
                    971: -              ;
                    972: -      for(; i >= 0; i--)
                    973: -              index[insts[i].iname[0]] = insts + i;
                    974: -      fd = popen("pwd", "r");
                    975: -      for(i = 0; i < sizeof(curdir) && !feof(fd); i++)
                    976: -              curdir[i] = getc(fd);
                    977: -      curdir[i-2] = 0;        /* thisdir\n */
                    978: -      fclose(fd);
                    979: -      for(i = 1; i < argc; i++) {
                    980: -              if(setfd(argv[i]))      /* fix fd, outs, outl */
                    981: -                      doarg();        /* do the work */
                    982: -      }
                    983: -      exit(0);
                    984: -}
                    985: -
                    986: -setfd(s)
                    987: -char *s;
                    988: -{     char outnams[24], outnaml[24];
                    989: -      fname[0] = 0;
                    990: -      cnt = 3;
                    991: -      if(fd != NULL)
                    992: -              fclose(fd);
                    993: -      if(outs != NULL)
                    994: -              fclose(outs);
                    995: -      if(outl != NULL)
                    996: -              fclose(outl);
                    997: -      sprintf(outnams, "X%s", s);
                    998: -      sprintf(outnaml, "%sL", s);
                    999: -      lastline = lineno = 0;
                   1000: -      fd = fopen(s, "r");
                   1001: -      if(fd == NULL) {
                   1002: -              perror(s);
                   1003: -              return(0);
                   1004: -      }
                   1005: -      outs = fopen(outnams, "w");
                   1006: -      if(outs == NULL) {
                   1007: -              perror(outnams);
                   1008: -              return(0);
                   1009: -      }
                   1010: -      outl = fopen(outnaml, "w");
                   1011: -      if(outl == NULL) {
                   1012: -              perror(outnaml);
                   1013: -              return(0);
                   1014: -      }
                   1015: -      curarg = s;
                   1016: -      return(1);
                   1017: -}
                   1018: -
                   1019: -doarg()
                   1020: -{     struct inst *x, *firstword();
                   1021: -      state = SBBLK;
                   1022: -      for(;;) {
                   1023: -              (void) fgets(line, sizeof(line), fd);
                   1024: -              if(feof(fd))
                   1025: -                      break;
                   1026: -              for(ptr = line; isspace(*ptr); *ptr++)
                   1027: -                      ;
                   1028: -              if(*ptr == 0 || *ptr == '#')
                   1029: -                      continue;
                   1030: -              testlabel();
                   1031: -              /* deal with symbol table info */
                   1032: -              if(*ptr == '.') {
                   1033: -                      stab();
                   1034: -                      fprintf(outs, "%s", ptr);
                   1035: -                      continue;
                   1036: -              }
                   1037: -              if(*ptr == 0 || *ptr == '\n')
                   1038: -                      continue;
                   1039: -              x = firstword();
                   1040: -              if(x == 0)
                   1041: -                      continue;
                   1042: -              if(state == SPRO)
                   1043: -                      prolog(x);
                   1044: -              if(state == SINST)
                   1045: -                      tally(x);
                   1046: -              if(state == SBBLK && (x->type & JUMP))
                   1047: -                      state = SINST;
                   1048: -              outinstr();
                   1049: -              if(x->type & BYTE)
                   1050: -                      fixinstr(x);
                   1051: -              fprintf(outs, "%s", ptr);
                   1052: -      }
                   1053: -      finish();
                   1054: -}
                   1055: -/* unbelievable variability in sdb info */
                   1056: -stab()
                   1057: -{     char buf[128];
                   1058: -      int i, j, k;
                   1059: -      if(state == SMAYBE && strncmp(ptr, ".word", 5) == 0) {
                   1060: -              state = SPRO;
                   1061: -              return;
                   1062: -      }
                   1063: -      if((i = *(ptr + 1)) != 's' && i != 'f' && i != 'l')
                   1064: -              return;
                   1065: -      /* real compiler output */
                   1066: -      if(sscanf(ptr, ".stabs \"%[^\"]\", %o", buf, &i) == 2 && i == 0144)
                   1067: -              strcat(fname, buf);
                   1068: -      else if(sscanf(ptr, ".stabs \"%[^\"]\", 0x%x", buf, &i) == 2 && i == 0x64)
                   1069: -              strcat(fname, buf);
                   1070: -      else if(sscanf(ptr, ".stabd %o,%o,%o", &i, &j, &k) == 3 && i == 0104)
                   1071: -              lineno = k;
                   1072: -      else if(sscanf(ptr, ".stabd 0x%x,0,%d", &i, &k) == 2 && i == 0x44)
                   1073: -              lineno = k;
                   1074: -      /* pwb 3.0 */
                   1075: -      else if(sscanf(ptr, ".stab %[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%d",
                   1076: -              buf, buf+2, buf+4, buf+6, buf+8, buf+10, buf+12, buf+14, &i)
                   1077: -              == 9 && i == 144) {
                   1078: -                      for(i = k = 0; buf[i] ; i++)
                   1079: -                              if(buf[i] == '\'')
                   1080: -                                      buf[k++] = buf[++i];
                   1081: -                      buf[k] = 0;
                   1082: -                      strcat(fname, buf);
                   1083: -              }
                   1084: -      else if(sscanf(ptr, ".stab %[0,]%d,%d,%d", buf,&i, &j, &k) == 4
                   1085: -              && i == 104)
                   1086: -              lineno = k;
                   1087: -      /* pwb 5.0 */
                   1088: -      else if(sscanf(ptr," .file \"%[^\"]\"", buf) == 1)
                   1089: -              strcat(fname, buf);
                   1090: -      else if(sscanf(ptr, " .ln %d",&k) == 1)
                   1091: -              lineno = k;
                   1092: -}
                   1093: -
                   1094: -testlabel()
                   1095: -{     char *p;
                   1096: -again:
                   1097: -      for(p = ptr; *p; p++) {
                   1098: -              if(*p == ':')
                   1099: -                      break;
                   1100: -              if(isalnum(*p) || *p == '_')
                   1101: -                      continue;
                   1102: -              if(p > ptr && *p == '.')        /* f77 */
                   1103: -                      continue;
                   1104: -              return;
                   1105: -      }
                   1106: -      if(*p == 0)
                   1107: -              return;
                   1108: -      *p++ = 0;       /* that is overwriting the : */
                   1109: -      fprintf(outs, "%s:\n", ptr);
                   1110: -      if(*ptr == '_') {
                   1111: -              state = SMAYBE;
                   1112: -              strcpy(curfunc, ptr);
                   1113: -      }
                   1114: -      else
                   1115: -              if(state != SPRO)
                   1116: -                      state = SINST;
                   1117: -      for(ptr = p; isspace(*ptr); ptr++)
                   1118: -              ;
                   1119: -      goto again;     /* L68:L70: ... */
                   1120: -}
                   1121: -
                   1122: -struct inst *
                   1123: -firstword()
                   1124: -{     char buf[sizeof(line)], *p, *q;
                   1125: -      struct inst *x;
                   1126: -      for(p = buf, q = ptr; isalnum(*q); )
                   1127: -              *p++ = *q++;
                   1128: -      if(p == buf)
                   1129: -              return((struct inst *)0);
                   1130: -      *p = 0;
                   1131: -      for(x = index[buf[0]]; x && x->iname[0] == buf[0]; x++)
                   1132: -              if(strcmp(buf, x->iname) == 0)
                   1133: -                      return(x);
                   1134: -      return(0);
                   1135: -}
                   1136: -
                   1137: -tally(x)
                   1138: -struct inst *x;
                   1139: -{
                   1140: -      if(x->type & E)
                   1141: -              fprintf(outs, "incl locprof+%d\n", 4*cnt++);
                   1142: -      else {
                   1143: -              fprintf(outs, "movpsl -(sp)\n");
                   1144: -              fprintf(outs, "incl locprof+%d\n", 4*cnt++);
                   1145: -              fprintf(outs, "movw (sp)+,(sp)\n");
                   1146: -              fprintf(outs, "bicpsw $0xff\n");
                   1147: -              fprintf(outs, "bispsw (sp)+\n");
                   1148: -              /* thanks to kirk mckusick */
                   1149: -      }
                   1150: -      state = SBBLK;
                   1151: -}
                   1152: -
                   1153: -outinstr()
                   1154: -{     int i;
                   1155: -      for(i = lastline + 1; i <= lineno; i++)
                   1156: -              fprintf(outl, "%d %s: %d\n", 4*(cnt - 1), fname, i);
                   1157: -      lastline = lineno;
                   1158: -      fprintf(outl, "%d %s", 4*(cnt - 1), ptr);
                   1159: -}
                   1160: -
                   1161: -prolog(x)     /* no liveness test, presumes can't get here by jump */
                   1162: -struct inst *x;
                   1163: -{     int i;
                   1164: -      fprintf(outs, ".data\n");
                   1165: -      fprintf(outs, ".comm _proFptr,4\n");    /* the global chain */
                   1166: -      fprintf(outs, ".text\n");
                   1167: -      fprintf(outs, "tstl locprof+4\n");
                   1168: -      fprintf(outs, "bneq L%da\n", i = cnt);
                   1169: -      fprintf(outs, "movl _proFptr,locprof+4\n");
                   1170: -      fprintf(outs, "moval locprof,_proFptr\n");
                   1171: -      fprintf(outs, "L%da: incl locprof+%d\n", i, 4*cnt++);
                   1172: -      state = SBBLK;
                   1173: -      fprintf(outl, "%d %s: %s\n", 4*(cnt-1), fname, curfunc);
                   1174: -}
                   1175: -
                   1176: -finish()
                   1177: -{     int i;
                   1178: -      fprintf(outs, ".data\n");
                   1179: -      fprintf(outs, "locprof: .long %d\n", cnt);
                   1180: -      fprintf(outs, ".long 0\n");
                   1181: -      fprintf(outs, ".long L%db\n", cnt);
                   1182: -      fprintf(outs, ".space %d\n", 4 * cnt);
                   1183: -      fprintf(outs, "L%db: .byte ", cnt);
                   1184: -      for(i = 0; curdir[i]; i++)
                   1185: -              fprintf(outs, "0x%x,", curdir[i]);
                   1186: -      fprintf(outs, "0x%x\n", '/');
                   1187: -      fprintf(outs, ".byte ");
                   1188: -      if(fname[0])
                   1189: -              for(i = 0; fname[i]; i++)
                   1190: -                      fprintf(outs, "0x%x,", fname[i]);
                   1191: -      else
                   1192: -              for(i = 0; curarg[i]; i++)
                   1193: -                      fprintf(outs, "0x%x,", curarg[i]);
                   1194: -      fprintf(outs, "0\n");
                   1195: -}
                   1196: -
                   1197: -fixinstr(x)
                   1198: -struct inst *x;
                   1199: -{
                   1200: -      if(x->iname[0] == 'b')
                   1201: -              *ptr = 'j';     /* let assembler worry about branches */
                   1202: -      /* this is where the code for aob and sob goes */
                   1203: -}
                   1204: //GO.SYSIN DD bb.c
                   1205: echo instr.c 1>&2
                   1206: sed 's/.//' >instr.c <<'//GO.SYSIN DD instr.c'
                   1207: -#define K     1       /* kills all condition codes */
                   1208: -#define JUMP  2       /* ends a basic block */
                   1209: -#define BYTE  4       /* target is byte offset */
                   1210: -#define C     8       /* kills all condition codes but for C bit*/
                   1211: -/* if((p->type & EXPAND) && p->iname[0] == 'b') replace first char with j */
                   1212: -/* aob and sob get replaced by two instructions */
                   1213: -
                   1214: -struct inst {
                   1215: -      char *iname;
                   1216: -      short type;
                   1217: -} insts[] = {
                   1218: -"acbb", C | JUMP,
                   1219: -"acbd", C | JUMP,
                   1220: -"acbf", C | JUMP,
                   1221: -"acbg", C | JUMP,
                   1222: -"acbh", C | JUMP,
                   1223: -"acbl", C | JUMP,
                   1224: -"acbw", C | JUMP,
                   1225: -"adawi", K,
                   1226: -"addb2", K,
                   1227: -"addb3", K,
                   1228: -"addd2", K,
                   1229: -"addd3", K,
                   1230: -"addf2", K,
                   1231: -"addf3", K,
                   1232: -"addg2", K,
                   1233: -"addg3", K,
                   1234: -"addh2", K,
                   1235: -"addh3", K,
                   1236: -"addl2", K,
                   1237: -"addl3", K,
                   1238: -"addp4", K,
                   1239: -"addp6", K,
                   1240: -"addw2", K,
                   1241: -"addw3", K,
                   1242: -"adwc", K,
                   1243: -"aobleq", C | JUMP | BYTE,
                   1244: -"aoblss", C | JUMP | BYTE,
                   1245: -"ashl", C,
                   1246: -"ashp", K,
                   1247: -"ashq", C,
                   1248: -"bbc", JUMP | BYTE,
                   1249: -"bbcc", JUMP | BYTE,
                   1250: -"bbcci", JUMP | BYTE,
                   1251: -"bbcs", JUMP | BYTE,
                   1252: -"bbs", JUMP | BYTE,
                   1253: -"bbsc", JUMP | BYTE,
                   1254: -"bbss", JUMP | BYTE,
                   1255: -"bbssi", JUMP | BYTE,
                   1256: -"bcc", JUMP | BYTE,
                   1257: -"bcs", JUMP | BYTE,
                   1258: -"beql", JUMP | BYTE,
                   1259: -"beqlu", JUMP | BYTE,
                   1260: -"bgeq", JUMP | BYTE,
                   1261: -"bgequ", JUMP | BYTE,
                   1262: -"bgtr", JUMP | BYTE,
                   1263: -"bgtru", JUMP | BYTE,
                   1264: -"bicb2", C,
                   1265: -"bicb3", C,
                   1266: -"bicl2", C,
                   1267: -"bicl3", C,
                   1268: -"bicpsw", K,
                   1269: -"bicw2", C,
                   1270: -"bicw3", C,
                   1271: -"bisb2", C,
                   1272: -"bisb3", C,
                   1273: -"bisl2", C,
                   1274: -"bisl3", C,
                   1275: -"bispsw", K,
                   1276: -"bisw2", C,
                   1277: -"bisw3", C,
                   1278: -"bitb", C,
                   1279: -"bitl", C,
                   1280: -"bitw", C,
                   1281: -"blbc", JUMP | BYTE,
                   1282: -"blbs", JUMP | BYTE,
                   1283: -"bleq", JUMP | BYTE,
                   1284: -"blequ", JUMP | BYTE,
                   1285: -"blss", JUMP | BYTE,
                   1286: -"blssu", JUMP | BYTE,
                   1287: -"bneq", JUMP | BYTE,
                   1288: -"bnequ", JUMP | BYTE,
                   1289: -"bpt",        K,
                   1290: -"brb", JUMP | BYTE,
                   1291: -"brw", JUMP,
                   1292: -"bsbb", JUMP | BYTE,
                   1293: -"bsbw", JUMP,
                   1294: -"bugl", 0,
                   1295: -"bugw", 0,
                   1296: -"bvc", JUMP | BYTE,
                   1297: -"bvs", JUMP | BYTE,
                   1298: -"callg", K,
                   1299: -"calls", K,
                   1300: -"caseb", K | JUMP,
                   1301: -"casel", K | JUMP,
                   1302: -"casew", K | JUMP,
                   1303: -"chme", K,
                   1304: -"chmk", K,
                   1305: -"chms", K,
                   1306: -"chmu", K,
                   1307: -"clrb", C,
                   1308: -"clrd", C,
                   1309: -"clrf", C,
                   1310: -"clrg", C,
                   1311: -"clrh", C,
                   1312: -"clrl", C,
                   1313: -"clro", C,
                   1314: -"clrq", C,
                   1315: -"clrw", C,
                   1316: -"cmpb", K,
                   1317: -"cmpc3", K,
                   1318: -"cmpc5", K,
                   1319: -"cmpd", K,
                   1320: -"cmpf", K,
                   1321: -"cmpg", K,
                   1322: -"cmph", K,
                   1323: -"cmpl", K,
                   1324: -"cmpp3", C,
                   1325: -"cmpp4", C,
                   1326: -"cmpv", K,
                   1327: -"cmpw", K,
                   1328: -"cmpzv", K,
                   1329: -"crc", C,
                   1330: -"cvtbd", K,
                   1331: -"cvtbf", K,
                   1332: -"cvtbg", K,
                   1333: -"cvtbh", K,
                   1334: -"cvtbl", K,
                   1335: -"cvtbw", K,
                   1336: -"cvtdb", K,
                   1337: -"cvtdf", K,
                   1338: -"cvtdh", K,
                   1339: -"cvtdl", K,
                   1340: -"cvtdw", K,
                   1341: -"cvtfb", K,
                   1342: -"cvtfd", K,
                   1343: -"cvtfg", K,
                   1344: -"cvtfh", K,
                   1345: -"cvtfl", K,
                   1346: -"cvtfw", K,
                   1347: -"cvtgb", K,
                   1348: -"cvtgf", K,
                   1349: -"cvtgh", K,
                   1350: -"cvtgl", K,
                   1351: -"cvtgw", K,
                   1352: -"cvthb", K,
                   1353: -"cvthd", K,
                   1354: -"cvthf", K,
                   1355: -"cvthg", K,
                   1356: -"cvthl", K,
                   1357: -"cvthw", K,
                   1358: -"cvtlb", K,
                   1359: -"cvtld", K,
                   1360: -"cvtlf", K,
                   1361: -"cvtlg", K,
                   1362: -"cvtlh", K,
                   1363: -"cvtlp", K,
                   1364: -"cvtlw", K,
                   1365: -"cvtpl", K,
                   1366: -"cvtps", K,
                   1367: -"cvtpt", K,
                   1368: -"cvtrdl", K,
                   1369: -"cvtrfl", K,
                   1370: -"cvtrgl", K,
                   1371: -"cvtrhl", K,
                   1372: -"cvtsp", K,
                   1373: -"cvttp", K,
                   1374: -"cvtwb", K,
                   1375: -"cvtwd", K,
                   1376: -"cvtwf", K,
                   1377: -"cvtwg", K,
                   1378: -"cvtwh", K,
                   1379: -"cvtwl", K,
                   1380: -"decb", K,
                   1381: -"decl", K,
                   1382: -"decw", K,
                   1383: -"divb2", K,
                   1384: -"divb3", K,
                   1385: -"divd2", K,
                   1386: -"divd3", K,
                   1387: -"divf2", K,
                   1388: -"divf3", K,
                   1389: -"divg2", K,
                   1390: -"divg3", K,
                   1391: -"divh2", K,
                   1392: -"divh3", K,
                   1393: -"divl2", K,
                   1394: -"divl3", K,
                   1395: -"divp", K,
                   1396: -"divw2", K,
                   1397: -"divw3", K,
                   1398: -"editpc", K,
                   1399: -"ediv", K,
                   1400: -"emodd", K,
                   1401: -"emodf", K,
                   1402: -"emodg", K,
                   1403: -"emodh", K,
                   1404: -"emul", K,
                   1405: -"escd", 0,
                   1406: -"esce", 0,
                   1407: -"escf", 0,
                   1408: -"extv", K,
                   1409: -"extzv", K,
                   1410: -"ffc", K,
                   1411: -"ffs", K,
                   1412: -"halt",       JUMP,
                   1413: -"incb", K,
                   1414: -"incl", K,
                   1415: -"incw", K,
                   1416: -"index", K,
                   1417: -"insqhi", K,
                   1418: -"insqti", K,
                   1419: -"insque", K,
                   1420: -"insv",       0,
                   1421: -"jbc", JUMP,
                   1422: -"jbcc", JUMP,
                   1423: -"jbcs", JUMP,
                   1424: -"jbr", JUMP,
                   1425: -"jbs", JUMP,
                   1426: -"jbsc", JUMP,
                   1427: -"jbss", JUMP,
                   1428: -"jcc", JUMP,
                   1429: -"jcs", JUMP,
                   1430: -"jeql", JUMP,
                   1431: -"jeqlu", JUMP,
                   1432: -"jgeq", JUMP,
                   1433: -"jgequ", JUMP,
                   1434: -"jgtr", JUMP,
                   1435: -"jgtru", JUMP,
                   1436: -"jlbc", JUMP,
                   1437: -"jlbs", JUMP,
                   1438: -"jleq", JUMP,
                   1439: -"jlequ", JUMP,
                   1440: -"jlss", JUMP,
                   1441: -"jlssu", JUMP,
                   1442: -"jmp", JUMP,
                   1443: -"jneq", JUMP,
                   1444: -"jnequ", JUMP,
                   1445: -"jsb", JUMP,
                   1446: -"jvc", JUMP,
                   1447: -"jvs", JUMP,
                   1448: -"ldpctx", 0,
                   1449: -"locc", K,
                   1450: -"matchc", K,
                   1451: -"mcomb", C,
                   1452: -"mcoml", C,
                   1453: -"mcomw", C,
                   1454: -"mfpr",       C,
                   1455: -"mnegb", K,
                   1456: -"mnegd", K,
                   1457: -"mnegf", K,
                   1458: -"mnegg", K,
                   1459: -"mnegh", K,
                   1460: -"mnegl", K,
                   1461: -"mnegw", K,
                   1462: -"movab", C,
                   1463: -"movad", C,
                   1464: -"movaf", C,
                   1465: -"movag", C,
                   1466: -"movah", C,
                   1467: -"moval", C,
                   1468: -"movao", C,
                   1469: -"movaq", C,
                   1470: -"movaw", C,
                   1471: -"movb",       C,
                   1472: -"movc3", K,
                   1473: -"movc5", K,
                   1474: -"movd",       C,
                   1475: -"movf",       C,
                   1476: -"movg", C,
                   1477: -"movh", C,
                   1478: -"movl",       C,
                   1479: -"movo", C,
                   1480: -"movp", C,
                   1481: -"movpsl", 0,
                   1482: -"movq",       C,
                   1483: -"movtc", K,
                   1484: -"movtuc", K,
                   1485: -"movw",       C,
                   1486: -"movzbl", C,
                   1487: -"movzbw", C,
                   1488: -"movzwl", C,
                   1489: -"mtpr",       C,
                   1490: -"mulb2", K,
                   1491: -"mulb3", K,
                   1492: -"muld2", K,
                   1493: -"muld3", K,
                   1494: -"mulf2", K,
                   1495: -"mulf3", K,
                   1496: -"mulg2", K,
                   1497: -"mulg3", K,
                   1498: -"mulh2", K,
                   1499: -"mulh3", K,
                   1500: -"mull2", K,
                   1501: -"mull3", K,
                   1502: -"mulp", K,
                   1503: -"mulw2", K,
                   1504: -"mulw3", K,
                   1505: -"nop", 0,
                   1506: -"polyd", K,
                   1507: -"polyf", K,
                   1508: -"polyg", K,
                   1509: -"polyh", K,
                   1510: -"popr", 0,
                   1511: -"prober", K,
                   1512: -"probew", K,
                   1513: -"pushab", C,
                   1514: -"pushad", C,
                   1515: -"pushaf", C,
                   1516: -"pushag", C,
                   1517: -"pushah", C,
                   1518: -"pushal", C,
                   1519: -"pushao", C,
                   1520: -"pushaq", C,
                   1521: -"pushaw", C,
                   1522: -"pushl", C,
                   1523: -"pushr", 0,
                   1524: -"rei", K,
                   1525: -"remqhi", K,
                   1526: -"remqti", K,
                   1527: -"remque", K,
                   1528: -"ret", K | JUMP,
                   1529: -"rotl", C,
                   1530: -"rsb", 0,
                   1531: -"sbwc", K,
                   1532: -"scanc", K,
                   1533: -"skpc", K,
                   1534: -"sobgeq", C | JUMP | BYTE,
                   1535: -"sobgtr", C | JUMP | BYTE,
                   1536: -"spanc", K,
                   1537: -"subb2", K,
                   1538: -"subb3", K,
                   1539: -"subd2", K,
                   1540: -"subd3", K,
                   1541: -"subf2", K,
                   1542: -"subf3", K,
                   1543: -"subg2", K,
                   1544: -"subg3", K,
                   1545: -"subh2", K,
                   1546: -"subh3", K,
                   1547: -"subl2", K,
                   1548: -"subl3", K,
                   1549: -"subp4", K,
                   1550: -"subp6", K,
                   1551: -"subw2", K,
                   1552: -"subw3", K,
                   1553: -"svpctx", 0,
                   1554: -"tstb", K,
                   1555: -"tstd", K,
                   1556: -"tstf", K,
                   1557: -"tstg", K,
                   1558: -"tstl", K,
                   1559: -"tstw", K,
                   1560: -"tstw", K,
                   1561: -"xfc",        K | JUMP,
                   1562: -"xorb2", C,
                   1563: -"xorb3", C,
                   1564: -"xorl2", C,
                   1565: -"xorl3", C,
                   1566: -"xorw2", C,
                   1567: -"xorw3", C,
                   1568: -0, 0
                   1569: -};
                   1570: //GO.SYSIN DD instr.c
                   1571: echo lcomp.1 1>&2
                   1572: sed 's/.//' >lcomp.1 <<'//GO.SYSIN DD lcomp.1'
                   1573: -.TH LCOMP 1
                   1574: -.SH NAME
                   1575: -lcomp, lprint \(mi line-by-line profiler
                   1576: -.SH SYNOPSIS
                   1577: -.B lcomp
                   1578: -[ option ... ] file ...
                   1579: -.PP
                   1580: -.B lprint
                   1581: -[ option ] [ file ... ]
                   1582: -.SH DESCRIPTION
                   1583: -.I Lcomp
                   1584: -is used in place of
                   1585: -.I cc (1)
                   1586: -or
                   1587: -.I f77 (1)
                   1588: -to insert instruction-counting code into programs.
                   1589: -It recognizes options whose initial letters are taken from the string
                   1590: -.LR CwpDUIRdlNnz ,
                   1591: -and accepts files whose names end in
                   1592: -.LR .c ,
                   1593: -.LR .f ,
                   1594: -.LR .s ,
                   1595: -or
                   1596: -.LR .o .
                   1597: -From each source file it derives a 
                   1598: -.L .o
                   1599: -file and a
                   1600: -.L .sL
                   1601: -file which
                   1602: -.I lprint
                   1603: -uses to correlate source lines with basic blocks.
                   1604: -.PP
                   1605: -Option
                   1606: -.B -C
                   1607: -declares that
                   1608: -.L .c
                   1609: -files (and
                   1610: -.L .o
                   1611: -files, if no source files are named)
                   1612: -are C++ files.
                   1613: -If the
                   1614: -.B -c
                   1615: -option is not present
                   1616: -.I lcomp
                   1617: -creates
                   1618: -.FR a.out .
                   1619: -Each time
                   1620: -.F a.out
                   1621: -is run statistics are added
                   1622: -to a profiling file
                   1623: -.FR prof.out .
                   1624: -.PP
                   1625: -.I Lprint
                   1626: -produces on the standard output a listing (in the style of
                   1627: -.IR pr (1))
                   1628: -of the programs compiled by
                   1629: -.I lcomp.
                   1630: -Without arguments or files,
                   1631: -each line of the listing is preceded by the number of times it was executed,
                   1632: -as determined from the data in
                   1633: -.FR prof.out .
                   1634: -.I Lprint
                   1635: -interprets the following options.
                   1636: -.TP
                   1637: -.B -a
                   1638: -Detailed listing of every machine instruction and how often it was executed.
                   1639: -.TP
                   1640: -.B -b
                   1641: -How often each basic block was executed.
                   1642: -.TP
                   1643: -.B -c
                   1644: -Compress the
                   1645: -.F prof.out
                   1646: -file, which otherwise grows with every execution of
                   1647: -.LR a.out .
                   1648: -.TP
                   1649: -.B -f
                   1650: -Print summary information by function: instruction executions, number of
                   1651: -invocations, source instructions, and number of instructions never executed.
                   1652: -.TP
                   1653: -.B -i
                   1654: -Before each line of source print the number of machine instructions executed.
                   1655: -.TP
                   1656: -.B -p
                   1657: -Before each line of source print the number of times the first basic block
                   1658: -in that line was executed.
                   1659: -.TP
                   1660: -.B -s
                   1661: -Summarize the counts by source file: instruction exectuions, source
                   1662: -instructions, instructions never executed, basic block executions, total
                   1663: -number of source basic blocks, and how many were never executed.
                   1664: -.PP
                   1665: -If any file names are given, the arguments
                   1666: -.L abip
                   1667: -apply only to them.
                   1668: -If no options are given,
                   1669: -.L -p
                   1670: -is assumed.
                   1671: -Any combination of options is allowed.
                   1672: -.SH FILES
                   1673: -.TF /usr/lib/nexit.o  
                   1674: -.TP
                   1675: -.F prof.out
                   1676: -counts
                   1677: -.TP
                   1678: -.F *.sL
                   1679: -for correlating with source
                   1680: -.TP
                   1681: -.F /usr/lib/bb
                   1682: -for finding basic blocks and inserting counting code
                   1683: -.TP
                   1684: -.F /usr/lib/nexit.o
                   1685: -for printing counts when
                   1686: -.L a.out
                   1687: -exits
                   1688: -.SH "SEE ALSO"
                   1689: -cc(1), f77(1)
                   1690: -.SH BUGS
                   1691: -A line in the source file may be in zero, one, or more basic
                   1692: -blocks;
                   1693: -the count given in the listing corresponds to some particular
                   1694: -choice of the basic block to associate with the line.
                   1695: -.br
                   1696: -Processing the output of
                   1697: -.IR yacc (1)
                   1698: -without removing
                   1699: -.L #line
                   1700: -directives will produce unsatisfactory results.
                   1701: -.br
                   1702: -Option
                   1703: -.B -C
                   1704: -masks an option of
                   1705: -.IR cc (1).
                   1706: //GO.SYSIN DD lcomp.1
                   1707: echo lprint.c 1>&2
                   1708: sed 's/.//' >lprint.c <<'//GO.SYSIN DD lprint.c'
                   1709: -#include "stdio.h"
                   1710: -#include "ctype.h"
                   1711: -typedef unsigned long ul;
                   1712: -typedef struct {
                   1713: -      char *fname;
                   1714: -      int len;        /* how many counts have been seen */
                   1715: -      int quot;       /* how much has been allocated for cnt */
                   1716: -      int flag;
                   1717: -      unsigned long *cnt;     /* the basic block counts */
                   1718: -      int *instrcnt;          /* instrs per basic block, from .sL */
                   1719: -      int *lastline;          /* last source line containing instr from bb */
                   1720: -} stab;
                   1721: -stab *tab;
                   1722: -int ntab, ltab;
                   1723: -unsigned long N, B, L, V;     /* for summary */
                   1724: -double A, U;
                   1725: -FILE *fd, *sfd, *cfd;
                   1726: -extern FILE *popen();
                   1727: -char fname[512] = "/";        /* not checked for overflow */
                   1728: -char buf[256];
                   1729: -char curfunc[256];
                   1730: -extern char *malloc();
                   1731: -char flg[128];
                   1732: -unsigned long val;
                   1733: -char prcmd[128] = "pr -h %s ";        /* space for extra args */
                   1734: -
                   1735: -main(argc, argv)
                   1736: -char **argv;
                   1737: -{     int i, j, seenpart = 0;
                   1738: -      if((fd = fopen("prof.out", "r")) == 0) {
                   1739: -              perror("prof.out");
                   1740: -              exit(1);
                   1741: -      }
                   1742: -      readall();
                   1743: -      fclose(fd);
                   1744: -      for(i = 1; i < argc; i++)
                   1745: -              if(argv[i][0] != '-') {
                   1746: -                      seenpart++;
                   1747: -                      okfile(argv[i]);
                   1748: -              }
                   1749: -              else for(j = 1; argv[i][j]; j++)
                   1750: -                      switch(argv[i][j]) {
                   1751: -                      default:        /* assume whole thing is for pr */
                   1752: -                              strcat(prcmd, argv[i]);
                   1753: -                              strcat(prcmd, " ");
                   1754: -                              break;
                   1755: -                      case 'b':       /* each bb */
                   1756: -                              flg['b']++;
                   1757: -                              break;
                   1758: -                      case 'a':       /* intermediate everything */
                   1759: -                              flg['a']++;
                   1760: -                              break;
                   1761: -                      case 'i':       /* count machine instrs */
                   1762: -                              flg['i']++;
                   1763: -                              break;
                   1764: -                      case 'f':       /* counts by function */
                   1765: -                              flg['f']++;
                   1766: -                              flg['s']++;
                   1767: -                              break;
                   1768: -                      case 'p':       /* print, in addition */
                   1769: -                              flg['p']++;
                   1770: -                              break;
                   1771: -                      case 's':       /* bb summary */
                   1772: -                              flg['s']++;
                   1773: -                              break;
                   1774: -                      case 'c':       /* compress prof.out */
                   1775: -                              flg['c']++;
                   1776: -                              break;
                   1777: -                      }
                   1778: -      if(argc <= seenpart + 1)
                   1779: -              flg['p']++;
                   1780: -      if(!seenpart)
                   1781: -              for(i = 0; i < ntab; i++)
                   1782: -                      tab[i].flag = 1;
                   1783: -      if(flg['f']) {
                   1784: -              for(i = 0; i < ntab; i++)
                   1785: -                      fsum(tab + i);
                   1786: -      }
                   1787: -      if(flg['s']) {
                   1788: -              for(i = 0; i < ntab; i++)
                   1789: -                      summary(tab + i);
                   1790: -              if(ntab > 1)
                   1791: -                      printf("%.0fie %ui %uin %.0fbbe %ubb %ubbne total\n",
                   1792: -                              A, N, B, U, L, V);
                   1793: -      }
                   1794: -      if(flg['c']) {
                   1795: -              fd = fopen("prof.out", "w");
                   1796: -              if(fd == 0) {
                   1797: -                      perror("rewriting prof.out");
                   1798: -                      exit(1);
                   1799: -              }
                   1800: -              for(i = 0; i < ntab; i++) {
                   1801: -                      fprintf(fd, "%s\n", tab[i].fname);
                   1802: -                      for(j = 0; j < tab[i].len; j++)
                   1803: -                              fprintf(fd, "%u\n", tab[i].cnt[j]);
                   1804: -              }
                   1805: -              fclose(fd);
                   1806: -      }
                   1807: -      if(flg['p'] || flg['i'] || flg['a'] || flg['b'])
                   1808: -              giantprint();
                   1809: -      exit(0);
                   1810: -}
                   1811: -
                   1812: -okfile(s)
                   1813: -char *s;
                   1814: -{     int i, j, k;
                   1815: -      j = strlen(s);
                   1816: -      for(i = 0; i < ntab; i++) {
                   1817: -              k = strlen(tab[i].fname);
                   1818: -              if(strcmp(s, tab[i].fname + k - j) == 0) {
                   1819: -                      tab[i].flag = 1;
                   1820: -                      return;
                   1821: -              }
                   1822: -      }
                   1823: -      fprintf(stderr, "argument %s not a source file\n", s);
                   1824: -      exit(1);
                   1825: -}
                   1826: -
                   1827: -readall()
                   1828: -{     int c, i, index;
                   1829: -      stab *curtab = 0;
                   1830: -sawnl:
                   1831: -      if((c = getc(fd)) == EOF)
                   1832: -              return;
                   1833: -      if(c == '\n')
                   1834: -              goto sawnl;
                   1835: -      if(c == '/') {
                   1836: -              fscanf(fd, "%s", fname+1);
                   1837: -              for(i = 0; i < ntab; i++)
                   1838: -                      if(strcmp(fname, tab[i].fname) == 0)
                   1839: -                              break;
                   1840: -              if(i >= ntab) { /* new file */
                   1841: -                      if(ltab == 0) {
                   1842: -                              tab = (stab *)malloc(20 * sizeof(stab));
                   1843: -                              ltab = 20;
                   1844: -                      }
                   1845: -                      else if(ntab >= ltab)
                   1846: -                              tab = (stab *)realloc((char *)tab,
                   1847: -                                      (ltab += 20) * sizeof(stab));
                   1848: -                      tab[ntab].fname = malloc(sizeof(fname) + 1);
                   1849: -                      strcpy(tab[ntab].fname, fname);
                   1850: -                      tab[ntab].flag = tab[ntab].len = tab[ntab].quot = 0;
                   1851: -                      ntab++;
                   1852: -              }
                   1853: -              curtab = tab + i;
                   1854: -              index = 0;
                   1855: -      }
                   1856: -      else if(c < '0' || c > '9') {
                   1857: -              fprintf(stderr, "prof.out has weird format\n");
                   1858: -              abort();
                   1859: -      }
                   1860: -      else {
                   1861: -              ungetc(c, fd);
                   1862: -              fscanf(fd, "%d", &val);
                   1863: -              if(curtab->len <= index) {
                   1864: -                      if(curtab->quot == 0) {
                   1865: -                              curtab->cnt = (ul *)malloc(100*sizeof(long));
                   1866: -                              curtab->quot = 100;
                   1867: -                              for(i = 0; i < 100; i++)
                   1868: -                                      curtab->cnt[i] = 0;
                   1869: -                      }
                   1870: -                      else if(curtab->len >= curtab->quot) {
                   1871: -                              curtab->cnt = (ul *)realloc((char *)curtab->cnt,
                   1872: -                                      (curtab->quot += 200) * sizeof(long));
                   1873: -                              for(i = curtab->quot-200; i < curtab->quot; i++)
                   1874: -                                      curtab->cnt[i] = 0;
                   1875: -                      }
                   1876: -                      curtab->len++;
                   1877: -              }
                   1878: -              curtab->cnt[index++] += val;
                   1879: -      }
                   1880: -      goto sawnl;
                   1881: -}
                   1882: -
                   1883: -summary(x)
                   1884: -stab *x;
                   1885: -{     unsigned long i, v, n, b;
                   1886: -      double a, u;
                   1887: -      for(i = u = v = 0; i < x->len; i++)
                   1888: -              if(x->cnt[i])
                   1889: -                      u += x->cnt[i];
                   1890: -              else
                   1891: -                      v++;
                   1892: -      n = strlen(x->fname);
                   1893: -      strcpy(buf, x->fname);
                   1894: -      strcpy(buf + n - 2, ".sL");
                   1895: -      if((fd = fopen(buf, "r")) == 0) {
                   1896: -              perror(buf);
                   1897: -              printf("%s %u bbs %.0f execs %u untouched\n",
                   1898: -                      x->fname, x->len, u, v);
                   1899: -              return;
                   1900: -      }
                   1901: -      for(n = a = b = 0; ;) {
                   1902: -              (void) fgets(buf, sizeof(buf), fd);
                   1903: -              if(feof(fd))
                   1904: -                      break;
                   1905: -              if(hascolon(buf))
                   1906: -                      continue;
                   1907: -              n++;
                   1908: -              i = atoi(buf)/4 - 3;
                   1909: -              if(x->cnt[i])
                   1910: -                      a += x->cnt[i];
                   1911: -              else
                   1912: -                      b++;
                   1913: -      }
                   1914: -      printf("%.0fie %ui %uine %.0fbbe %ubb %ubbne %s\n", a, n, b, u, x->len,
                   1915: -              v, x->fname);
                   1916: -      fclose(fd);
                   1917: -      A += a; N += n; B += b; U += u; L += x->len; V += v;
                   1918: -}
                   1919: -
                   1920: -fsum(x)
                   1921: -stab *x;
                   1922: -{     unsigned i, v, n, b, cnt;
                   1923: -      double a, u;
                   1924: -      char *p;
                   1925: -      strcpy(buf, x->fname);
                   1926: -      n = strlen(x->fname);
                   1927: -      strcpy(buf + n - 2, ".sL");
                   1928: -      if((fd = fopen(buf, "r")) == 0) {
                   1929: -              perror(buf);
                   1930: -              return;
                   1931: -      }
                   1932: -      curfunc[0] = 0;
                   1933: -      for(cnt = v = n = b = a = u = 0;;) {
                   1934: -              (void) fgets(buf, sizeof(buf), fd);
                   1935: -              if(feof(fd))
                   1936: -                      break;
                   1937: -              if(hascolon(buf)) {
                   1938: -                      /* 24 foo.c: 456        or
                   1939: -                       * 24 foo.c: _funcjunk */
                   1940: -                      for(p = buf; *p != ':'; p++)
                   1941: -                              ;
                   1942: -                      while(isspace(*++p))
                   1943: -                              ;
                   1944: -                      if(isdigit(*p))
                   1945: -                              continue;
                   1946: -                      if(curfunc[0] != 0)
                   1947: -                              printf("%.0fie %dcalls %ui %uine %s\n",
                   1948: -                                      a, v, n, b, curfunc);
                   1949: -                      for(i = 0; *p && *p != '\n'; i++)
                   1950: -                              curfunc[i] = *p++;
                   1951: -                      curfunc[i] = 0;
                   1952: -                      a = n = b = 0;
                   1953: -                      i = atoi(buf)/4 - 3;
                   1954: -                      v = x->cnt[i];
                   1955: -                      continue;
                   1956: -              }
                   1957: -              n++;
                   1958: -              i = atoi(buf)/4 - 3;
                   1959: -              if(x->cnt[i])
                   1960: -                      a += x->cnt[i];
                   1961: -              else
                   1962: -                      b++;
                   1963: -      }
                   1964: -      if(n > 0)
                   1965: -              printf("%.0fie %dcalls %ui %uine %s\n", a, v, n, b, curfunc);
                   1966: -      fclose(fd);
                   1967: -}
                   1968: -
                   1969: -giantprint()
                   1970: -{     int i, n;
                   1971: -      for(i = 0; i < ntab; i++) {
                   1972: -              if(tab[i].flag == 0)
                   1973: -                      continue;
                   1974: -      /* the fname file is the source, there should be a corresponding
                   1975: -       * .sL file for correlation between basic blocks and source.
                   1976: -       * If fname is a .s file, the .sL file is all there is */
                   1977: -              n = strlen(tab[i].fname);
                   1978: -              if(strcmp(".s", tab[i].fname + n - 2) == 0) {
                   1979: -                      sfile(tab + i);
                   1980: -                      continue;
                   1981: -              }
                   1982: -              sfd = fopen(tab[i].fname, "r");
                   1983: -              if(sfd == 0 && !flg['a']) {
                   1984: -                      perror(tab[i].fname);
                   1985: -                      return;
                   1986: -              }
                   1987: -              strcpy(buf, tab[i].fname);
                   1988: -              strcpy(buf + n - 1, "sL");
                   1989: -              if((cfd = fopen(buf, "r")) == 0) {
                   1990: -                      fprintf(stderr, "no intermediate listing file ");
                   1991: -                      perror(buf);
                   1992: -                      fclose(sfd);
                   1993: -                      return;
                   1994: -              }
                   1995: -              sprintf(buf, prcmd, tab[i].fname);
                   1996: -              if(!flg['a'])
                   1997: -                      fd = popen(buf, "w");
                   1998: -              if(!flg['a'])
                   1999: -                      xlistit(tab + i);
                   2000: -              else
                   2001: -                      listit(tab + i);
                   2002: -              if(fd)
                   2003: -                      pclose(fd);
                   2004: -              if(sfd)
                   2005: -                      fclose(sfd);
                   2006: -              fclose(cfd);
                   2007: -      }
                   2008: -}
                   2009: -
                   2010: -sfile(x)
                   2011: -stab *x;
                   2012: -{     int i;
                   2013: -      char *p;
                   2014: -      strcpy(buf, x->fname);
                   2015: -      strcat(buf, "L");
                   2016: -      sfd = fopen(buf, "r");
                   2017: -      if(sfd == 0) {
                   2018: -              perror(buf);
                   2019: -              return;
                   2020: -      }
                   2021: -      sprintf(buf, "pr -h %s", x->fname);
                   2022: -      fd = popen(buf, "w");
                   2023: -      if(fd == 0) {
                   2024: -              perror(buf);
                   2025: -              fclose(sfd);
                   2026: -              return;
                   2027: -      }
                   2028: -      for(;;) {
                   2029: -              (void) fgets(buf, sizeof(buf), sfd);
                   2030: -              if(feof(sfd)) {
                   2031: -                      pclose(fd);
                   2032: -                      fclose(sfd);
                   2033: -                      return;
                   2034: -              }
                   2035: -              for(i = 0, p = buf; *p >= '0' && *p <= '9'; p++)
                   2036: -                      i = 10 * i + *p - '0';
                   2037: -              i = i/4 - 3;
                   2038: -              fprintf(fd, "%u\t%s", x->cnt[i], p);
                   2039: -      }
                   2040: -}
                   2041: -
                   2042: -/* function added, so name (stripnum) is now misleading */
                   2043: -char *
                   2044: -stripnum(s)
                   2045: -char *s;
                   2046: -{     char *p;
                   2047: -      while(*s && (isdigit(*s) || isspace(*s)))
                   2048: -              s++;
                   2049: -      for(p = s; *p && *p != '\n'; p++)
                   2050: -              ;
                   2051: -      if(*p == '\n')
                   2052: -              *p = ' ';
                   2053: -      return(s);
                   2054: -}
                   2055: -
                   2056: -listit(x)
                   2057: -stab *x;
                   2058: -{     int i;
                   2059: -      char *p;
                   2060: -      for(;;) {
                   2061: -              (void) fgets(buf, sizeof(buf), cfd);
                   2062: -              if(feof(cfd))
                   2063: -                      break;
                   2064: -              for(p = buf; *p && *p != ':' ; p++)
                   2065: -                      ;
                   2066: -              if(*p++ != ':') {       /* these are instructions */
                   2067: -                      i = x->cnt[atoi(buf)/4 - 3];
                   2068: -                      printf("%d\t%s\n", i, stripnum(buf));
                   2069: -                      continue;
                   2070: -              }
                   2071: -              else {
                   2072: -                      printf("%s", stripnum(buf));
                   2073: -                      if(atoi(p) == 0) {      /* foo.c: _main */
                   2074: -                              putchar('\n');
                   2075: -                              continue;
                   2076: -                      }
                   2077: -                      (void) fgets(buf, sizeof(buf), sfd);
                   2078: -                      printf("%s", buf);
                   2079: -                      continue;
                   2080: -              }
                   2081: -      }
                   2082: -}
                   2083: -
                   2084: -xlistit(x)
                   2085: -stab *x;
                   2086: -{     int lnum, i, icnt, bcnt;
                   2087: -      char *p;
                   2088: -      x->instrcnt = (int *) malloc(x->len * sizeof(int));
                   2089: -      x->lastline = (int *) malloc(x->len * sizeof(int));
                   2090: -      if(!x->instrcnt || !x->lastline) {
                   2091: -              fprintf(stderr, "out of memory\n");
                   2092: -              return;
                   2093: -      }
                   2094: -      for(i = 0; i < x->len; i++)
                   2095: -              x->instrcnt[i] = x->lastline[i] = 0;
                   2096: -      for(;;) {
                   2097: -              (void) fgets(buf, sizeof(buf), cfd);
                   2098: -              if(feof(cfd))
                   2099: -                      break;
                   2100: -              for(p = buf; *p && *p != ':'; p++)
                   2101: -                      ;
                   2102: -              if(*p++ != ':') {       /* instruction */
                   2103: -                      x->instrcnt[atoi(buf)/4 - 3]++;
                   2104: -                      continue;
                   2105: -              }
                   2106: -              lnum = atoi(p);         /* hmm (atoi (" x..") is zero?)*/
                   2107: -              if(lnum <= 0)
                   2108: -                      continue;
                   2109: -              i = atoi(buf)/4 - 3;
                   2110: -              x->lastline[i] = lnum;
                   2111: -      }
                   2112: -      /* now read all the source lines and print out appropriate stuff */
                   2113: -      for(lnum = 1, i = 0;; lnum++) {
                   2114: -              (void) fgets(buf, sizeof(buf), sfd);
                   2115: -              if(feof(sfd))
                   2116: -                      return;
                   2117: -              icnt = bcnt = 0;
                   2118: -              for(; i < x->len && x->lastline[i] <= lnum; i++) {
                   2119: -                      if(flg['b'] && flg['i'])
                   2120: -                              fprintf(fd, "%u,%ui ", x->cnt[i],
                   2121: -                                      x->cnt[i] * x->instrcnt[i]);
                   2122: -                      else if(flg['b'])
                   2123: -                              fprintf(fd, "%u ", x->cnt[i]);
                   2124: -                      else {
                   2125: -                              icnt += x->cnt[i] * x->instrcnt[i];
                   2126: -                              bcnt += x->cnt[i];
                   2127: -                      }
                   2128: -              }
                   2129: -              if(!flg['b'] && flg['p'] && bcnt)
                   2130: -                      fprintf(fd, "%u ", bcnt);
                   2131: -              if(!flg['b'] && flg['i'] && icnt)
                   2132: -                      fprintf(fd, "%ui ", icnt);
                   2133: -              fprintf(fd, "\t%s", buf);
                   2134: -      }
                   2135: -}
                   2136: -
                   2137: -hascolon(s)
                   2138: -register char *s;
                   2139: -{
                   2140: -      for(; *s && *s != ':'; s++)
                   2141: -              ;
                   2142: -      if(*s == ':')
                   2143: -              return(1);
                   2144: -      else
                   2145: -              return(0);
                   2146: -}
                   2147: //GO.SYSIN DD lprint.c
                   2148: echo lsub.c 1>&2
                   2149: sed 's/.//' >lsub.c <<'//GO.SYSIN DD lsub.c'
                   2150: -#include "stdio.h"
                   2151: -typedef unsigned long ul;
                   2152: -typedef struct {
                   2153: -      char *fname;
                   2154: -      int len;        /* how many counts have been seen */
                   2155: -      int quot;       /* how much has been allocated for cnt */
                   2156: -      unsigned long *cnt;
                   2157: -} stab;
                   2158: -stab *tab;
                   2159: -int ntab, ltab;
                   2160: -FILE *fd, *sfd, *cfd;
                   2161: -char buf[256];
                   2162: -char fname[512] = "/";
                   2163: -extern char *malloc();
                   2164: -char flg[128];
                   2165: -unsigned long val;
                   2166: -
                   2167: -main(argc, argv)
                   2168: -char **argv;
                   2169: -{     int i, j;
                   2170: -      if(argc <= 1) {
                   2171: -              fprintf(stderr, "subtract from where?\n");
                   2172: -              exit(1);
                   2173: -      }
                   2174: -      if((fd = fopen("prof.out", "r")) == 0) {
                   2175: -              perror("prof.out");
                   2176: -              exit(1);
                   2177: -      }
                   2178: -      readall(fd);
                   2179: -      fclose(fd);
                   2180: -      sfd = fopen(argv[1], "r");
                   2181: -      if(sfd == 0) {
                   2182: -              perror(argv[1]);
                   2183: -              exit(1);
                   2184: -      }
                   2185: -      suball(sfd);
                   2186: -      fclose(sfd);
                   2187: -      if((fd = fopen("prof.out", "w")) == 0) {
                   2188: -              perror(argv[1]);
                   2189: -              exit(1);
                   2190: -      }
                   2191: -      for(i = 0; i < ntab; i++)
                   2192: -              rewrite(tab + i);
                   2193: -      exit(0);
                   2194: -}
                   2195: -
                   2196: -readall(fd)
                   2197: -FILE *fd;
                   2198: -{     int c, i, index;
                   2199: -      stab *curtab = 0;
                   2200: -sawnl:
                   2201: -      if((c = getc(fd)) == EOF)
                   2202: -              return;
                   2203: -      if(c == '\n')
                   2204: -              goto sawnl;
                   2205: -      if(c == '/') {
                   2206: -              fscanf(fd, "%s", fname+1);
                   2207: -              for(i = 0; i < ntab; i++)
                   2208: -                      if(strcmp(fname, tab[i].fname) == 0)
                   2209: -                              break;
                   2210: -              if(i >= ntab) { /* new file */
                   2211: -                      if(ltab == 0) {
                   2212: -                              tab = (stab *)malloc(20 * sizeof(stab));
                   2213: -                              ltab = 20;
                   2214: -                      }
                   2215: -                      else if(ntab >= ltab)
                   2216: -                              tab = (stab *)realloc((char *)tab,
                   2217: -                                      (ltab += 20) * sizeof(stab));
                   2218: -                      tab[ntab].fname = malloc(sizeof(fname) + 1);
                   2219: -                      strcpy(tab[ntab].fname, fname);
                   2220: -                      tab[ntab].len = tab[ntab].quot = 0;
                   2221: -                      ntab++;
                   2222: -              }
                   2223: -              curtab = tab + i;
                   2224: -              index = 0;
                   2225: -      }
                   2226: -      else if(c < '0' || c > '9') {
                   2227: -              fprintf(stderr, "prof.out has weird format\n");
                   2228: -              abort();
                   2229: -      }
                   2230: -      else {
                   2231: -              ungetc(c, fd);
                   2232: -              fscanf(fd, "%d", &val);
                   2233: -              if(curtab->len <= index) {
                   2234: -                      if(curtab->quot == 0) {
                   2235: -                              curtab->cnt = (ul *)malloc(100*sizeof(long));
                   2236: -                              curtab->quot = 100;
                   2237: -                              for(i = 0; i < 100; i++)
                   2238: -                                      curtab->cnt[i] = 0;
                   2239: -                      }
                   2240: -                      else if(curtab->len >= curtab->quot) {
                   2241: -                              curtab->cnt = (ul *)realloc(curtab->cnt,
                   2242: -                                      (curtab->quot += 200) * sizeof(long));
                   2243: -                              for(i = curtab->quot-200; i < curtab->quot; i++)
                   2244: -                                      curtab->cnt[i] = 0;
                   2245: -                      }
                   2246: -                      curtab->len++;
                   2247: -              }
                   2248: -              curtab->cnt[index++] += val;
                   2249: -      }
                   2250: -      goto sawnl;
                   2251: -}
                   2252: -
                   2253: -rewrite(x)
                   2254: -stab *x;
                   2255: -{     int i;
                   2256: -      for(i = 0; i < x->len; i++)
                   2257: -              if(x->cnt[i])
                   2258: -                      break;
                   2259: -      if(i >= x->len)
                   2260: -              return;
                   2261: -      fprintf(fd, "%s\n", x->fname);
                   2262: -      for(i = 0; i < x->len; i++)
                   2263: -              fprintf(fd, "%u\n", x->cnt[i]);
                   2264: -}
                   2265: -suball(fd)
                   2266: -FILE *fd;
                   2267: -{     int c, i, index;
                   2268: -      stab *curtab = 0;
                   2269: -sawnl:
                   2270: -      if((c = getc(fd)) == EOF)
                   2271: -              return;
                   2272: -      if(c == '\n')
                   2273: -              goto sawnl;
                   2274: -      if(c == '/') {
                   2275: -              fscanf(fd, "%s", fname+1);
                   2276: -              for(i = 0; i < ntab; i++)
                   2277: -                      if(strcmp(fname, tab[i].fname) == 0)
                   2278: -                              break;
                   2279: -              if(i >= ntab) { /* new file */
                   2280: -                      fprintf(stderr, "new file %s ignored\n", fname);
                   2281: -                      goto sawnl;
                   2282: -              }
                   2283: -              curtab = tab + i;
                   2284: -              index = 0;
                   2285: -      }
                   2286: -      else if(c < '0' || c > '9') {
                   2287: -              fprintf(stderr, "prof.out has weird format\n");
                   2288: -              abort();
                   2289: -      }
                   2290: -      else {
                   2291: -              ungetc(c, fd);
                   2292: -              fscanf(fd, "%d", &val);
                   2293: -              curtab->cnt[index++] -= val;
                   2294: -      }
                   2295: -      goto sawnl;
                   2296: -}
                   2297: //GO.SYSIN DD lsub.c
                   2298: echo lcomp 1>&2
                   2299: sed 's/.//' >lcomp <<'//GO.SYSIN DD lcomp'
                   2300: -# lcomp recognizes the following arguments to cc: c, w, p, D, U, I g.
                   2301: -# lcomp recognizes the following arguments to f77: c, w, p.
                   2302: -# it does not accept ratfor or efl
                   2303: -# lcomp recognizes the following argument to as: R
                   2304: -# lcomp recognizes the following arguments to ld: d, l, N, n, z
                   2305: -# the output from -c is .o plus .sL
                   2306: -DIR=/usr/lib
                   2307: -COMP=${COMP-cc}
                   2308: -PATH=/bin:/usr/bin
                   2309: -for i in $*
                   2310: -do
                   2311: -      case $i in
                   2312: -      -c)     compflag=1
                   2313: -              ;;
                   2314: -      *.c)    clist="$clist $i"
                   2315: -              u=`basename $i | sed 's/c$//'`
                   2316: -              bblist="$bblist "$u"s"
                   2317: -              rmlist="$rmlist "$u"s"
                   2318: -              slist="$slist "X$u"s"
                   2319: -              llist="$llist "$u"o"
                   2320: -              ;;
                   2321: -      -D*|-I*|-U*)
                   2322: -              clist="$clist $i"
                   2323: -              ;;
                   2324: -      *.f)    flist="$flist "$i
                   2325: -              u=`basename $i | sed 's/f$//'`
                   2326: -              bblist="$bblist "$u"s"
                   2327: -              rmlist="$rmlist "$u"s"
                   2328: -              slist="$slist "X$u"s"
                   2329: -              llist="$llist "$u"o"
                   2330: -              ;;
                   2331: -      *.s)    bblist="$bblist "$i
                   2332: -              u=`basename $i | sed 's/s$//'`
                   2333: -              slist="$slist "X$u"s"
                   2334: -              llist="$llist "$u"o"
                   2335: -              ;;
                   2336: -      -w|-p|-R|-d|-l*|-N|-n|-t|-z|*.o|*.a)
                   2337: -              llist="$llist "$i
                   2338: -              ;;
                   2339: -      *)      echo incomprehensible argument $i ignored
                   2340: -              ;;
                   2341: -      -g)
                   2342: -              ;;
                   2343: -      esac
                   2344: -done
                   2345: -# get .s files
                   2346: -if test "$flist"
                   2347: -then
                   2348: -      f77 -g -S $flist
                   2349: -fi
                   2350: -if test "$clist"
                   2351: -then
                   2352: -      $COMP -g -S $clist
                   2353: -fi
                   2354: -# create X*.s and *.sL files
                   2355: -if test "$bblist"
                   2356: -then
                   2357: -      $DIR/bb $bblist
                   2358: -fi
                   2359: -# create X*.o files
                   2360: -if test "$flist"
                   2361: -then
                   2362: -      f77 -g -c $slist
                   2363: -elif test "$clist"
                   2364: -then
                   2365: -      $COMP -g -c $slist
                   2366: -fi
                   2367: -# make them into real .o files
                   2368: -if test "$rmlist"
                   2369: -then
                   2370: -      for i in X*.o
                   2371: -              do
                   2372: -              mv $i `echo $i | sed s/X//`
                   2373: -      done
                   2374: -fi
                   2375: -rm -f X*.s $rmlist prof.out
                   2376: -
                   2377: -if test $compflag
                   2378: -then  exit 0
                   2379: -fi
                   2380: -if test "$flist"
                   2381: -then
                   2382: -      f77 -g $DIR/nexit.o $llist
                   2383: -else
                   2384: -      $COMP -g $DIR/nexit.o $llist $lC
                   2385: -fi
                   2386: //GO.SYSIN DD lcomp

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.