1985-01-08 15:34:54 +00:00
|
|
|
#ifndef NORCSID
|
1994-06-24 14:02:31 +00:00
|
|
|
static char rcsid[] = "$Id$";
|
1985-01-08 15:34:54 +00:00
|
|
|
#endif
|
|
|
|
|
2017-11-13 17:44:17 +00:00
|
|
|
#include <stdlib.h> /* atoi */
|
1985-01-08 15:34:54 +00:00
|
|
|
#include "param.h"
|
|
|
|
#include "tables.h"
|
2017-11-13 17:44:17 +00:00
|
|
|
#include "types.h"
|
2019-10-25 22:17:13 +00:00
|
|
|
#include "xmach.h"
|
1985-01-08 15:34:54 +00:00
|
|
|
|
|
|
|
/*
|
1987-03-10 01:26:51 +00:00
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
1985-01-08 15:34:54 +00:00
|
|
|
*
|
|
|
|
* Author: Hans van Staveren
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *progname;
|
2017-11-12 21:11:05 +00:00
|
|
|
extern byte startupcode[]; /* codegen.c */
|
1985-01-08 15:34:54 +00:00
|
|
|
int maxply=1;
|
|
|
|
#ifndef NDEBUG
|
|
|
|
int Debug=0;
|
|
|
|
char *strtdebug="";
|
|
|
|
#endif
|
|
|
|
|
2017-11-13 17:44:17 +00:00
|
|
|
static unsigned ggd(unsigned, unsigned);
|
2017-11-12 16:25:18 +00:00
|
|
|
|
2017-11-13 17:44:17 +00:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
unsigned n;
|
|
|
|
extern unsigned cc1,cc2,cc3,cc4; /* tables.c */
|
1985-01-08 15:34:54 +00:00
|
|
|
|
|
|
|
progname = argv[0];
|
|
|
|
while (--argc && **++argv == '-') {
|
|
|
|
switch(argv[0][1]) {
|
|
|
|
#ifndef NDEBUG
|
|
|
|
case 'd':
|
|
|
|
if ((Debug = argv[0][2]) != 0) {
|
|
|
|
Debug -= '0';
|
|
|
|
if (argv[0][3] == '@') {
|
|
|
|
Debug = 0;
|
|
|
|
strtdebug = &argv[0][4];
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
Debug++;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef TABLEDEBUG
|
|
|
|
case 'u':
|
|
|
|
case 'U':
|
|
|
|
initlset(argv[0]+1);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case 'p':
|
|
|
|
maxply = atoi(argv[0]+2);
|
|
|
|
break;
|
|
|
|
case 'w': /* weight percentage for size */
|
|
|
|
n=atoi(argv[0]+2);
|
|
|
|
cc1 *= n;
|
|
|
|
cc2 *= 50;
|
|
|
|
cc3 *= (100-n);
|
|
|
|
cc4 *= 50;
|
|
|
|
n=ggd(cc1,cc2);
|
|
|
|
cc1 /= n;
|
|
|
|
cc2 /= n;
|
|
|
|
n=ggd(cc3,cc4);
|
|
|
|
cc3 /= n;
|
|
|
|
cc4 /= n;
|
|
|
|
break;
|
|
|
|
default:
|
1992-03-27 17:38:54 +00:00
|
|
|
#ifdef MACH_OPTIONS
|
|
|
|
mach_option(argv[0]);
|
|
|
|
#else
|
1985-01-08 15:34:54 +00:00
|
|
|
error("Unknown flag %c",argv[0][1]);
|
1992-03-27 17:38:54 +00:00
|
|
|
#endif
|
|
|
|
break;
|
1985-01-08 15:34:54 +00:00
|
|
|
}
|
|
|
|
}
|
1987-11-25 16:55:51 +00:00
|
|
|
if (argc > 2)
|
|
|
|
error("Usage: %s [ EMfile ] [ asfile ]",progname);
|
|
|
|
in_init(argc >= 1 ? argv[0] : (char *) 0);
|
|
|
|
out_init(argc >= 2 ? argv[1] : (char *) 0);
|
1985-01-08 15:34:54 +00:00
|
|
|
readcodebytes();
|
|
|
|
itokcost();
|
1986-11-28 13:47:44 +00:00
|
|
|
in_start();
|
1985-01-08 15:34:54 +00:00
|
|
|
codegen(startupcode,maxply,TRUE,MAXINT,0);
|
|
|
|
error("Bombed out of codegen");
|
|
|
|
}
|
|
|
|
|
2017-11-13 17:44:17 +00:00
|
|
|
unsigned ggd(unsigned a, unsigned b) {
|
|
|
|
unsigned c;
|
1985-01-08 15:34:54 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
c = a%b; a=b; b=c;
|
|
|
|
} while (c!=0);
|
|
|
|
return(a);
|
|
|
|
}
|