X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=expr.c;h=e552c39e9becf0d853436565d7bc4d731f5730b1;hp=6e0bd18b4360f92e587deef291dcb707bc1672e5;hb=f6e6a55c4cdaf0dffa0897792dc5926c7b173a23;hpb=d16b8ea0ee65b2ad901ca6b0624c07e6e4930cc4 diff --git a/expr.c b/expr.c index 6e0bd18..e552c39 100644 --- a/expr.c +++ b/expr.c @@ -12,7 +12,7 @@ #include "listing.h" #include "mach.h" #include "procln.h" -#include "risca.h" +#include "riscasm.h" #include "sect.h" #include "symbol.h" #include "token.h" @@ -60,7 +60,7 @@ static VALUE str_value(char * p) { VALUE v; - for(v=0; *p; ++p) + for(v=0; *p; p++) v = (v << 8) | (*p & 0xFF); return v; @@ -76,7 +76,7 @@ void init_expr(void) char * p; // Token pointer // Initialize token-class table - for(i=0; i<128; ++i) // Mark all entries END + for(i=0; i<128; i++) // Mark all entries END tokcl[i] = END; for(i=0, p=itokcl; *p!=1; p++) @@ -162,16 +162,7 @@ int expr1(void) #else p = string[*tok++]; #endif - -#if 0 - if (lookup(p, MACRO, 0) == NULL) - w = 0; - else - w = 1; -#else w = (lookup(p, MACRO, 0) == NULL ? 0 : 1); -#endif - *tk++ = CONST; *tk++ = (TOKEN)w; break; @@ -194,15 +185,7 @@ getsym: if (*p == '.') j = curenv; -#if 0 - if ((sy = lookup(p, LABEL, j)) != NULL && (sy->sattr & w)) - w = 1; - else - w = 0; -#else w = ((sy = lookup(p, LABEL, j)) != NULL && (sy->sattr & w) ? 1 : 0); -#endif - *tk++ = CONST; *tk++ = (TOKEN)w; break; @@ -345,12 +328,17 @@ int expr2(void) // int expr(TOKEN * otk, VALUE * a_value, WORD * a_attr, SYM ** a_esym) { + // Passed in values (once derefenced, that is) can all be zero. They are + // there so that the expression analyzer can fill them in as needed. The + // expression analyzer gets its input from "tok", and not from anything + // passed in by the user. SYM * sy; char * p; int j; - tk = otk; // Set token pointer to 'exprbuf' (direct.c) -// symbolNum = 0; // Set symbol number in symbolPtr[] to 0 + tk = otk; // Set token pointer to 'exprbuf' (direct.c) + // Also set in various other places too (riscasm.c, e.g.) +// symbolNum = 0; // Set symbol number in symbolPtr[] to 0 // Optimize for single constant or single symbol. if ((tok[1] == EOL) @@ -398,15 +386,16 @@ int expr(TOKEN * otk, VALUE * a_value, WORD * a_attr, SYM ** a_esym) } else { -#if 0 - p = (char *)tok[1]; -#else p = string[tok[1]]; -#endif + +#if 0 j = 0; if (*p == '.') j = curenv; +#else + j = (*p == '.' ? curenv : 0); +#endif sy = lookup(p, LABEL, j); @@ -415,14 +404,22 @@ int expr(TOKEN * otk, VALUE * a_value, WORD * a_attr, SYM ** a_esym) sy->sattr |= REFERENCED; + // Check for undefined register equates + if (sy->sattre & UNDEF_EQUR) + { + errors("undefined register equate '%s'", sy->sname); +//if we return right away, it returns some spurious errors... +// return ERROR; + } + // Check register bank usage if (sy->sattre & EQUATEDREG) { if ((regbank == BANK_0) && (sy->sattre & BANK_1) && !altbankok) - warns("equated symbol \'%s\' cannot be used in register bank 0", sy->sname); + warns("equated symbol '%s' cannot be used in register bank 0", sy->sname); if ((regbank == BANK_1) && (sy->sattre & BANK_0) && !altbankok) - warns("equated symbol \'%s\' cannot be used in register bank 1", sy->sname); + warns("equated symbol '%s' cannot be used in register bank 1", sy->sname); } *tk++ = SYMBOL;