From: pjs Date: Sat, 19 Jan 2002 04:43:15 +0000 (+0000) Subject: Added --xram-movc option X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=8fca63fbcde6e36936906190fa8e41f072a69e34;p=fw%2Fsdcc Added --xram-movc option git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1815 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index ec5582be..df8458fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-01-18 Paul Stoffregen + + * Added --xram-movc option + 2002-01-13 Bernhard Held * support/regression/Makefile: don't include test-mcs51-stack-auto in target all diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index 6927200d..7c28242b 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -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 index 00000000..00506fb8 --- /dev/null +++ b/device/lib/_gptrgetc.c @@ -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 ; + +} diff --git a/device/lib/libsdcc.lib b/device/lib/libsdcc.lib index 4732a292..25246d10 100644 --- a/device/lib/libsdcc.lib +++ b/device/lib/libsdcc.lib @@ -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 diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 258be0f6..ef7d64ed 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -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 */ diff --git a/src/SDCCmain.c b/src/SDCCmain.c index c65ebd24..3dfa2fc7 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -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 }, diff --git a/src/SDCCpeeph.c b/src/SDCCpeeph.c index e1c68e8b..dfd7d84c 100644 --- a/src/SDCCpeeph.c +++ b/src/SDCCpeeph.c @@ -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 } diff --git a/src/mcs51/peeph.def b/src/mcs51/peeph.def index e26372e8..2a4c7c6c 100644 --- a/src/mcs51/peeph.def +++ b/src/mcs51/peeph.def @@ -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 + + + diff --git a/src/xa51/Makefile.dep b/src/xa51/Makefile.dep index 4635445b..a7437109 100644 --- a/src/xa51/Makefile.dep +++ b/src/xa51/Makefile.dep @@ -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