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);
45 while((opt = getopt_long(argc, argv, "tTdM:C:h", longopts, NULL)) != -1) {
48 execmode.trace = true;
51 execmode.trace = true;
52 execmode.logical = true;
58 memsize = atoi(optarg);
61 clocks = atoi(optarg);
64 fprintf(stdout, usage, argv[0]);
67 fprintf(stderr, usage, argv[0]);
71 if(argv[optind] == NULL) {
72 setcerr(208, NULL); /* object file is not specified */
73 fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
76 /* COMET II仮想マシンのリセット */
77 reset(memsize, clocks);
79 if(loadassemble(argv[optind]) == true) {
80 create_code_type(); /* タイプがキーの命令ハッシュ表を作成 */
82 free_code_type(); /* タイプがキーの命令ハッシュ表を解放 */
84 /* COMET II仮想マシンのシャットダウン */