実行時に汎用レジスタの指定が不正だった場合のエラー「209」を追加
authorj8takagi <j8takagi@nifty.com>
Sun, 6 Mar 2011 13:21:32 +0000 (22:21 +0900)
committerj8takagi <j8takagi@nifty.com>
Sun, 6 Mar 2011 13:21:32 +0000 (22:21 +0900)
src/exec.c
test/system/comet2/err_209/0.txt [new file with mode: 0644]
test/system/comet2/err_209/Makefile [new file with mode: 0644]
test/system/comet2/err_209/cmd [new file with mode: 0755]
test/system/comet2/err_209/desc.txt [new file with mode: 0644]

index e942602..887d9fe 100644 (file)
@@ -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 (file)
index 0000000..5740af0
--- /dev/null
@@ -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 (file)
index 0000000..b6dac59
--- /dev/null
@@ -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 (executable)
index 0000000..314942d
--- /dev/null
@@ -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 (file)
index 0000000..e06570c
--- /dev/null
@@ -0,0 +1 @@
+エラー209 "not GR in operand x"の発生