ブレークポイント機能の修正
[YACASL2.git] / src / exec.c
index 718a936..b920fb1 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "exec.h"
 #include "cerr.h"
+#include "debugger.h"
 
 /**
  * @brief プログラムレジスタ(PR)を表すWORD値を文字列に変換
@@ -109,7 +110,7 @@ static CERR cerr_load[] = {
 };
 
 /**
- * @brief 実行モード: trace, logical, dump, debugger
+ * @brief 実行モード: trace, logical, dump, step
  */
 EXECMODE execmode = {false, false, false, false};
 
@@ -786,32 +787,6 @@ char *grstr(WORD word)
     return str;
 }
 
-void debugger()
-{
-    char *buf = malloc_chk(DBINSIZE + 1, "debugger.buf");
-    for( ; ;) {
-        fprintf(stdout, "COMET II (Type ? for help) > ");
-        fgets(buf, DBINSIZE, stdin);
-        if(*buf == 'r') {
-            execmode.debugger = false;
-            break;
-        } else if(*buf == 's') {
-            break;
-        } else if(*buf == 't') {
-            fprintf(stdout, "#%04X: Register::::\n", sys->cpu->pr);
-            dspregister();
-        } else if(*buf == 'd') {
-            dumpmemory();
-        } else if(*buf == '?') {
-            fprintf(stdout, "r -- Continue running your program.\n");
-            fprintf(stdout, "s -- Continue running your program until next interaction.\n");
-            fprintf(stdout, "t -- Display CPU register.\n");
-            fprintf(stdout, "d -- Display memory dump.\n");
-            break;
-        }
-    }
-}
-
 void exec()
 {
     clock_t clock_begin, clock_end;
@@ -837,7 +812,7 @@ void exec()
             fprintf(stdout, "\n");
         }
         /* デバッガーモードの場合、デバッガーを起動 */
-        if(execmode.debugger == true) {
+        if(execmode.step == true || getbps(sys->cpu->pr) == true) {
             debugger();
         }
         /* プログラムレジスタをチェック */
@@ -875,6 +850,7 @@ void exec()
         } while(clock_end - clock_begin < CLOCKS_PER_SEC / sys->clocks);
     }
 execfin:
+    freebps();
     free_code_cmdtype();                           /* 命令のコードとタイプがキーのハッシュ表を解放 */
     if(cerr->num > 0) {
         fprintf(stderr, "Execute error - %d: %s\n", cerr->num, cerr->msg);