From: j8takagi Date: Sun, 31 Jan 2010 04:33:33 +0000 (+0900) Subject: CALL命令で、ローカルレベルも読み込めるように仕様変更 X-Git-Tag: v0.1~74^2~6 X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=commitdiff_plain;h=cc884e475afe3f48804b35336e68bce4088be61a CALL命令で、ローカルレベルも読み込めるように仕様変更 --- diff --git a/src/assemble.c b/src/assemble.c index bfd15e1..15d991a 100644 --- a/src/assemble.c +++ b/src/assemble.c @@ -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); diff --git a/test/integration/comet2/Makefile b/test/integration/comet2/Makefile index 3e9bfab..d60aaa1 100644 --- a/test/integration/comet2/Makefile +++ b/test/integration/comet2/Makefile @@ -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 index 0000000..003e069 --- /dev/null +++ b/test/integration/comet2/hanoi/0.txt @@ -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 index 0000000..a5ef0eb --- /dev/null +++ b/test/integration/comet2/hanoi/Makefile @@ -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 index 0000000..eef0eb6 Binary files /dev/null and b/test/integration/comet2/hanoi/a.o differ