From c1a7b0d0e3f43a1f3cd5495ae87ff3c43fd84752 Mon Sep 17 00:00:00 2001 From: vrokas Date: Fri, 1 Oct 2004 14:57:24 +0000 Subject: [PATCH] * device/lib/pic16/libsdcc/gptr/{*.c, Makefile}: NEW git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3514 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- device/lib/pic16/libsdcc/gptr/Makefile | 30 +++++++ device/lib/pic16/libsdcc/gptr/gptrget1.c | 93 ++++++++++++++++++++ device/lib/pic16/libsdcc/gptr/gptrget2.c | 96 ++++++++++++++++++++ device/lib/pic16/libsdcc/gptr/gptrget3.c | 102 +++++++++++++++++++++ device/lib/pic16/libsdcc/gptr/gptrget4.c | 107 +++++++++++++++++++++++ device/lib/pic16/libsdcc/gptr/gptrput1.c | 84 ++++++++++++++++++ device/lib/pic16/libsdcc/gptr/gptrput2.c | 85 ++++++++++++++++++ device/lib/pic16/libsdcc/gptr/gptrput3.c | 86 ++++++++++++++++++ device/lib/pic16/libsdcc/gptr/gptrput4.c | 87 ++++++++++++++++++ 9 files changed, 770 insertions(+) create mode 100644 device/lib/pic16/libsdcc/gptr/Makefile create mode 100644 device/lib/pic16/libsdcc/gptr/gptrget1.c create mode 100644 device/lib/pic16/libsdcc/gptr/gptrget2.c create mode 100644 device/lib/pic16/libsdcc/gptr/gptrget3.c create mode 100644 device/lib/pic16/libsdcc/gptr/gptrget4.c create mode 100644 device/lib/pic16/libsdcc/gptr/gptrput1.c create mode 100644 device/lib/pic16/libsdcc/gptr/gptrput2.c create mode 100644 device/lib/pic16/libsdcc/gptr/gptrput3.c create mode 100644 device/lib/pic16/libsdcc/gptr/gptrput4.c diff --git a/device/lib/pic16/libsdcc/gptr/Makefile b/device/lib/pic16/libsdcc/gptr/Makefile new file mode 100644 index 00000000..9e36970e --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/Makefile @@ -0,0 +1,30 @@ +# +# Makefile - Makefile to build pic16 generic pointer support library +# +# This file is part of the GNU PIC Library. +# +# January, 2004 +# The GNU PIC Library is maintained by, +# Vangelis Rokas +# +# $Id$ +# +# + + +SRCS = gptrget1 \ + gptrget2 \ + gptrget3 \ + gptrget4 \ + gptrput1 \ + gptrput2 \ + gptrput3 \ + gptrput4 + + +include ../Makefile.rules + +all: build-library + +build-library: $(OFILES) +# @$(CP) -v $(OFILES) ../../bin diff --git a/device/lib/pic16/libsdcc/gptr/gptrget1.c b/device/lib/pic16/libsdcc/gptr/gptrget1.c new file mode 100644 index 00000000..084ccae6 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrget1.c @@ -0,0 +1,93 @@ +/*------------------------------------------------------------------------- + + gptrget1.c :- get 1 byte value from generic pointer + + Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + 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! +-------------------------------------------------------------------------*/ +/* +** $Id$ +*/ + +/* the return value is expected to be in WREG, therefore we choose return + * type void here. Generic pointer is expected to be in WREG:FSR0H:FSR0L, + * so function arguments are void, too */ + +extern POSTINC0; +extern INDF0; +extern FSR0L; +extern FSR0H; +extern WREG; +extern TBLPTRL; +extern TBLPTRH; +extern TBLPTRU; +extern TABLAT; +extern PRODL; + +void _gptrget1(void) +{ + _asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code + * 01 -> EEPROM + * 10 -> data + * 11 -> unimplemented + */ + btfss _WREG, 7 + goto _lab_01_ + + /* data pointer */ + /* data are already in FSR0 */ + + /* debug info */ + movf _POSTINC0, w + + goto _end_ + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto _lab_02_ + + ; code pointer + movwf _TBLPTRU + movff _FSR0L, _TBLPTRL + movff _FSR0H, _TBLPTRH + + TBLRD* + + /* result in TBLAT */ + movf _TABLAT, w + + goto _end_ + + +_lab_02_: + /* EEPROM pointer */ + + /* unimplemented yet */ + +_end_: + + _endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrget2.c b/device/lib/pic16/libsdcc/gptr/gptrget2.c new file mode 100644 index 00000000..c16581f2 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrget2.c @@ -0,0 +1,96 @@ +/*------------------------------------------------------------------------- + + gptrget2.c :- get 2 byte value from generic pointer + + Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + 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! +-------------------------------------------------------------------------*/ + +/* +** $Id$ +*/ + +/* the return value is expected to be in WREG:PRODL, therefore we choose return + * type void here. Generic pointer is expected to be in WREG:FSR0H:FSR0L, + * so function arguments are void, too */ + +extern POSTINC0; +extern INDF0; +extern FSR0L; +extern FSR0H; +extern WREG; +extern TBLPTRL; +extern TBLPTRH; +extern TBLPTRU; +extern TABLAT; +extern PRODL; + +void _gptrget2(void) +{ + _asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code + * 01 -> EEPROM + * 10 -> data + * 11 -> unimplemented + */ + btfss _WREG, 7 + goto _lab_01_ + + /* data pointer */ + /* data are already in FSR0 */ + movf _POSTINC0, w + movff _POSTINC0, _PRODL + + goto _end_ + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto _lab_02_ + + ; code pointer + movwf _TBLPTRU + movff _FSR0L, _TBLPTRL + movff _FSR0H, _TBLPTRH + + /* fetch first byte */ + TBLRD*+ + movf _TABLAT, w + + /* fetch second byte */ + TBLRD*+ + movff _TABLAT, _PRODL + + goto _end_ + + +_lab_02_: + /* EEPROM pointer */ + + /* unimplemented yet */ + +_end_: + + _endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrget3.c b/device/lib/pic16/libsdcc/gptr/gptrget3.c new file mode 100644 index 00000000..0e5d5868 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrget3.c @@ -0,0 +1,102 @@ +/*------------------------------------------------------------------------- + + gptrget3.c :- get 3 byte value from generic pointer + + Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + 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! +-------------------------------------------------------------------------*/ + +/* +** $Id$ +*/ + +/* the return value is expected to be in WREG:PRODL:PRODH, therefore we choose return + * type void here. Generic pointer is expected to be in WREG:FSR0H:FSR0L, + * so function arguments are void, too */ + +extern POSTINC0; +extern INDF0; +extern FSR0L; +extern FSR0H; +extern WREG; +extern TBLPTRL; +extern TBLPTRH; +extern TBLPTRU; +extern TABLAT; +extern PRODL; +extern PRODH; + +void _gptrget3(void) +{ + _asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code + * 01 -> EEPROM + * 10 -> data + * 11 -> unimplemented + */ + btfss _WREG, 7 + goto _lab_01_ + + /* data pointer */ + /* data are already in FSR0 */ + movf _POSTINC0, w + movff _POSTINC0, _PRODL + movff _POSTINC0, _PRODH + + goto _end_ + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto _lab_02_ + + ; code pointer + movwf _TBLPTRU + movff _FSR0L, _TBLPTRL + movff _FSR0H, _TBLPTRH + + /* fetch first byte */ + TBLRD*+ + movf _TABLAT, w + + /* fetch second byte */ + TBLRD*+ + movff _TABLAT, _PRODL + + /* fetch third byte */ + TBLRD*+ + movff _TABLAT, _PRODH + + goto _end_ + + +_lab_02_: + /* EEPROM pointer */ + + /* unimplemented yet */ + +_end_: + + _endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrget4.c b/device/lib/pic16/libsdcc/gptr/gptrget4.c new file mode 100644 index 00000000..74f0a2cc --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrget4.c @@ -0,0 +1,107 @@ +/*------------------------------------------------------------------------- + + gptrget4.c :- get 4 byte value from generic pointer + + Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + 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! +-------------------------------------------------------------------------*/ + +/* +** $Id$ +*/ + +/* the return value is expected to be in WREG:PRODL, therefore we choose return + * type void here. Generic pointer is expected to be in WREG:FSR0H:FSR0L, + * so function arguments are void, too */ + +extern POSTINC0; +extern INDF0; +extern FSR0L; +extern FSR0H; +extern WREG; +extern TBLPTRL; +extern TBLPTRH; +extern TBLPTRU; +extern TABLAT; +extern PRODL; +extern PRODH; + +void _gptrget4(void) +{ + _asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code + * 01 -> EEPROM + * 10 -> data + * 11 -> unimplemented + */ + btfss _WREG, 7 + goto _lab_01_ + + /* data pointer */ + /* data are already in FSR0 */ + movf _POSTINC0, w + movff _POSTINC0, _PRODL + movff _POSTINC0, _PRODH + movff _POSTINC0, _FSR0L + + goto _end_ + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto _lab_02_ + + ; code pointer + movwf _TBLPTRU + movff _FSR0L, _TBLPTRL + movff _FSR0H, _TBLPTRH + + /* fetch first byte */ + TBLRD*+ + movf _TABLAT, w + + /* fetch second byte */ + TBLRD*+ + movff _TABLAT, _PRODL + + /* fetch third byte */ + TBLRD*+ + movff _TABLAT, _PRODH + + /* fetch fourth byte */ + TBLRD*+ + movff _TABLAT, _FSR0L + + goto _end_ + + +_lab_02_: + /* EEPROM pointer */ + + /* unimplemented yet */ + +_end_: + + _endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrput1.c b/device/lib/pic16/libsdcc/gptr/gptrput1.c new file mode 100644 index 00000000..edda1e99 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrput1.c @@ -0,0 +1,84 @@ +/*------------------------------------------------------------------------- + + gptrput1.c :- put 1 byte value at generic pointer + + Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + 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! +-------------------------------------------------------------------------*/ + +/* +** $Id$ +*/ + +/* write address is expected to be in WREG:FSR0H:FSR0L while + * write value is in TBLPTRL:TBLPTRH:PRODH:PRODL */ + +extern POSTINC0; +extern INDF0; +extern FSR0L; +extern FSR0H; +extern WREG; +extern TBLPTRL; +extern TBLPTRH; +extern TBLPTRU; +extern TABLAT; +extern PRODL; +extern PRODH; + +void _gptrput1(void) +{ + _asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code (unimplemented) + * 01 -> EEPROM (unimplemented) + * 10 -> data + * 11 -> unimplemented + */ + btfss _WREG, 7 + goto _lab_01_ + + /* data pointer */ + /* data are already in FSR0 */ + movff _PRODL, _POSTINC0 + + goto _end_ + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto _lab_02_ + + /* code pointer, cannot write code pointers */ + + goto _end_ + + +_lab_02_: + /* EEPROM pointer */ + + /* unimplemented yet */ + +_end_: + + _endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrput2.c b/device/lib/pic16/libsdcc/gptr/gptrput2.c new file mode 100644 index 00000000..58e2daa5 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrput2.c @@ -0,0 +1,85 @@ +/*------------------------------------------------------------------------- + + gptrput1.c :- put 1 byte value at generic pointer + + Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + 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! +-------------------------------------------------------------------------*/ + +/* +** $Id$ +*/ + +/* write address is expected to be in WREG:FSR0H:FSR0L while + * write value is in TBLPTRL:TBLPTRH:PRODH:PRODL */ + +extern POSTINC0; +extern INDF0; +extern FSR0L; +extern FSR0H; +extern WREG; +extern TBLPTRL; +extern TBLPTRH; +extern TBLPTRU; +extern TABLAT; +extern PRODL; +extern PRODH; + +void _gptrput2(void) +{ + _asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code (unimplemented) + * 01 -> EEPROM (unimplemented) + * 10 -> data + * 11 -> unimplemented + */ + btfss _WREG, 7 + goto _lab_01_ + + /* data pointer */ + /* data are already in FSR0 */ + movff _PRODL, _POSTINC0 + movff _PRODH, _POSTINC0 + + goto _end_ + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto _lab_02_ + + /* code pointer, cannot write code pointers */ + + goto _end_ + + +_lab_02_: + /* EEPROM pointer */ + + /* unimplemented yet */ + +_end_: + + _endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrput3.c b/device/lib/pic16/libsdcc/gptr/gptrput3.c new file mode 100644 index 00000000..7ce8762e --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrput3.c @@ -0,0 +1,86 @@ +/*------------------------------------------------------------------------- + + gptrput1.c :- put 1 byte value at generic pointer + + Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + 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! +-------------------------------------------------------------------------*/ + +/* +** $Id$ +*/ + +/* write address is expected to be in WREG:FSR0H:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:PRODL */ + +extern POSTINC0; +extern INDF0; +extern FSR0L; +extern FSR0H; +extern WREG; +extern TBLPTRL; +extern TBLPTRH; +extern TBLPTRU; +extern TABLAT; +extern PRODL; +extern PRODH; + +void _gptrput3(void) +{ + _asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code (unimplemented) + * 01 -> EEPROM (unimplemented) + * 10 -> data + * 11 -> unimplemented + */ + btfss _WREG, 7 + goto _lab_01_ + + /* data pointer */ + /* data are already in FSR0 */ + movff _PRODL, _POSTINC0 + movff _PRODH, _POSTINC0 + movff _TBLPTRL, _POSTINC0 + + goto _end_ + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto _lab_02_ + + /* code pointer, cannot write code pointers */ + + goto _end_ + + +_lab_02_: + /* EEPROM pointer */ + + /* unimplemented yet */ + +_end_: + + _endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrput4.c b/device/lib/pic16/libsdcc/gptr/gptrput4.c new file mode 100644 index 00000000..adf5a8f9 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrput4.c @@ -0,0 +1,87 @@ +/*------------------------------------------------------------------------- + + gptrput1.c :- put 1 byte value at generic pointer + + Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + 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! +-------------------------------------------------------------------------*/ + +/* +** $Id$ +*/ + +/* write address is expected to be in WREG:FSR0H:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:PRODL */ + +extern POSTINC0; +extern INDF0; +extern FSR0L; +extern FSR0H; +extern WREG; +extern TBLPTRL; +extern TBLPTRH; +extern TBLPTRU; +extern TABLAT; +extern PRODL; +extern PRODH; + +void _gptrput4(void) +{ + _asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code (unimplemented) + * 01 -> EEPROM (unimplemented) + * 10 -> data + * 11 -> unimplemented + */ + btfss _WREG, 7 + goto _lab_01_ + + /* data pointer */ + /* data are already in FSR0 */ + movff _PRODL, _POSTINC0 + movff _PRODH, _POSTINC0 + movff _TBLPTRL, _POSTINC0 + movff _TBLPTRH, _POSTINC0 + + goto _end_ + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto _lab_02_ + + /* code pointer, cannot write code pointers */ + + goto _end_ + + +_lab_02_: + /* EEPROM pointer */ + + /* unimplemented yet */ + +_end_: + + _endasm; +} -- 2.47.2