This source file includes following definitions.
- main
1 #include "package.h"
2 #include "exec.h"
3 #include "load.h"
4
5
6
7
8 static struct option longopts[] = {
9 {"trace", no_argument, NULL, 't'},
10 {"tracearithmetic", no_argument, NULL, 't'},
11 {"tracelogical", no_argument, NULL, 'T'},
12 {"dump", no_argument, NULL, 'd'},
13 {"monitor", no_argument, NULL, 'm'},
14 {"memorysize", required_argument, NULL, 'M'},
15 {"clocks", required_argument, NULL, 'C'},
16 {"version", no_argument, NULL, 'v' },
17 {"help", no_argument, NULL, 'h'},
18 {0, 0, 0, 0},
19 };
20
21
22
23
24
25
26
27
28
29
30 int main(int argc, char *argv[])
31 {
32 int memsize = DEFAULT_MEMSIZE;
33 int clocks = DEFAULT_CLOCKS;
34 int opt = 0;
35 int stat = 0;
36 const char *version = PACKAGE_VERSION;
37 const char *cmdversion = "comet2 of YACASL2 version %s\n";
38 const char *usage = "Usage: %s [-tTdmvh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n";
39
40
41 cerr_init();
42 addcerrlist_load();
43 addcerrlist_exec();
44
45
46 while((opt = getopt_long(argc, argv, "tTdmM:C:vh", longopts, NULL)) != -1) {
47 switch(opt) {
48 case 't':
49 execmode.trace = true;
50 break;
51 case 'T':
52 execmode.trace = true;
53 execmode.logical = true;
54 break;
55 case 'd':
56 execmode.dump = true;
57 break;
58 case 'm':
59 execmode.monitor = true;
60 break;
61 case 'M':
62 memsize = atoi(optarg);
63 break;
64 case 'C':
65 clocks = atoi(optarg);
66 break;
67 case 'v':
68 fprintf(stdout, cmdversion, version);
69 goto comet2fin;
70 case 'h':
71 fprintf(stdout, usage, argv[0]);
72 goto comet2fin;
73 case '?':
74 fprintf(stderr, usage, argv[0]);
75 setcerr(212, "");
76 goto comet2fin;
77 }
78 }
79 if(argv[optind] == NULL) {
80 setcerr(211, "");
81 fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
82 goto comet2fin;
83 }
84 reset(memsize, clocks);
85 execptr->start = 0;
86 execptr->end = loadassemble(argv[optind], execptr->start);
87 if(execptr->end > 0 && cerr->num == 0) {
88 exec();
89 }
90 shutdown();
91 comet2fin:
92 if(cerr->num > 0) {
93 stat = 1;
94 }
95 freecerr();
96 return stat;
97 }