|
|
1.1 ! root 1: # ! 2: # @(#)awkprog 1.1 86/02/03 SMI ! 3: # ! 4: ! 5: BEGIN{ ! 6: flavor = "AS" ! 7: FS = " " ! 8: MNEMONIC = 1 ! 9: OPTYPE = 2 ! 10: SUBOP = 3 ! 11: OPCODES = 4 ! 12: TOUCHOP = 5 ! 13: OPACCESS = 6 ! 14: CCODES = 7 ! 15: NASSOC = 8 ! 16: MACHINE = 9 ! 17: } ! 18: { ! 19: if (NF == 0){ ! 20: printf("\n") ! 21: next ! 22: } ! 23: if ($MNEMONIC == "FLAVOR"){ ! 24: flavor = $OPTYPE ! 25: next ! 26: } ! 27: if ($MNEMONIC == "##"){ ! 28: next ! 29: } ! 30: nop = split( $OPTYPE, op, "," ) ! 31: noperand = split( $TOUCHOP, touch, ",") ! 32: if (flavor == "C2"){ ! 33: if ( $OPTYPE == "PSEUDO" ){ ! 34: # flavor is C2, and this is a pseudoop ! 35: nop = split( $3, op, "," ) ! 36: printf( "P(\"%s\", OP_%s, %d, %d, SUBOP_%s )\n", $MNEMONIC, op[2], $5, $7, $4 ) ! 37: next ! 38: } ! 39: # flavor is C2, this is a machine instruction. ! 40: if ( nop == 2){ ! 41: $OPTYPE = op[2] ! 42: } else if ( $OPTYPE == "JBRNCH" || $OPTYPE == "cp_branch" ) { ! 43: $OPTYPE = "BRANCH" ! 44: } else if ( $OPTYPE != "BRANCH" && $OPTYPE != "DBRA" ) { ! 45: $OPTYPE = "OTHER" ! 46: } ! 47: if ( $OPTYPE != "BRANCH" && $OPTYPE != "DBRA" && $OPTYPE != "FBRANCH" && $OPTYPE != "FDBRA" ) { ! 48: $SUBOP = "SUBOP_" $SUBOP ! 49: } ! 50: printf( "I(\"%s\", OP_%s, %s, ", $MNEMONIC, $OPTYPE, $SUBOP ) ! 51: if (touch[1] == "X"){ ! 52: printf("T_X, ") ! 53: noperand = 0 ! 54: } else { ! 55: if (noperand == 1){ ! 56: printf("T_ONE(%s),", $TOUCHOP) ! 57: } else if (noperand == 2){ ! 58: printf("T_TWO(%s),", $TOUCHOP) ! 59: } else { ! 60: printf("T_THREE(%s),",$TOUCHOP) ! 61: } ! 62: } ! 63: printf( "%d, %s, %d, ", noperand, $CCODES, $NASSOC ) ! 64: naccess = split( $OPACCESS, access, ",") ! 65: # next, go print OPACCESS info. ! 66: } else if (flavor == "AS"){ ! 67: if ( $OPTYPE == "PSEUDO"){ ! 68: # flavor is AS, this is a pseodoop ! 69: nop = split( $3, op, "," ) ! 70: if ($8 == "") $8 = "0" ! 71: naccess = split( $8, access, ",") ! 72: printf( "P(\"%s\", %s, OP_%s, SUBOP_%s, %d, %d, %d, ", $MNEMONIC, op[1], op[2], $4, $5, $6, $7 ) ! 73: if (naccess==1){ ! 74: printf("A_ONE( %s )", $8 ) ! 75: } else if (naccess==2){ ! 76: printf("A_TWO( %s )", $8 ) ! 77: } else printf("help") ! 78: print ")\n" ! 79: next ! 80: } ! 81: # flavor is AS, and this is a machine instruction. ! 82: naccess = split( $OPACCESS, access, ",") ! 83: ncode = split( $OPCODES, code, "," ) ! 84: if (touch[1] == "X"){ ! 85: noperand = 0 ! 86: $OPACCESS = 0 ! 87: } ! 88: if (op[1] == "BRANCH" ){ ! 89: if ($MNEMONIC ~ /b..s/ ){ ! 90: op[1] = "BRNCHS" ! 91: } else if ( $MNEMONIC ~ /b..l/){ ! 92: op[1] = "BRNCHL" ! 93: } ! 94: if (op[2]==""){ ! 95: op[2] = "BRANCH" ! 96: } ! 97: } ! 98: if (op[2] == "") op[2] = "OTHER" ! 99: if (length($SUBOP) == 1) $SUBOP = "SUBOP_" $SUBOP ! 100: printf("I(\"%s\", %s, OP_%s, %s, ", $MNEMONIC, op[1], op[2], $SUBOP ) ! 101: printf("%d, ", noperand) ! 102: if (touch[1] == "X"){ ! 103: printf("T_X, ") ! 104: } else { ! 105: if (noperand == 1){ ! 106: printf("T_ONE(%s),", $TOUCHOP) ! 107: } else if (noperand == 2){ ! 108: printf("T_TWO(%s),", $TOUCHOP) ! 109: } else { ! 110: printf("T_THREE(%s),",$TOUCHOP) ! 111: } ! 112: } ! 113: if (ncode==1) { ! 114: printf("A_ONE(%s), ",$OPCODES) ! 115: } else if (ncode==2){ ! 116: printf("A_TWO(%s, %s), ",code[1], code[2]) ! 117: } else if (ncode==3){ ! 118: printf("A_TH3(%s, %s, %s), ",code[1], code[2], code[3] ) ! 119: } else if (ncode==4){ ! 120: printf("A_4R(%s, %s, %s, %s), ", code[1], code[2], code[3], code[4] ) ! 121: } else { ! 122: printf("A_5V(%s, %s, %s, %s, %s), ", code[1], code[2], code[3], code[4], code[5] ) ! 123: } ! 124: } else { ! 125: print "FLAVOR IS " flavor ! 126: exit ! 127: } ! 128: # here we print the OPACCESS stuff for any flavor. ! 129: if (naccess == 1){ ! 130: printf("A_ONE(%s) ", access[1] ) ! 131: } else if (naccess==2){ ! 132: printf("A_TWO(%s, %s) ", access[1], access[2] ) ! 133: } else if (naccess==3){ ! 134: printf("A_TH3(%s, %s, %s) ", access[1], access[2], access[3] ) ! 135: } else if (naccess==4){ ! 136: printf("A_4R(%s, %s, %s, %s) ", access[1], access[2], access[3], access[4] ) ! 137: } else if (naccess==5){ ! 138: printf("A_5V(%s, %s, %s, %s, %s) ", access[1], access[2], access[3], access[4], access[5] ) ! 139: } else if (naccess==6){ ! 140: printf("A_6X(%s, %s, %s, %s, %s, %s) ", access[1], access[2], access[3], access[4], access[5], access[6] ) ! 141: } else if (naccess==8){ ! 142: printf("A_8T(%s, %s, %s, %s, %s, %s, %s, %s) ", access[1], access[2], access[3], access[4], access[5], access[6], access[7], access[8] ) ! 143: } else { ! 144: printf("\n#include NACCESS==%d NOT DEALT WITH IN AWK PROG",naccess) ! 145: } ! 146: print " )" ! 147: next ! 148: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.