13 static struct option longopts[] = {
14 {"trace", no_argument, NULL, 't'},
15 {"tracearithmetic", no_argument, NULL, 't'},
16 {"tracelogical", no_argument, NULL, 'T'},
17 {"dump", no_argument, NULL, 'd'},
18 {"memorysize", required_argument, NULL, 'M'},
19 {"clocks", required_argument, NULL, 'C'},
20 {"help", no_argument, NULL, 'h'},
27 static CERR cerr_comet2[] = {
28 { 208, "object file is not specified" },
34 int main(int argc, char *argv[])
36 int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS;
38 const char *usage = "Usage: %s [-tTdh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n";
41 addcerrlist(ARRAYSIZE(cerr_comet2), cerr_comet2); /* エラーリスト作成 */
44 while((opt = getopt_long(argc, argv, "tTdM:C:h", longopts, NULL)) != -1) {
47 execmode.trace = true;
50 execmode.trace = true;
51 execmode.logical = true;
57 memsize = atoi(optarg);
60 clocks = atoi(optarg);
63 fprintf(stdout, usage, argv[0]);
66 fprintf(stderr, usage, argv[0]);
70 if(argv[optind] == NULL) {
71 setcerr(208, NULL); /* object file is not specified */
72 fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
75 /* COMET II仮想マシンのリセット */
76 reset(memsize, clocks);
78 if(loadassemble(argv[optind]) == true) {
79 create_code_type(); /* タイプがキーの命令ハッシュ表を作成 */
81 free_code_type(); /* タイプがキーの命令ハッシュ表を解放 */
83 /* COMET II仮想マシンのシャットダウン */