X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=as%2Fxa51%2Fxa_main.c;h=345ca7e4ec44498a524c0ff0e3430715f88149c7;hb=065bada9e65008212e5f02c21d625cb61971da41;hp=aadba0f5468e1cb2990b5480c1617c6ec200a466;hpb=6f77a9c7e2f2183c54082a545ec13e744df02455;p=fw%2Fsdcc diff --git a/as/xa51/xa_main.c b/as/xa51/xa_main.c index aadba0f5..345ca7e4 100644 --- a/as/xa51/xa_main.c +++ b/as/xa51/xa_main.c @@ -57,7 +57,7 @@ struct target *targ_list=NULL; int lineno=1; int p1=0, p2=0, p3=0; int expr_result, expr_ok, jump_dest, inst; -int opcode, operand; +int opcode; char symbol_name[1000]; struct area_struct area[NUM_AREAS]; int current_area=0; @@ -76,9 +76,9 @@ char *areaToString (int area) { case AREA_XISEG: return "XISEG"; case AREA_XINIT: return "XINIT"; case AREA_GSINIT: return "GSINIT"; - case AREA_GSFINAL: return "GSFINAL"; - case AREA_HOME: return "HOME"; - case AREA_SSEG: return "SSEG"; + //case AREA_GSFINAL: return "GSFINAL"; + //case AREA_HOME: return "HOME"; + //case AREA_SSEG: return "SSEG"; } return ("UNKNOW"); } @@ -96,9 +96,12 @@ struct symbol * build_sym_list(char *thename) struct symbol *new, *p; if ((p=findSymbol(thename))) { - p->area=current_area; - //fprintf (stderr, "warning, symbol %s already defined\n", thename); - return p; + if (p->isdef) { + fprintf (stderr, "error: symbol %s already defined\n", thename); + exit (1); + } else { + return p; + } } //printf(" Symbol: %s Line: %d\n", thename, lineno); @@ -131,22 +134,22 @@ struct symbol *findSymbol (char *thename) { return NULL; } -int assign_value(char *thename, int thevalue, char mode) -{ - struct symbol *p; - - p = sym_list; - while (p != NULL) { - if (!(strcasecmp(thename, p->name))) { - p->value = thevalue; - p->isdef = 1; - p->mode = mode; - return (0); - } - p = p->next; - } - fprintf(stderr, "Internal Error! Couldn't find symbol\n"); - exit(1); +int assign_value(char *thename, int thevalue, char mode) { + struct symbol *p; + + p = sym_list; + while (p != NULL) { + if (!(strcasecmp(thename, p->name))) { + p->area=current_area; + p->value = thevalue; + p->isdef = 1; + p->mode = mode; + return (0); + } + p = p->next; + } + fprintf(stderr, "Internal Error! Couldn't find symbol\n"); + exit(1); } int mk_bit(char *thename, int area) @@ -223,7 +226,7 @@ int get_value(char *thename) while (p != NULL) { if (!(strcasecmp(thename, p->name))) { if (p->mode=='=') - return 0; + ;//return 0; return (p->value); } p = p->next; @@ -283,15 +286,15 @@ void print_symbol_table() fprintf(sym_fp, " Line %d\n", p->line_def); #else if (p->issfr) { - fprintf (sym_fp, "%-5s", "SFR"); + fprintf (sym_fp, "%-7s", "SFR"); } else if (p->isbit && !p->area) { - fprintf (sym_fp, "%-5s", "SBIT"); + fprintf (sym_fp, "%-7s", "SBIT"); } else if (p->mode=='=') { - fprintf (sym_fp,"ABS"); + fprintf (sym_fp,"ABS "); } else if (!p->isdef) { - fprintf (sym_fp,"EXTRN"); + fprintf (sym_fp,"EXTRN "); } else { - fprintf (sym_fp, "%-5s", areaToString(p->area)); + fprintf (sym_fp, "%-7s", areaToString(p->area)); } fprintf (sym_fp, " 0x%04x (%5d)", p->value, p->value); fprintf (sym_fp, " %s", p->isdef ? "D" : "-"); @@ -381,6 +384,17 @@ struct symbol *is_ref(char *thename) { return NULL; } +int is_abs(char *thename) { + struct symbol *p; + p = sym_list; + while (p != NULL) { + if (strcasecmp(thename, p->name)==0) + return p->mode == '='; + p = p->next; + } + return 0; +} + /* this routine is used to dump a group of bytes to the output */ /* it is responsible for generating the list file and sending */ /* the bytes one at a time to the object code generator */ @@ -425,7 +439,6 @@ void out(int *byte_list, int num) { } if (current_area==AREA_CSEG || current_area==AREA_GSINIT || - current_area==AREA_GSFINAL || current_area==AREA_XINIT) { if (num) { for (i=0; i 15) boob_error(); - out(0x20 + (operand & 15)); - } else { - if (operand > 15) boob_error(); - out(0x30 + (operand & 15)); - } - } -} -*/ - /* turn a string like "10010110b" into an int */ int binary2int(char *str) @@ -552,9 +546,8 @@ void relPrelude() { } for (p=sym_list; p; p=p->next) { if (p->isdef) { - // skip temp labels, sfr and sbit - if (p->name[strlen(p->name)-1]!='$' && - p->area) { + // skip temp labels + if (p->name[strlen(p->name)-1]!='$') { globals++; } }