X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fcomet2.c;h=1adf4266580c3ad8b36ac8a15a063e2f542315df;hp=1c47d193d1305cf1df2f83038f273d78a539dd1a;hb=f3433b11c1e3a2ec3d6f7b332afa5cf5f69dc360;hpb=712486afe58b10ef37c5fa915de889ab8d1dd6cd diff --git a/src/comet2.c b/src/comet2.c index 1c47d19..1adf426 100644 --- a/src/comet2.c +++ b/src/comet2.c @@ -3,6 +3,7 @@ #define _GNU_SOURCE #include +/* comet2コマンドのオプション */ static struct option longopts[] = { {"trace", no_argument, NULL, 't'}, {"tracearithmetic", no_argument, NULL, 't'}, @@ -14,12 +15,24 @@ static struct option longopts[] = { {0, 0, 0, 0} }; +/* 実行モード: trace, logical, dump */ EXECMODE execmode = {false, false, false}; -/* 指定されたファイルからCOMET II仮想メモリ(アセンブル結果)を読込 */ -bool inassemble(char *file) { +/* エラー番号とエラーメッセージ */ +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 loadassemble(char *file) { FILE *fp; - reset(); if((fp = fopen(file, "r")) == NULL) { perror(file); return false; @@ -29,6 +42,7 @@ bool inassemble(char *file) { return true; } +/* comet2コマンド */ int main(int argc, char *argv[]) { int opt; @@ -37,14 +51,14 @@ int main(int argc, char *argv[]) while((opt = getopt_long(argc, argv, "tTdM:C:h", longopts, NULL)) != -1) { switch(opt) { case 't': - (&execmode)->tracemode = true; + (&execmode)->trace = true; break; case 'T': - (&execmode)->tracemode = true; - (&execmode)->logicalmode = true; + (&execmode)->trace = true; + (&execmode)->logical = true; break; case 'd': - (&execmode)->dumpmode = true; + (&execmode)->dump = true; break; case 'M': memsize = atoi(optarg); @@ -60,7 +74,8 @@ int main(int argc, char *argv[]) exit(-1); } } - if(inassemble(argv[optind]) == true) { + reset(); + if(loadassemble(argv[optind]) == true) { exec(); /* プログラム実行 */ } if(cerrno > 0) {