]> j8takagi.net Git Repository - YACASL2.git/commitdiff
デバッガー機能をsrc/debbugger.cに独立
authorj8takagi <j8takagi@nifty.com>
Sat, 23 Jun 2018 15:56:34 +0000 (00:56 +0900)
committerj8takagi <j8takagi@nifty.com>
Sat, 23 Jun 2018 15:56:34 +0000 (00:56 +0900)
include/exec.h
src/Makefile
src/debugger.c [new file with mode: 0644]
src/exec.c
src/word.c

index 0794a9101d6827fa1aa36b021cf2b6523496ee28..dea36e8929dd213998f5cb7a9beef151a543ba69 100644 (file)
@@ -384,7 +384,6 @@ void dumpmemory();
  */
 void dspregister();
 
-
 /**
  * @brief CASL IIのオブジェクトファイルを逆アセンブルし、標準出力へ出力する
  *
@@ -394,4 +393,11 @@ void dspregister();
  */
 bool disassemble_file(const char *file);
 
+/**
+ * @brief COMET IIデバッガーを起動する
+ *
+ * @return なし
+ */
+void debugger();
+
 #endif            /* YACASL2_EXEC_INCLUDEDの終端 */
index 57d6e99f9ca07024b79ef9e9179d382db0960947..4d62d9cb5e515d82137475fd44dc48e75d1b410f 100644 (file)
@@ -3,7 +3,7 @@ CMDOBJ := casl2 comet2 dumpword casl2rev
 COMMONOBJ := word cmem cerr
 CASL2OBJ := struct hash
 ASOBJ := assemble token label
-EXECOBJ := exec dump
+EXECOBJ := exec dump debugger
 
 # ヘッダファイル
 INCLUDEDIR := ../include
diff --git a/src/debugger.c b/src/debugger.c
new file mode 100644 (file)
index 0000000..68e24fb
--- /dev/null
@@ -0,0 +1,27 @@
+#include "exec.h"
+
+void debugger()
+{
+    char *buf = malloc_chk(DBINSIZE + 1, "debugger.buf");
+    for( ; ;) {
+        fprintf(stdout, "COMET II (Type ? for help) > ");
+        fgets(buf, DBINSIZE, stdin);
+        if(*buf == '\0' || *buf == 's') {
+            break;
+        } else if(*buf == 'c') {
+            execmode.debugger = false;
+            break;
+        } else if(*buf == 't') {
+            fprintf(stdout, "#%04X: Register::::\n", sys->cpu->pr);
+            dspregister();
+        } else if(*buf == 'd') {
+            dumpmemory();
+        } else if(*buf == '?') {
+            fprintf(stdout, "s (default) -- Step by step running your program until next interaction.\n");
+            fprintf(stdout, "c -- Continue running your program.\n");
+            fprintf(stdout, "t -- Display CPU register.\n");
+            fprintf(stdout, "d -- Display memory dump.\n");
+            break;
+        }
+    }
+}
index 718a936a38dc924f5870365561bd6b064ffeebaf..978fb8a2e2c2d23c5ea046dfa33c382bc706a7f2 100644 (file)
@@ -786,32 +786,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;
index 64e9f55607aba5dae75ca5614287c180dc6f4a6b..e7b646c0101d92847387e4d6977402b047868895 100644 (file)
@@ -62,7 +62,7 @@ WORD h2word(const char *str)
     str++;
     if(*str == '-' || strlen(str) > 4) {
         setcerr(116, str-1);    /* out of hex range */
-        return 0;
+        return 0x0;
     }
     /* WORD値に変換 */
     w = (WORD)strtol(str, &check, 16);