X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fcasl2.c;h=fb4290a9e4f33e0f47b0f644c3bb58d6d52023b5;hp=216496ebf9662ae88872019e654bdb860f44f1a2;hb=2f0b91ab1a54973a084e1609b46a1432c8b8e334;hpb=c2820a4ee2f34c794268b5a61d3223f1c270d39c diff --git a/src/casl2.c b/src/casl2.c index 216496e..fb4290a 100644 --- a/src/casl2.c +++ b/src/casl2.c @@ -1,6 +1,5 @@ #include "package.h" #include "assemble.h" -#include "exec.h" /** * @brief CASL IIのエラーをエラーリストに追加 @@ -18,16 +17,6 @@ void addcerrlist_casl2(); */ const char *objfile_name(const char *str); -/** - * @brief 指定された1つまたは複数のファイルを2回アセンブル - * - * @return なし - * - * @param filec アセンブルするファイルの数 - * @param filev アセンブルするファイル名の配列 - */ -void assemble(int filec, char *filev[]); - /** * @brief casl2コマンドのオプション */ @@ -43,6 +32,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' }, @@ -68,50 +58,6 @@ const char *objfile_name(const char *str) return (str == NULL) ? default_name : str; } -void assemble(int filec, char *filev[]) -{ - int i; - PASS pass; - WORD bp[filec]; - - create_cmdtype_code(); /* 命令の名前とタイプがキーのハッシュ表を作成 */ - asptr = malloc_chk(sizeof(ASPTR), "asptr"); /* アセンブル時のプロパティ用の領域確保 */ - asptr->prog = malloc_chk(LABELSIZE + 1, "asptr.prog"); - asptr->ptr = 0; - /* アセンブル。ラベル表作成のため、2回行う */ - for(pass = FIRST; pass <= SECOND; pass++) { - for(i = 0; i < filec; i++) { - /* データの格納開始位置 */ - if(pass == FIRST) { - bp[i] = asptr->ptr; - } else if(pass == SECOND) { - asptr->ptr = bp[i]; - } - if(execmode.trace == true || execmode.dump == true || - asmode.src == true || asmode.label == true || asmode.asdetail == true) - { - fprintf(stdout, "\nAssemble %s (%d)\n", filev[i], pass); - } - /* ファイルをアセンブル */ - if(assemblefile(filev[i], pass) == false) { - goto asfin; - } - } - if(pass == FIRST && asmode.label == true) { - fprintf(stdout, "\nLabel::::\n"); - printlabel(); - if(asmode.onlylabel == true) { - break; - } - } - } -asfin: - freelabel(); /* ラベルハッシュ表を解放 */ - free_cmdtype_code(); /* 命令の名前とタイプがキーのハッシュ表を解放 */ - FREE(asptr->prog); /* アセンブル時のプロパティを解放 */ - FREE(asptr); -} - /** * @brief casl2コマンドのメイン * @@ -126,10 +72,10 @@ int main(int argc, char *argv[]) char *af[argc], *objfile = NULL; const char *version = PACKAGE_VERSION, *cmdversion = "casl2 of YACASL2 version %s\n"; const char *usage = - "Usage: %s [-slLaAtTdbvh] [-oO[]] [-M ] [-C ] FILE1[ FILE2 ...]\n"; + "Usage: %s [-slLaAtTdmvh] [-oO[]] [-M ] [-C ] FILE1[ FILE2 ...]\n"; /* オプションの処理 */ - while((opt = getopt_long(argc, argv, "tTdslLbao::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; @@ -165,7 +111,7 @@ int main(int argc, char *argv[]) case 'd': execmode.dump = true; break; - case 'b': + case 'm': execmode.step = true; break; case 'M': @@ -203,7 +149,7 @@ int main(int argc, char *argv[]) for(i = 0; i < argc - optind; i++) { /* 引数からファイル名配列を取得 */ af[i] = argv[optind + i]; } - assemble(i, af); /* アセンブル */ + assemble(i, af, 0); /* アセンブル */ if(asmode.onlylabel == true || cerr->num > 0) { goto casl2fin; }