From: j8takagi Date: Wed, 20 Jun 2018 09:54:00 +0000 (+0900) Subject: disassembleをcasl2revに名前変更 X-Git-Tag: v0.4p0~10 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8b0bb2a7b5ef20cdbee5f555c5846dfc1c7f981;p=YACASL2.git disassembleをcasl2revに名前変更 --- diff --git a/.gitignore b/.gitignore index 7359497..dfb9c09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ /casl2 /comet2 /dumpword -/disassemble +/casl2rev *.o *.o.casl !as/sample/hello.o diff --git a/Makefile b/Makefile index a16c13c..67d7de3 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ clean src-clean gtags-clean \ test-clean doc-clean doc_inner-clean -CMD := casl2 comet2 dumpword disassemble +CMD := casl2 comet2 dumpword casl2rev CAT := cat CP := cp diff --git a/src/.gitignore b/src/.gitignore index a13272b..b9840fb 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -5,4 +5,4 @@ tags casl2 comet2 dumpword -disassemble \ No newline at end of file +casl2rev \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index 60d447e..57d6e99 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ # ソースファイル。グループに分類 -CMDOBJ := casl2 comet2 dumpword disassemble +CMDOBJ := casl2 comet2 dumpword casl2rev COMMONOBJ := word cmem cerr CASL2OBJ := struct hash ASOBJ := assemble token label @@ -31,7 +31,7 @@ comet2: $(addsuffix .o,comet2 $(COMMONOBJ) $(CASL2OBJ) $(EXECOBJ)) dumpword: $(addsuffix .o,dumpword $(COMMONOBJ)) -disassemble:$(addsuffix .o,disassemble $(COMMONOBJ) $(CASL2OBJ) $(EXECOBJ)) +casl2rev:$(addsuffix .o,casl2rev $(COMMONOBJ) $(CASL2OBJ) $(EXECOBJ)) # .dファイルからヘッダファイルの依存関係を取得する # tags、check、clean、.d で終わるターゲットの場合は除く diff --git a/src/disassemble.c b/src/casl2rev.c similarity index 89% rename from src/disassemble.c rename to src/casl2rev.c index 8107d45..c849ecb 100644 --- a/src/disassemble.c +++ b/src/casl2rev.c @@ -1,5 +1,6 @@ #include #include + #define _GNU_SOURCE #include #include @@ -11,6 +12,7 @@ char *grstr(WORD word) { + assert(word <= 7); char *str = malloc_chk(3 + 1, "grstr.str"); sprintf(str, "GR%d", word); return str; @@ -22,7 +24,7 @@ bool disassemble(const char *file) FILE *fp; WORD i = 0, w, cmd, r, x, r1, r2, adr; CMDTYPE cmdtype = 0; - char *cmdname, *g1, *g2; + char *cmdname; assert(file != NULL); if((fp = fopen(file, "rb")) == NULL) { @@ -49,13 +51,11 @@ bool disassemble(const char *file) fprintf(stdout, "\t%s\t", cmdname); if(cmdtype == R_ADR_X) { r = (w & 0x00F0) >> 4; - fprintf(stdout, "%s,", (g1 = grstr(r))); - FREE(g1); + fprintf(stdout, "%s,", grstr(r)); } fprintf(stdout, "#%04X", adr); if((x = w & 0x000F) != 0) { - fprintf(stdout, ",%s", (g1 = grstr(x))); - FREE(g1); + fprintf(stdout, ",%s", grstr(x)); } fprintf(stdout, "\t\t\t\t; #%04X: #%04X #%04X", i, w, adr); i += 2; @@ -64,13 +64,10 @@ bool disassemble(const char *file) if(cmdtype == R1_R2) { r1 = (w & 0x00F0) >> 4; r2 = w & 0x000F; - fprintf(stdout, "\t%s,%s", (g1=grstr(r1)), (g2=grstr(r2))); - FREE(g1); - FREE(g2); + fprintf(stdout, "\t%s,%s", grstr(r1), grstr(r2)); } else if(cmdtype == R_) { r = (w & 0x00F0) >> 4; - fprintf(stdout, "\t%s", (g1 = grstr(r))); - FREE(g1); + fprintf(stdout, "\t%s", grstr(r)); } fprintf(stdout, "\t\t\t\t; #%04X: #%04X", i++, w); } diff --git a/src/doxygen.c b/src/doxygen.c index 07ca15f..8fffe8d 100644 --- a/src/doxygen.c +++ b/src/doxygen.c @@ -4,7 +4,7 @@ * - src/casl2.c * - src/comet2.c * - src/dumpword.c - * - src/disassemble.c + * - src/casl2rev.c * * \section そのほかのソースファイル * - src/assemble.c diff --git a/test/system/casl2rev/Define.mk b/test/system/casl2rev/Define.mk new file mode 120000 index 0000000..b4a58e1 --- /dev/null +++ b/test/system/casl2rev/Define.mk @@ -0,0 +1 @@ +../../template/Define.mk \ No newline at end of file diff --git a/test/system/casl2rev/Makefile b/test/system/casl2rev/Makefile new file mode 120000 index 0000000..4f4e7b0 --- /dev/null +++ b/test/system/casl2rev/Makefile @@ -0,0 +1 @@ +../../template/Group.mk \ No newline at end of file diff --git a/test/system/casl2rev/Test.mk b/test/system/casl2rev/Test.mk new file mode 120000 index 0000000..ada05aa --- /dev/null +++ b/test/system/casl2rev/Test.mk @@ -0,0 +1 @@ +../../template/Test.mk \ No newline at end of file diff --git a/test/system/casl2rev/sum_10/0.txt b/test/system/casl2rev/sum_10/0.txt new file mode 100644 index 0000000..4b20b83 --- /dev/null +++ b/test/system/casl2rev/sum_10/0.txt @@ -0,0 +1,15 @@ +MAIN START + PUSH #0000,GR1 ; #0000: #7001 #0000 + LAD GR0,#0000 ; #0002: #1200 #0000 + LD GR1,#0011 ; #0004: #1010 #0011 + ADDL GR0,GR1 ; #0006: #2601 + ADDL GR1,#0013 ; #0007: #2210 #0013 + CPL GR1,#0012 ; #0009: #4110 #0012 + JPL #000F ; #000B: #6500 #000F + JUMP #0006 ; #000D: #6400 #0006 + POP GR1 ; #000F: #7110 + RET ; #0010: #8100 + DC 1 ; #0011: #0001 :: 1 = #0001 = 0000000000000001 + DC 10 ; #0012: #000A :: 10 = #000A = 0000000000001010 = '\n' + DC 1 ; #0013: #0001 :: 1 = #0001 = 0000000000000001 + END diff --git a/test/system/casl2rev/sum_10/Makefile b/test/system/casl2rev/sum_10/Makefile new file mode 100644 index 0000000..b6dac59 --- /dev/null +++ b/test/system/casl2rev/sum_10/Makefile @@ -0,0 +1,2 @@ +include ../Define.mk +include ../Test.mk diff --git a/test/system/casl2rev/sum_10/cmd b/test/system/casl2rev/sum_10/cmd new file mode 100755 index 0000000..248e49f --- /dev/null +++ b/test/system/casl2rev/sum_10/cmd @@ -0,0 +1 @@ +../../../../casl2rev ../../../../as/sample/sum_10.o