diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
| commit | 268a53de823a6750d6256ee1fb1e7707b4b45740 (patch) | |
| tree | 42c1799a9a82b2f7d9790ee9fe181d72a7274751 /device/lib/pic16/libsdcc/gptr | |
| download | sdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz | |
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'device/lib/pic16/libsdcc/gptr')
26 files changed, 1902 insertions, 0 deletions
diff --git a/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget1.c b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget1.c new file mode 100644 index 0000000..85d2f08 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget1.c @@ -0,0 +1,62 @@ +/*------------------------------------------------------------------------- + eeprom16_gptrget1.c - get 1 byte value from EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int EEADR; +extern int EEADRH; +extern int EECON1; +extern int EEDATA; +extern int FSR0L; +extern int INTCON; +extern int PRODL; +extern int TBLPTRL; + +void +__eeprom16_gptrget1(void) __naked +{ + __asm + MOVFF _INTCON, _TBLPTRL ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + + MOVFF _FSR0L, _EEADR ; address first byte + MOVFF _PRODL, _EEADRH ; high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVF _EEDATA, 0, 0 ; W = EEPROM[adr] + + BTFSC _TBLPTRL, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget2.c b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget2.c new file mode 100644 index 0000000..ae2563c --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget2.c @@ -0,0 +1,67 @@ +/*------------------------------------------------------------------------- + eeprom16_gptrget2.c - get 2 byte value from EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int EEADR; +extern int EEADRH; +extern int EECON1; +extern int EEDATA; +extern int FSR0L; +extern int INTCON; +extern int PRODL; +extern int TBLPTRL; + +void +__eeprom16_gptrget2(void) __naked +{ + __asm + MOVFF _INTCON, _TBLPTRL ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + + MOVFF _FSR0L, _EEADR ; address first byte + MOVFF _PRODL, _EEADRH ; address first byte, high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVF _EEDATA, 0, 0 ; W = EEPROM[adr] + + INFSNZ _EEADR, 1, 0 ; address second byte + INCF _EEADRH, 1, 0 ; high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVFF _EEDATA, _PRODL ; PRODL = EEPROM[adr+1] + + BTFSC _TBLPTRL, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget3.c b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget3.c new file mode 100644 index 0000000..43d9ce5 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget3.c @@ -0,0 +1,73 @@ +/*------------------------------------------------------------------------- + eeprom16_gptrget3.c - get 3 byte value from EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int EEADR; +extern int EEADRH; +extern int EECON1; +extern int EEDATA; +extern int FSR0L; +extern int INTCON; +extern int PRODH; +extern int PRODL; +extern int TBLPTRL; + +void +__eeprom16_gptrget3(void) __naked +{ + __asm + MOVFF _INTCON, _TBLPTRL ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + + MOVFF _FSR0L, _EEADR ; address first byte + MOVFF _PRODL, _EEADRH ; high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVF _EEDATA, 0, 0 ; W = EEPROM[adr] + + INFSNZ _EEADR, 1, 0 ; address second byte + INCF _EEADRH, 1, 0 ; high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVFF _EEDATA, _PRODL ; PRODL = EEPROM[adr+1] + + INFSNZ _EEADR, 1, 0 ; address third byte + INCF _EEADRH, 1, 0 ; high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVFF _EEDATA, _PRODH ; PRODH = EEPROM[adr+2] + + BTFSC _TBLPTRL, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget4.c b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget4.c new file mode 100644 index 0000000..647597e --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrget4.c @@ -0,0 +1,79 @@ +/*------------------------------------------------------------------------- + eeprom16_gptrget4.c - get 4 byte value from EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int EEADR; +extern int EEADRH; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PRODH; +extern int PRODL; +extern int TBLPTRL; + +void +__eeprom16_gptrget4(void) __naked +{ + __asm + MOVFF _INTCON, _TBLPTRL ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + + MOVFF _FSR0L, _EEADR ; address first byte + MOVFF _PRODL, _EEADRH ; high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVF _EEDATA, 0, 0 ; W = EEPROM[adr] + + INFSNZ _EEADR, 1, 0 ; address second byte + INCF _EEADRH, 1, 0 ; high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVFF _EEDATA, _PRODL ; PRODL = EEPROM[adr+1] + + INFSNZ _EEADR, 1, 0 ; address third byte + INCF _EEADRH, 1, 0 ; high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVFF _EEDATA, _PRODH ; PRODH = EEPROM[adr+2] + + INFSNZ _EEADR, 1, 0 ; address fourth byte + INCF _EEADRH, 1, 0 ; high address bits + BSF _EECON1, 0, 0 ; RD = 1: read EEPROM + MOVFF _EEDATA, _FSR0H ; FSR0H = EEPROM[adr+3] + + BTFSC _TBLPTRL, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput1.c b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput1.c new file mode 100644 index 0000000..7889f47 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput1.c @@ -0,0 +1,67 @@ +/*------------------------------------------------------------------------- + eeprom16_gptrput1.c - write 1 byte value to EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int EEADR; +extern int EEADRH; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PREINC1; +extern int PRODL; +extern int __eeprom16_write; + +void +__eeprom16_gptrput1(void) __naked +{ + __asm + MOVFF _INTCON, _FSR0H ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + BSF _EECON1, 2, 0 ; WREN = 1: enable write access + + MOVFF _FSR0L, _EEADR ; address first byte + MOVFF _PRODL, _EEADRH ; high address bits + + MOVFF _PREINC1, _EEDATA ; load first byte + CALL ___eeprom16_write ; write and address next byte + + BCF _EECON1, 2, 0 ; WREN = 0: disable write access + + BTFSC _FSR0H, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput2.c b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput2.c new file mode 100644 index 0000000..62acd47 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput2.c @@ -0,0 +1,71 @@ +/*------------------------------------------------------------------------- + eeprom16_gptrput2.c - write 2 byte value to EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int EEADR; +extern int EEADRH; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PREINC1; +extern int PRODH; +extern int PRODL; +extern int __eeprom16_write; + +void +__eeprom16_gptrput2(void) __naked +{ + __asm + MOVFF _INTCON, _FSR0H ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + BSF _EECON1, 2, 0 ; WREN = 1: enable write access + + MOVFF _FSR0L, _EEADR ; address first byte + MOVFF _PRODL, _EEADRH ; high address bits + + MOVFF _PREINC1, _EEDATA ; load first byte + CALL ___eeprom16_write ; write and address next byte + + MOVFF _PRODH, _EEDATA ; load second byte + CALL ___eeprom16_write ; write and address next byte + + BCF _EECON1, 2, 0 ; WREN = 0: disable write access + + BTFSC _FSR0H, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput3.c b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput3.c new file mode 100644 index 0000000..62cdb7c --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput3.c @@ -0,0 +1,75 @@ +/*------------------------------------------------------------------------- + eeprom16_gptrput3.c - write 3 byte value to EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int EEADR; +extern int EEADRH; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PREINC1; +extern int PRODH; +extern int PRODL; +extern int TBLPTRL; +extern int __eeprom16_write; + +void +__eeprom16_gptrput3(void) __naked +{ + __asm + MOVFF _INTCON, _FSR0H ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + BSF _EECON1, 2, 0 ; WREN = 1: enable write access + + MOVFF _FSR0L, _EEADR ; address first byte + MOVFF _PRODL, _EEADRH ; high address bits + + MOVFF _PREINC1, _EEDATA ; load first byte + CALL ___eeprom16_write ; write and address next byte + + MOVFF _PRODH, _EEDATA ; load second byte + CALL ___eeprom16_write ; write and address next byte + + MOVFF _TBLPTRL, _EEDATA ; load third byte + CALL ___eeprom16_write ; write and address next byte + + BCF _EECON1, 2, 0 ; WREN = 0: disable write access + + BTFSC _FSR0H, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput4.c b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput4.c new file mode 100644 index 0000000..2bd907d --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom16_gptrput4.c @@ -0,0 +1,79 @@ +/*------------------------------------------------------------------------- + eeprom16_gptrput4.c - write 4 byte value to EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int EEADR; +extern int EEADRH; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PREINC1; +extern int PRODH; +extern int PRODL; +extern int TBLPTRL; +extern int TBLPTRH; +extern int __eeprom16_write; + +void +__eeprom16_gptrput4(void) __naked +{ + __asm + MOVFF _INTCON, _FSR0H ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + BSF _EECON1, 2, 0 ; WREN = 1: enable write access + + MOVFF _FSR0L, _EEADR ; address first byte + MOVFF _PRODL, _EEADRH ; high address bits + + MOVFF _PREINC1, _EEDATA ; load first byte + CALL ___eeprom16_write ; write and address next byte + + MOVFF _PRODH, _EEDATA ; load second byte + CALL ___eeprom16_write ; write and address next byte + + MOVFF _TBLPTRL, _EEDATA ; load third byte + CALL ___eeprom16_write ; write and address next byte + + MOVFF _TBLPTRH, _EEDATA ; load fourth byte + CALL ___eeprom16_write ; write and address next byte + + BCF _EECON1, 2, 0 ; WREN = 0: disable write access + + BTFSC _FSR0H, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom16_write.c b/device/lib/pic16/libsdcc/gptr/eeprom16_write.c new file mode 100644 index 0000000..92ff0ce --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom16_write.c @@ -0,0 +1,51 @@ +/*------------------------------------------------------------------------- + eeprom_write16.c - write one byte to EEPROM and wait for completion + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +extern char EEADR; +extern char EEADRH; +extern char EECON1; +extern char EECON2; + +void __eeprom16_write(void) __naked +{ + __asm + movlw 0x55 + movwf _EECON2, 0 + movlw 0xAA + movwf _EECON2, 0 + bsf _EECON1, 1, 0 ; WR + + wait_till_done: + btfsc _EECON1, 1, 0 ; WR still set? + bra wait_till_done + + infsnz _EEADR, 1, 0 ; address next byte + incf _EEADRH, 1, 0 ; address next byte + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget1.c b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget1.c new file mode 100644 index 0000000..a702dec --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget1.c @@ -0,0 +1,59 @@ +/*------------------------------------------------------------------------- + eeprom8_gptrget1.c - get 1 byte value from EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int EEADR; +extern int EECON1; +extern int EEDATA; +extern int FSR0L; +extern int INTCON; +extern int TBLPTRL; + +void +__eeprom8_gptrget1(void) __naked +{ + __asm + MOVFF _INTCON, _TBLPTRL ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + + MOVFF _FSR0L, _EEADR ; address first byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVF _EEDATA, 0, 0 ; W = EEPROM[adr] + + BTFSC _TBLPTRL, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget2.c b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget2.c new file mode 100644 index 0000000..35aeb81 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget2.c @@ -0,0 +1,64 @@ +/*------------------------------------------------------------------------- + eeprom8_gptrget2.c - get 2 byte value from EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int EEADR; +extern int EECON1; +extern int EEDATA; +extern int FSR0L; +extern int INTCON; +extern int PRODL; +extern int TBLPTRL; + +void +__eeprom8_gptrget2(void) __naked +{ + __asm + MOVFF _INTCON, _TBLPTRL ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + + MOVFF _FSR0L, _EEADR ; address first byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVF _EEDATA, 0, 0 ; W = EEPROM[adr] + + INCF _EEADR, 1, 0 ; address second byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVFF _EEDATA, _PRODL ; PRODL = EEPROM[adr+1] + + BTFSC _TBLPTRL, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget3.c b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget3.c new file mode 100644 index 0000000..de738d5 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget3.c @@ -0,0 +1,69 @@ +/*------------------------------------------------------------------------- + eeprom8_gptrget3.c - get 3 byte value from EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int EEADR; +extern int EECON1; +extern int EEDATA; +extern int FSR0L; +extern int INTCON; +extern int PRODH; +extern int PRODL; +extern int TBLPTRL; + +void +__eeprom8_gptrget3(void) __naked +{ + __asm + MOVFF _INTCON, _TBLPTRL ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + + MOVFF _FSR0L, _EEADR ; address first byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVF _EEDATA, 0, 0 ; W = EEPROM[adr] + + INCF _EEADR, 1, 0 ; address second byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVFF _EEDATA, _PRODL ; PRODL = EEPROM[adr+1] + + INCF _EEADR, 1, 0 ; address third byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVFF _EEDATA, _PRODH ; PRODH = EEPROM[adr+2] + + BTFSC _TBLPTRL, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget4.c b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget4.c new file mode 100644 index 0000000..b2765a5 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrget4.c @@ -0,0 +1,74 @@ +/*------------------------------------------------------------------------- + eeprom8_gptrget4.c - get 4 byte value from EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int EEADR; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PRODH; +extern int PRODL; +extern int TBLPTRL; + +void +__eeprom8_gptrget4(void) __naked +{ + __asm + MOVFF _INTCON, _TBLPTRL ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + + MOVFF _FSR0L, _EEADR ; address first byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVF _EEDATA, 0, 0 ; W = EEPROM[adr] + + INCF _EEADR, 1, 0 ; address second byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVFF _EEDATA, _PRODL ; PRODL = EEPROM[adr+1] + + INCF _EEADR, 1, 0 ; address third byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVFF _EEDATA, _PRODH ; PRODH = EEPROM[adr+2] + + INCF _EEADR, 1, 0 ; address fourth byte + BSF _EECON1, 0, 0 ; RD = 1 + MOVFF _EEDATA, _FSR0H ; PRODL = EEPROM[adr+3] + + BTFSC _TBLPTRL, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput1.c b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput1.c new file mode 100644 index 0000000..2d0befc --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput1.c @@ -0,0 +1,64 @@ +/*------------------------------------------------------------------------- + eeprom8_gptrput1.c - write 1 byte value to EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int EEADR; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PREINC1; +extern int __eeprom8_write; + +void +__eeprom8_gptrput1(void) __naked +{ + __asm + MOVFF _INTCON, _FSR0H ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + BSF _EECON1, 2, 0 ; WREN = 1: enable write access + + MOVFF _FSR0L, _EEADR ; address first byte + + MOVFF _PREINC1, _EEDATA ; load first byte + CALL ___eeprom8_write ; write and address next byte + + BCF _EECON1, 2, 0 ; WREN = 0: disable write access + + BTFSC _FSR0H, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput2.c b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput2.c new file mode 100644 index 0000000..900227b --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput2.c @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- + eeprom8_gptrput2.c - write 2 byte value to EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int EEADR; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PREINC1; +extern int PRODH; +extern int __eeprom8_write; + +void +__eeprom8_gptrput2(void) __naked +{ + __asm + MOVFF _INTCON, _FSR0H ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + BSF _EECON1, 2, 0 ; WREN = 1: enable write access + + MOVFF _FSR0L, _EEADR ; address first byte + + MOVFF _PREINC1, _EEDATA ; load first byte + CALL ___eeprom8_write ; write and address next byte + + MOVFF _PRODH, _EEDATA ; load second byte + CALL ___eeprom8_write ; write and address next byte + + BCF _EECON1, 2, 0 ; WREN = 0: disable write access + + BTFSC _FSR0H, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput3.c b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput3.c new file mode 100644 index 0000000..42aa6c1 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput3.c @@ -0,0 +1,72 @@ +/*------------------------------------------------------------------------- + eeprom8_gptrput3.c - write 3 byte value to EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int EEADR; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PREINC1; +extern int PRODH; +extern int TBLPTRL; +extern int __eeprom8_write; + +void +__eeprom8_gptrput3(void) __naked +{ + __asm + MOVFF _INTCON, _FSR0H ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + BSF _EECON1, 2, 0 ; WREN = 1: enable write access + + MOVFF _FSR0L, _EEADR ; address first byte + + MOVFF _PREINC1, _EEDATA ; load first byte + CALL ___eeprom8_write ; write and address next byte + + MOVFF _PRODH, _EEDATA ; load second byte + CALL ___eeprom8_write ; write and address next byte + + MOVFF _TBLPTRL, _EEDATA ; load third byte + CALL ___eeprom8_write ; write and address next byte + + BCF _EECON1, 2, 0 ; WREN = 0: disable write access + + BTFSC _FSR0H, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput4.c b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput4.c new file mode 100644 index 0000000..03aede4 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom8_gptrput4.c @@ -0,0 +1,75 @@ +/*------------------------------------------------------------------------- + eeprom8_gptrput4.c - write 4 byte value to EEPROM via a generic pointer + + Copyright (C) 2012 Raphael Neider <rneider AT web.de> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int EEADR; +extern int EECON1; +extern int EEDATA; +extern int FSR0H; +extern int FSR0L; +extern int INTCON; +extern int PREINC1; +extern int PRODH; +extern int TBLPTRL; +extern int TBLPTRH; +extern int __eeprom8_write; + +void +__eeprom8_gptrput4(void) __naked +{ + __asm + MOVFF _INTCON, _FSR0H ; save previous interupt state + BCF _INTCON, 7, 0 ; GIE = 0: disable interrupts + + BCF _EECON1, 7, 0 ; EEPGD = 0: access EEPROM, not program memory + BCF _EECON1, 6, 0 ; CFGS = 0: access EEPROM, not config words + BSF _EECON1, 2, 0 ; WREN = 1: enable write access + + MOVFF _FSR0L, _EEADR ; address first byte + MOVFF _PREINC1, _EEDATA ; load first byte + CALL ___eeprom8_write ; write and address next byte + + MOVFF _PRODH, _EEDATA ; load second byte + CALL ___eeprom8_write ; write and address next byte + + MOVFF _TBLPTRL, _EEDATA ; load third byte + CALL ___eeprom8_write ; write and address next byte + + MOVFF _TBLPTRH, _EEDATA ; load fourth byte + CALL ___eeprom8_write ; write and address next byte + + BCF _EECON1, 2, 0 ; WREN = 0: disable write access + + BTFSC _FSR0H, 7, 0 ; check previous interrupt state + BSF _INTCON, 7, 0 ; conditionally re-enable interrupts + + RETURN + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/eeprom8_write.c b/device/lib/pic16/libsdcc/gptr/eeprom8_write.c new file mode 100644 index 0000000..82cac16 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/eeprom8_write.c @@ -0,0 +1,49 @@ +/*------------------------------------------------------------------------- + eeprom_write8.c - write one byte to EEPROM and wait for completion + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +extern char EEADR; +extern char EECON1; +extern char EECON2; + +void __eeprom8_write(void) __naked +{ + __asm + movlw 0x55 + movwf _EECON2, 0 + movlw 0xAA + movwf _EECON2, 0 + bsf _EECON1, 1, 0 ; WR + + wait_till_done: + btfsc _EECON1, 1, 0 ; WR still set? + bra wait_till_done + + infsnz _EEADR, 1, 0 ; address next byte + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrget1.c b/device/lib/pic16/libsdcc/gptr/gptrget1.c new file mode 100644 index 0000000..f7d932c --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrget1.c @@ -0,0 +1,87 @@ +/*------------------------------------------------------------------------- + gptrget1.c - get 1 byte value from generic pointer + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int POSTINC0; +extern int INDF0; +extern int FSR0L; +extern int FSR0H; +extern int WREG; +extern int TBLPTRL; +extern int TBLPTRH; +extern int TBLPTRU; +extern int TABLAT; +extern int PRODL; +extern int __eeprom_gptrget1; + +void _gptrget1(void) __naked +{ + __asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code + * 01 -> EEPROM + * 10 -> data + * 11 -> data + * + * address in (WREG, PRODL, FSR0L) + * result in (FSR0L, PRODH, PRODL, WREG) + */ + btfss _WREG, 7, 0 + bra _lab_01_ + + /* data pointer */ + /* FSR0L is already set up */ + movff _PRODL, _FSR0H + + movf _POSTINC0, 0, 0 + + return + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6, 0 + goto ___eeprom_gptrget1 + + ; code pointer + movff _FSR0L, _TBLPTRL + movff _PRODL, _TBLPTRH + movwf _TBLPTRU, 0 + + /* fetch first byte */ + TBLRD*+ + movf _TABLAT, 0, 0 + + return + + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrget2.c b/device/lib/pic16/libsdcc/gptr/gptrget2.c new file mode 100644 index 0000000..4fd7b05 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrget2.c @@ -0,0 +1,92 @@ +/*------------------------------------------------------------------------- + gptrget2.c - get 2 byte value from generic pointer + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int POSTINC0; +extern int INDF0; +extern int FSR0L; +extern int FSR0H; +extern int WREG; +extern int TBLPTRL; +extern int TBLPTRH; +extern int TBLPTRU; +extern int TABLAT; +extern int PRODL; +extern int __eeprom_gptrget2; + +void _gptrget2(void) __naked +{ + __asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code + * 01 -> EEPROM + * 10 -> data + * 11 -> data + * + * address in (WREG, PRODL, FSR0L) + * result in (FSR0L, PRODH, PRODL, WREG) + */ + btfss _WREG, 7, 0 + bra _lab_01_ + + /* data pointer */ + /* FSR0L is already set up */ + movff _PRODL, _FSR0H + + movf _POSTINC0, 0, 0 + movff _POSTINC0, _PRODL + + return + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6, 0 + goto ___eeprom_gptrget2 + + ; code pointer + movff _FSR0L, _TBLPTRL + movff _PRODL, _TBLPTRH + movwf _TBLPTRU, 0 + + /* fetch first byte */ + TBLRD*+ + movf _TABLAT, 0, 0 + + /* fetch second byte */ + TBLRD*+ + movff _TABLAT, _PRODL + + return + + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrget3.c b/device/lib/pic16/libsdcc/gptr/gptrget3.c new file mode 100644 index 0000000..f6327eb --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrget3.c @@ -0,0 +1,98 @@ +/*------------------------------------------------------------------------- + gptrget3.c - get 3 byte value from generic pointer + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int POSTINC0; +extern int INDF0; +extern int FSR0L; +extern int FSR0H; +extern int WREG; +extern int TBLPTRL; +extern int TBLPTRH; +extern int TBLPTRU; +extern int TABLAT; +extern int PRODL; +extern int PRODH; +extern int __eeprom_gptrget3; + +void _gptrget3(void) __naked +{ + __asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code + * 01 -> EEPROM + * 10 -> data + * 11 -> data + * + * address in (WREG, PRODL, FSR0L) + * result in (FSR0L, PRODH, PRODL, WREG) + */ + btfss _WREG, 7, 0 + bra _lab_01_ + + /* data pointer */ + /* FSR0L is already set up */ + movff _PRODL, _FSR0H + + movf _POSTINC0, 0, 0 + movff _POSTINC0, _PRODL + movff _POSTINC0, _PRODH + + return + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6, 0 + goto ___eeprom_gptrget3 + + ; code pointer + movff _FSR0L, _TBLPTRL + movff _PRODL, _TBLPTRH + movwf _TBLPTRU, 0 + + /* fetch first byte */ + TBLRD*+ + movf _TABLAT, 0, 0 + + /* fetch second byte */ + TBLRD*+ + movff _TABLAT, _PRODL + + /* fetch third byte */ + TBLRD*+ + movff _TABLAT, _PRODH + + return + + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrget4.c b/device/lib/pic16/libsdcc/gptr/gptrget4.c new file mode 100644 index 0000000..ca96d67 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrget4.c @@ -0,0 +1,103 @@ +/*------------------------------------------------------------------------- + gptrget4.c - get 4 byte value from generic pointer + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* the return value is expected to be in (FSR0H, PRODH, PRODL, WREG), + * therefore we choose return type void here. Generic pointer is expected + * to be in (WREG, PRODL, FSR0L), so function arguments are void, too */ + +extern int POSTINC0; +extern int INDF0; +extern int FSR0L; +extern int FSR0H; +extern int WREG; +extern int TBLPTRL; +extern int TBLPTRH; +extern int TBLPTRU; +extern int TABLAT; +extern int PRODL; +extern int PRODH; +extern int __eeprom_gptrget4; + +void _gptrget4(void) __naked +{ + __asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code + * 01 -> EEPROM + * 10 -> data + * 11 -> data + * + * address in (WREG, PRODL, FSR0L) + * result in (FSR0L, PRODH, PRODL, WREG) + */ + btfss _WREG, 7, 0 + bra _lab_01_ + + /* data pointer */ + /* FSR0L is already set up */ + movff _PRODL, _FSR0H + + movf _POSTINC0, 0, 0 + movff _POSTINC0, _PRODL + movff _POSTINC0, _PRODH + movff _POSTINC0, _FSR0L + + return + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6, 0 + goto ___eeprom_gptrget4 + + ; code pointer + movff _FSR0L, _TBLPTRL + movff _PRODL, _TBLPTRH + movwf _TBLPTRU, 0 + + /* fetch first byte */ + TBLRD*+ + movf _TABLAT, 0, 0 + + /* fetch second byte */ + TBLRD*+ + movff _TABLAT, _PRODL + + /* fetch third byte */ + TBLRD*+ + movff _TABLAT, _PRODH + + /* fetch fourth byte */ + TBLRD*+ + movff _TABLAT, _FSR0L + + return + + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrput1.c b/device/lib/pic16/libsdcc/gptr/gptrput1.c new file mode 100644 index 0000000..f18e00b --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrput1.c @@ -0,0 +1,73 @@ +/*------------------------------------------------------------------------- + gptrput1.c - put 1 byte value at generic pointer + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int FSR0H; +extern int POSTINC0; +extern int PREINC1; +extern int PRODL; +extern int WREG; +extern int __eeprom_gptrput1; + +void _gptrput1(void) __naked +{ + __asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code (unimplemented) + * 01 -> EEPROM + * 10 -> data + * 11 -> data + * + * address: (WREG, PRODL, FSR0L) + * value: (TBLPTRH, TBLPTRL, PRODH, STACK1[+1]) + */ + btfss _WREG, 7 + bra _lab_01_ + + /* data pointer */ + /* FSR0L is already set up */ + movff _PRODL, _FSR0H + + movff _PREINC1, _POSTINC0 + + return + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto ___eeprom_gptrput1 + + /* code pointer, cannot write code pointers */ + return + + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrput2.c b/device/lib/pic16/libsdcc/gptr/gptrput2.c new file mode 100644 index 0000000..2d62a36 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrput2.c @@ -0,0 +1,75 @@ +/*------------------------------------------------------------------------- + gptrput2.c - put 2 byte value at generic pointer + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int FSR0H; +extern int POSTINC0; +extern int PREINC1; +extern int PRODH; +extern int PRODL; +extern int WREG; +extern int __eeprom_gptrput2; + +void _gptrput2(void) __naked +{ + __asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code (unimplemented) + * 01 -> EEPROM + * 10 -> data + * 11 -> data + * + * address: (WREG, PRODL, FSR0L) + * value: (TBLPTRH, TBLPTRL, PRODH, STACK1[+1]) + */ + btfss _WREG, 7 + bra _lab_01_ + + /* data pointer */ + /* FSR0L is already set up */ + movff _PRODL, _FSR0H + + movff _PREINC1, _POSTINC0 + movff _PRODH, _POSTINC0 + + return + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto ___eeprom_gptrput2 + + /* code pointer, cannot write code pointers */ + return + + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrput3.c b/device/lib/pic16/libsdcc/gptr/gptrput3.c new file mode 100644 index 0000000..dc9c7c9 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrput3.c @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------- + gptrput3.c - put 3 byte value at generic pointer + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int FSR0H; +extern int POSTINC0; +extern int PREINC1; +extern int PRODH; +extern int PRODL; +extern int TBLPTRL; +extern int WREG; +extern int __eeprom_gptrput3; + +void _gptrput3(void) __naked +{ + __asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code (unimplemented) + * 01 -> EEPROM + * 10 -> data + * 11 -> data + * + * address: (WREG, PRODL, FSR0L) + * value: (TBLPTRH, TBLPTRL, PRODH, STACK1[+1]) + */ + btfss _WREG, 7 + bra _lab_01_ + + /* data pointer */ + /* FSR0L is already set up */ + movff _PRODL, _FSR0H + + movff _PREINC1, _POSTINC0 + movff _PRODH, _POSTINC0 + movff _TBLPTRL, _POSTINC0 + + return + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto ___eeprom_gptrput3 + + /* code pointer, cannot write code pointers */ + return + + __endasm; +} diff --git a/device/lib/pic16/libsdcc/gptr/gptrput4.c b/device/lib/pic16/libsdcc/gptr/gptrput4.c new file mode 100644 index 0000000..0044786 --- /dev/null +++ b/device/lib/pic16/libsdcc/gptr/gptrput4.c @@ -0,0 +1,79 @@ +/*------------------------------------------------------------------------- + gptrput4.c - put 4 byte value at generic pointer + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + Adopted for pic16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr> + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* write address is expected to be in WREG:PRODL:FSR0L while + * write value is in TBLPTRH:TBLPTRL:PRODH:[stack] */ + +extern int FSR0H; +extern int POSTINC0; +extern int PREINC1; +extern int PRODH; +extern int PRODL; +extern int TBLPTRH; +extern int TBLPTRL; +extern int WREG; +extern int __eeprom_gptrput4; + +void _gptrput4(void) __naked +{ + __asm + /* decode generic pointer MSB (in WREG) bits 6 and 7: + * 00 -> code (unimplemented) + * 01 -> EEPROM + * 10 -> data + * 11 -> data + * + * address: (WREG, PRODL, FSR0L) + * value: (TBLPTRH, TBLPTRL, PRODH, STACK1[+1]) + */ + btfss _WREG, 7 + bra _lab_01_ + + /* data pointer */ + /* FSR0L is already set up */ + movff _PRODL, _FSR0H + + movff _PREINC1, _POSTINC0 + movff _PRODH, _POSTINC0 + movff _TBLPTRL, _POSTINC0 + movff _TBLPTRH, _POSTINC0 + + return + + +_lab_01_: + /* code or eeprom */ + btfsc _WREG, 6 + goto ___eeprom_gptrput4 + + /* code pointer, cannot write code pointers */ + return + + __endasm; +} |
