1984-05-18 21:27:39 +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".
|
1984-05-18 21:27:39 +00:00
|
|
|
*
|
|
|
|
* Author: Hans van Staveren
|
|
|
|
*/
|
2019-05-10 17:11:54 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "tables.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include <cg_pattern.h>
|
|
|
|
#include "data.h"
|
|
|
|
#include "tables.h"
|
|
|
|
#include "param.h"
|
|
|
|
#include "mach.h"
|
|
|
|
#include "subr.h"
|
|
|
|
#include "fillem.h"
|
|
|
|
#include "gencode.h"
|
|
|
|
#include "codegen.h"
|
1984-05-18 21:27:39 +00:00
|
|
|
|
|
|
|
char *progname;
|
2019-05-10 17:11:54 +00:00
|
|
|
extern byte startupcode[];
|
1984-05-18 21:27:39 +00:00
|
|
|
int maxply=1;
|
|
|
|
#ifndef NDEBUG
|
|
|
|
int Debug=0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int endofprog;
|
|
|
|
|
2019-05-10 17:11:54 +00:00
|
|
|
|
|
|
|
unsigned ggd(unsigned int a,unsigned int b)
|
|
|
|
{
|
|
|
|
register unsigned c;
|
|
|
|
|
|
|
|
do {
|
|
|
|
c = a%b; a=b; b=c;
|
|
|
|
} while (c!=0);
|
|
|
|
return(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
1984-05-18 21:27:39 +00:00
|
|
|
register unsigned n;
|
|
|
|
extern unsigned cc1,cc2,cc3,cc4;
|
2019-05-10 17:11:54 +00:00
|
|
|
|
1984-05-18 21:27:39 +00:00
|
|
|
|
|
|
|
progname = argv[0];
|
|
|
|
while (--argc && **++argv == '-') {
|
|
|
|
switch(argv[0][1]) {
|
|
|
|
#ifndef NDEBUG
|
|
|
|
case 'd':
|
1988-04-11 10:55:07 +00:00
|
|
|
Debug++; break;
|
1984-05-18 21:27:39 +00:00
|
|
|
#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
|
1984-05-18 21:27:39 +00:00
|
|
|
error("Unknown flag %c",argv[0][1]);
|
1992-03-27 17:38:54 +00:00
|
|
|
#endif
|
|
|
|
break;
|
1984-05-18 21:27:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (argc < 1 || argc > 2)
|
|
|
|
error("Usage: %s EMfile [ asfile ]",progname);
|
|
|
|
in_init(argv[0]);
|
|
|
|
out_init(argv[1]);
|
1985-04-16 16:14:55 +00:00
|
|
|
in_start();
|
1984-05-18 21:27:39 +00:00
|
|
|
codegen(startupcode,maxply,TRUE,MAXINT,0);
|
|
|
|
in_finish();
|
|
|
|
if (!endofprog)
|
|
|
|
error("Bombed out of codegen");
|
|
|
|
out_finish();
|
|
|
|
}
|
|
|
|
|