+bool assemble(int filec, char *filev[], WORD adr)
+{
+ int i;
+ PASS pass;
+ WORD bp[filec];
+ bool stat = false;
+
+ asptr = malloc_chk(sizeof(ASPTR), "asptr"); /* アセンブル時のプロパティ用の領域確保 */
+ asptr->prog = malloc_chk(LABELSIZE + 1, "asptr.prog");
+ asptr->ptr = adr;
+ /* アセンブル。ラベル表作成のため、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);
+ }
+ /* ファイルをアセンブル */
+ stat = assemblefile(filev[i], pass);
+ if(stat == false) {
+ goto asfin;
+ }
+ }
+ if(pass == FIRST && asmode.label == true) {
+ fprintf(stdout, "\nLabel::::\n");
+ printlabel();
+ if(asmode.onlylabel == true) {
+ break;
+ }
+ }
+ }
+asfin:
+ freelabel(); /* ラベルハッシュ表を解放 */
+ FREE(asptr->prog); /* アセンブル時のプロパティを解放 */
+ FREE(asptr);
+ return stat;
+}
+