From 7bfb6d78ba07ac3613107e88578ab7c3daee2cc3 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Sun, 14 Feb 2010 01:47:05 +0900 Subject: [PATCH] =?utf8?q?assemble.c=E3=81=8C=E5=8F=A4=E3=81=84=E7=8A=B6?= =?utf8?q?=E6=85=8B=E3=81=A0=E3=81=A3=E3=81=9F=E3=81=9F=E3=82=81=E3=80=81?= =?utf8?q?=E5=BE=A9=E5=85=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/assemble.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/assemble.c b/src/assemble.c index f2f5978..42c035e 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; @@ -10,9 +13,6 @@ WORD lptr; /* 他のプログラムで参照する入口名 */ char *prog; -/* アセンブルモード: src, label, onlylabel, asdetail, onlyassemble */ -ASMODE asmode = {false, false, false, false, false}; - /* 汎用レジスタを表す文字列「GR[0-7]」から、レジスタ番号[0-7]をWORD値で返す */ /* 文字列が汎用レジスタを表さない場合は、0xFFFFを返す */ /* is_xがtrueの場合は指標レジスタ。GR0は、COMET IIの仕様により、エラー発生 */ @@ -398,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) @@ -425,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) { @@ -442,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); -- 2.18.0