Added --xram-movc option
authorpjs <pjs@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 19 Jan 2002 04:43:15 +0000 (04:43 +0000)
committerpjs <pjs@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 19 Jan 2002 04:43:15 +0000 (04:43 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1815 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
device/lib/Makefile.in
device/lib/_gptrgetc.c [new file with mode: 0644]
device/lib/libsdcc.lib
src/SDCCglobl.h
src/SDCCmain.c
src/SDCCpeeph.c
src/mcs51/peeph.def
src/xa51/Makefile.dep

index ec5582be12389d425dbf808f2b22e18919bbe564..df8458fbb7a28cc140a537f530042206980c5e83 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2002-01-18  Paul Stoffregen  <paul@pjrc.com>
+
+       * Added --xram-movc option
+
 2002-01-13  Bernhard Held  <bernhard@bernhardheld.de>
 
        * support/regression/Makefile: don't include test-mcs51-stack-auto in target all
index 6927200d672de1cc3971baa8eb28496b6f281751..7c28242bdceab319260914a0e00410576f0c2ec3 100644 (file)
@@ -44,7 +44,7 @@ SOURCES               = _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \
                  _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
                  _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
                  _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
-                 _fsneq.c _fssub.c _gptrget.c _gptrput.c \
+                 _fsneq.c _fssub.c _gptrget.c _gptrgetc.c _gptrput.c \
                  _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
                  _islower.c _isprint.c _ispunct.c _isspace.c \
                  _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
diff --git a/device/lib/_gptrgetc.c b/device/lib/_gptrgetc.c
new file mode 100644 (file)
index 0000000..00506fb
--- /dev/null
@@ -0,0 +1,81 @@
+/*-------------------------------------------------------------------------
+
+  _gptrget.c :- get value for a generic pointer (used with --xram-movc)
+
+             Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1999)
+
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!
+-------------------------------------------------------------------------*/
+
+unsigned char _gptrgetc ()
+{
+    _asm
+    ;   save values passed
+       xch    a,r0
+       push   acc
+    ;
+    ;   depending on the pointer type acc. to SDCCsymt.h
+    ;
+        mov     a,b
+        jz      00001$ ; 0 near
+       dec     a
+       jz      00003$  ; 1 far
+        dec     a
+        jz      00003$ ; 2 code
+       dec     a
+       jz      00004$
+       dec     a       ; 4 skip generic pointer
+       dec     a
+       jz      00001$  ; 5 idata
+    ;
+    ;   any other value for type
+    ;   return xFF
+       mov     a,#0xff
+       sjmp    00005$
+    ;
+    ;   Pointer to data space
+    ;
+ 00001$:
+       mov     r0,dpl     ; use only low order address
+       mov     a,@r0
+        sjmp    00005$
+;
+;   pointer to xternal data
+;   pointer to code area
+;
+ 00003$:
+       ; clr     a  is already 0
+        movc    a,@a+dptr
+        sjmp    00005$
+;
+;   pointer to xternal stack
+;
+ 00004$:
+       mov     r0,dpl
+        movx    a,@r0
+;
+;   restore and return
+;
+ 00005$:
+        mov     r0,a
+        pop     acc
+       xch     a,r0
+     _endasm ;
+
+}
index 4732a29243be751bdae04a506931f7ddd544ad60..25246d103babcb57f07d9a92cfe858dd74e2dc11 100644 (file)
@@ -25,6 +25,7 @@ _memcmp
 _memcpy
 _memset
 _gptrget
+_gptrgetc
 _gptrput
 _decdptr
 _bp
@@ -44,4 +45,4 @@ printf_fast
 vprintf
 assert
 time
-bpx
\ No newline at end of file
+bpx
index 258be0f63b344e340ed5bdf9c96bb612f8bd1b19..ef7d64ed2c001bc5707cca0459f483843abe03d8 100644 (file)
@@ -220,6 +220,7 @@ struct options
     int cyclomatic;            /* print cyclomatic information */
     int noOverlay;             /* don't overlay local variables & parameters */
     int mainreturn;            /* issue a return after main */
+    int xram_movc;              /* use movc instead of movx to read xram (mcs51) */
     int nopeep;                        /* no peep hole optimization */
     int asmpeep;               /* pass inline assembler thru peep hole */
     int debug;                 /* generate extra debug info */
index c65ebd24ef5483038e8852bf1bd5ff7fa9c105e3..3dfa2fc71aa0fa0bf7abf653720d790ea8abdac5 100644 (file)
@@ -190,6 +190,7 @@ optionsTable[] = {
     { 0,    "--cyclomatic",         &options.cyclomatic, NULL },
     { 0,    "--nooverlay",          &options.noOverlay, NULL },
     { 0,    "--main-return",        &options.mainreturn, "Issue a return after main()" },
+    { 0,    "--xram-movc",          &options.xram_movc, "Use movc instead of movx to read xram (xdata)" },
     { 0,    "--no-peep",            &options.nopeep, "Disable the peephole assembly file optimisation" },
     { 0,    "--no-reg-params",      &options.noRegParams, "On some ports, disable passing some parameters in registers" },
     { 0,    "--peep-asm",           &options.asmpeep, NULL },
index e1c68e8be00669c8b295b75e10d4b3694a20e824..dfd7d84cd3372d46ed12da9582c7ee56fdc53d68 100644 (file)
@@ -114,6 +114,14 @@ FBYNAME (flat24bitMode)
   return (options.model == MODEL_FLAT24);
 }
 
+/*-----------------------------------------------------------------*/
+/* xramMovcOption - check if using movc to read xram               */
+/*-----------------------------------------------------------------*/
+FBYNAME (xramMovcOption)
+{
+  return (options.xram_movc && (strcmp(port->target,"mcs51") == 0));
+}
+
 /*-----------------------------------------------------------------*/
 /* labelInRange - will check to see if label %5 is within range    */
 /*-----------------------------------------------------------------*/
@@ -266,6 +274,10 @@ callFuncByName (char *fname,
       "24bitMode", flat24bitMode
     }
     ,
+    {
+      "xramMovcOption", xramMovcOption
+    }
+    ,
     {
       "labelRefCount", labelRefCount
     }
index e26372e8135f77f2f585f0af33c465453a4cbe4f..2a4c7c6cda6a113ac1b59b4c31cecc773fefe71e 100644 (file)
@@ -1928,4 +1928,21 @@ replace {
         mov     dptr,#%2
 }
 
+replace {
+        movx    a,@dptr
+} by {
+        ; Peephole 232   using movc to read xdata (--xram-movc)
+        clr     a
+        movc    a,@a+dptr
+} if xramMovcOption
+
+replace {
+        lcall   _gptrget
+} by {
+        ; Peephole 233   using _gptrgetc instead of _gptrget (--xram-movc)
+        lcall   _gptrgetc
+} if xramMovcOption
+
+
+
 
index 4635445b7fdf54f61ad8bd6df88233dece9faa6f..a7437109b52d329dbd74ce1c5dff2faa015bdb66 100644 (file)
@@ -1,23 +1,21 @@
-gen.o: gen.c ../SDCCglobl.h ../../sdccconf.h \
- ../../support/Util/SDCCerr.h ../../support/Util/newalloc.h \
- ../common.h ../SDCCmem.h ../SDCCast.h ../SDCCsymt.h ../SDCChasht.h \
- ../SDCCval.h ../SDCCset.h ../SDCCy.h ../SDCCbitv.h ../SDCCicode.h \
- ../SDCClabel.h ../SDCCBBlock.h ../SDCCloop.h ../SDCCcse.h \
- ../SDCCcflow.h ../SDCCdflow.h ../SDCClrange.h ../SDCCptropt.h \
- ../SDCCopt.h ../SDCCglue.h ../SDCCpeeph.h ../asm.h ../port.h ralloc.h \
- gen.h
+gen.o: gen.c ../SDCCglobl.h ../../sdccconf.h ../../support/Util/SDCCerr.h \
+  ../../support/Util/newalloc.h ../common.h ../SDCCmem.h ../SDCCast.h \
+  ../SDCCsymt.h ../SDCChasht.h ../SDCCval.h ../SDCCset.h ../SDCCy.h \
+  ../SDCCbitv.h ../SDCCicode.h ../SDCClabel.h ../SDCCBBlock.h \
+  ../SDCCloop.h ../SDCCcse.h ../SDCCcflow.h ../SDCCdflow.h \
+  ../SDCClrange.h ../SDCCptropt.h ../SDCCopt.h ../SDCCglue.h \
+  ../SDCCpeeph.h ../asm.h ../port.h ralloc.h gen.h
 main.o: main.c ../common.h ../SDCCglobl.h ../../sdccconf.h \
- ../../support/Util/SDCCerr.h ../SDCCmem.h ../SDCCast.h ../SDCCsymt.h \
- ../SDCChasht.h ../SDCCval.h ../SDCCset.h ../SDCCy.h ../SDCCbitv.h \
- ../SDCCicode.h ../SDCClabel.h ../SDCCBBlock.h ../SDCCloop.h \
- ../SDCCcse.h ../SDCCcflow.h ../SDCCdflow.h ../SDCClrange.h \
- ../SDCCptropt.h ../SDCCopt.h ../SDCCglue.h ../SDCCpeeph.h ../asm.h \
- ../port.h ../../support/Util/newalloc.h main.h ralloc.h gen.h \
- peeph.rul
+  ../../support/Util/SDCCerr.h ../SDCCmem.h ../SDCCast.h ../SDCCsymt.h \
+  ../SDCChasht.h ../SDCCval.h ../SDCCset.h ../SDCCy.h ../SDCCbitv.h \
+  ../SDCCicode.h ../SDCClabel.h ../SDCCBBlock.h ../SDCCloop.h \
+  ../SDCCcse.h ../SDCCcflow.h ../SDCCdflow.h ../SDCClrange.h \
+  ../SDCCptropt.h ../SDCCopt.h ../SDCCglue.h ../SDCCpeeph.h ../asm.h \
+  ../port.h ../../support/Util/newalloc.h main.h ralloc.h gen.h peeph.rul
 ralloc.o: ralloc.c ../common.h ../SDCCglobl.h ../../sdccconf.h \
- ../../support/Util/SDCCerr.h ../SDCCmem.h ../SDCCast.h ../SDCCsymt.h \
- ../SDCChasht.h ../SDCCval.h ../SDCCset.h ../SDCCy.h ../SDCCbitv.h \
- ../SDCCicode.h ../SDCClabel.h ../SDCCBBlock.h ../SDCCloop.h \
- ../SDCCcse.h ../SDCCcflow.h ../SDCCdflow.h ../SDCClrange.h \
- ../SDCCptropt.h ../SDCCopt.h ../SDCCglue.h ../SDCCpeeph.h ../asm.h \
- ../port.h ../../support/Util/newalloc.h ralloc.h gen.h
 ../../support/Util/SDCCerr.h ../SDCCmem.h ../SDCCast.h ../SDCCsymt.h \
 ../SDCChasht.h ../SDCCval.h ../SDCCset.h ../SDCCy.h ../SDCCbitv.h \
 ../SDCCicode.h ../SDCClabel.h ../SDCCBBlock.h ../SDCCloop.h \
 ../SDCCcse.h ../SDCCcflow.h ../SDCCdflow.h ../SDCClrange.h \
 ../SDCCptropt.h ../SDCCopt.h ../SDCCglue.h ../SDCCpeeph.h ../asm.h \
 ../port.h ../../support/Util/newalloc.h ralloc.h gen.h