/**
* 指定された名前のファイルをアセンブル
- * 2回実行される
+ * 1回目ではラベルを登録し、2回目ではラベルからアドレスを読み込む
+ * アセンブル完了時はtrue、エラー発生時はfalseを返す
*/
-void assemble(const char *file, PASS pass)
+bool assemblefile(const char *file, PASS pass)
{
int lineno = 0;
- bool status = true;
- char *line = malloc_chk(LINESIZE + 1, "assemble.line");
+ char *line;
FILE *fp;
if((fp = fopen(file, "r")) == NULL) {
perror(file);
- setcerr(127, NULL);
- return;
+ return false;
}
+ line = malloc_chk(LINESIZE + 1, "assemble.line");
while(fgets(line, LINESIZE, fp)) {
lineno++;
if((pass == FIRST && asmode.src == true) ||
if(cerr->num > 0) {
fprintf(stderr, "Assemble error - %d: %s\n", cerr->num, cerr->msg);
printline(stderr, file, lineno, line);
- status = false;
}
FREE(line);
fclose(fp);
+ return (cerr->num == 0) ? true : false;
}
/**