6 static struct option longopts[] = {
7 {"trace", no_argument, NULL, 't'},
8 {"tracearithmetic", no_argument, NULL, 't'},
9 {"tracelogical", no_argument, NULL, 'T'},
10 {"dump", no_argument, NULL, 'd'},
11 {"memorysize", required_argument, NULL, 'M'},
12 {"clocks", required_argument, NULL, 'C'},
13 {"help", no_argument, NULL, 'h'},
17 EXECMODE execmode = {false, false, false};
21 { 201, "execute - out of COMET II memory" },
22 { 202, "SVC input - out of Input memory" },
23 { 203, "SVC output - out of COMET II memory" },
24 { 204, "Program Register (PR) - out of COMET II memory" },
25 { 205, "Stack Pointer (SP) - cannot allocate stack buffer" },
26 { 206, "Address - out of COMET II memory" },
27 { 207, "Stack Pointer (SP) - out of COMET II memory" },
31 /* 指定されたファイルからアセンブル結果を読込 */
32 bool inassemble(char *file) {
35 if((fp = fopen(file, "r")) == NULL) {
39 fread(memory, sizeof(WORD), memsize, fp);
45 int main(int argc, char *argv[])
48 const char *usage = "Usage: %s [-tTdh] [-M <memorysize>] [-C <clocks>] FILE\n";
50 while((opt = getopt_long(argc, argv, "tTdM:C:h", longopts, NULL)) != -1) {
53 (&execmode)->tracemode = true;
56 (&execmode)->tracemode = true;
57 (&execmode)->logicalmode = true;
60 (&execmode)->dumpmode = true;
63 memsize = atoi(optarg);
66 clocks = atoi(optarg);
69 fprintf(stdout, usage, argv[0]);
72 fprintf(stderr, usage, argv[0]);
76 if(inassemble(argv[optind]) == true) {