Minor ds390 performance enhancement on generic pointer reads
[fw/sdcc] / src / asm.c
index c7ef55c5d1e24fdd80dfcd4d27e92ec23956b5ba..d31b0ea154e871dc96b071ae33243d187be0c732 100644 (file)
--- a/src/asm.c
+++ b/src/asm.c
@@ -130,7 +130,7 @@ tvsprintf (char *buffer, const char *format, va_list ap)
              break;
            case 'F':
              // Source file name.
-             pInto = _appendAt (pInto, newFormat, srcFileName);
+             pInto = _appendAt (pInto, newFormat, fullSrcFileName);
               sz++;
              break;
             case 'N':
@@ -203,6 +203,52 @@ asm_addTree (const ASM_MAPPINGS * pMappings)
   }
 }
 
+/*-----------------------------------------------------------------*/
+/* printCLine - try to find the c-code for this lineno             */
+/*-----------------------------------------------------------------*/
+static FILE *inFile=NULL;
+static char inLineString[1024];
+static int inLineNo=0;
+static char lastSrcFile[PATH_MAX];
+int rewinds=0;
+
+char *printCLine (char *srcFile, int lineno) {
+  char *ilsP=inLineString;
+
+  if (inFile) {
+    if (strcmp (lastSrcFile, srcFile) != 0) {
+      fclose (inFile);
+      inFile = NULL;
+      inLineNo = 0;
+    }
+  }
+  if (!inFile) {
+    inFile=fopen(srcFile, "r");
+    if (!inFile) {
+      perror ("printCLine");
+      exit (1);
+    }
+    strcpy (lastSrcFile, srcFile);
+  }
+  if (lineno<inLineNo) {
+    fseek (inFile, 0, SEEK_SET);
+    inLineNo=0;
+    rewinds++;
+  }
+  while (fgets (inLineString, 1024, inFile)) {
+    inLineNo++;
+    if (inLineNo==lineno) {
+      // remove the trailing NL
+      inLineString[strlen(inLineString)-1]='\0';
+      break;
+    }
+  }
+  while (isspace ((int)*ilsP))
+    ilsP++;
+
+  return ilsP;
+}
+
 static const ASM_MAPPING _asxxxx_mapping[] =
 {
   {"labeldef", "%s::"},
@@ -347,6 +393,58 @@ static const ASM_MAPPING _a390_mapping[] =
   {NULL, NULL}
 };
 
+static const ASM_MAPPING _xa_asm_mapping[] =
+{
+  {"labeldef", "%s:"},
+  {"slabeldef", "%s:"},
+  {"tlabeldef", "L%05d:"},
+  {"tlabel", "L%05d"},
+  {"immed", "#"},
+  {"zero", "#0"},
+  {"one", "#1"},
+  {"area", ".area %s"},
+  {"areacode", ".area %s"},
+  {"areadata", ".area %s"},
+  {"areahome", ".area %s"},
+  {"ascii", ".db \"%s\""},
+  {"ds", ".ds %d"},
+  {"db", ".db"},
+  {"dbs", ".db \"%s\""},
+  {"dw", ".dw"},
+  {"dws", ".dw %s"},
+  {"constbyte", "0x%02x"},
+  {"constword", "0x%04x"},
+  {"immedword", "0x%04x"},
+  {"immedbyte", "0x%02x"},
+  {"hashedstr", "#%s"},
+  {"lsbimmeds", "#<%s"},
+  {"msbimmeds", "#>%s"},
+  {"module", "; .module %s"},
+  {"global", ".globl %s"},
+  {"fileprelude", ""},
+  {"functionheader",
+   "; ---------------------------------\n"
+   "; Function %s\n"
+   "; ---------------------------------"
+  },
+  {"functionlabeldef", "%s:"},
+  {"bankimmeds", "0    ; PENDING: bank support"},  
+  {"los","(%s & 0FFh)"},
+  {"his","((%s / 256) & 0FFh)"},
+  {"hihis","((%s / 65536) & 0FFh)"},
+  {"hihihis","((%s / 16777216) & 0FFh)"},
+  {"lod","(%d & 0FFh)"},
+  {"hid","((%d / 256) & 0FFh)"},
+  {"hihid","((%d / 65536) & 0FFh)"},
+  {"hihihid","((%d / 16777216) & 0FFh)"},
+  {"lol","(L%05d & 0FFh)"},
+  {"hil","((L%05d / 256) & 0FFh)"},
+  {"hihil","((L%05d / 65536) & 0FFh)"},
+  {"hihihil","((L%09d / 16777216) & 0FFh)"},
+  {"equ"," equ"},
+  {NULL, NULL}
+};
+
 const ASM_MAPPINGS asm_asxxxx_mapping =
 {
   NULL,
@@ -364,3 +462,9 @@ const ASM_MAPPINGS asm_a390_mapping =
   NULL,
   _a390_mapping
 };
+
+const ASM_MAPPINGS asm_xa_asm_mapping =
+{
+  NULL,
+  _xa_asm_mapping
+};