/*----------------------------------------------------------------------------- * parse the given assembly file, return FALSE if failed *----------------------------------------------------------------------------*/ static void parseline(ParseCtx *ctx) { int start_num_errors; next_PC(); /* update assembler program counter */ EOL = FALSE; /* reset END OF LINE flag */ start_num_errors = get_num_errors(); scan_expect_opcode(); GetSym(); if (get_num_errors() != start_num_errors) /* detect errors in GetSym() */ Skipline(); else if (!parse_statement(ctx)) { if (get_num_errors() == start_num_errors) /* no error output yet */ error_syntax(); Skipline(); } list_end_line(); /* Write current source line to list file */ }
void DEFGROUP (void) { struct expr *postfixexpr; long constant, enumconst = 0; writeline = OFF; /* DEFGROUP definitions are not output'ed to listing file */ while (!feof (z80asmfile) && GetSym () != lcurly) { Skipline (z80asmfile); EOL = OFF; ++CURRENTFILE->line; } if (sym == lcurly) { while (!feof (z80asmfile) && sym != rcurly) { if (EOL == ON) { ++CURRENTFILE->line; EOL = OFF; } else { do { GetSym (); switch (sym) { case rcurly: case semicolon: case newline: break; case name: strcpy (stringconst, ident); /* remember name */ if (GetSym () == assign) { GetSym (); if ((postfixexpr = ParseNumExpr ()) != NULL) { if (postfixexpr->rangetype & NOTEVALUABLE) ReportError (CURRENTFILE->fname, CURRENTFILE->line, 2); else { constant = EvalPfixExpr (postfixexpr); enumconst = constant; DefineSymbol (stringconst, enumconst++, 0); } RemovePfixlist (postfixexpr); } GetSym (); /* prepare for next identifier */ } else DefineSymbol (stringconst, enumconst++, 0); break; default: ReportError (CURRENTFILE->fname, CURRENTFILE->line, 1); break; } } while (sym == comma); /* get enum definitions separated by comma in current line */ Skipline (z80asmfile); /* ignore rest of line */ } } } }
void DEFVARS (void) { struct expr *postfixexpr; long offset; enum flag globaldefv; writeline = OFF; /* DEFVARS definitions are not output'ed to listing file */ GetSym (); if ((postfixexpr = ParseNumExpr ()) != NULL) { /* expr. must not be stored in relocatable file */ if (postfixexpr->rangetype & NOTEVALUABLE) { ReportError (CURRENTFILE->fname, CURRENTFILE->line, 2); RemovePfixlist (postfixexpr); return; } else { offset = EvalPfixExpr (postfixexpr); /* offset expression must not contain undefined symbols */ RemovePfixlist (postfixexpr); } if ((offset != -1) && (offset != 0)) { DEFVPC = offset; globaldefv = ON; } else { if (offset == -1) { globaldefv = ON; offset = DEFVPC; } else { /* offset = 0, use temporarily without smashing DEFVPC */ globaldefv = OFF; } } } else return; /* syntax error - get next line from file... */ while (!feof (z80asmfile) && sym != lcurly) { Skipline (z80asmfile); EOL = OFF; ++CURRENTFILE->line; GetSym (); } if (sym == lcurly) { while (!feof (z80asmfile) && GetSym () != rcurly) { if (EOL == ON) { ++CURRENTFILE->line; EOL = OFF; } else offset += Parsedefvarsize (offset); } if (globaldefv == ON) { DEFVPC = offset; } } }