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 {"help", no_argument, NULL, 'h'},
18 /* 実行モード: trace, logical, dump */
19 EXECMODE execmode = {false, false, false};
23 { 201, "execute - out of COMET II memory" },
24 { 202, "SVC input - out of Input memory" },
25 { 203, "SVC output - out of COMET II memory" },
26 { 204, "Program Register (PR) - out of COMET II memory" },
27 { 205, "Stack Pointer (SP) - cannot allocate stack buffer" },
28 { 206, "Address - out of COMET II memory" },
29 { 207, "Stack Pointer (SP) - out of COMET II memory" },
33 /* 指定されたファイルからアセンブル結果を読込 */
34 bool loadassemble(char *file) {
36 if((fp = fopen(file, "r")) == NULL) {
40 fread(memory, sizeof(WORD), memsize, fp);
46 int main(int argc, char *argv[])
49 const char *usage = "Usage: %s [-tTdh] [-M <memorysize>] [-C <clocks>] FILE\n";
51 while((opt = getopt_long(argc, argv, "tTdM:C:h", longopts, NULL)) != -1) {
54 (&execmode)->trace = true;
57 (&execmode)->trace = true;
58 (&execmode)->logical = true;
61 (&execmode)->dump = true;
64 memsize = atoi(optarg);
67 clocks = atoi(optarg);
70 fprintf(stdout, usage, argv[0]);
73 fprintf(stderr, usage, argv[0]);
78 if(loadassemble(argv[optind]) == true) {