CALL命令で、ローカルレベルも読み込めるように仕様変更
authorj8takagi <j8takagi@nifty.com>
Sun, 31 Jan 2010 04:33:33 +0000 (13:33 +0900)
committerj8takagi <j8takagi@nifty.com>
Sun, 31 Jan 2010 08:30:41 +0000 (17:30 +0900)
src/assemble.c
test/integration/comet2/Makefile
test/integration/comet2/hanoi/0.txt [new file with mode: 0644]
test/integration/comet2/hanoi/Makefile [new file with mode: 0644]
test/integration/comet2/hanoi/a.o [new file with mode: 0644]

index bfd15e1..15d991a 100644 (file)
@@ -83,7 +83,9 @@ WORD getadr(const char *prog, const char *str, PASS pass)
         adr = getint(str);
     } else {
         if(pass == SECOND && (adr = getlabel(prog, str)) == 0xFFFF) {
-            setcerr(103, str);    /* label not found */
+            if(prog != NULL) {
+                setcerr(103, str);    /* label not found */
+            }
         }
     }
     return adr;
@@ -299,7 +301,6 @@ bool macrocmd(const CMDLINE *cmdl, PASS pass)
     return status;
 }
 
-
 /* 機械語命令の書込
    書込に成功した場合はtrue、それ以外の場合はfalseを返す */
 bool cometcmd(const CMDLINE *cmdl, PASS pass)
@@ -335,7 +336,7 @@ bool cometcmd(const CMDLINE *cmdl, PASS pass)
             if((cmd = getcmdcode(cmdl->cmd, R1_R2)) == 0xFFFF) {
                 setcerr(109, cmdl->cmd);    /* not command of operand "r1,r2" */
                 return false;
-            } 
+            }
             cmd |= ((r1 << 4) | r2);
             if(cerrno == 0 && writememory(cmd, ptr++, pass) == true) {
                 status = true;
@@ -388,7 +389,8 @@ bool cometcmd(const CMDLINE *cmdl, PASS pass)
            それ以外の場合は同一プログラム内のラベルを取得 */
         if(cmd == 0x8000) {        /* CALL命令 */
             adr = getadr(NULL, cmdl->opd->opdv[0], pass);
-        } else {
+        }
+        if(cmd != 0x8000 || (pass == SECOND && adr == 0xFFFF)) {
             adr = getadr(prog, cmdl->opd->opdv[0], pass);
         }
         writememory(cmd, ptr++, pass);
index 3e9bfab..d60aaa1 100644 (file)
@@ -63,7 +63,7 @@ endif
 ifdef INFILE
        @echo 'IN = <$(INFILE)' >>$(UNITNAME)/Makefile
 endif
-       @echo 'CMD = $$(COMET2) $$(COMET2FLAG) $$(UNITNAME).o $$(IN)' >>$(UNITNAME)/Makefile; \
+       @echo 'CMD = $$(COMET2) $$(COMET2FLAG) $$(OBJFILE)' >>$(UNITNAME)/Makefile; \
      echo 'include ../TEST.mk' >>$(UNITNAME)/Makefile
 else
        @echo "no test created. set UNITNAME"
diff --git a/test/integration/comet2/hanoi/0.txt b/test/integration/comet2/hanoi/0.txt
new file mode 100644 (file)
index 0000000..003e069
--- /dev/null
@@ -0,0 +1,8 @@
+../../../../comet2 a.o
+from A to C
+from A to B
+from C to B
+from A to C
+from B to A
+from B to C
+from A to C
diff --git a/test/integration/comet2/hanoi/Makefile b/test/integration/comet2/hanoi/Makefile
new file mode 100644 (file)
index 0000000..a5ef0eb
--- /dev/null
@@ -0,0 +1,5 @@
+include ../CMD.mk    # YACASL2DIR, CASL2, COMET2
+ASDIR = $(YACASL2DIR)/as/FUNC
+ASFILE = $(ASDIR)/hanoi.casl
+CMD = $(COMET2) $(COMET2FLAG) $(OBJFILE)
+include ../TEST.mk
diff --git a/test/integration/comet2/hanoi/a.o b/test/integration/comet2/hanoi/a.o
new file mode 100644 (file)
index 0000000..eef0eb6
Binary files /dev/null and b/test/integration/comet2/hanoi/a.o differ