X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcasl2.c;h=a54adb860a5d67bc3f8100c6c94c1352dfc62203;hb=2a1b2ba47ff6596864ab38c8d9419e3c1372ef6e;hp=6a1d76fb2b2816f5f53920ef0418255c64a0cfc4;hpb=1708c99d4b6263863304d48ebca3b3473d6a0112;p=YACASL2.git diff --git a/src/casl2.c b/src/casl2.c index 6a1d76f..a54adb8 100644 --- a/src/casl2.c +++ b/src/casl2.c @@ -1,14 +1,6 @@ -#include -#include - -#define _GNU_SOURCE -#include - -#include "cmem.h" -#include "cerr.h" +#include "package.h" #include "assemble.h" #include "exec.h" -#include "package.h" /** * @brief CASL IIのエラーをエラーリストに追加 @@ -51,6 +43,7 @@ static struct option longopts[] = { { "tracearithmetic", no_argument, NULL, 't' }, { "tracelogical", no_argument, NULL, 'T' }, { "dump", no_argument, NULL, 'd' }, + { "monitor", no_argument, NULL, 'm' }, { "memorysize", required_argument, NULL, 'M' }, { "clocks", required_argument, NULL, 'C' }, { "version", no_argument, NULL, 'v' }, @@ -130,18 +123,14 @@ asfin: */ int main(int argc, char *argv[]) { - int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS, opt, i, stat; + int memsize = DEFAULT_MEMSIZE, clocks = DEFAULT_CLOCKS, opt, i, stat = 0; char *af[argc], *objfile = NULL; const char *version = PACKAGE_VERSION, *cmdversion = "casl2 of YACASL2 version %s\n"; const char *usage = - "Usage: %s [-slLaAtTdvh] [-oO[]] [-M ] [-C ] FILE1[ FILE2 ...]\n"; + "Usage: %s [-slLaAtTdmvh] [-oO[]] [-M ] [-C ] FILE1[ FILE2 ...]\n"; - cerr_init(); - addcerrlist_casl2(); - addcerrlist_assemble(); - addcerrlist_exec(); /* オプションの処理 */ - while((opt = getopt_long(argc, argv, "tTdslLao::O::AM:C:vh", longopts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, "tTdslLmao::O::AM:C:vh", longopts, NULL)) != -1) { switch(opt) { case 's': asmode.src = true; @@ -177,6 +166,9 @@ int main(int argc, char *argv[]) case 'd': execmode.dump = true; break; + case 'm': + execmode.step = true; + break; case 'M': memsize = atoi(optarg); break; @@ -194,10 +186,18 @@ int main(int argc, char *argv[]) exit(1); } } + + /* エラーの定義 */ + cerr_init(); + addcerrlist_casl2(); + addcerrlist_assemble(); + addcerrlist_exec(); + /* ソースファイルが指定されていない場合は終了 */ if(argv[optind] == NULL) { setcerr(126, ""); /* no source file */ fprintf(stderr, "CASL2 error - %d: %s\n", cerr->num, cerr->msg); + freecerr(); /* エラーの解放 */ exit(1); } reset(memsize, clocks); /* 仮想マシンCOMET IIのリセット */