From: j8takagi Date: Sat, 23 Jun 2018 15:56:34 +0000 (+0900) Subject: デバッガー機能をsrc/debbugger.cに独立 X-Git-Tag: v0.4p1~10 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb35f74f287988bbfb2815b4c7f55a1d861dccfd;p=YACASL2.git デバッガー機能をsrc/debbugger.cに独立 --- diff --git a/include/exec.h b/include/exec.h index 0794a91..dea36e8 100644 --- a/include/exec.h +++ b/include/exec.h @@ -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の終端 */ diff --git a/src/Makefile b/src/Makefile index 57d6e99..4d62d9c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 index 0000000..68e24fb --- /dev/null +++ b/src/debugger.c @@ -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; + } + } +} diff --git a/src/exec.c b/src/exec.c index 718a936..978fb8a 100644 --- a/src/exec.c +++ b/src/exec.c @@ -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; diff --git a/src/word.c b/src/word.c index 64e9f55..e7b646c 100644 --- a/src/word.c +++ b/src/word.c @@ -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);