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 {"debug", no_argument, NULL, 'b'},
13 {"memorysize", required_argument, NULL, 'M'},
14 {"clocks", required_argument, NULL, 'C'},
15 { "version", no_argument, NULL, 'v' },
16 {"help", no_argument, NULL, 'h'},
21 * @brief comet2コマンドのメイン
23 * @return 正常終了時は0、異常終了時は1
25 * @param argc コマンドライン引数の数
26 * @param *argv[] コマンドライン引数の配列
28 int main(int argc, char *argv[])
30 int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS;
32 const char *version = PACKAGE_VERSION, *cmdversion = "comet2 of YACASL2 version %s\n";
33 const char *usage = "Usage: %s [-btTdvh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n";
40 while((opt = getopt_long(argc, argv, "tTdM:C:vh", longopts, NULL)) != -1) {
43 execmode.trace = true;
46 execmode.trace = true;
47 execmode.logical = true;
53 execmode.debugger = true;
56 memsize = atoi(optarg);
59 clocks = atoi(optarg);
62 fprintf(stdout, cmdversion, version);
65 fprintf(stdout, usage, argv[0]);
68 fprintf(stderr, usage, argv[0]);
72 if(argv[optind] == NULL) {
73 setcerr(211, ""); /* object file not specified */
74 fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
77 /* COMET II仮想マシンのリセット */
78 reset(memsize, clocks);
80 if(loadassemble(argv[optind]) == true) {
83 /* COMET II仮想マシンのシャットダウン */
85 stat = (cerr->num == 0) ? 0 : 1;