fix some grossness in the logic operations (genAnd, genOr, genXor)
[fw/sdcc] / src / asm.c
index 8d92b3778410c9d4654ce3e58964112a585e599a..6e7e133263e640d2fe4b1ecd30a3f8734441bb9a 100644 (file)
--- a/src/asm.c
+++ b/src/asm.c
@@ -20,6 +20,10 @@ FileBaseName (char *fileFullName)
 {
   char *p = fileFullName;
 
+  if (!fileFullName) {
+    return "unknown";
+  }
+
   while (*fileFullName)
     {
       if ((*fileFullName == '/') || (*fileFullName == '\\') || (*fileFullName == ':'))
@@ -179,7 +183,7 @@ tvsprintf (char *buffer, const char *format, va_list ap)
   // This is acheived by expanding the tokens and zero arg formats into
   // one big format string, which is passed to the native printf.
   static int count;
-  char newformat[MAX_INLINEASM];
+  char newformat[INITIAL_INLINEASM];
   char *pInto = newformat;
   char *p;
   char token[MAX_TOKEN_LEN];
@@ -261,7 +265,7 @@ void
 tfprintf (FILE * fp, const char *szFormat,...)
 {
   va_list ap;
-  char buffer[MAX_INLINEASM];
+  char buffer[INITIAL_INLINEASM];
 
   va_start (ap, szFormat);
   tvsprintf (buffer, szFormat, ap);
@@ -280,15 +284,15 @@ void
 asm_addTree (const ASM_MAPPINGS * pMappings)
 {
   const ASM_MAPPING *pMap;
+
   /* Traverse down first */
   if (pMappings->pParent)
     asm_addTree (pMappings->pParent);
   pMap = pMappings->pMappings;
-  while (pMap->szKey && pMap->szValue)
-    {
+  while (pMap->szKey && pMap->szValue) {
       shash_add (&_h, pMap->szKey, pMap->szValue);
       pMap++;
-    }
+  }
 }
 
 static const ASM_MAPPING _asxxxx_mapping[] =
@@ -330,8 +334,53 @@ static const ASM_MAPPING _asxxxx_mapping[] =
   {NULL, NULL}
 };
 
+static const ASM_MAPPING _gas_mapping[] =
+{
+  {"labeldef", "%s::"},
+  {"slabeldef", "%s:"},
+  {"tlabeldef", "%05d$:"},
+  {"tlabel", "%05d$"},
+  {"immed", "#"},
+  {"zero", "#0x00"},
+  {"one", "#0x01"},
+  {"area", ".section %s"},
+  {"areacode", ".section %s"},
+  {"areadata", ".section %s"},
+  {"areahome", ".section %s"},
+  {"ascii", ".ascii \"%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", ".file \"%s.c\""},
+  {"global", ".globl %s"},
+  {"fileprelude", ""},
+  {"functionheader",
+   "; ---------------------------------\n"
+   "; Function %s\n"
+   "; ---------------------------------"
+  },
+  {"functionlabeldef", "%s:"},
+  {"bankimmeds", "0    ; PENDING: bank support"},
+  {NULL, NULL}
+};
+
 const ASM_MAPPINGS asm_asxxxx_mapping =
 {
   NULL,
   _asxxxx_mapping
 };
+
+const ASM_MAPPINGS asm_gas_mapping =
+{
+  NULL,
+  _gas_mapping
+};