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'},
22 * @brief comet2コマンドのメイン
24 * @return 正常終了時は0、異常終了時は1
26 * @param argc コマンドライン引数の数
27 * @param *argv[] コマンドライン引数の配列
29 int main(int argc, char *argv[])
31 int memsize = DEFAULT_MEMSIZE;
32 int clocks = DEFAULT_CLOCKS;
35 const char *version = PACKAGE_VERSION;
36 const char *cmdversion = "comet2 of YACASL2 version %s\n";
37 const char *usage = "Usage: %s [-tTdmvh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n";
45 while((opt = getopt_long(argc, argv, "tTdmM:C:vh", longopts, NULL)) != -1) {
48 execmode.trace = true;
51 execmode.trace = true;
52 execmode.logical = true;
58 execmode.monitor = true;
61 memsize = atoi(optarg);
64 clocks = atoi(optarg);
67 fprintf(stdout, cmdversion, version);
70 fprintf(stdout, usage, argv[0]);
73 fprintf(stderr, usage, argv[0]);
74 setcerr(212, ""); /* invalid option */
78 if(argv[optind] == NULL) {
79 setcerr(211, ""); /* object file not specified */
80 fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
83 reset(memsize, clocks); /* COMET II仮想マシンのリセット */
85 execptr->end = loadassemble(argv[optind], execptr->start);
86 if(execptr->end > 0 && cerr->num == 0) {
89 shutdown(); /* COMET II仮想マシンのシャットダウン */
94 freecerr(); /* エラーの解放 */