disassembleをcasl2revに名前変更
authorj8takagi <j8takagi@nifty.com>
Wed, 20 Jun 2018 09:54:00 +0000 (18:54 +0900)
committerj8takagi <j8takagi@nifty.com>
Wed, 20 Jun 2018 11:28:15 +0000 (20:28 +0900)
12 files changed:
.gitignore
Makefile
src/.gitignore
src/Makefile
src/casl2rev.c [moved from src/disassemble.c with 89% similarity]
src/doxygen.c
test/system/casl2rev/Define.mk [new symlink]
test/system/casl2rev/Makefile [new symlink]
test/system/casl2rev/Test.mk [new symlink]
test/system/casl2rev/sum_10/0.txt [new file with mode: 0644]
test/system/casl2rev/sum_10/Makefile [new file with mode: 0644]
test/system/casl2rev/sum_10/cmd [new file with mode: 0755]

index 7359497..dfb9c09 100644 (file)
@@ -1,7 +1,7 @@
 /casl2
 /comet2
 /dumpword
-/disassemble
+/casl2rev
 *.o
 *.o.casl
 !as/sample/hello.o
index a16c13c..67d7de3 100644 (file)
--- 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
index a13272b..b9840fb 100644 (file)
@@ -5,4 +5,4 @@ tags
 casl2
 comet2
 dumpword
-disassemble
\ No newline at end of file
+casl2rev
\ No newline at end of file
index 60d447e..57d6e99 100644 (file)
@@ -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 で終わるターゲットの場合は除く
similarity index 89%
rename from src/disassemble.c
rename to src/casl2rev.c
index 8107d45..c849ecb 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+
 #define _GNU_SOURCE
 #include <getopt.h>
 #include <assert.h>
@@ -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);
         }
index 07ca15f..8fffe8d 100644 (file)
@@ -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 (symlink)
index 0000000..b4a58e1
--- /dev/null
@@ -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 (symlink)
index 0000000..4f4e7b0
--- /dev/null
@@ -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 (symlink)
index 0000000..ada05aa
--- /dev/null
@@ -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 (file)
index 0000000..4b20b83
--- /dev/null
@@ -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 (file)
index 0000000..b6dac59
--- /dev/null
@@ -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 (executable)
index 0000000..248e49f
--- /dev/null
@@ -0,0 +1 @@
+../../../../casl2rev ../../../../as/sample/sum_10.o