comet2monitorの追加と、モニター機能作成
[YACASL2.git] / src / comet2.c
index f499022..55bab75 100644 (file)
@@ -9,11 +9,10 @@ static struct option longopts[] = {
     {"tracearithmetic", no_argument, NULL, 't'},
     {"tracelogical", no_argument, NULL, 'T'},
     {"dump", no_argument, NULL, 'd'},
-    {"debug", no_argument, NULL, 'b'},
     {"monitor", no_argument, NULL, 'm'},
     {"memorysize", required_argument, NULL, 'M'},
     {"clocks", required_argument, NULL, 'C'},
-    { "version", no_argument, NULL, 'v' },
+    {"version", no_argument, NULL, 'v' },
     {"help", no_argument, NULL, 'h'},
     {0, 0, 0, 0},
 };
@@ -47,7 +46,7 @@ int main(int argc, char *argv[])
             execmode.dump = true;
             break;
         case 'm':
-            execmode.step = true;
+            execmode.monitor = true;
             break;
         case 'M':
             memsize = atoi(optarg);
@@ -74,18 +73,15 @@ int main(int argc, char *argv[])
     if(argv[optind] == NULL) {
         setcerr(211, "");    /* object file not specified */
         fprintf(stderr, "comet2 error - %d: %s\n", cerr->num, cerr->msg);
-        freecerr();             /* エラーの解放 */
-        exit(1);
+        goto fin;
     }
-
-    /* COMET II仮想マシンのリセット */
-    reset(memsize, clocks);
+    reset(memsize, clocks);     /* COMET II仮想マシンのリセット */
     execptr->start = 0;
-    if(loadassemble(argv[optind]) == true) {
-        exec();                /* プログラム実行 */
+    if((execptr->end = loadassemble(argv[optind], execptr->start)) > 0 && cerr->num == 0) {
+        exec();                 /* プログラム実行 */
     }
-    /* COMET II仮想マシンのシャットダウン */
-    shutdown();
+    shutdown();                 /* COMET II仮想マシンのシャットダウン */
+fin:
     stat = (cerr->num == 0) ? 0 : 1;
     freecerr();                 /* エラーの解放 */
     return stat;