From cc884e475afe3f48804b35336e68bce4088be61a Mon Sep 17 00:00:00 2001 From: j8takagi Date: Sun, 31 Jan 2010 13:33:33 +0900 Subject: [PATCH 1/1] =?utf8?q?CALL=E5=91=BD=E4=BB=A4=E3=81=A7=E3=80=81?= =?utf8?q?=E3=83=AD=E3=83=BC=E3=82=AB=E3=83=AB=E3=83=AC=E3=83=99=E3=83=AB?= =?utf8?q?=E3=82=82=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=82=81=E3=82=8B=E3=82=88?= =?utf8?q?=E3=81=86=E3=81=AB=E4=BB=95=E6=A7=98=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/assemble.c | 10 ++++++---- test/integration/comet2/Makefile | 2 +- test/integration/comet2/hanoi/0.txt | 8 ++++++++ test/integration/comet2/hanoi/Makefile | 5 +++++ test/integration/comet2/hanoi/a.o | Bin 0 -> 186 bytes 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 test/integration/comet2/hanoi/0.txt create mode 100644 test/integration/comet2/hanoi/Makefile create mode 100644 test/integration/comet2/hanoi/a.o 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 0000000000000000000000000000000000000000..eef0eb6b0c3535b39d03f32c7bb73e453123e3e2 GIT binary patch literal 186 zcmY+7I}XA?3`E~19ci3Bfw{pdC*V`@ZD{y)NOTbxaR72-j(~R?6j_#L{Hz&dg~$e# zElGCpX<%S>f?EgEGu0DnU$tbJj(taPmTzKO_{i(U)1*C++T;H-?!9jf-wKIWG=`$p Z#29KC<}6rp=f#5_#oKwi&MK6d@B;~F8aV&} literal 0 HcmV?d00001 -- 2.18.0