added asm mappings for xa51
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 21 Jan 2002 15:19:08 +0000 (15:19 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 21 Jan 2002 15:19:08 +0000 (15:19 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1831 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCglue.c
src/asm.c
src/asm.h
src/xa51/gen.c
src/xa51/main.c

index 53f2d85ec4f18c3b05c1385941774003a8f873fb..3ef987054d3f432fdc94e1516915e289eda2bd7d 100644 (file)
@@ -1143,7 +1143,7 @@ emitMaps ()
 
   emitStaticSeg (statsg, code->oFile);
   if (port->genXINIT) {
-    fprintf (code->oFile, "\t.area\t%s\n", xinit->sname);
+    tfprintf (code->oFile, "\t!area\n", xinit->sname);
     emitStaticSeg (xinit, code->oFile);
   }
   inInitMode--;
index cd819e432e17b1803e8a497c1f4601ff08c8fffe..66e8d20195a34280569778f7b7d277b99ef9379f 100644 (file)
--- a/src/asm.c
+++ b/src/asm.c
@@ -383,6 +383,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", "0%02xh"},
+  {"constword", "0%04xh"},
+  {"immedword", "#0%04Xh"},
+  {"immedbyte", "#0%02Xh"},
+  {"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,
@@ -400,3 +452,9 @@ const ASM_MAPPINGS asm_a390_mapping =
   NULL,
   _a390_mapping
 };
+
+const ASM_MAPPINGS asm_xa_asm_mapping =
+{
+  NULL,
+  _xa_asm_mapping
+};
index 96baca6b91b4d361bb94a393507daf92dbfe54c2..3ae8fc6a5a8bd033265fab8eb72376f2cf45cf59 100644 (file)
--- a/src/asm.h
+++ b/src/asm.h
@@ -27,6 +27,7 @@ struct _ASM_MAPPINGS
 extern const ASM_MAPPINGS asm_asxxxx_mapping;
 extern const ASM_MAPPINGS asm_gas_mapping;
 extern const ASM_MAPPINGS asm_a390_mapping;
+extern const ASM_MAPPINGS asm_xa_asm_mapping;
 
 /** Last entry has szKey = NULL.
  */
index ef5c986c2e6e967dc5a541ac1d3bab5b798cd1c9..8653e54a282f65dbdf2818d965450b95d9093c2a 100755 (executable)
@@ -972,7 +972,13 @@ static void genPointerGet (iCode * ic, iCode *pi) {
       } else {
        instr=MOVW;
       }
-      emitcode (instr, "%s,[%s]", AOP_NAME(result)[0], AOP_NAME(left)[0]);
+      // if result=onstack
+      if (AOP_TYPE(result)==AOP_STK) {
+       emitcode (instr, "r0,[%s]", AOP_NAME(left)[0]);
+       emitcode (instr, "%s,r0", AOP_NAME(result)[0]);
+      } else {
+       emitcode (instr, "%s,[%s]", AOP_NAME(result)[0], AOP_NAME(left)[0]);
+      }
       if (AOP_SIZE(result) > 2) {
        // result is generic pointer
        sym_link *optype=operandType(left);
@@ -996,7 +1002,7 @@ static void genPointerGet (iCode * ic, iCode *pi) {
          emitcode ("mov", "%s,r0", AOP_NAME(result)[0]);
        }
       } else {
-       if (AOP_SIZE(result)==3) {
+       if (AOP_SIZE(result)==1) {
          emitcode ("mov.b", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]);
        } else {
          emitcode ("mov.w", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]);
@@ -1229,18 +1235,33 @@ static void genAssign (iCode * ic) {
   } else {
     instr=MOVW;
   }
-  emitcode (instr, "%s,%s",
-           result->aop->name[0], right->aop->name[0]);
+  if (AOP_TYPE(right)==AOP_STK && AOP_TYPE(result)==AOP_STK) {
+    emitcode (instr, "%s,%s", size==1 ? "r0l":"r0", right->aop->name[0]);
+    emitcode (instr, "%s,%s", AOP_NAME(result)[0], size==1 ? "r0l":"r0");
+  } else {
+    emitcode (instr, "%s,%s",
+             result->aop->name[0], right->aop->name[0]);
+  }
   if (AOP_SIZE(result) > 2) {
+    if (AOP_TYPE(right)==AOP_LIT) {
+      emitcode (instr, "%s,%s", result->aop->name[1], 
+               *AOP_NAME(right)[1] ? AOP_NAME(right)[1] : "#0x00");
+      return;
+    }
     if (size==3) {
       instr=MOVB;
     } else {
       instr=MOVW;
     }
-    emitcode (instr, "%s,%s",
-             result->aop->name[1], right->aop->name[1]);
+    if (AOP_TYPE(right)==AOP_STK && AOP_TYPE(result)==AOP_STK) {
+      emitcode (instr, "%s,%s", size==1 ? "r0l":"r0", right->aop->name[1]);
+      emitcode (instr, "%s,%s", AOP_NAME(result)[1], size==1 ? "r0l":"r0");
+    } else {
+      emitcode (instr, "%s,%s",
+               result->aop->name[1], right->aop->name[1]);
+    }
+    return;
   }
-  
 }
 
 /*-----------------------------------------------------------------*/
index 429a2cda3373963830093ee2da71f791c8388d05..f7bb02d4f891130f04fe19f1d3b318ab0f98c694 100755 (executable)
@@ -57,7 +57,7 @@ static int regParmFlg = 0;    /* determine if we can register a parameter */
 static void
 _xa51_init (void)
 {
-  asm_addTree (&asm_asxxxx_mapping);
+  asm_addTree (&asm_xa_asm_mapping);
 }
 
 static void