xa51, work in progress
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 13 Feb 2002 18:28:07 +0000 (18:28 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 13 Feb 2002 18:28:07 +0000 (18:28 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1924 4a8a32a2-be11-0410-ad9d-d568d2c75423

as/xa51/xa_link.c
device/examples/xa51/Makefile
device/examples/xa51/hello.c
device/lib/Makefile.in
src/SDCCicode.c
src/SDCCmain.c
src/xa51/gen.c
support/regression/ports/xa51/spec.mk
support/regression/ports/xa51/support.c
support/regression/tests/bug-460010.c

index 3284925ddac7e783847d058ac2c2de9e6380bdff..30dbe9784cb2140681fca25eb9d2a2332f2b3a45 100644 (file)
@@ -14,7 +14,7 @@
 
 /* This is a cheap hack. The xa51 has a couple of ways to scramble
    relocation info into it's opcode that the standard linker can't
-   handle. 
+   handle. No hash or qsort yet.
 
    The relocatable format looks like the known one, BUT ISN'T.
 
@@ -34,7 +34,7 @@
      the address of the following instruction).
 
    So, this is not a standalone linker. It will only link files generated
-   by xa_asm, which will only process files generated by the xa51 sdcc
+   by xa_rasm, which will only process files generated by the xa51 sdcc
    port.
 */
 
@@ -121,6 +121,7 @@ struct MODULE {
   char *name;
   int offset[MAX_SEGMENTS];
   int size[MAX_SEGMENTS];
+  int isLib;
   struct MODULE *next;
   struct MODULE *last;
 } *modules=NULL;
@@ -143,16 +144,19 @@ struct REFERENCE {
   int lineno;
   unsigned address, pc;
   short how;
+  short resolved;
   struct REFERENCE *next;
   struct REFERENCE *last;
 } *references=NULL;
 
-char *libPaths[128];
+char *libraryPaths[128];
 int nlibPaths=0;
-char *libFiles[128];
+char *libraryFiles[128];
 int nlibFiles=0;
 
 static char outFileName[PATH_MAX]={'\0'};
+static char mapFileName[PATH_MAX]={'\0'};
+FILE *mapOut;
 
 struct SEGMENT *currentSegment;
 struct MODULE *currentModule;
@@ -188,20 +192,19 @@ struct SYMBOL *findSymbolByName(char *symName) {
   return 0;
 }
 
-void addToModules (char *name) {
+void addToModules (char *name, int isLib) {
   struct MODULE *module;
   int s;
 
-  //fprintf (stderr, "addToModules: %s\n", name);
-
   module=calloc(1, sizeof(struct MODULE));
   module->name=strdup(name);
   for (s=0; s<MAX_SEGMENTS; s++) {
     module->offset[s]=segments[s].current;
   }
+  module->isLib=isLib;
   if (!modules) {
     modules=module;
-  } else {
+   } else {
     modules->last->next=module;
   }
   currentModule=modules->last=module;
@@ -210,8 +213,6 @@ void addToModules (char *name) {
 void addToRefs(char *ref, int address, char *how, int pc) {
   struct REFERENCE *reference;
 
-  //fprintf (stderr, "addToRefs: %s\n", ref);
-
   reference=calloc(1, sizeof(struct REFERENCE));
   reference->name=strdup(ref);
   reference->module=currentModule;
@@ -227,14 +228,37 @@ void addToRefs(char *ref, int address, char *how, int pc) {
   references->last=reference;
 }
 
+void resolve() {
+  struct REFERENCE *reference;
+  for (reference=references; reference; reference=reference->next) {
+    if (findSymbolByName(reference->name)) {
+      reference->resolved=1;
+    }
+  }
+}
+
+int isUnresolved(char *ref, int resolved) {
+  struct REFERENCE *reference;
+
+  for (reference=references; reference; reference=reference->next) {
+    if (strcmp(reference->name, ref)==0) {
+      // found 
+      if (reference->resolved) {
+       // already resolved
+       return 0;
+      }
+      if (resolved) {
+       reference->resolved=1;
+       return 1;
+      }
+    }
+  }
+  return 0;
+}
+
 void addToDefs(char *def, int address, char absolute) {
   struct SYMBOL *symbol;
 
-  /* fprintf (stderr, "addToDefs: %s %s 0x%04x + 0x%04x\n", 
-     currentSegment->name, def, 
-     currentModule->offset[currentSegment->id],
-     address); */
-
   // no duplicates allowed
   if ((symbol=findSymbolByName(def))) {
     fprintf (stderr, "*** %s:%d duplicate symbol %s first defined in "
@@ -263,37 +287,10 @@ void addToDefs(char *def, int address, char absolute) {
 void syntaxError (char *err) {
   fprintf (stderr, "*** %s:%d error while parsing '%s'\n", 
           currentModule->name, currentLine, err);
-  exit(1);
+  fatalErrors++;
 }
 
-void baseName(char *name, char*base) {
-  int i, first, last;
-
-  // find the last path seperator in name
-  for (first=strlen(name)-1; 
-       (name[first]!='/' && name[first]!='\\') && first;
-       first--);
-  if (name[first]=='/' || name[first]=='\\') {
-    first++;
-  }
-
-  // find the last ext seperator in name
-  for (last=strlen(name)-1; 
-       (name[last]!='.' && last);
-       last--);
-  if (!last) {
-    last=strlen(name);
-  }
-
-  fprintf (stderr, "baseName: %s %d %d\n", name, first, last);
-  // fill the base with the baseName
-  for (i=first; i<last; i++) {
-    base[i-first]=name[i];
-  }
-  base[i]='\0';
-}
-  
-void readModule(char *module) {
+void readModule(char *module, int isLib) {
   double hisVersion;
   char line[132];
   FILE *relModule;
@@ -307,8 +304,6 @@ void readModule(char *module) {
     exit (1);
   }
 
-  //fprintf (stderr, "ReadModule: %s\n", module);
-
   // first we need to check if this is a valid file
   if (sscanf(fgets(line, 132, relModule), 
             "SDCCXA rel, version %lf", &hisVersion)!=1) {
@@ -337,10 +332,8 @@ void readModule(char *module) {
   }
 
   // add this to the known modules with current offsets
-  addToModules(module);
+  addToModules(module, isLib);
 
-  fprintf (stderr, "module %s has %d segment%s and %d globals\n",
-          moduleName, segments, segments==1?"":"s", globals);
   currentLine++;
 
   // now for the ASTR tags
@@ -360,6 +353,7 @@ void readModule(char *module) {
                   currentLine, segment);
          exit (1);
        }
+       // double check repeated 'A' records
        if (currentModule->size[currentSegment->id]) {
          if (currentModule->size[currentSegment->id] != size) {
            fprintf (stderr, "*** %s:%d error %s size %d != %d\n",
@@ -367,6 +361,7 @@ void readModule(char *module) {
                     currentSegment->name,
                     currentModule->size[currentSegment->id], 
                     size);
+           fatalErrors++;
          } else {
            // pleased to meet you again
          }
@@ -375,7 +370,6 @@ void readModule(char *module) {
          currentModule->offset[currentSegment->id]+=currentSegment->_size;
          currentSegment->_size += size;
        }
-       //fprintf (stderr, "Area: %s size: %d\n", segment, size);
        // never mind about the flags for now
        break;
       }
@@ -417,26 +411,22 @@ void readModule(char *module) {
        }
        if (sscanf(strtok(&line[2], " "), "%04x", &address)!=1) {
          fprintf (stderr, "%s:%d error in T record\n", module, currentLine);
-         exit (1);
+         fatalErrors++;
        }
-       //fprintf (stderr, "%04x:", address);
        address+=currentSegment->current;
        for ( ;
              (tline=strtok(NULL, " \t\n")) && 
                (sscanf(tline, "%02x", &byte)==1);
              ) {
-         //fprintf (stderr, " %02x", byte);
          currentSegment->image[address++]=byte;
          currentSegment->current++;
        }
-       //fprintf (stderr, "\n");
        break;
       }
       case 'R': {
        unsigned address, from;
        char symbol[132];
        char how[32];
-       //fprintf (stderr, "%s", line);
        sscanf (line, "R %x %[^ ] %[^ ] %x", &address, how, symbol, &from);
        addToRefs (symbol, address, how, from);
        break;
@@ -456,7 +446,6 @@ void readModule(char *module) {
 void writeModule(char *outFileName) {
   FILE *fOut;
 
-  fprintf (stderr, "WriteModule: %s\n", outFileName);
   if ((fOut=fopen(outFileName, "w"))==NULL) {
     perror (outFileName);
   }
@@ -464,15 +453,14 @@ void writeModule(char *outFileName) {
   fclose (fOut);
 }
 
-void relocate() {
+int relocate() {
   struct SYMBOL *symbol;
   struct REFERENCE *reference;
   char *from, *to;
   int length=segments[GSINIT].current +
     segments[CSEG].current +
     segments[XINIT].current;
-
-  //fprintf (stderr, "relocate: total code size: 0x%04x\n", length);
+  int unresolved=0;
 
   // first check if it will fit
   if (length > 0xffff) {
@@ -480,10 +468,21 @@ void relocate() {
     fatalErrors++;
   }
 
+  // resolve reverences
+  for (reference=references; reference; reference=reference->next) {
+    if (!reference->resolved && !findSymbolByName(reference->name)) {
+      unresolved++;
+    }
+  }
+  if (unresolved) {
+    // first scan the libraries
+    return unresolved;
+  }
+
   // GSINIT gets the --code-loc
   segments[GSINIT].start=segments[CSEG].start;
   segments[CSEG].start=segments[GSINIT].start+segments[GSINIT]._size;
-  // concat cseg to gsinit
+  // concat cseg and gsinit
   from=csegImage;
   to=&gsinitImage[segments[GSINIT].start+segments[GSINIT]._size];
   memcpy(to, from, segments[CSEG]._size);
@@ -503,19 +502,14 @@ void relocate() {
       symbol->address += symbol->segment->start;
     }
   }
-  // add the segment symbols
-  currentSegment=findSegmentByName("XINIT");
-  addToDefs("s_XINIT", segments[XINIT].start, 0);
-  addToDefs("l_XINIT", segments[XINIT]._size, 0);
-  currentSegment=findSegmentByName("XISEG");
-  addToDefs("s_XISEG", segments[XISEG].start, 0);
-  addToDefs("l_XISEG", segments[XISEG]._size, 0);
   // and the references
   for (reference=references; reference; reference=reference->next) {
     if (!(symbol=findSymbolByName(reference->name))) {
+      // this reference isn't defined after all
       fprintf (stderr, "*** %s:%d undefined symbol %s\n",
               reference->module->name, reference->lineno,
               reference->name);
+      fatalErrors++;
     } else {
       reference->address += symbol->segment->start;
       switch (reference->how) 
@@ -556,6 +550,7 @@ void relocate() {
        }
     }
   }
+  return 0;
 }
 
 void usage (char * progName, int errNo) {
@@ -565,6 +560,48 @@ void usage (char * progName, int errNo) {
   }
 }
 
+int scanLibraries(int unresolved) {
+  int resolved=0;
+  int nlp, nlf;
+  char libFiles[PATH_MAX];
+  char libFile[PATH_MAX];
+  char line[132];
+  char symName[132];
+  FILE *lf, *lfs;
+  
+  for (nlp=0; nlp<nlibPaths; nlp++) {
+    for (nlf=0; nlf<nlibFiles; nlf++) {
+      sprintf (libFiles, "%s/%s.lib", libraryPaths[nlp], libraryFiles[nlf]);
+      //fprintf (stderr, "  %s\n", libFiles);
+      if ((lfs=fopen(libFiles,"r"))==NULL) {
+       continue;
+      }
+      while (fgets(line, 132, lfs)) {
+       // remove trailing \n
+       line[strlen(line)-1]='\0';
+       sprintf (libFile, "%s/%s", libraryPaths[nlp], line);
+       //fprintf (stderr, "    %s\n", libFile);
+       if ((lf=fopen(libFile,"r"))==0) {
+         continue;
+       }
+       while (fgets(line, 132, lf)) {
+         if (sscanf(line, "S %[^ ] Def", symName)==1) {
+           if (isUnresolved(symName, 1)) {
+             fprintf (stderr, "%s:%s\n", libFile, symName);
+             readModule(libFile,1);
+             if (resolved++ == unresolved) {
+               // we are done
+               return resolved;
+             }
+           }
+         }
+       }
+      }
+    }
+  }
+  return resolved;
+}
+
 int main(int argc, char **argv) {
   FILE *linkCommandsFile;
   char linkCommandsPath[PATH_MAX];
@@ -572,6 +609,7 @@ int main(int argc, char **argv) {
   struct MODULE *module;
   struct SYMBOL *symbol;
   int s;
+  int unresolved;
 
   if (argc!=2) {
     usage(argv[0], 1);
@@ -613,8 +651,6 @@ int main(int argc, char **argv) {
                           &segments[s].start)!=1) {
                  syntaxError(linkCommand);
                }
-               /* fprintf (stderr, "%s starts at 0x%04x\n", segments[s].name,
-                  segments[s].start); */
                break;
              }
            }
@@ -625,60 +661,96 @@ int main(int argc, char **argv) {
          break;
        case 'k':
          // a lib path like: "-k /usr/local/share/sdcc/lib/xa51"; one/line
-         libPaths[nlibPaths++]=strdup(&linkCommand[3]);
+         libraryPaths[nlibPaths++]=strdup(&linkCommand[3]);
          break;
        case 'l':
          // a lib file like: "-l libsdcc"; one/line
-         libFiles[nlibFiles++]=strdup(&linkCommand[3]);
+         libraryFiles[nlibFiles++]=strdup(&linkCommand[3]);
          break;
        default:
          syntaxError(linkCommand);
        }
     } else {
       // not a switch, must be an inputfile; one/line
-      readModule(linkCommand);
+      readModule(linkCommand, 0);
       // the first one defines the output name
       if (!outFileName[0]) {
        strncpy(outFileName, linkCommand,
                strlen(linkCommand)-4);
+       sprintf(mapFileName, "%s.map", outFileName);
        strcat(outFileName, ".hex");
+       if ((mapOut=fopen(mapFileName, "w"))==NULL) {
+         perror(mapFileName);
+       }
+      }
+    }
+  }
+
+  // add the segment symbols
+  currentSegment=findSegmentByName("XINIT");
+  addToDefs("s_XINIT", segments[XINIT].start, 0);
+  addToDefs("l_XINIT", segments[XINIT]._size, 0);
+  currentSegment=findSegmentByName("XISEG");
+  addToDefs("s_XISEG", segments[XISEG].start, 0);
+  addToDefs("l_XISEG", segments[XISEG]._size, 0);
+
+  // mark the resolved references
+  resolve();
+
+  // now do something :) EXTREMELY SLOW AND INEFFICIENT
+  while ((unresolved=relocate())) {
+    if (!scanLibraries(unresolved)) {
+      struct REFERENCE *reference;
+      for (reference=references; reference; reference=reference->next) {
+       if (!reference->resolved) {
+         fprintf (stderr, "*** unresolved symbol %s in %s:%d\n",
+                  reference->name, reference->module->name,
+                  reference->lineno);
+         fatalErrors++;
+       }
       }
+      break;
     }
   }
 
-  relocate();
+  if (unresolved==0) {
+    writeModule(outFileName);
+  }
 
   // the modules
+  fprintf (mapOut, "Modules:\n");
   for (module=modules; module; module=module->next) {
-    fprintf (stderr, "%s: ", module->name);
+    fprintf (mapOut, "\t%s\n", module->name);
     for (s=0; s<MAX_SEGMENTS; s++) {
       if (module->size[s]) {
-       fprintf (stderr, "%s:0x%04x-0x%04x ", segments[s].name,
+       fprintf (mapOut, "\t\t%s:0x%04x-0x%04x\n", segments[s].name,
                 module->offset[s], module->offset[s]+module->size[s]);
       }
     }
-    fprintf (stderr, "\n");
-  }
-
-  // the symbols
-  for (symbol=symbols; symbol; symbol=symbol->next) {
-    fprintf (stderr, "%s %s %s0x%04x %s\n", symbol->name, 
-            symbol->segment->name,
-            symbol->absolute ? "= " : "",
-            symbol->address, symbol->module->name);
   }
 
   // the segments
+  fprintf (mapOut, "\nSegments:\n");
   for (s=1; s<MAX_SEGMENTS; s++) {
     if (segments[s]._size) {
-      fprintf (stderr, "%s start 0x%04x size 0x%04x %d symbols\n",
+      fprintf (mapOut, "\t%s start 0x%04x size 0x%04x %d symbols\n",
               segments[s].name, segments[s].start,
               segments[s]._size, 
               segments[s].hasSymbols);
     }
   }
 
+  // the symbols
+  fprintf (mapOut, "\nSymbols:\n");
+  for (symbol=symbols; symbol; symbol=symbol->next) {
+    fprintf (mapOut, "%s\t%s %s0x%04x %s\n", symbol->name, 
+            symbol->segment->name,
+            symbol->absolute ? "= " : "",
+            symbol->address, symbol->module->name);
+  }
+
   writeModule(outFileName);
+  fclose(mapOut);
   return fatalErrors? 1 : 0;
 }
 
index de7a759e993404d58ea0915ae97180ea46d6d2dd..fcc126119962aa09fbcca9bbafa6c0cb8060521e 100644 (file)
@@ -1,6 +1,6 @@
 CC = sdcc
 
-CFLAGS= -Wa-s -V
+CFLAGS= -Wa-s 
 MFLAGS= -mxa51
 LFLAGS= --xram-loc 0x4000
 
index c7906cd045243da066829a3d0ad2f4dd9b436367..f908681d735d0ea2370f01f6b6c87ff1b8aec702 100755 (executable)
@@ -13,7 +13,7 @@ xdata at 0x1234 abs;
 extern xdata xee;
 
 void main(void) {
-  xe=getchar();
+  //xe=getchar();
   abs=1;
   putchar('1');
   putchar('2');
index 8efe2a186ff047ce281b105a9cdf57c746ed26d0..8583abf104e73863d158fc669f0c2256fd541e8c 100644 (file)
@@ -113,7 +113,7 @@ XA51SOURCES      = _atoi.c _atol.c _schar2fs.c \
                  asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
                  sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c
 
-XA51OBJECTS      = $(XA51SOURCES:%.c=$(PORTDIR)/%.xa)
+XA51OBJECTS      = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
 
 OEXT            = .rel
 
@@ -139,11 +139,11 @@ model-ds390:
 
 model-xa51:
        if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
-         $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51 OEXT=.xa; \
+         $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
        fi
 
 objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
-       cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
+       cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
 
 model-z80:
        if [ "`grep z80 ../../ports.build`" = z80 ]; then \
@@ -234,7 +234,7 @@ include clean.mk
 $(PORTDIR)/%$(OEXT): %.c
        $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
        mv -f `basename $@` $@
-       -mv -f `basename $@ $(OEXT)`.asm $(PORTDIR)
+       mv -f `basename $@ $(OEXT)`.asm $(PORTDIR)
 
 # Remaking configuration
 # ----------------------
index 0f3e0725ad90725de33233b577fb63f7942c93fb..4b44dd2540c427dc1b0b439d6e47f91e2592a997 100644 (file)
@@ -1645,7 +1645,6 @@ geniCodeRValue (operand * op, bool force)
   if (IS_SPEC (type) &&
       IS_TRUE_SYMOP (op) &&
       (!IN_FARSPACE (SPEC_OCLS (etype)) ||
-      /* TARGET_IS_DS390)) */
       (options.model == MODEL_FLAT24) ))
     {
       op = operandFromOperand (op);
@@ -2933,7 +2932,6 @@ geniCodeReceive (value * args)
 
              if (IN_FARSPACE (SPEC_OCLS (sym->etype)) &&
                  options.stackAuto == 0 &&
-                 /* !TARGET_IS_DS390) */
                  (!(options.model == MODEL_FLAT24)) )
                {
                }
index 10d42aa00420719b15fb14aa542ce05a38100be9..710d72be4607391abf4b1895d6da8ffccec385b1 100644 (file)
@@ -1160,11 +1160,14 @@ linkEdit (char **envp)
       mfprintf (lnkfile, getRuntimeVariables(), "-k {libdir}{sep}%s\n", c);
 
       /* standard library files */
-      /* if (strcmp (port->target, "ds390") == 0) */
       if (options.model == MODEL_FLAT24)
        {
          fprintf (lnkfile, "-l %s\n", STD_DS390_LIB);
        }
+      if (options.model == MODEL_PAGE0)
+       {
+         fprintf (lnkfile, "-l %s\n", STD_XA51_LIB);
+       }
       fprintf (lnkfile, "-l %s\n", STD_LIB);
       fprintf (lnkfile, "-l %s\n", STD_INT_LIB);
       fprintf (lnkfile, "-l %s\n", STD_LONG_LIB);
index 7395180170b3b44a818178a9dd5b3e55c115767e..ddadefa85a2c012ca4e9590f1a318b531593540a 100755 (executable)
@@ -861,28 +861,31 @@ genEndFunction (iCode * ic)
 /*-----------------------------------------------------------------*/
 static void genRet (iCode * ic) {
 
-  printIc ("genRet", ic, 0,1,0);
-
-  aopOp(IC_LEFT(ic), TRUE, TRUE);
+  if (!IC_LEFT(ic)) {
+    printIc ("genRet", ic, 0, 0, 0);
+  } else {
+    printIc ("genRet", ic, 0, 1, 0);
+    aopOp(IC_LEFT(ic), TRUE, TRUE);
+    switch (AOP_SIZE(IC_LEFT(ic)))
+      {
+      case 4:
+       emitcode ("mov", "r1,%s", AOP_NAME(IC_LEFT(ic))[1]);
+       emitcode ("mov", "r0,%s", AOP_NAME(IC_LEFT(ic))[0]);
+       break;
+      case 3:
+       emitcode ("mov", "r1l,%s", AOP_NAME(IC_LEFT(ic))[1]);
+       // fall through
+      case 2:
+       emitcode ("mov", "r0,%s", AOP_NAME(IC_LEFT(ic))[0]);
+       break;
+      case 1:
+       emitcode ("mov", "r0l,%s", AOP_NAME(IC_LEFT(ic))[0]);
+       break;
+      default:
+       bailOut("genRet");
+      }
+  }
 
-  switch (AOP_SIZE(IC_LEFT(ic)))
-    {
-    case 4:
-      emitcode ("mov", "r1,%s", AOP_NAME(IC_LEFT(ic))[1]);
-      emitcode ("mov", "r0,%s", AOP_NAME(IC_LEFT(ic))[0]);
-      break;
-    case 3:
-      emitcode ("mov", "r1l,%s", AOP_NAME(IC_LEFT(ic))[1]);
-      // fall through
-    case 2:
-      emitcode ("mov", "r0,%s", AOP_NAME(IC_LEFT(ic))[0]);
-      break;
-    case 1:
-      emitcode ("mov", "r0l,%s", AOP_NAME(IC_LEFT(ic))[0]);
-      break;
-    default:
-      bailOut("genRet");
-    }
   emitcode ("jmp", "%05d$", returnLabel->key+100);
 }
 
@@ -941,6 +944,27 @@ static void genPlus (iCode * ic) {
   aopOp(left, !aopIsPtr(result), !aopIsDir(result));
   aopOp(right, !aopIsPtr(result), !aopIsDir(result));
 
+  // special case for * = * + char, needs a closer look
+  // heck, this shouldn't have come here but bug-223113 does
+  if (size==3 && AOP_SIZE(right)==1) {
+    emitcode ("mov", "r1l,%s", AOP_NAME(right)[0]);
+    emitcode ("mov", "r1h,#0"); // ptr arith unsigned????????????
+    emitcode ("mov", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]);
+    emitcode ("add.w", "%s,r1", AOP_NAME(result)[0]);
+    emitcode ("mov", "%s,%s", AOP_NAME(result)[1], AOP_NAME(left)[1]);
+    return;
+  }
+
+  // special case for (whatever)* = (whatever)** + char, needs a closer look
+  // heck, this shouldn't have come here but bug-441448 does
+  if (size==2 && AOP_SIZE(right)==1) {
+    emitcode ("mov", "r1l,%s", AOP_NAME(right)[0]);
+    emitcode ("mov", "r1h,#0"); // ptr arith unsigned????????????
+    emitcode ("mov", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]);
+    emitcode ("add.w", "%s,r1", AOP_NAME(result)[0]);
+    return;
+  }
+
   if (size>1) {
     instr="add.w";
   } else {
@@ -1276,6 +1300,10 @@ static void genPointerGet (iCode * ic, iCode *pi) {
 
   switch (AOP_TYPE(left)) 
     {
+    case AOP_LIT:
+      emitcode("mov","r1,%s", AOP_NAME(left)[0]);
+      sprintf (AOP_NAME(left)[0], "r1");
+      // fall through
     case AOP_REG:
       if (size>1) {
        if (codePointer) {
@@ -1472,7 +1500,7 @@ static void genAddrOf (iCode * ic) {
              getStackOffset(OP_SYMBOL(left)->stack));
     if (size > 2) {
       // this must be a generic pointer
-      emitcode ("mov", "%s,#0x%02x", AOP_NAME(IC_RESULT(ic))[1], FPOINTER);
+      emitcode ("mov.b", "%s,#0x%02x", AOP_NAME(IC_RESULT(ic))[1], FPOINTER);
     }
     return;
   }
@@ -1648,13 +1676,13 @@ static void genCast (iCode * ic) {
       switch (ptrType)
        {
        case POINTER:
-         emitcode ("mov", "%s,#0x00", AOP_NAME(result)[1]);
+         emitcode ("mov.b", "%s,#0x00", AOP_NAME(result)[1]);
          break;
        case FPOINTER:
-         emitcode ("mov", "%s,#0x01", AOP_NAME(result)[1]);
+         emitcode ("mov.b", "%s,#0x01", AOP_NAME(result)[1]);
          break;
        case CPOINTER:
-         emitcode ("mov", "%s,#0x02", AOP_NAME(result)[1]);
+         emitcode ("mov.b", "%s,#0x02", AOP_NAME(result)[1]);
          break;
        default:
          bailOut("genCast: got unknown storage class");
index a235690c685adcd0b4c3f8bad3a50ee18d5784f6..27137dde134c7d6740c0489b28e3f1e3a9996997 100755 (executable)
@@ -25,7 +25,7 @@ EXTRAS = fwk/lib/testfwk$(OBJEXT) $(PORTS_DIR)/$(PORT)/support$(OBJEXT)
 # run simulator with 10 seconds timeout
 %.out: %$(EXEEXT) fwk/lib/timeout
        mkdir -p `dirname $@`
-       -fwk/lib/timeout 10 $(SXA) -S in=/dev/null,out=$@ $< < $(PORTS_DIR)/xa51/uCsim.cmd >/dev/null || \
+       -fwk/lib/timeout 1 $(SXA) -S in=/dev/null,out=$@ $< < $(PORTS_DIR)/xa51/uCsim.cmd >/dev/null || \
           echo -e --- FAIL: \"timeout, simulation killed\" in $(<:.ihx=.c)"\n"--- Summary: 1/1/1: timeout >> $@
        -grep -n FAIL $@ /dev/null || true
 
index fa3f3cd47baa4be60ce5aeac895596b5b4b873c7..a725e4e51c77c2ebec1b6c8e661c6b66efb5d204 100755 (executable)
 
 #include <tinibios.h>
 
+void external_startup(void) {
+  return;
+}
+
 void
 _putchar (char c)
 {
+  c;
   _asm
     mov.b r0l,[r7+2]
     trap #0x0e
index d42caabbb2301436b5cee1552e8e4af699916de3..600205523119f671e7b3090a3af20a7d54dc0e9a 100644 (file)
@@ -2,7 +2,7 @@
  */
 #include <testfwk.h>
 
-#if defined __mcs51 || defined __ds390
+#if defined __mcs51 || defined __ds390 || defined __xa51
 #define XDATA xdata
 #else
 #define XDATA