X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fcomet2.c;h=bfe1634a7d8c91ad0305c25be73d7ab9d7a13a71;hb=85744703060a90c21ee325d3a692f80233bc281f;hp=24040b3c1aff2d76fc69f7aef8f5e5ea66c03d8a;hpb=ecd73ba08f9b8721742ae5dbb72e1c4261574b36;p=YACASL2.git diff --git a/src/comet2.c b/src/comet2.c index 24040b3..bfe1634 100644 --- a/src/comet2.c +++ b/src/comet2.c @@ -3,7 +3,32 @@ #define _GNU_SOURCE #include -/* 指定されたファイルから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,33 +41,23 @@ 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'}, - {"memsize", 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; - const char *usage = "Usage: %s [-tTdh] [-M] [-C] FILE\n"; + const char *usage = "Usage: %s [-tTdh] [-M ] [-C ] FILE\n"; 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); @@ -52,7 +67,7 @@ int main(int argc, char *argv[]) break; case 'h': fprintf(stdout, usage, argv[0]); - exit(-1); + return 0; case '?': fprintf(stderr, usage, argv[0]); exit(-1);