2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
6 static char rcsid[] = "$Id: convert.c,v 1.3 1994/06/24 13:57:37 ceriel Exp $";
9 /* This program converts either human-readable or compact EM
10 assembly code to calls of the procedure-interface.
11 It must be linked with two libraries:
12 - a library to read EM code, according to read_em(3)
13 - a library implementing the em_code(3) interface.
14 Thus, this program could serve as an EM_encoder, an
15 EM_decoder, or some code generator, depending on how it is
28 char *filename; /* Name of input file */
29 char *out_file; /* Name of output file */
30 int errors; /* Number of errors */
39 register struct e_instr *p = &buf;
46 for (ac=argc-1,av=argv+1;ac;ac--,av++)
48 if (av[0][0]=='-' && av[0][1]=='d' && av[0][2]==0)
53 if (! strcmp(av[0], "-gdb")) {
68 fatal ("too many arguments");
70 if (!EM_open(filename)) {
74 C_init((arith) EM_wordsize, (arith) EM_pointersize);
75 if (!C_open(out_file)) {
76 fatal("C_open failed");
79 while (p->em_type != EM_EOF) {
80 if (p->em_type == EM_FATAL) {
81 fatal("%s", EM_error);
84 error("%s", EM_error);
86 if (p->em_type != EM_ERROR && !C_out(p)) {
102 filename ? filename : "standard input",
104 fprint(STDERR,s,a1,a2,a3,a4);
105 fprint(STDERR, "\n");
113 if (C_busy()) C_close();
114 error(s,a1,a2,a3,a4);