X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fassemble.c;h=0c13893117f289731849c70bb5aa5062efe35fd6;hp=36edd2bf783cb67c94f70330f2a70bb7f9456060;hb=62a189b4cdc7045922b132d5ff3371da948f2dbe;hpb=f958640f07ddce6100e7eed1504ecaf05f6c1f02 diff --git a/src/assemble.c b/src/assemble.c index 36edd2b..0c13893 100644 --- a/src/assemble.c +++ b/src/assemble.c @@ -1,6 +1,9 @@ #include "casl2.h" #include "assemble.h" +/* アセンブルモード: src, label, onlylabel, asdetail, onlyassemble */ +ASMODE asmode = {false, false, false, false, false}; + /* 値を格納するポインタ */ WORD ptr; @@ -95,7 +98,7 @@ void writestr(const char *str, bool literal, PASS pass) for(; ;) { /* 閉じ「'」がないまま文字列が終了した場合 */ if(*p == '\0') { - setcerr(123, str); /* illegal string */ + setcerr(123, str); /* unclosed quote */ break; } /* 「'」の場合、次の文字が「'」でない場合は正常終了 */ @@ -143,7 +146,7 @@ bool assemblecmd(const CMDLINE *cmdl, PASS pass) CMDARRAY ascmd[] = { { START, 0, 1, "START" }, { END, 0, 0, "END" }, - { DC, 0, OPDSIZE, "DC" }, + { DC, 1, OPDSIZE, "DC" }, { DS, 1, 1, "DS" }, { 0, 0, 0, NULL } }; @@ -395,6 +398,10 @@ bool assembleline(const CMDLINE *cmdl, PASS pass) return status; } +void printline(FILE *stream, const char *filename, int lineno, char *line) { + fprintf(stream, "%s:%5d:%s", filename, lineno, line); +} + /* 指定された名前のファイルをアセンブル */ /* 2回実行される */ bool assemble(const char *file, PASS pass) @@ -422,7 +429,7 @@ bool assemble(const char *file, PASS pass) if((pass == FIRST && (&asmode)->src == true) || (pass == SECOND && (&asmode)->asdetail == true)) { - fprintf(stdout, "%s:%5d:%s", file, lineno, line); + printline(stdout, file, lineno, line); } if((cmdl = linetok(line)) != NULL) { if(pass == FIRST && cmdl->label != NULL) { @@ -439,7 +446,8 @@ bool assemble(const char *file, PASS pass) } } if(cerrno > 0) { - fprintf(stderr, "Assemble error - %d: %s\n %s:%d: %s\n", cerrno, cerrmsg, file, lineno, line); + fprintf(stderr, "Assemble error - %d: %s\n", cerrno, cerrmsg); + printline(stderr, file, lineno, line); status = false; } fclose(fp);