]> git.gag.com Git - fw/sdcc/commitdiff
* src/ds390/peeph.def: fix #123; add 14 rules by Fiorenzo D. Ramaglia <fd.ramaglia...
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 13 Jan 2003 14:38:14 +0000 (14:38 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 13 Jan 2003 14:38:14 +0000 (14:38 +0000)
* src/mcs51/peeph.def: fix #123; add 14 rules by Fiorenzo
* src/mcs51/gen.c (genFunction): emit r0 instead of ar0 by Fiorenzo
* as/mcs51/lkmem (summary): better fix for sp problem
* src/SDCCglue.c (glue): __start_stack - 1, saves 1 byte!
* src/ds390/main.c (_ds390_finaliseOptions, _tininative_finaliseOptions): stack_loc = 0x400008

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2151 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
as/mcs51/lkmem.c
src/SDCCglue.c
src/ds390/main.c
src/ds390/peeph.def
src/mcs51/gen.c
src/mcs51/peeph.def

index 68194eaf303ccf79f7d87105e17f908d537d9431..4153b7ef6f9ce3002a4e9e210f173bd594616e3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-01-13  Bernhard Held <bernhard@bernhardheld.de>
+
+       * src/ds390/peeph.def: fix #123; add 14 rules by Fiorenzo D. Ramaglia <fd.ramaglia@tin.it>
+       * src/mcs51/peeph.def: fix #123; add 14 rules by Fiorenzo
+       * src/mcs51/gen.c (genFunction): emit r0 instead of ar0 by Fiorenzo
+       * as/mcs51/lkmem (summary): better fix for sp problem
+       * src/SDCCglue.c (glue): __start_stack - 1, saves 1 byte!
+       * src/ds390/main.c (_ds390_finaliseOptions, _tininative_finaliseOptions): stack_loc = 0x400008
+
 2003-01-12  Bernhard Held <bernhard@bernhardheld.de>
 
        * src/SDCCmain.c (main): port->finaliseOptions() moved for z80 linking
index ae09af3f225e68c5a4e1eed31cf6f96487bf2db8..9ff0c161f9bf91956ce938565e31598dd2e114a7 100644 (file)
@@ -251,46 +251,45 @@ int summary(struct area * areap)
        }
 
        /*Report the position of the begining of the stack*/
-       fprintf(of, "\nStack starts at: 0x%02lx", Stack.Start);
+       /* TODO find flag for DS390 */
+       fprintf(of, "\n%stack starts at: 0x%02lx (sp set to 0x%02lx)",
+               0 ? "16 bit mode initial s" : "S", Stack.Start, Stack.Start-1);
 
        /*Check that the stack pointer is landing in a safe place:*/
-       // if (!flat24Mode) TODO: bypass stack check for ds390
+       if( (dram[Stack.Start] & 0x8000) == 0x8000 )
        {
-               if( (dram[Stack.Start] & 0x8000) == 0x8000 )
-               {
-                       fprintf(of, ".\n");
-                       sprintf(buff, "Stack set to unavailable memory.\n");
-                       REPORT_ERROR(buff, 1);
-               }
-               else if(dram[Stack.Start+1])
+               fprintf(of, ".\n");
+               sprintf(buff, "Stack set to unavailable memory.\n");
+               REPORT_ERROR(buff, 1);
+       }
+       else if(dram[Stack.Start])
+       {
+               fprintf(of, ".\n");
+               sprintf(buff, "Stack overlaps area ");
+               REPORT_ERROR(buff, 1);
+               for(j=0; j<7; j++)
                {
-                       fprintf(of, ".\n");
-                       sprintf(buff, "Stack overlaps area ");
-                       REPORT_ERROR(buff, 1);
-                       for(j=0; j<7; j++)
+                               if(dram[Stack.Start]&Ram[j].flag)
                        {
-                               if(dram[Stack.Start+1]&Ram[j].flag)
-                               {
-                                       sprintf(buff, "'%s'\n", Ram[j].Name);
-                                       break;
-                               }
+                               sprintf(buff, "'%s'\n", Ram[j].Name);
+                               break;
                        }
-                       if(dram[Stack.Start]&IRam.flag)
-                       {
-                               sprintf(buff, "'%s'\n", IRam.Name);
-                       }
-                       REPORT_ERROR(buff, 0);
                }
-               else
+               if(dram[Stack.Start]&IRam.flag)
                {
-                       for(j=Stack.Start, k=0; (j<(int)iram_size)&&(dram[j]==0); j++, k++);
-                       fprintf(of, " with %d bytes available\n", k);
-                       if (k<MIN_STACK)
-                       {
-                               sprintf(buff, "Only %d byte%s available for stack.\n",
-                                       k, (k==1)?"":"s");
-                               REPORT_WARNING(buff, 1);
-                       }
+                       sprintf(buff, "'%s'\n", IRam.Name);
+               }
+               REPORT_ERROR(buff, 0);
+       }
+       else
+       {
+               for(j=Stack.Start, k=0; (j<(int)iram_size)&&(dram[j]==0); j++, k++);
+               fprintf(of, " with %d bytes available\n", k);
+               if (k<MIN_STACK)
+               {
+                       sprintf(buff, "Only %d byte%s available for stack.\n",
+                               k, (k==1)?"":"s");
+                       REPORT_WARNING(buff, 1);
                }
        }
 
index 75c40870403e09a3b6afb4ada19a4d72ef3579b4..99a4f959e75783ef63558396f92a3e873310b522 100644 (file)
@@ -1633,7 +1633,7 @@ glue (void)
        }
 
       /* initialise the stack pointer.  JCF: aslink takes care of the location */
-       fprintf (asmFile, "\tmov\tsp,#__start__stack\n");       /* MOF */
+       fprintf (asmFile, "\tmov\tsp,#__start__stack - 1\n");   /* MOF */
 
       fprintf (asmFile, "\tlcall\t__sdcc_external_startup\n");
       fprintf (asmFile, "\tmov\ta,dpl\n");
index a52127d9c71bad1eeb59a2db7663a54686759a20..10bae81765cebedab90dfa0819552c48a7749b76 100644 (file)
@@ -155,7 +155,7 @@ _ds390_finaliseOptions (void)
     fprintf (stderr,
             "*** error: ds390 port only supports the 10 bit stack mode.\n");
     } else {
-       if (!options.stack_loc) options.stack_loc = 0x400007;
+       if (!options.stack_loc) options.stack_loc = 0x400008;
     }
     
     /* generate native code 16*16 mul/div */
@@ -456,7 +456,7 @@ static void _tininative_finaliseOptions (void)
        fprintf(stderr,"TININative supports only stack10bit \n");
     }
     
-    if (!options.stack_loc) options.stack_loc = 0x400007;
+    if (!options.stack_loc) options.stack_loc = 0x400008;
     
     /* generate native code 16*16 mul/div */
     if (options.useAccelerator) 
index 91d7579a4891926f18a27fa3ba75c19dcbe706ee..07381dbc48a91326b7c7e66cc9ebc9ebd22615e6 100644 (file)
@@ -2265,3 +2265,104 @@ replace {
        mov     dptr,#%1
        dec     dps
 } 
+
+// 14 rules by Fiorenzo D. Ramaglia <fd.ramaglia@tin.it>
+
+replace {
+        add  a,ar%1
+} by {
+        ; Peephole 236a
+        add  a,r%1
+}
+
+replace {
+        addc  a,ar%1
+} by {
+        ; Peephole 236b
+        addc  a,r%1
+}
+
+replace {
+        anl  a,ar%1
+} by {
+        ; Peephole 236c
+        anl  a,r%1
+}
+
+replace {
+        dec  ar%1
+} by {
+        ; Peephole 236d
+        dec  r%1
+}
+
+replace {
+        djnz  ar%1,%2
+} by {
+        ; Peephole 236e
+        djnz  r%1,%2
+}
+
+replace {
+        inc  ar%1
+} by {
+        ; Peephole 236f
+        inc  r%1
+}
+
+replace {
+        mov  a,ar%1
+} by {
+        ; Peephole 236g
+        mov  a,r%1
+}
+
+replace {
+        mov  ar%1,#%2
+} by {
+        ; Peephole 236h
+        mov  r%1,#%2
+}
+
+replace {
+        mov  ar%1,a
+} by {
+        ; Peephole 236i
+        mov  r%1,a
+}
+
+replace {
+        mov  ar%1,ar%2
+} by {
+        ; Peephole 236j
+        mov  r%1,ar%2
+}
+
+replace {
+        orl  a,ar%1
+} by {
+        ; Peephole 236k
+        orl  a,r%1
+}
+
+replace {
+        subb  a,ar%1
+} by {
+        ; Peephole 236l
+        subb  a,r%1
+}
+
+replace {
+        xch  a,ar%1
+} by {
+        ; Peephole 236m
+        xch  a,r%1
+}
+
+replace {
+        xrl  a,ar%1
+} by {
+        ; Peephole 236n
+        xrl  a,r%1
+}
+
index 55094e63b6973e051fc05ff657ffb2030695dcab..8b816f10f8280136078215ce0436d15aedec0c50 100644 (file)
@@ -2521,12 +2521,12 @@ genFunction (iCode * ic)
            }
          else
            {
-             /* not callee-saves, we can clobber ar0 */
-             emitcode ("mov", "ar0,a");
+             /* not callee-saves, we can clobber r0 */
+             emitcode ("mov", "r0,a");
              emitcode ("mov", "a,sp");
              emitcode ("add", "a,#0x%02x", ((char) sym->stack & 0xff));
              emitcode ("mov", "sp,a");
-             emitcode ("mov", "a,ar0");
+             emitcode ("mov", "a,r0");
            }
        }
       else
index 87592d92040c593a6551ab62db74844f82fa2f35..e850afb713ce13f8b1467e257d25ad183615f9e3 100644 (file)
@@ -1969,3 +1969,103 @@ replace {
         ret
 }
 
+// 14 rules by Fiorenzo D. Ramaglia <fd.ramaglia@tin.it>
+
+replace {
+        add  a,ar%1
+} by {
+        ; Peephole 236a
+        add  a,r%1
+}
+
+replace {
+        addc  a,ar%1
+} by {
+        ; Peephole 236b
+        addc  a,r%1
+}
+
+replace {
+        anl  a,ar%1
+} by {
+        ; Peephole 236c
+        anl  a,r%1
+}
+
+replace {
+        dec  ar%1
+} by {
+        ; Peephole 236d
+        dec  r%1
+}
+
+replace {
+        djnz  ar%1,%2
+} by {
+        ; Peephole 236e
+        djnz  r%1,%2
+}
+
+replace {
+        inc  ar%1
+} by {
+        ; Peephole 236f
+        inc  r%1
+}
+
+replace {
+        mov  a,ar%1
+} by {
+        ; Peephole 236g
+        mov  a,r%1
+}
+
+replace {
+        mov  ar%1,#%2
+} by {
+        ; Peephole 236h
+        mov  r%1,#%2
+}
+
+replace {
+        mov  ar%1,a
+} by {
+        ; Peephole 236i
+        mov  r%1,a
+}
+
+replace {
+        mov  ar%1,ar%2
+} by {
+        ; Peephole 236j
+        mov  r%1,ar%2
+}
+
+replace {
+        orl  a,ar%1
+} by {
+        ; Peephole 236k
+        orl  a,r%1
+}
+
+replace {
+        subb  a,ar%1
+} by {
+        ; Peephole 236l
+        subb  a,r%1
+}
+
+replace {
+        xch  a,ar%1
+} by {
+        ; Peephole 236m
+        xch  a,r%1
+}
+
+replace {
+        xrl  a,ar%1
+} by {
+        ; Peephole 236n
+        xrl  a,r%1
+}
+