From: j8takagi Date: Sun, 6 Mar 2011 13:21:32 +0000 (+0900) Subject: 実行時に汎用レジスタの指定が不正だった場合のエラー「209」を追加 X-Git-Tag: v0.1p23~1 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e30fe2ecea035a6b9dbcd879f975b1ade3ff8eb8;p=YACASL2.git 実行時に汎用レジスタの指定が不正だった場合のエラー「209」を追加 --- 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"の発生