10 bit stack mode: almost working...
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 9 Mar 2000 06:57:21 +0000 (06:57 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 9 Mar 2000 06:57:21 +0000 (06:57 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@181 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/mcs51/gen.c
src/mcs51/main.c
src/mcs51/peeph.def

index 2121e19c0cc64f503e3bd4ed32be04ed531f5956..37f9a78e20d3014d655f7cfe9299123e442b397b 100644 (file)
@@ -232,6 +232,20 @@ static asmop *newAsmop (short type)
     return aop;
 }
 
+static void genSetDPTR(int n)
+{
+    if (!n)
+    {
+        emitcode(";", "Select standard DPTR");
+        emitcode("mov", "dps, #0x00");
+    }
+    else
+    {
+        emitcode(";", "Select alternate DPTR");
+        emitcode("mov", "dps, #0x01");
+    }
+}
+
 /*-----------------------------------------------------------------*/
 /* pointerCode - returns the code for a pointer type               */
 /*-----------------------------------------------------------------*/
@@ -329,29 +343,16 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result)
                    ((char)(sym->stack - _G.nRegsSaved )) :
                    ((char)sym->stack)) & 0xff);
         
-        if (/* result */ 1)
-        {
-            emitcode (";", "#switchDPTR(2)");
-        }
-       emitcode ("mov","dpx,#0x40");
-       emitcode ("mov","dph,#0x00");
-       emitcode ("mov", "dpl, a");
-       if (/* result */ 1)
-       {
-           emitcode (";", "#switchDPTR(1)");
-       }
+        genSetDPTR(1);
+        emitcode ("mov","dpx1,#0x40");
+        emitcode ("mov","dph1,#0x00");
+        emitcode ("mov","dpl1, a");
+        genSetDPTR(0);
        
         if ( _G.accInUse )
             emitcode("pop","acc");
             
-        if (/* !result */ 0)
-        {
-           sym->aop = aop = newAsmop(AOP_DPTR);
-       }
-       else
-       {
-           sym->aop = aop = newAsmop(AOP_DPTR2);
-       }
+        sym->aop = aop = newAsmop(AOP_DPTR2);
        aop->size = getSize(sym->type); 
        return aop;
     }
@@ -772,10 +773,10 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
     case AOP_DPTR:
     case AOP_DPTR2:
     
-       if (aop->type == AOP_DPTR2)
-       {
-           emitcode (";", "#switchDPTR(2)");
-       }
+    if (aop->type == AOP_DPTR2)
+    {
+        genSetDPTR(1);
+    }
     
        while (offset > aop->coff) {
            emitcode ("inc","dptr");
@@ -792,13 +793,14 @@ static char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
            emitcode("clr","a");
            emitcode("movc","a,@a+dptr");
         }
-       else
+    else {
            emitcode("movx","a,@dptr");
+    }
            
-       if (aop->type == AOP_DPTR2)
-       {
-           emitcode (";", "#switchDPTR(1)");
-       }           
+    if (aop->type == AOP_DPTR2)
+    {
+        genSetDPTR(0);
+    }
            
        return (dname ? "acc" : "a");
        
@@ -915,10 +917,10 @@ static void aopPut (asmop *aop, char *s, int offset)
     case AOP_DPTR:
     case AOP_DPTR2:
     
-        if (aop->type == AOP_DPTR2)
-       {
-           emitcode (";", "#switchDPTR(2)");
-       }
+    if (aop->type == AOP_DPTR2)
+    {
+        genSetDPTR(1);
+    }
     
        if (aop->code) {
            werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
@@ -944,9 +946,9 @@ static void aopPut (asmop *aop, char *s, int offset)
        emitcode ("movx","@dptr,a");
        
     if (aop->type == AOP_DPTR2)
-       {
-           emitcode (";", "#switchDPTR(1)");
-       }       
+    {
+        genSetDPTR(0);
+    }
        break;
        
     case AOP_R0:
@@ -1095,14 +1097,16 @@ static void reAdjustPreg (asmop *aop)
         case AOP_DPTR2:
             if (aop->type == AOP_DPTR2)
            {
-               emitcode (";", "#switchDPTR(2)");
+                genSetDPTR(1);
            } 
             while (size--)
+            {
                 emitcode("lcall","__decdptr");
+            }
                 
            if (aop->type == AOP_DPTR2)
            {
-               emitcode (";", "#switchDPTR(1)");
+                genSetDPTR(0);
            }                
             break;  
 
index 7d0a5a1f05bcbce4426641bc9696793db665d86a..80280ccbc07eb0636e6b028f12725888ebad4934 100644 (file)
@@ -118,7 +118,10 @@ static void _mcs51_genAssemblerPreamble(FILE *of)
    {
        fputs(".flat24 on\t\t; 24 bit flat addressing\n", of);
        fputs("dpx = 0x93\t\t; dpx register unknown to assembler\n", of);
-
+       fputs("dps = 0x86\t\t; dps register unknown to assembler\n", of);
+       fputs("dpl1 = 0x84\t\t; dpl1 register unknown to assembler\n", of);
+       fputs("dph1 = 0x85\t\t; dph1 register unknown to assembler\n", of);
+       fputs("dpx1 = 0x95\t\t; dpx1 register unknown to assembler\n", of);
    }
 }
 
index 3065ce6e4ba17c15a7b5188989a27b032f332eb9..315c72f86bec058045486709bcdf783e266ddaa6 100644 (file)
@@ -1758,4 +1758,20 @@ replace {
        movx  @dptr,a
        mov   dptr,%2
        movx  @dptr,a
-}
\ No newline at end of file
+}
+
+replace {
+        mov     dps, #0x00
+        mov     dps, #0x01
+} by {
+        ; Peephole 220a removed bogus DPS set
+        mov     dps, #0x01
+}
+
+replace {
+        mov     dps, #0x01
+        mov     dps, #0x00
+} by {
+        ; Peephole 220b removed bogus DPS set
+        mov     dps, #0x00
+}