X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=token.c;h=4ec487204ea74a6eec2ea0b8a4553e82b4458aaf;hp=8726eb4b9ee256ed536f9eff6ae061bb48d27dc0;hb=26019087571ebcafae571c7d32f485ceb8af8c5d;hpb=60f204cb9e3905100da0d89f14bb40db764acd9e diff --git a/token.c b/token.c index 8726eb4..4ec4872 100644 --- a/token.c +++ b/token.c @@ -7,9 +7,11 @@ // #include "token.h" +#include "direct.h" #include "error.h" #include "macro.h" #include "procln.h" +#include "sect.h" #include "symbol.h" #define DECL_KW // Declare keyword arrays @@ -18,7 +20,7 @@ int lnsave; // 1; strcpy() text of current line -int curlineno; // Current line number +uint16_t curlineno; // Current line number (64K max currently) int totlines; // Total # of lines int mjump_align = 0; // mjump alignment flag char lntag; // Line tag @@ -515,11 +517,11 @@ DEBUG printf("ExM: SYMBOL=\"%s\"", d); *dst++ = '"'; continue; break; -// Shamus: Changing the format specifier from %lx to %ux caused -// the assembler to choke on legitimate code... Need to investigate -// this further before changing anything else here! +// Shamus: Changing the format specifier from %lx to %ux caused the assembler +// to choke on legitimate code... Need to investigate this further +// before changing anything else here! case CONST: - sprintf(numbuf, "$%lx", (LONG)*tk++); + sprintf(numbuf, "$%lx", (long unsigned int)*tk++); d = numbuf; break; case DEQUALS: @@ -646,7 +648,6 @@ char * GetNextMacroLine(void) // char * GetNextRepeatLine(void) { - IREPT * irept = cur_inobj->inobj.irept; LONG * strp = irept->ir_nextln; // initial null @@ -1160,6 +1161,7 @@ if (debug) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); // Handle multiple-character tokens if (c & MULTX) { + switch (*ln++) { case '!': // ! or != @@ -1173,19 +1175,20 @@ if (debug) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); continue; case '\'': // 'string' + if (m6502) + { + // Hardcoded for now, maybe this will change in the future + *tk++ = STRINGA8; + goto dostring; + } + // Fall through case '\"': // "string" - c1 = ln[-1]; *tk++ = STRING; -//#warning -// More char * stuffing (8 bytes) into the space of 4 (TOKEN). -// Need to figure out how to fix this crap. -#if 0 - *tk++ = (TOKEN)ln; -#else +dostring: + c1 = ln[-1]; string[stringNum] = ln; *tk++ = stringNum; stringNum++; -#endif for(p=ln; *ln!=EOS && *ln!=c1;) { @@ -1563,17 +1566,12 @@ goteol: // expansion, and is NOT subject to macro expansion. The whitespace may also // be EOL. // -//int d_goto(WORD siz) { -//int d_goto(void) int d_goto(WORD unused) { - char * s1, * s2; - // Setup for the search if (*tok != SYMBOL) return error("missing label"); -// sym = (char *)tok[1]; char * sym = string[tok[1]]; tok += 2; @@ -1581,39 +1579,35 @@ int d_goto(WORD unused) return error("goto not in macro"); IMACRO * imacro = cur_inobj->inobj.imacro; -// defln = (LONG *)imacro->im_macro->svalue; struct LineList * defln = imacro->im_macro->lineList; - // Find the label, starting with the first line. + // Attempt to find the label, starting with the first line. for(; defln!=NULL; defln=defln->next) { -// if (*(char *)(defln + 1) == ':') + // Must start with a colon if (defln->line[0] == ':') { // Compare names (sleazo string compare) - // This string compare is not right. Doesn't check for lengths. - // (actually it does, but in a crappy, unclear way.) -WARNING(!!!! Bad string comparison !!!) - s1 = sym; -// s2 = (char *)(defln + 1) + 1; - s2 = defln->line; - - while (*s1 == *s2) + char * s1 = sym; + char * s2 = defln->line; + + // Either we will match the strings to EOS on both, or we will + // match EOS on string 1 to whitespace on string 2. Otherwise, we + // have no match. + while ((*s1 == *s2) || ((*s1 == EOS) && (chrtab[*s2] & WHITE))) { + // If we reached the end of string 1 (sym), we're done. + // Note that we're also checking for the end of string 2 as + // well, since we've established they're equal above. if (*s1 == EOS) - break; - else { - s1++; - s2++; + // Found the label, set new macro next-line and return. + imacro->im_nextln = defln; + return 0; } - } - // Found the label, set new macro next-line and return. - if ((*s2 == EOS) || ((int)chrtab[*s2] & WHITE)) - { - imacro->im_nextln = defln; - return 0; + s1++; + s2++; } } }