From e30fe2ecea035a6b9dbcd879f975b1ade3ff8eb8 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Sun, 6 Mar 2011 22:21:32 +0900 Subject: [PATCH] =?utf8?q?=E5=AE=9F=E8=A1=8C=E6=99=82=E3=81=AB=E6=B1=8E?= =?utf8?q?=E7=94=A8=E3=83=AC=E3=82=B8=E3=82=B9=E3=82=BF=E3=81=AE=E6=8C=87?= =?utf8?q?=E5=AE=9A=E3=81=8C=E4=B8=8D=E6=AD=A3=E3=81=A0=E3=81=A3=E3=81=9F?= =?utf8?q?=E5=A0=B4=E5=90=88=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=80=8C2?= =?utf8?q?09=E3=80=8D=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/exec.c | 15 +++++++++++++-- test/system/comet2/err_209/0.txt | 1 + test/system/comet2/err_209/Makefile | 2 ++ test/system/comet2/err_209/cmd | 2 ++ test/system/comet2/err_209/desc.txt | 1 + 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 test/system/comet2/err_209/0.txt create mode 100644 test/system/comet2/err_209/Makefile create mode 100755 test/system/comet2/err_209/cmd create mode 100644 test/system/comet2/err_209/desc.txt diff --git a/src/exec.c b/src/exec.c index e942602..887d9fe 100644 --- a/src/exec.c +++ b/src/exec.c @@ -16,6 +16,7 @@ static CERR cerr_exec[] = { { 205, "Stack Pointer (SP) - cannot allocate stack buffer" }, { 206, "Address - out of COMET II memory" }, { 207, "Stack Pointer (SP) - out of COMET II memory" }, + { 209, "not GR in operand x" }, }; /** @@ -393,11 +394,21 @@ bool exec() sys->cpu->pr++; /* オペランドの取り出し */ if(cmdtype == R1_R2) { - assert(x_r2 < GRSIZE); + /* オペランドの数値が汎用レジスタの範囲外の場合はエラー */ + if(x_r2 > GRSIZE - 1) { + sprintf(errpr, "PR:#%04X", sys->cpu->pr-1); + setcerr(209, errpr); /* not GR in operand x */ + goto execerr; + } val = sys->cpu->gr[x_r2]; } else if(cmdtype == R_ADR_X || cmdtype == R_ADR_X_ || cmdtype == ADR_X) { - assert(x_r2 < GRSIZE); + /* オペランドの数値が汎用レジスタの範囲外の場合はエラー */ + if(x_r2 > GRSIZE - 1) { + sprintf(errpr, "PR:#%04X", sys->cpu->pr-1); + setcerr(209, errpr); /* not GR in operand x */ + goto execerr; + } /* 実効アドレス(値または値が示す番地)を取得 */ val = sys->memory[sys->cpu->pr++]; /* 指標アドレスを加算 */ diff --git a/test/system/comet2/err_209/0.txt b/test/system/comet2/err_209/0.txt new file mode 100644 index 0000000..5740af0 --- /dev/null +++ b/test/system/comet2/err_209/0.txt @@ -0,0 +1 @@ +Execute error - 209: PR:#0001: not GR in operand x diff --git a/test/system/comet2/err_209/Makefile b/test/system/comet2/err_209/Makefile new file mode 100644 index 0000000..b6dac59 --- /dev/null +++ b/test/system/comet2/err_209/Makefile @@ -0,0 +1,2 @@ +include ../Define.mk +include ../Test.mk diff --git a/test/system/comet2/err_209/cmd b/test/system/comet2/err_209/cmd new file mode 100755 index 0000000..314942d --- /dev/null +++ b/test/system/comet2/err_209/cmd @@ -0,0 +1,2 @@ +../../../../comet2 ../../../../as/addl.casl +rm -f a.o diff --git a/test/system/comet2/err_209/desc.txt b/test/system/comet2/err_209/desc.txt new file mode 100644 index 0000000..e06570c --- /dev/null +++ b/test/system/comet2/err_209/desc.txt @@ -0,0 +1 @@ +エラー209 "not GR in operand x"の発生 -- 2.18.0