This source file includes following definitions.
- addcerrlist_comet2monitor
- main
1 #include "package.h"
2 #include "exec.h"
3 #include "load.h"
4
5
6
7
8 static struct option longopts[] = {
9 {"memorysize", required_argument, NULL, 'M'},
10 {"clocks", required_argument, NULL, 'C'},
11 {"version", no_argument, NULL, 'v' },
12 {"help", no_argument, NULL, 'h'},
13 {0, 0, 0, 0},
14 };
15
16
17
18
19 CERR cerr_comet2monitor[] = {
20 { 401, "invalid option" },
21 };
22
23 void addcerrlist_comet2monitor()
24 {
25 addcerrlist(ARRAYSIZE(cerr_comet2monitor), cerr_comet2monitor);
26 }
27
28
29
30
31
32
33
34
35
36 int main(int argc, char *argv[])
37 {
38 int memsize = DEFAULT_MEMSIZE;
39 int clocks = DEFAULT_CLOCKS;
40 int opt = 0;
41 int stat = 0;
42 const char *version = PACKAGE_VERSION;
43 const char *cmdversion = "comet2monitor: COMET II machine code monitor of YACASL2 version %s\n";
44 const char *usage = "Usage: %s [-vh] [-M <MEMORYSIZE>] [-C <CLOCKS>]\n";
45
46
47 cerr_init();
48 addcerrlist_load();
49 addcerrlist_exec();
50 addcerrlist_comet2monitor();
51
52
53 while((opt = getopt_long(argc, argv, "M:C:vh", longopts, NULL)) != -1) {
54 switch(opt) {
55 case 'M':
56 memsize = atoi(optarg);
57 break;
58 case 'C':
59 clocks = atoi(optarg);
60 break;
61 case 'v':
62 fprintf(stdout, cmdversion, version);
63 return 0;
64 case 'h':
65 fprintf(stdout, usage, argv[0]);
66 goto comet2monitorfin;
67 case '?':
68 fprintf(stderr, usage, argv[0]);
69 setcerr(212, "");
70 goto comet2monitorfin;
71 }
72 }
73 create_cmdtable(HASH_CMDTYPE);
74 reset(memsize, clocks);
75 execptr->start = 0;
76 execmode.monitor = true;
77 exec();
78 shutdown();
79 comet2monitorfin:
80 free_cmdtable(HASH_CMDTYPE);
81 free_cmdtable(HASH_CODE);
82 if(cerr->num > 0) {
83 stat = 1;
84 }
85 freecerr();
86 return stat;
87 }