エラー表をコマンドごとに持つよう内部構造を変更
[YACASL2.git] / src / comet2.c
index c6cf486..bfe1634 100644 (file)
@@ -3,7 +3,32 @@
 #define _GNU_SOURCE
 #include <getopt.h>
 
-/* 指定されたファイルからCOMET II仮想メモリ(アセンブル結果)を読込 */
+static struct option longopts[] = {
+    {"trace", no_argument, NULL, 't'},
+    {"tracearithmetic", no_argument, NULL, 't'},
+    {"tracelogical", no_argument, NULL, 'T'},
+    {"dump", no_argument, NULL, 'd'},
+    {"memorysize", required_argument, NULL, 'M'},
+    {"clocks", required_argument, NULL, 'C'},
+    {"help", no_argument, NULL, 'h'},
+    {0, 0, 0, 0}
+};
+
+EXECMODE execmode = {false, false, false};
+
+/* エラー番号とエラーメッセージ */
+CERRARRAY cerr[] = {
+    { 201, "execute - out of COMET II memory" },
+    { 202, "SVC input - out of Input memory" },
+    { 203, "SVC output - out of COMET II memory" },
+    { 204, "Program Register (PR) - out of COMET II memory" },
+    { 205, "Stack Pointer (SP) - cannot allocate stack buffer" },
+    { 206, "Address - out of COMET II memory" },
+    { 207, "Stack Pointer (SP) - out of COMET II memory" },
+    { 0, NULL },
+};
+
+/* 指定されたファイルからアセンブル結果を読込 */
 bool inassemble(char *file) {
     FILE *fp;
     reset();
@@ -16,17 +41,7 @@ bool inassemble(char *file) {
     return true;
 }
 
-static struct option longopts[] = {
-    {"trace", no_argument, NULL, 't'},
-    {"tracearithmetic", no_argument, NULL, 't'},
-    {"tracelogical", no_argument, NULL, 'T'},
-    {"dump", no_argument, NULL, 'd'},
-    {"memorysize", required_argument, NULL, 'M'},
-    {"clocks", required_argument, NULL, 'C'},
-    {"help", no_argument, NULL, 'h'},
-    {0, 0, 0, 0}
-};
-
+/* comet2コマンド */
 int main(int argc, char *argv[])
 {
     int opt;
@@ -35,14 +50,14 @@ int main(int argc, char *argv[])
     while((opt = getopt_long(argc, argv, "tTdM:C:h", longopts, NULL)) != -1) {
         switch(opt) {
         case 't':
-            tracemode = true;
+            (&execmode)->tracemode = true;
             break;
         case 'T':
-            tracemode = true;
-            logicalmode = true;
+            (&execmode)->tracemode = true;
+            (&execmode)->logicalmode = true;
             break;
         case 'd':
-            dumpmode = true;
+            (&execmode)->dumpmode = true;
             break;
         case 'M':
             memsize = atoi(optarg);