Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / pic16 / libsdcc / gptr / gptrput2.c
1 /*-------------------------------------------------------------------------
2
3    gptrput1.c :- put 2 byte value at generic pointer
4
5    Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr)
6
7              Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1999)
8
9    This library is free software; you can redistribute it and/or modify it
10    under the terms of the GNU Library General Public License as published by the
11    Free Software Foundation; either version 2, or (at your option) any
12    later version.
13
14    This library is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU Library General Public License for more details.
18
19    You should have received a copy of the GNU Library General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23    In other words, you are welcome to use, share and improve this program.
24    You are forbidden to forbid anyone else to use, share and improve
25    what you give them.   Help stamp out software-hoarding!
26 -------------------------------------------------------------------------*/
27
28 /*
29 ** $Id: gptrput2.c 3714 2005-04-02 13:13:53Z vrokas $
30 */
31
32 /* write address is expected to be in WREG:PRODL:FSR0L while
33  * write value is in TBLPTRL:TBLPTRH:PRODH:[stack] */
34  
35 extern POSTINC0;
36 extern PREINC1;
37 extern INDF0;
38 extern FSR0L;
39 extern FSR0H;
40 extern WREG;
41 extern TBLPTRL;
42 extern TBLPTRH;
43 extern TBLPTRU;
44 extern TABLAT;
45 extern PRODL;
46 extern PRODH;
47
48 void _gptrput2(void) __naked
49 {
50   __asm
51     /* decode generic pointer MSB (in WREG) bits 6 and 7:
52      * 00 -> code (unimplemented)
53      * 01 -> EEPROM (unimplemented)
54      * 10 -> data
55      * 11 -> unimplemented
56      */
57     btfss       _WREG, 7
58     bra         _lab_01_
59     
60     /* data pointer  */
61     /* data are already in FSR0 */
62     movff       _PRODL, _FSR0H
63     
64     movff       _PREINC1, _POSTINC0
65     movff       _PRODH, _POSTINC0
66     
67     return
68     
69
70 _lab_01_:
71     /* code or eeprom */
72     btfss       _WREG, 6
73     return
74     
75     /* code pointer, cannot write code pointers */
76     
77   
78 _lab_02_:
79     /* EEPROM pointer */
80
81     /* unimplemented yet */
82
83
84   return
85   __endasm;
86 }