diff options
Diffstat (limited to 'lib/assembler.c')
-rw-r--r-- | lib/assembler.c | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/lib/assembler.c b/lib/assembler.c index 8e9452e..043b28f 100644 --- a/lib/assembler.c +++ b/lib/assembler.c @@ -1235,9 +1235,10 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_ break; } } - - debug_print_expression(e); +#ifdef DEBUG + debug_print_expression(e); +#endif for (instructs = instructs->next; instructs; instructs = instructs->next) { t = e; go_out = 0; @@ -1264,13 +1265,13 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_ if ((t->e_subtype == E_OPERATION) && ((t->op == OP_PLUS) || (t->op == OP_MOINS))) { if (((t->child->e_subtype == E_LABEL) - && (t->child->next->e_subtype == E_VALUE)) - || ((t->child->e_subtype == E_VALUE) - && (t->child->next->e_subtype == E_LABEL))) { + && (t->child->next->e_subtype == E_VALUE)) + || ((t->child->e_subtype == E_VALUE) + && (t->child->next->e_subtype == E_LABEL))) { go_out = 0; } } - + if ((t->e_subtype == E_OPERATION) && (t->op == OP_FUNC_CALL)) { go_out = 0; } @@ -1293,7 +1294,7 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_ break; } } - +#ifdef DEBUG if (instructs) { fprintf(stderr, " o Instruction contenant %i champs explicites et %i champs implicites.\n", instructs->nbexplicit, instructs->nbimplicit); @@ -1322,6 +1323,7 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_ } } } +#endif return instructs; } @@ -1650,7 +1652,10 @@ void asm_eol(void) t->pattern = NULL; t->symbol = NULL; InsererVarDansTab(&it, CreerElement(instr->names[i], t)); - fprintf(stderr, "On a %s qui vaut %i\n", instr->names[i], e_current->index); +#ifdef DEBUG + fprintf(stderr, "On a %s qui vaut %i\n", instr->names[i], + e_current->index); +#endif evaluate_pattern(&it, e_current); break; default: @@ -1676,7 +1681,9 @@ void asm_eol(void) t->pattern = NULL; t->symbol = NULL; } - fprintf(stderr, "On a %s qui vaut %i\n", instr->implicits[i], t->avalue); +#ifdef DEBUG + fprintf(stderr, "On a %s qui vaut %i\n", instr->implicits[i], t->avalue); +#endif InsererVarDansTab(&it, CreerElement(instr->implicits[i], t)); break; case 1: /* type prédéfinit */ @@ -1689,7 +1696,9 @@ void asm_eol(void) t->child = t->next = NULL; t->pattern = NULL; t->symbol = NULL; - fprintf(stderr, "On a %s qui vaut %i\n", instr->implicits[i], t->avalue); +#ifdef DEBUG + fprintf(stderr, "On a %s qui vaut %i\n", instr->implicits[i], t->avalue); +#endif InsererVarDansTab(&it, CreerElement(instr->implicits[i], t)); break; case 2: /* type valeur */ @@ -1699,7 +1708,9 @@ void asm_eol(void) t->child = t->next = NULL; t->pattern = NULL; t->symbol = NULL; - fprintf(stderr, "On a %s qui vaut %i\n", instr->implicits[i], t->avalue); +#ifdef DEBUG + fprintf(stderr, "On a %s qui vaut %i\n", instr->implicits[i], t->avalue); +#endif InsererVarDansTab(&it, CreerElement(instr->implicits[i], t)); break; } @@ -1727,8 +1738,9 @@ static void writeword(unsigned long int a, FILE * f, int n) { int i; +#ifdef DEBUG fprintf(stderr, "ÉCriture de %08lX sur %i\n", a, fileno(f)); - +#endif if (fwrite(&a, sizeof(unsigned long int), 1, f) != 1) { if (ferror(f)) { pushcontext(strerror(errno)); @@ -1821,7 +1833,9 @@ void asm_eof(FILE * f) for (ttext = ttext->next; ttext; ttext = ttext->next) { sprintf(errctx, _("Processing word number %i coming from line %i of the file %s."), ttext->offset, ttext->line, ttext->filename); +#ifdef DEBUG fprintf(stderr, "%s\n", errctx); +#endif pushcontext(errctx); a = 0; @@ -1832,7 +1846,9 @@ void asm_eof(FILE * f) a = ttext->Expr->avalue; break; case E_LABEL: +#ifdef DEBUG fprintf(stderr, "Symbole externe %s\n", ttext->Expr->symbol); +#endif a = ttext->Expr->avalue; nbsymbols++; writeword(1, f2, 1); @@ -1851,7 +1867,9 @@ void asm_eof(FILE * f) if (ttext->Expr->op == OP_DECAL) { if ((ttext->Expr->child->e_subtype == E_LABEL) && (ttext->Expr->child->next->e_subtype == E_VALUE)) { +#ifdef DEBUG fprintf(stderr, "Symbole externe %s\n", ttext->Expr->child->symbol); +#endif a = ttext->Expr->child->next->avalue; nbsymbols++; writeword(1, f2, 1); @@ -1868,8 +1886,10 @@ void asm_eof(FILE * f) || ((ttext->Expr->child->e_subtype == E_VALUE) && (ttext->Expr->child->next->e_subtype == E_LABEL))) { if (ttext->Expr->child->e_subtype == E_LABEL) { +#ifdef DEBUG fprintf(stderr, "Symbole externe %s\n", ttext->Expr->child->symbol); +#endif a = ttext->Expr->child->next->avalue; nbsymbols++; writeword(1, f2, 1); @@ -1878,8 +1898,10 @@ void asm_eof(FILE * f) writestring(ttext->Expr->child->symbol, f2); nbe++; } else { +#ifdef DEBUG fprintf(stderr, "Symbole externe %s\n", ttext->Expr->child->next->symbol); +#endif a = ttext->Expr->child->avalue; nbsymbols++; writeword(1, f2, 1); @@ -1930,7 +1952,9 @@ void asm_eof(FILE * f) } else { if (ttext->Label) { nbsymbols++; +#ifdef DEBUG fprintf(stderr, "Symbole interne %s\n", ttext->Label); +#endif writeword(0, f2, 1); writeword(ttext->offset, f2, 1); if (ttext->Label[strlen(ttext->Label) - 1] == ':') { @@ -1951,7 +1975,9 @@ void asm_eof(FILE * f) for (tdata = tdata->next; tdata; tdata = tdata->next) { sprintf(errctx, _("Processing word number %i coming from line %i of the file %s."), tdata->offset, tdata->line, tdata->filename); +#ifdef DEBUG fprintf(stderr, "%s\n", errctx); +#endif pushcontext(errctx); a = 0; @@ -1963,7 +1989,9 @@ void asm_eof(FILE * f) break; case E_LABEL: a = tdata->Expr->avalue; +#ifdef DEBUG fprintf(stderr, "Symbole externe %s\n", tdata->Expr->child->symbol); +#endif nbsymbols++; writeword(3, f2, 1); writeword(tdata->offset, f2, 1); @@ -2011,7 +2039,9 @@ void asm_eof(FILE * f) } else { if (tdata->Label) { nbsymbols++; +#ifdef DEBUG fprintf(stderr, "Symbole interne %s\n", tdata->Label); +#endif writeword(2, f2, 1); writeword(tdata->offset, f2, 1); writeword(strlen(tdata->Label), f2, 1); @@ -2037,7 +2067,9 @@ void asm_eof(FILE * f) if (tbss->Label) { nbsymbols++; writeword(4, f2, 1); +#ifdef DEBUG fprintf(stderr, "Symbole interne %s\n", tbss->Label); +#endif writeword(tbss->offset, f2, 1); writeword(strlen(tbss->Label), f2, 1); writestring(tbss->Label, f2); |