return 0;
}
+struct MODULE *findModuleByName(char *modName) {
+ struct MODULE *module;
+ for (module=modules; module; module=module->next) {
+ if (strcmp(module->name, modName)==0) {
+ return module;
+ }
+ }
+ return NULL;
+}
+
void addToModules (char *name, int isLib) {
struct MODULE *module;
int s;
// no duplicates allowed
if ((symbol=findSymbolByName(def))) {
fprintf (stderr, "*** %s:%d duplicate symbol %s first defined in "
- "module %s:%d\n",
+ "module %s:%d\n",
currentModule->name, currentLine, def,
symbol->module->name, symbol->lineno);
fatalErrors++;
continue;
}
while (fgets(line, 132, lf)) {
- if (sscanf(line, "S %[^ ] Def", symName)==1) {
+ int dummy; // we need this to get the right count of the next sscanf
+ if (sscanf(line, "S %[^ ] Def%04x", symName, &dummy)==2) {
if (isUnresolved(symName, 1)) {
- fprintf (stderr, "%s:%s\n", libFile, symName);
+ //fprintf (stderr, "%s:%s\n", libFile, symName);
readModule(libFile,1);
if (resolved++ == unresolved) {
// we are done
return resolved;
}
+ // skip to next lib module
+ break;
}
}
}
// mark the resolved references
resolve();
- // now do something :) EXTREMELY SLOW AND INEFFICIENT
+ // now do something EXTREMELY SLOW AND INEFFICIENT :)
while ((unresolved=relocate())) {
if (!scanLibraries(unresolved)) {
struct REFERENCE *reference;
+ resolve();
for (reference=references; reference; reference=reference->next) {
if (!reference->resolved) {
fprintf (stderr, "*** unresolved symbol %s in %s:%d\n",
{
case 1:
emitcode (MOV, "r0,#%s", sym->rname);
- emitcode (MOVC, "r0l,[r0]");
+ emitcode (MOVC, "r0l,[r0+]");
sprintf (aop->name[0], "r0l");
return aop;
case 2:
emitcode (MOV, "r0,#%s", sym->rname);
- emitcode (MOVC, "r0,[r0]");
+ emitcode (MOVC, "r0,[r0+]");
sprintf (aop->name[0], "r0");
return aop;
case 3:
emitcode (MOV, "r0,#%s", sym->rname);
- emitcode (MOVC, "r1l,[r0+2]");
- sprintf (aop->name[1], "r1l");
- emitcode (MOV, "r0,[r0]");
- sprintf (aop->name[0], "r0");
+ emitcode (MOVC, "r0,[r0+]");
+ sprintf (aop->name[1], "r0");
+ emitcode (MOV, "r1l,[r0+]");
+ sprintf (aop->name[0], "r1l");
return aop;
case 4:
emitcode (MOV, "r0,#%s", sym->rname);
- emitcode (MOVC, "r1,[r0+2]");
- sprintf (aop->name[1], "r1");
- emitcode (MOVC, "r0,[r0]");
+ emitcode (MOVC, "r1,[r0+]");
+ emitcode (MOVC, "r0,[r0+]");
+ emitcode ("xch", "r0,r1");
sprintf (aop->name[0], "r0");
+ sprintf (aop->name[1], "r1");
return aop;
}
printIc ("genMod", ic, 1,1,1);
}
-/*-----------------------------------------------------------------*/
+ /*-----------------------------------------------------------------*/
/* genCmpGt :- greater than comparison */
/*-----------------------------------------------------------------*/
static void genCmpGt (iCode * ic) {
printIc ("genCmpGt", ic, 1,1,1);
}
/*-----------------------------------------------------------------*/
-/* genCmpGt :- greater than comparison */
-/*-----------------------------------------------------------------*/
-static void genCmpLe (iCode * ic) {
- printIc ("genCmpLe", ic, 1,1,1);
-}
-/*-----------------------------------------------------------------*/
-/* genCmpGt :- greater than comparison */
-/*-----------------------------------------------------------------*/
-static void genCmpGe (iCode * ic) {
- printIc ("genCmpGe", ic, 1,1,1);
-}
-/*-----------------------------------------------------------------*/
-/* genCmpGt :- greater than comparison */
-/*-----------------------------------------------------------------*/
-static void genCmpNe (iCode * ic) {
- printIc ("genCmpNe", ic, 1,1,1);
-}
-/*-----------------------------------------------------------------*/
/* genCmpLt - less than comparisons */
/*-----------------------------------------------------------------*/
static void genCmpLt (iCode * ic) {
break;
case LE_OP:
- genCmpLe (ic);
- break;
-
case GE_OP:
- genCmpGe (ic);
- break;
-
case NE_OP:
- genCmpNe (ic);
+
+ /* note these two are xlated by algebraic equivalence
+ during parsing SDCC.y */
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "got '>=' or '<=' shouldn't have come here");
break;
case EQ_OP: