]> git.gag.com Git - fw/sdcc/commitdiff
added seperate segments for initialized data
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 16 Dec 2001 12:55:53 +0000 (12:55 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 16 Dec 2001 12:55:53 +0000 (12:55 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1676 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/avr/main.c
src/ds390/gen.c
src/ds390/main.c
src/ds390/ralloc.c
src/izt/i186.c
src/izt/tlcs900h.c
src/mcs51/gen.c
src/mcs51/main.c
src/pic/gen.c
src/pic/main.c
src/z80/main.c

index ba5a470bc05c3f28a665b0b5bc8526f0e32f7c7b..010957530b5e4008bdd015a0ae5e0218abb5375a 100644 (file)
@@ -185,6 +185,8 @@ PORT avr_port = {
         "OSEG",
         "GSFINAL",
         "HOME",
+        NULL, // initialized xdata
+        NULL, // a code copy of xiseg
         NULL,
         NULL,
         0,
@@ -205,6 +207,7 @@ PORT avr_port = {
        _avr_keywords,
        _avr_genAssemblerPreamble,
        _avr_genIVT,
+       NULL, // _avr_genXINIT
        _avr_reset_regparm,
        _avr_regparm,
         NULL,
index 6a073a73168dcad7631415bd5d2df548a239fd1c..10508322f85c5e40cdedb8a8824301277b8851be 100644 (file)
@@ -3666,7 +3666,7 @@ genPlus (iCode * ic)
              while (size--)
                {
                  MOVA (aopGet (AOP (IC_RIGHT (ic)), offset, FALSE, FALSE, TRUE));
-                 emitcode ("addc", "a,#00");
+                 emitcode ("addc", "a,#0");
                  aopPut (AOP (IC_RESULT (ic)), "a", offset++);
                }
              _endLazyDPSEvaluation ();
@@ -5062,24 +5062,24 @@ genCmp (operand * left, operand * right,
          CLRC;
          while (size--)
            {
-             emitcode (";", "genCmp #1: %d/%d/%d", size, sign, offset);
+             //emitcode (";", "genCmp #1: %d/%d/%d", size, sign, offset);
              MOVA (aopGet (AOP (left), offset, FALSE, FALSE, TRUE));
-             emitcode (";", "genCmp #2");
+             //emitcode (";", "genCmp #2");
              if (sign && (size == 0))
                {
-                 emitcode (";", "genCmp #3");
+                 //emitcode (";", "genCmp #3");
                  emitcode ("xrl", "a,#0x80");
                  if (AOP_TYPE (right) == AOP_LIT)
                    {
                      unsigned long lit = (unsigned long)
                      floatFromVal (AOP (right)->aopu.aop_lit);
-                     emitcode (";", "genCmp #3.1");
+                     //emitcode (";", "genCmp #3.1");
                      emitcode ("subb", "a,#!constbyte",
                                0x80 ^ (unsigned int) ((lit >> (offset * 8)) & 0x0FFL));
                    }
                  else
                    {
-                     emitcode (";", "genCmp #3.2");
+                     //emitcode (";", "genCmp #3.2");
                      if (AOP_NEEDSACC (right))
                        {
                          emitcode ("push", "acc");
@@ -5098,11 +5098,11 @@ genCmp (operand * left, operand * right,
                {
                  const char *s;
 
-                 emitcode (";", "genCmp #4");
+                 //emitcode (";", "genCmp #4");
                  if (AOP_NEEDSACC (right))
                    {
                      /* Yuck!! */
-                     emitcode (";", "genCmp #4.1");
+                     //emitcode (";", "genCmp #4.1");
                      emitcode ("xch", "a, b");
                      MOVA (aopGet (AOP (right), offset++, FALSE, FALSE, TRUE));
                      emitcode ("xch", "a, b");
@@ -5110,7 +5110,7 @@ genCmp (operand * left, operand * right,
                    }
                  else
                    {
-                     emitcode (";", "genCmp #4.2");
+                     //emitcode (";", "genCmp #4.2");
                      s = aopGet (AOP (right), offset++, FALSE, FALSE, FALSE);
                    }
 
@@ -7831,7 +7831,7 @@ genLeftShiftLiteral (operand * left,
   aopOp(left, ic, FALSE, FALSE);
   aopOp(result, ic, FALSE, (AOP_TYPE(left) == AOP_DPTR));
 
-#if 1 // debug spew
+#if 0 // debug spew
   if (IS_SYMOP(left) && OP_SYMBOL(left)->aop)
   {
        emitcode(";", "left (%s) is %d", OP_SYMBOL(left)->rname, AOP_TYPE(left));
index 45f04e03e3fce37ca0d56b2a05fe051635ad6e6a..03e681846618b678a006bdc643a0f5ae9cf22d80 100644 (file)
@@ -291,10 +291,12 @@ PORT ds390_port =
     "XSEG    (XDATA)",
     "BSEG    (BIT)",
     "RSEG    (DATA)",
-    "GSINIT  (CODE)",
+    /* "GSINIT  (CODE)", */ "CSEG    (CODE)",
     "OSEG    (OVR,DATA)",
     "GSFINAL (CODE)",
-    "HOME       (CODE)",
+    "HOME    (CODE)",
+    NULL, // xidata
+    NULL, // xinit
     NULL,
     NULL,
     1
@@ -316,6 +318,7 @@ PORT ds390_port =
   _ds390_keywords,
   _ds390_genAssemblerPreamble,
   _ds390_genIVT,
+  NULL, // _ds390_genXINIT
   _ds390_reset_regparm,
   _ds390_regparm,
   NULL,
index a3385230af01eb13c1df6f2bccff39492ed62a1d..922c68b04089aeca5cfbab85bcbd84626431905f 100644 (file)
@@ -36,7 +36,7 @@
 /* since the pack the registers depending strictly on the MCU      */
 /*-----------------------------------------------------------------*/
 
-#define D(x)
+#define D(x) x
 
 /* Global data */
 static struct
@@ -2116,7 +2116,13 @@ packRegsDPTRuse (operand * op)
            if (OP_SYMBOL(IC_RESULT(ic))->liveTo == 
                OP_SYMBOL(IC_RESULT(ic))->liveFrom) continue ;
            etype = getSpec(type = operandType(IC_RESULT(ic)));
-           if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic))) continue ;
+#if 0
+           if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic))) 
+             continue ;
+#else
+           if (getSize(type)==0) 
+             continue;
+#endif
            return NULL ;
        }
 
index c9e19639228c7cd08ec2921fcf1813d972051e04..8ee41fb2597ab5f925b8829c8d760f21fabd7e91 100644 (file)
@@ -175,6 +175,8 @@ PORT i186_port = {
         ".DATA",
         ".TEXT",
         ".TEXT",
+       NULL, // xidata
+       NULL, // xinit
         NULL,
         NULL,
         1
@@ -196,6 +198,7 @@ PORT i186_port = {
     _i186_keywords,
     _i186_genAssemblerPreamble,
     _i186_genIVT ,
+    NULL, // _i186_genXINIT
     _i186_reset_regparm,
     _i186_regparm,
     NULL,
index 3be389c1d29e85608076a1859f6916ac6e8641e6..02b37b38b9b020ea415ec034a54653f08369a6c9 100644 (file)
@@ -174,6 +174,8 @@ PORT tlcs900h_port =
     "OSEG    (OVR,DATA)",
     "GSFINAL (CODE)",
     "HOME       (CODE)",
+    NULL, // xidata
+    NULL, // xinit
     NULL,
     NULL,
     1
@@ -195,6 +197,7 @@ PORT tlcs900h_port =
   _tlcs900h_keywords,
   _tlcs900h_genAssemblerPreamble,
   _tlcs900h_genIVT,
+  0, // _tlcs900h_genXINIT
   _tlcs900h_reset_regparm,
   _tlcs900h_regparm,
   NULL,
index 9a81b0cf89a13d9b950b56a970c8b83f82fbf817..fdcca632cbec309cff387b310e0443dfea898ae8 100644 (file)
@@ -8744,66 +8744,6 @@ genReceive (iCode * ic)
   freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
 }
 
-/*-----------------------------------------------------------------*/
-/* gen51AggregateAssign - copy complete array's or structures            */
-/*-----------------------------------------------------------------*/
-void gen51AggregateAssign(iCode *ic) {
-  operand *left=IC_LEFT(ic);
-  operand *right=IC_RIGHT(ic);
-  char *fromName=OP_SYMBOL(right)->rname;
-  char *toName=OP_SYMBOL(left)->rname;
-  int fromSize=getSize(OP_SYMBOL(right)->type);
-  int toSize=getSize(OP_SYMBOL(left)->type);
-  int count=toSize;
-
-  D(emitcode (";", "gen51AggregateAssign"));
-
-  if (SPEC_OCLS(OP_SYMBOL(left)->etype)!=xdata ||
-      SPEC_OCLS(OP_SYMBOL(right)->etype)!=code) {
-    // well, this code isn't used yet from anywhere else as for initialising
-    fprintf (stderr, "*** error: %s:%d can only assign aggregates from cseg to xseg for now\n", ic->filename, ic->lineno);
-    exit (457);
-  }
-
-  if (fromSize!=toSize) {
-    fprintf (stderr, "*** error: %s:%d aggregates have different size\n",
-            ic->filename, ic->lineno);
-    exit (821);
-  }
-
-#if 1
-  // use the generic memcpy() for now
-  emitcode (";", "initialize %s", OP_SYMBOL(IC_LEFT(ic))->name);
-  emitcode ("mov", "dptr,#_memcpy_PARM_2");
-  emitcode ("mov", "a,#%s", fromName);
-  emitcode ("movx", "@dptr,a");
-  emitcode ("inc", "dptr");
-  emitcode ("mov", "a,#(%s>>8)", fromName);
-  emitcode ("movx", "@dptr,a");
-  emitcode ("inc", "dptr");
-  emitcode ("mov", "a,#%02x;   only from cseg for now", 2);
-  emitcode ("movx", "@dptr,a");
-  emitcode ("mov", "dptr,#_memcpy_PARM_3");
-  emitcode ("mov", "a,#(%d>>0);        number of bytes", count);
-  emitcode ("movx", "@dptr,a");
-  emitcode ("inc", "dptr");
-  emitcode ("mov", "a,#(%d>>8)", count);
-  emitcode ("movx", "@dptr,a");
-  emitcode ("mov", "dptr,#%s", toName);
-  emitcode ("mov", "b,#%02x;   only to xseg for now", 1);
-  emitcode ("lcall", "_memcpy");
-#else
-  // more efficient, but will require the native_memcpy_cs2xs
-  emitcode ("mov", "r0,#%s", fromName);
-  emitcode ("mov", "r1,#(%s>>8)", fromName);
-  emitcode ("mov", "r2,#%s", toName);
-  emitcode ("mov", "r3,#(%s>>8)", toName);
-  emitcode ("mov", "r4,#%d", count);
-  emitcode ("mov", "r5,#(%d>>8)", count);
-  emitcode ("lcall", "_native_memcpy_cs2xs");
-#endif
-}
-
 /*-----------------------------------------------------------------*/
 /* gen51Code - generate code for 8051 based controllers            */
 /*-----------------------------------------------------------------*/
@@ -9043,10 +8983,6 @@ gen51Code (iCode * lic)
          addSet (&_G.sendSet, ic);
          break;
 
-       case ARRAYINIT:
-         gen51AggregateAssign(ic);
-         break;
-
        default:
          ic = ic;
        }
index bbe4921c6319352360ddfebce789653669531596..41a7e1ac941e53a93bb5aaab49909133d7f7531c 100644 (file)
@@ -120,6 +120,34 @@ _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
   return FALSE;
 }
 
+/* Generate code to copy XINIT to XISEG */
+static void _mcs51_genXINIT (FILE * of) {
+  fprintf (of, ";      _mcs51_genXINIT() start\n");
+  fprintf (of, "       mov     a,#s_XINIT\n");
+  fprintf (of, "       add     a,#l_XINIT\n");
+  fprintf (of, "       mov     r1,a\n");
+  fprintf (of, "       mov     a,#s_XINIT>>8\n");
+  fprintf (of, "       addc    a,#l_XINIT>>8\n");
+  fprintf (of, "       mov     r2,a\n");
+  fprintf (of, "       mov     dptr,#s_XINIT\n");
+  fprintf (of, "       mov     r0,#s_XISEG\n");
+  fprintf (of, "       mov     p2,#(s_XISEG >> 8)\n");
+  fprintf (of, "00001$:        clr     a\n");
+  fprintf (of, "       movc    a,@a+dptr\n");
+  fprintf (of, "       movx    @r0,a\n");
+  fprintf (of, "       inc     dptr\n");
+  fprintf (of, "       inc     r0\n");
+  fprintf (of, "       cjne    r0,#0,00002$\n");
+  fprintf (of, "       inc     p2\n");
+  fprintf (of, "00002$:        mov     a,dpl\n");
+  fprintf (of, "       cjne    a,ar1,00001$\n");
+  fprintf (of, "       mov     a,dph\n");
+  fprintf (of, "       cjne    a,ar2,00001$\n");
+  fprintf (of, "       mov     p2,#0xFF\n");
+  fprintf (of, ";      _mcs51_genXINIT() end\n");
+}
+
+
 /* Do CSE estimation */
 static bool cseCostEstimation (iCode *ic, iCode *pdic)
 {
@@ -200,10 +228,12 @@ PORT mcs51_port =
     "XSEG    (XDATA)",
     "BSEG    (BIT)",
     "RSEG    (DATA)",
-    "GSINIT  (CODE)",
+    /* "GSINIT  (CODE)", */ "CSEG    (CODE)",
     "OSEG    (OVR,DATA)",
     "GSFINAL (CODE)",
-    "HOME       (CODE)",
+    "HOME    (CODE)",
+    "XISEG   (XDATA)", // initialized xdata
+    "XINIT   (CODE)", // a code copy of xiseg
     NULL,
     NULL,
     1
@@ -225,6 +255,7 @@ PORT mcs51_port =
   _mcs51_keywords,
   _mcs51_genAssemblerPreamble,
   _mcs51_genIVT,
+  _mcs51_genXINIT,
   _mcs51_reset_regparm,
   _mcs51_regparm,
   NULL,
index f34f62775c8ff6944dd567e879fbd5f3c7ebca39..3fffd135bc0d52732305710c99fa3aa2b99c5101 100644 (file)
@@ -3482,6 +3482,7 @@ static void genSkipCond(resolvedIfx *rifx,operand *op, int offset, int bit)
   rifx->generated = 1;
 }
 
+#if 0
 /*-----------------------------------------------------------------*/
 /* genChkZeroes :- greater or less than comparison                 */
 /*     For each byte in a literal that is zero, inclusive or the   */
@@ -3508,6 +3509,7 @@ static int genChkZeroes(operand *op, int lit,  int size)
 
   return (flag==0);
 }
+#endif
 
 /*-----------------------------------------------------------------*/
 /* genCmp :- greater or less than comparison                       */
@@ -3550,7 +3552,6 @@ static void genCmp (operand *left,operand *right,
     } else {
 
       symbol *lbl  = newiTempLabel(NULL);
-      int flag;
       int emitFinalCheck=1;
       symbol *truelbl  = newiTempLabel(NULL);
 
@@ -3616,7 +3617,6 @@ static void genCmp (operand *left,operand *right,
        /* special cases */
 
        if(sign) {
-         unsigned int mlit = -lit;
 
          if(lit == 0) {
            genSkipCond(&rIfx,left,size,7);
@@ -3865,7 +3865,6 @@ static void genCmp (operand *left,operand *right,
 
 
          if(sign) {
-           int mlit = -lit;
            int lp1 = lit+1;
 
            size--;
index d0cd1a33f00c2e1ad9e36b93b721743caf9a7aee..d88ae7e2f77ff209f9cd037bad85552790cda3f3 100644 (file)
@@ -265,6 +265,8 @@ PORT pic_port =
     "OSEG    (OVR,DATA)",
     "GSFINAL (CODE)",
     "HOME       (CODE)",
+    NULL, // xidata
+    NULL, // xinit
     NULL,
     NULL,
     1
@@ -286,6 +288,7 @@ PORT pic_port =
   _pic14_keywords,
   _pic14_genAssemblerPreamble,
   _pic14_genIVT,
+  NULL, // _pic14_genXINIT
   _pic14_reset_regparm,
   _pic14_regparm,
   NULL,
index 0f9f5a81221f7b90582c0a1d4e6632244c0e74b3..9c9618795a84a35d73f63b57946f2a42074ab248 100644 (file)
@@ -486,6 +486,8 @@ PORT z80_port =
     "OVERLAY",
     "GSFINAL",
     "HOME",
+    NULL, // xidata
+    NULL, // xinit
     NULL,
     NULL,
     1
@@ -507,6 +509,7 @@ PORT z80_port =
   _keywords,
   0,                           /* no assembler preamble */
   0,                           /* no local IVT generation code */
+  0,                            /* no genXINIT code */
   _reset_regparm,
   _reg_parm,
   _process_pragma,
@@ -570,6 +573,8 @@ PORT gbz80_port =
     "OVERLAY",
     "GSFINAL",
     "HOME",
+    NULL, // xidata
+    NULL, // xinit
     NULL,
     NULL,
     1
@@ -591,6 +596,7 @@ PORT gbz80_port =
   _keywords,
   0,                           /* no assembler preamble */
   0,                           /* no local IVT generation code */
+  0,                            /* no genXINIT code */
   _reset_regparm,
   _reg_parm,
   _process_pragma,