7 static struct option longopts[] = {
8 {"trace", no_argument, NULL, 't'},
9 {"tracearithmetic", no_argument, NULL, 't'},
10 {"tracelogical", no_argument, NULL, 'T'},
11 {"dump", no_argument, NULL, 'd'},
12 {"monitor", no_argument, NULL, 'm'},
13 {"memorysize", required_argument, NULL, 'M'},
14 {"clocks", required_argument, NULL, 'C'},
15 {"version", no_argument, NULL, 'v' },
16 {"help", no_argument, NULL, 'h'},
24 CERR cerr_comet2[] = {
25 { 127, "invalid option" },
28 void addcerrlist_comet2()
30 addcerrlist(ARRAYSIZE(cerr_comet2), cerr_comet2);
34 * @brief comet2コマンドのメイン
36 * @return 正常終了時は0、異常終了時は1
38 * @param argc コマンドライン引数の数
39 * @param *argv[] コマンドライン引数の配列
41 int main(int argc, char *argv[])
43 int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS;
45 const char *version = PACKAGE_VERSION, *cmdversion = "comet2 of YACASL2 version %s\n";
46 const char *usage = "Usage: %s [-tTdmvh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n";
55 while((opt = getopt_long(argc, argv, "tTdmM:C:vh", longopts, NULL)) != -1) {
58 execmode.trace = true;
61 execmode.trace = true;
62 execmode.logical = true;
68 execmode.monitor = true;
71 memsize = atoi(optarg);
74 clocks = atoi(optarg);
77 fprintf(stdout, cmdversion, version);
80 fprintf(stdout, usage, argv[0]);
83 fprintf(stderr, usage, argv[0]);
84 setcerr(212, ""); /* invalid option */
88 if(argv[optind] == NULL) {
89 setcerr(211, ""); /* object file not specified */
90 fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
93 reset(memsize, clocks); /* COMET II仮想マシンのリセット */
95 execptr->end = loadassemble(argv[optind], execptr->start);
96 if(execptr->end > 0 && cerr->num == 0) {
99 shutdown(); /* COMET II仮想マシンのシャットダウン */
104 freecerr(); /* エラーの解放 */