From a3d177d3e521b6905a6f503d371912c266b99f5f Mon Sep 17 00:00:00 2001 From: johanknol Date: Thu, 14 Feb 2002 15:30:54 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1927 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- as/xa51/xa_link.c | 22 ++++++++++++++++---- src/xa51/gen.c | 51 +++++++++++++++-------------------------------- src/xa51/main.c | 6 +++--- 3 files changed, 37 insertions(+), 42 deletions(-) diff --git a/as/xa51/xa_link.c b/as/xa51/xa_link.c index 30dbe978..c083f929 100644 --- a/as/xa51/xa_link.c +++ b/as/xa51/xa_link.c @@ -192,6 +192,16 @@ struct SYMBOL *findSymbolByName(char *symName) { 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; @@ -262,7 +272,7 @@ void addToDefs(char *def, int address, char absolute) { // 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++; @@ -585,14 +595,17 @@ int scanLibraries(int unresolved) { 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; } } } @@ -697,10 +710,11 @@ int main(int argc, char **argv) { // 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", diff --git a/src/xa51/gen.c b/src/xa51/gen.c index ddadefa8..57e8cf0f 100755 --- a/src/xa51/gen.c +++ b/src/xa51/gen.c @@ -264,27 +264,28 @@ static asmop *aopForSym(symbol *sym, { 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; } @@ -1016,31 +1017,13 @@ static void genMod (iCode * ic) { 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) { @@ -1934,15 +1917,13 @@ void genXA51Code (iCode * lic) { 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: diff --git a/src/xa51/main.c b/src/xa51/main.c index 0c1584b2..f6ae8c8d 100755 --- a/src/xa51/main.c +++ b/src/xa51/main.c @@ -285,9 +285,9 @@ PORT xa51_port = TRUE, // use_dw_for_init 0, /* leave lt */ 0, /* leave gt */ - 0, /* transform <= to ! > */ - 0, /* transform >= to ! < */ - 0, /* transform != to !(a == b) */ + 1, /* transform <= to ! > */ + 1, /* transform >= to ! < */ + 1, /* transform != to !(a == b) */ 0, /* leave == */ FALSE, /* No array initializer support. */ cseCostEstimation, -- 2.39.5