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 {"memorysize", required_argument, NULL, 'M'},
13 {"clocks", required_argument, NULL, 'C'},
14 { "version", no_argument, NULL, 'v' },
15 {"help", no_argument, NULL, 'h'},
20 * @brief comet2コマンドのメイン
22 * @return 正常終了時は0、異常終了時は1
24 * @param argc コマンドライン引数の数
25 * @param *argv[] コマンドライン引数の配列
27 int main(int argc, char *argv[])
29 int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS;
31 const char *version = PACKAGE_VERSION, *cmdversion = "comet2 of YACASL2 version %s\n";
32 const char *usage = "Usage: %s [-tTdvh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n";
39 while((opt = getopt_long(argc, argv, "tTdM:C:vh", longopts, NULL)) != -1) {
42 execmode.trace = true;
45 execmode.trace = true;
46 execmode.logical = true;
52 memsize = atoi(optarg);
55 clocks = atoi(optarg);
58 fprintf(stdout, cmdversion, version);
61 fprintf(stdout, usage, argv[0]);
64 fprintf(stderr, usage, argv[0]);
68 if(argv[optind] == NULL) {
69 setcerr(211, ""); /* object file not specified */
70 fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
73 /* COMET II仮想マシンのリセット */
74 reset(memsize, clocks);
76 if(loadassemble(argv[optind]) == true) {
79 /* COMET II仮想マシンのシャットダウン */
81 stat = (cerr->num == 0) ? 0 : 1;