#define DEF_KW
#include "kwtab.h"
-TOKEN exprbuf[128]; // Expression buffer
+TOKEN exprbuf[128]; // Expression buffer
+SYM * symbolPtr[1000000]; // Symbol pointers table
// Directive handler table
int (*dirtab[])() = {
d_include, // 33 include
fpop, // 34 end
d_unimpl, // 35* macro
- exitmac, // 36* exitm
+ ExitMacro, // 36* exitm
d_unimpl, // 37* endm
d_list, // 38 list
d_nlist, // 39 nlist
switch(*tok)
{
case STRING:
- sprintf(prntstr, "%s", (char *)tok[1]);
+// sprintf(prntstr, "%s", (char *)tok[1]);
+ sprintf(prntstr, "%s", string[tok[1]]);
printf("%s", prntstr);
if (list_fd)
if (tok[1] != SYMBOL)
goto token_err;
- strcpy(prntstr, (char *)tok[2]);
+// strcpy(prntstr, (char *)tok[2]);
+ strcpy(prntstr, string[tok[2]]);
switch(prntstr[0])
{
return ERROR;
}
- ccname = lookup((char *)tok[1], LABEL, 0);
+// ccname = lookup((char *)tok[1], LABEL, 0);
+ ccname = lookup(string[tok[1]], LABEL, 0);
// Make sure symbol is a valid ccdef
if (!ccname || !(ccname->sattre & EQUATEDCC))
}
// Lookup and undef if equated register
- regname = lookup((char *)tok[1], LABEL, 0);
+// regname = lookup((char *)tok[1], LABEL, 0);
+ regname = lookup(string[tok[1]], LABEL, 0);
if (regname && (regname->sattre & EQUATEDREG))
regname->sattre |= UNDEF_EQUR;
long pos, size;
char buf;
+ // Check to see if we're in BSS, and, if so, throw an error
+ if (scattr & SBSS)
+ {
+ errors("Cannot include binary file \"%s\" in BSS section", string[tok[1]]);
+ return ERROR;
+ }
+
if (*tok != STRING)
{
error(syntax_error);
return ERROR;
}
- if ((j = open((char *)tok[1], _OPEN_INC)) >= 0)
+// if ((j = open((char *)tok[1], _OPEN_INC)) >= 0)
+ if ((j = open(string[tok[1]], _OPEN_INC)) >= 0)
{
size = lseek(j, 0L, SEEK_END);
chcheck(size);
pos = lseek(j, 0L, SEEK_SET);
-
+
+ DEBUG
+ {
+ printf("INCBIN: File '%s' is %li bytes.\n", string[tok[1]], size);
+ }
+
for(i=0; i<size; i++)
{
buf = '\0';
}
else
{
- errors("cannot open include binary file (%s)", (char *)tok[1]);
+// errors("cannot open include binary file (%s)", (char *)tok[1]);
+ errors("cannot open include binary file (%s)", string[tok[1]]);
return ERROR;
}
if (*tok != SYMBOL)
return error(em);
+#if 0
if ((*func)(tok[1]) != OK)
+#else
+ if ((*func)(string[tok[1]]) != OK)
+#endif
break;
tok += 2;
char buf[128];
char buf1[128];
- if (*tok == STRING) // Leave strings ALONE
+ if (*tok == STRING) // Leave strings ALONE
+#if 0
fn = (char *)*++tok;
+#else
+ fn = string[*++tok];
+#endif
else if (*tok == SYMBOL) // Try to append ".s" to symbols
{
+#if 0
strcpy(buf, (char *)*++tok);
+#else
+ strcpy(buf, string[*++tok]);
+#endif
fext(buf, ".s", 0);
fn = &buf[0];
}
- else // Punt if no STRING or SYMBOL
+ else // Punt if no STRING or SYMBOL
return error("missing filename");
// Make sure the user didn't try anything like:
if (*++tok != EOL)
return error("extra stuff after filename -- enclose it in quotes");
- // Attempt to open the include file in the current directory, then (if that failed) try list
- // of include files passed in the enviroment string or by the "-d" option.
+ // Attempt to open the include file in the current directory, then (if that
+ // failed) try list of include files passed in the enviroment string or by
+ // the "-d" option.
if ((j = open(fn, 0)) < 0)
{
for(i=0; nthpath("RMACPATH", i, buf1)!=0; ++i)
{
j = strlen(buf1);
- if (j > 0 && buf1[j-1] != SLASHCHAR) // Append path char if necessary
+ if (j > 0 && buf1[j-1] != SLASHCHAR) // Append path char if necessary
strcat(buf1, SLASHSTRING);
strcat(buf1, fn);
if ((sy = lookup(p, LABEL, 0)) == NULL)
{
- sy = newsym(p, LABEL, 0);
+ sy = NewSymbol(p, LABEL, 0);
sy->svalue = 0;
sy->sattr = GLOBAL;
}
// dc.b 'string' [,] ...
if (siz == SIZB && *tok == STRING && (tok[2] == ',' || tok[2] == EOL))
{
- i = strlen((const char*)tok[1]);
+// i = strlen((const char*)tok[1]);
+ i = strlen(string[tok[1]]);
if ((challoc - ch_size) < i)
chcheck(i);
- for(p=(char *)tok[1]; *p!=EOS; ++p)
+ for(p=string[tok[1]]; *p!=EOS; ++p)
D_byte(*p);
tok += 2;
if (*tok != SYMBOL)
return error("missing symbol");
- p = (char *)tok[1];
+// p = (char *)tok[1];
+ p = string[tok[1]];
tok += 2;
- if (*p == '.') // Cannot .comm a local symbol
+ if (*p == '.') // Cannot .comm a local symbol
return error(locgl_error);
if ((sym = lookup(p, LABEL, 0)) == NULL)
- sym = newsym(p, LABEL, 0);
+ sym = NewSymbol(p, LABEL, 0);
else
{
if (sym->sattr & DEFINED)
return error(".comm symbol already defined");
}
- sym->sattr = GLOBAL|COMMON|BSS;
+ sym->sattr = GLOBAL | COMMON | BSS;
if (*tok++ != ',')
return error(comma_error);
- if (abs_expr(&eval) != OK) // Parse size of common region
+ if (abs_expr(&eval) != OK) // Parse size of common region
return 0;
- sym->svalue = eval; // Install common symbol's size
+ sym->svalue = eval; // Install common symbol's size
at_eol();
return 0;
}
if (abs_expr(&eval) != OK)
return 0;
- if (*tok == ',') // Eat comma if it's there
+ if (*tok == ',') // Eat comma if it's there
++tok;
}
else
{
if (*tok == SYMBOL)
{
- p = (char *)tok[1];
+// p = (char *)tok[1];
+ p = string[tok[1]];
if (*p == '.')
env = curenv;
if (sy == NULL)
{
- sy = newsym(p, LABEL, env);
+ sy = NewSymbol(p, LABEL, env);
sy->sattr = 0;
}
else if (sy->sattr & DEFINED)