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'},
23 * @brief comet2コマンドのメイン
25 * @return 正常終了時は0、異常終了時は1
27 * @param argc コマンドライン引数の数
28 * @param *argv[] コマンドライン引数の配列
30 int main(int argc, char *argv[])
32 int memsize = DEFAULT_MEMSIZE;
33 int clocks = DEFAULT_CLOCKS;
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";
46 while((opt = getopt_long(argc, argv, "tTdmM:C:vh", longopts, NULL)) != -1) {
49 execmode.trace = true;
52 execmode.trace = true;
53 execmode.logical = true;
59 execmode.monitor = true;
62 memsize = atoi(optarg);
65 clocks = atoi(optarg);
68 fprintf(stdout, cmdversion, version);
71 fprintf(stdout, usage, argv[0]);
74 fprintf(stderr, usage, argv[0]);
75 setcerr(212, ""); /* invalid option */
79 if(argv[optind] == NULL) {
80 setcerr(211, ""); /* object file not specified */
81 fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
84 reset(memsize, clocks); /* COMET II仮想マシンのリセット */
86 execptr->end = loadassemble(argv[optind], execptr->start);
87 if(execptr->end > 0 && cerr->num == 0) {
90 shutdown(); /* COMET II仮想マシンのシャットダウン */
95 freecerr(); /* エラーの解放 */