diff --git a/util/int/global.h b/util/int/global.h index d90f09b7a..216835325 100644 --- a/util/int/global.h +++ b/util/int/global.h @@ -1,8 +1,8 @@ /* Defines and externs of general interest */ - -/* $Id$ */ +#ifndef GLOBAL_H_ +#define GLOBAL_H_ #include #include @@ -157,3 +157,4 @@ extern ptr SL; /* Stack Limit */ #define min(i,j) (((i) < (j)) ? (i) : (j)) +#endif /* GLOBAL_H_ */ diff --git a/util/int/switch/mkiswitch.c b/util/int/switch/mkiswitch.c index 8be3d54a9..b66122949 100644 --- a/util/int/switch/mkiswitch.c +++ b/util/int/switch/mkiswitch.c @@ -9,9 +9,11 @@ /* $Id$ */ +#include #include +#include + -extern FILE *popen(); #include #include @@ -26,7 +28,132 @@ FILE *ifp; /* Input File Pointer */ FILE *ofp; /* Output File Pointer */ char *Prefix; /* Prefix for function name */ -main(argc, argv) + +int +in(flgs, c) + char *flgs; + char c; +{ + while (*flgs) + if (c == *flgs++) + return 1; + return 0; +} + + + +void OutCase(mnem, base, first, i, argstr) + char *mnem; + char *base; + int first; + int i; + char *argstr; +{ + /* Output a case in the switch statement */ + fprintf(ofp, "\t\tcase %s+%d:\t%s%s(%s); break;\n", + base, first+i, Prefix, mnem, argstr); +} + + + + +void ImplicitArg(argstr) + char *argstr; +{ + sprintf(argstr, "uwpop()"); +} + +void NoArgs(argstr) + char *argstr; +{ + sprintf(argstr, ""); +} + +void Mini(argstr, i, flgs) + char *argstr; + int i; + char *flgs; +{ + int newi = in(flgs, 'N') ? (-i-1) : in(flgs, 'o') ? (i+1) : i; + + switch (newi) { + case -1: + sprintf(argstr, "%s", + in(flgs, 'w') ? "-wsize" : "-1L"); + break; + case 0: + sprintf(argstr, "0L"); + break; + case 1: + sprintf(argstr, "%s", + in(flgs, 'w') ? "wsize" : "1L"); + break; + default: + sprintf(argstr, "%dL%s", + newi, in(flgs, 'w') ? "*wsize" : ""); + break; + } +} + +void Shortie(argstr, i, flgs) + char *argstr; + int i; + char *flgs; +{ + int newi = in(flgs, 'N') ? (-i-1) : in(flgs, 'o') ? (i+1) : i; + + sprintf(argstr, "S_arg(%d)*%s", + newi, in(flgs, 'w') ? "wsize" : "1L"); +} + +void TwoSgn(argstr, flgs) + char *argstr; + char *flgs; +{ + + sprintf(argstr, "%s*%s", in(flgs, 'P') ? "P_arg_2()" : in(flgs, 'N') ? "N_arg_2()" : "L_arg_2()", + in(flgs, 'w') ? "wsize" : "1L"); +} + +void TwoUns(argstr, flgs) + char *argstr; + char *flgs; +{ + + sprintf(argstr, "%s*%s", "U_arg()", + in(flgs, 'w') ? "wsize" : "((unsigned long) 1)"); +} + +void FourSgn(argstr, flgs) + char *argstr; + char *flgs; +{ + + sprintf(argstr, "%s*%s", in(flgs, 'P') ? "P_arg_4()" : in(flgs, 'N') ? "N_arg_4()" : "L_arg_4()", + in(flgs, 'w') ? "wsize" : "1L"); +} + + +void fatal(fmt, str) + char *fmt; + char *str; +{ + fprintf(stderr, "%s, (fatal error): ", progname); + fprintf(stderr, fmt, str); + fprintf(stderr, "\n"); + exit(1); +} +int getmnem(str) char *str ; { + char (*ptr)[4] ; + + for ( ptr = em_mnem ; *ptr<= &em_mnem[sp_lmnem][0] ; ptr++ ) { + if ( strcmp(*ptr,str)==0 ) return (ptr-em_mnem) ; + } + fatal("%s","Illegal mnemonic") ; + return 0 ; +} + +int main(argc, argv) int argc; char **argv; { @@ -148,128 +275,5 @@ main(argc, argv) fatal("no opcode flag in ip_spec %s\n", flgs); } } - exit(0); + return EXIT_SUCCESS; } - - -OutCase(mnem, base, first, i, argstr) - char *mnem; - char *base; - int first; - int i; - char *argstr; -{ - /* Output a case in the switch statement */ - fprintf(ofp, "\t\tcase %s+%d:\t%s%s(%s); break;\n", - base, first+i, Prefix, mnem, argstr); -} - - - - -ImplicitArg(argstr) - char *argstr; -{ - sprintf(argstr, "uwpop()"); -} - -NoArgs(argstr) - char *argstr; -{ - sprintf(argstr, ""); -} - -Mini(argstr, i, flgs) - char *argstr; - int i; - char *flgs; -{ - int newi = in(flgs, 'N') ? (-i-1) : in(flgs, 'o') ? (i+1) : i; - - switch (newi) { - case -1: - sprintf(argstr, "%s", - in(flgs, 'w') ? "-wsize" : "-1L"); - break; - case 0: - sprintf(argstr, "0L"); - break; - case 1: - sprintf(argstr, "%s", - in(flgs, 'w') ? "wsize" : "1L"); - break; - default: - sprintf(argstr, "%dL%s", - newi, in(flgs, 'w') ? "*wsize" : ""); - break; - } -} - -Shortie(argstr, i, flgs) - char *argstr; - int i; - char *flgs; -{ - int newi = in(flgs, 'N') ? (-i-1) : in(flgs, 'o') ? (i+1) : i; - - sprintf(argstr, "S_arg(%d)*%s", - newi, in(flgs, 'w') ? "wsize" : "1L"); -} - -TwoSgn(argstr, flgs) - char *argstr; - char *flgs; -{ - - sprintf(argstr, "%s*%s", in(flgs, 'P') ? "P_arg_2()" : in(flgs, 'N') ? "N_arg_2()" : "L_arg_2()", - in(flgs, 'w') ? "wsize" : "1L"); -} - -TwoUns(argstr, flgs) - char *argstr; - char *flgs; -{ - - sprintf(argstr, "%s*%s", "U_arg()", - in(flgs, 'w') ? "wsize" : "((unsigned long) 1)"); -} - -FourSgn(argstr, flgs) - char *argstr; - char *flgs; -{ - - sprintf(argstr, "%s*%s", in(flgs, 'P') ? "P_arg_4()" : in(flgs, 'N') ? "N_arg_4()" : "L_arg_4()", - in(flgs, 'w') ? "wsize" : "1L"); -} - -int -in(flgs, c) - char *flgs; - char c; -{ - while (*flgs) - if (c == *flgs++) - return 1; - return 0; -} - -fatal(fmt, str) - char *fmt; - char *str; -{ - fprintf(stderr, "%s, (fatal error): ", progname); - fprintf(stderr, fmt, str); - fprintf(stderr, "\n"); - exit(1); -} -int getmnem(str) char *str ; { - char (*ptr)[4] ; - - for ( ptr = em_mnem ; *ptr<= &em_mnem[sp_lmnem][0] ; ptr++ ) { - if ( strcmp(*ptr,str)==0 ) return (ptr-em_mnem) ; - } - fatal("Illegal mnemonic") ; - return 0 ; -} - diff --git a/util/int/switch/mkswitch.c b/util/int/switch/mkswitch.c index 2ada08a3c..b90e0133b 100644 --- a/util/int/switch/mkswitch.c +++ b/util/int/switch/mkswitch.c @@ -11,6 +11,7 @@ /* $Id$ */ +#include #include extern FILE *popen(); @@ -22,7 +23,154 @@ FILE *ofp; /* Output File Pointer */ FILE *ffp = 0; /* Function File Pointer */ char *Prefix; /* Prefix for function name */ -main(argc, argv) +int in(char *flgs, char c) +{ + while (*flgs) + if (c == *flgs++) + return 1; + return 0; +} + + +void NoArgs(base, first, mnem) + char *base; + int first; + char *mnem; +{ + fprintf(ofp, "\t\tcase %s+%d:\t%s%sz(); break;\n", + base, first, Prefix, mnem); + if (ffp) { + fprintf(ffp, "%s%sz() {", Prefix, mnem); + fprintf(ffp, "LOG((\"@ %s%sz()\"));}\n", Prefix, mnem); + } +} + +void Mini(i, flgs, base, first, mnem) + int i; + char *flgs; + char *base; + int first; + char *mnem; +{ + char arg[16]; + int newi = in(flgs, 'N') ? (-i-1) : in(flgs, 'o') ? (i+1) : i; + + switch (newi) { + case -1: + sprintf(arg, "%s", + in(flgs, 'w') ? "-wsize" : "-1L"); + break; + case 0: + sprintf(arg, "0L"); + break; + case 1: + sprintf(arg, "%s", + in(flgs, 'w') ? "wsize" : "1L"); + break; + default: + sprintf(arg, "%dL%s", + newi, in(flgs, 'w') ? "*wsize" : ""); + break; + } + fprintf(ofp, "\t\tcase %s+%d:\t%s%sm(%s); break;\n", + base, first+i, Prefix, mnem, arg); + if (ffp) { + fprintf(ffp, "%s%sm(arg) long arg; {", + Prefix, mnem); + fprintf(ffp, "LOG((\"@ %s%sm(%%d)\", arg));}\n", + Prefix, mnem); + } +} + +void Shortie(i, flgs, base, first, mnem) + int i; + char *flgs; + char *base; + int first; + char *mnem; +{ + char arg[16]; + int newi = in(flgs, 'N') ? (-i-1) : in(flgs, 'o') ? (i+1) : i; + + sprintf(arg, "%dL, %s", newi, (in(flgs, 'w') ? "wsize" : "1L")); + fprintf(ofp, "\t\tcase %s+%d:\t%s%ss(%s); break;\n", + base, first+i, Prefix, mnem, arg); + if (ffp) { + fprintf(ffp, "%s%ss(hob, wfac) long hob; size wfac; {", + Prefix, mnem); + fprintf(ffp, "LOG((\"@ %s%ss(%%d)\", hob, wfac));", + Prefix, mnem); + fprintf(ffp, " newPC(PC+1);}\n"); + } +} + +void TwoSgn(flgs, base, first, mnem) + char *flgs; + char *base; + int first; + char *mnem; +{ + char *xy = in(flgs, 'P') ? "p2" : in(flgs, 'N') ? "n2" : "l2"; + + fprintf(ofp, "\t\tcase %s+%d:\t%s%s%s(%s); break;\n", + base, first, Prefix, mnem, xy, + in(flgs, 'w') ? "wsize" : "1L"); + if (ffp) { + fprintf(ffp, "%s%s%s(arg) long arg; {", Prefix, mnem, xy); + fprintf(ffp, "LOG((\"@ %s%s%s(%%d)\", arg));", + Prefix, mnem, xy); + fprintf(ffp, " newPC(PC+2);}\n"); + } +} + +void TwoUns(flgs, base, first, mnem) + char *flgs; + char *base; + int first; + char *mnem; +{ + char *xy = "u"; + + fprintf(ofp, "\t\tcase %s+%d:\t%s%s%s(%s); break;\n", + base, first, Prefix, mnem, xy, + in(flgs, 'w') ? "wsize" : "1L"); + if (ffp) { + fprintf(ffp, "%s%s%s(arg) long arg; {", Prefix, mnem, xy); + fprintf(ffp, "LOG((\"@ %s%s%s(%%d)\", arg));", + Prefix, mnem, xy); + fprintf(ffp, " newPC(PC+2);}\n"); + } +} + +void FourSgn(flgs, base, first, mnem) + char *flgs; + char *base; + int first; + char *mnem; +{ + char *xy = in(flgs, 'P') ? "p4" : in(flgs, 'N') ? "n4" : "l4"; + + fprintf(ofp, "\t\tcase %s+%d:\t%s%s%s(%s); break;\n", + base, first, Prefix, mnem, xy, + in(flgs, 'w') ? "wsize" : "1L"); + if (ffp) { + fprintf(ffp, "%s%s%s(arg) long arg; {", Prefix, mnem, xy); + fprintf(ffp, "LOG((\"@ %s%s%s(%%d)\", arg));", + Prefix, mnem, xy); + fprintf(ffp, " newPC(PC+4);}\n"); + } +} + + +void fatal(char *fmt, char *str) +{ + fprintf(stderr, "%s, (fatal error): ", progname); + fprintf(stderr, fmt, str); + fprintf(stderr, "\n"); + exit(1); +} + +int main(argc, argv) int argc; char **argv; { @@ -136,153 +284,3 @@ main(argc, argv) } exit(0); } - -NoArgs(base, first, mnem) - char *base; - int first; - char *mnem; -{ - fprintf(ofp, "\t\tcase %s+%d:\t%s%sz(); break;\n", - base, first, Prefix, mnem); - if (ffp) { - fprintf(ffp, "%s%sz() {", Prefix, mnem); - fprintf(ffp, "LOG((\"@ %s%sz()\"));}\n", Prefix, mnem); - } -} - -Mini(i, flgs, base, first, mnem) - int i; - char *flgs; - char *base; - int first; - char *mnem; -{ - char arg[16]; - int newi = in(flgs, 'N') ? (-i-1) : in(flgs, 'o') ? (i+1) : i; - - switch (newi) { - case -1: - sprintf(arg, "%s", - in(flgs, 'w') ? "-wsize" : "-1L"); - break; - case 0: - sprintf(arg, "0L"); - break; - case 1: - sprintf(arg, "%s", - in(flgs, 'w') ? "wsize" : "1L"); - break; - default: - sprintf(arg, "%dL%s", - newi, in(flgs, 'w') ? "*wsize" : ""); - break; - } - fprintf(ofp, "\t\tcase %s+%d:\t%s%sm(%s); break;\n", - base, first+i, Prefix, mnem, arg); - if (ffp) { - fprintf(ffp, "%s%sm(arg) long arg; {", - Prefix, mnem); - fprintf(ffp, "LOG((\"@ %s%sm(%%d)\", arg));}\n", - Prefix, mnem); - } -} - -Shortie(i, flgs, base, first, mnem) - int i; - char *flgs; - char *base; - int first; - char *mnem; -{ - char arg[16]; - int newi = in(flgs, 'N') ? (-i-1) : in(flgs, 'o') ? (i+1) : i; - - sprintf(arg, "%dL, %s", newi, (in(flgs, 'w') ? "wsize" : "1L")); - fprintf(ofp, "\t\tcase %s+%d:\t%s%ss(%s); break;\n", - base, first+i, Prefix, mnem, arg); - if (ffp) { - fprintf(ffp, "%s%ss(hob, wfac) long hob; size wfac; {", - Prefix, mnem); - fprintf(ffp, "LOG((\"@ %s%ss(%%d)\", hob, wfac));", - Prefix, mnem); - fprintf(ffp, " newPC(PC+1);}\n"); - } -} - -TwoSgn(flgs, base, first, mnem) - char *flgs; - char *base; - int first; - char *mnem; -{ - char *xy = in(flgs, 'P') ? "p2" : in(flgs, 'N') ? "n2" : "l2"; - - fprintf(ofp, "\t\tcase %s+%d:\t%s%s%s(%s); break;\n", - base, first, Prefix, mnem, xy, - in(flgs, 'w') ? "wsize" : "1L"); - if (ffp) { - fprintf(ffp, "%s%s%s(arg) long arg; {", Prefix, mnem, xy); - fprintf(ffp, "LOG((\"@ %s%s%s(%%d)\", arg));", - Prefix, mnem, xy); - fprintf(ffp, " newPC(PC+2);}\n"); - } -} - -TwoUns(flgs, base, first, mnem) - char *flgs; - char *base; - int first; - char *mnem; -{ - char *xy = "u"; - - fprintf(ofp, "\t\tcase %s+%d:\t%s%s%s(%s); break;\n", - base, first, Prefix, mnem, xy, - in(flgs, 'w') ? "wsize" : "1L"); - if (ffp) { - fprintf(ffp, "%s%s%s(arg) long arg; {", Prefix, mnem, xy); - fprintf(ffp, "LOG((\"@ %s%s%s(%%d)\", arg));", - Prefix, mnem, xy); - fprintf(ffp, " newPC(PC+2);}\n"); - } -} - -FourSgn(flgs, base, first, mnem) - char *flgs; - char *base; - int first; - char *mnem; -{ - char *xy = in(flgs, 'P') ? "p4" : in(flgs, 'N') ? "n4" : "l4"; - - fprintf(ofp, "\t\tcase %s+%d:\t%s%s%s(%s); break;\n", - base, first, Prefix, mnem, xy, - in(flgs, 'w') ? "wsize" : "1L"); - if (ffp) { - fprintf(ffp, "%s%s%s(arg) long arg; {", Prefix, mnem, xy); - fprintf(ffp, "LOG((\"@ %s%s%s(%%d)\", arg));", - Prefix, mnem, xy); - fprintf(ffp, " newPC(PC+4);}\n"); - } -} - -int -in(flgs, c) - char *flgs; - char c; -{ - while (*flgs) - if (c == *flgs++) - return 1; - return 0; -} - -fatal(fmt, str) - char *fmt; - char *str; -{ - fprintf(stderr, "%s, (fatal error): ", progname); - fprintf(stderr, fmt, str); - fprintf(stderr, "\n"); - exit(1); -}