Change from GPL to LPGL
[fw/sdcc] / device / lib / _gptrput.c
1 /*-------------------------------------------------------------------------
2
3   _gptrput.c :- put value for a generic pointer               
4
5              Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1999)
6
7    This library is free software; you can redistribute it and/or modify it
8    under the terms of the GNU Library General Public License as published by the
9    Free Software Foundation; either version 2, or (at your option) any
10    later version.
11    
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU Library General Public License for more details.
16    
17    You should have received a copy of the GNU Library General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20    
21    In other words, you are welcome to use, share and improve this program.
22    You are forbidden to forbid anyone else to use, share and improve
23    what you give them.   Help stamp out software-hoarding!  
24 -------------------------------------------------------------------------*/
25
26 unsigned char _gptrput ()
27 {
28     _asm
29         xch      a,r0
30         push     acc
31         xch      a,r0
32         push     acc
33     ;
34     ;   depending on the pointer type
35     ;
36         mov     a,b
37         jz      00001$
38         dec     a
39         jz      00002$
40         dec     a
41         jz      00003$
42         dec     a
43         jz      00004$
44         pop     acc
45         sjmp    00005$
46 ;
47 ;       store into near space
48 ;       
49  00001$:
50         pop     acc
51         mov     r0,dpl
52         mov     @r0,a
53         sjmp    00005$
54
55  00002$:
56         pop     acc
57         movx    @dptr,a
58         sjmp    00005$
59
60  00003$:
61         pop     acc    ; do nothing
62         sjmp    00005$
63
64  00004$:
65         pop     acc
66         mov     r0,dpl
67         movx    @r0,a
68  00005$:       
69         xch     a,r0
70         pop     acc
71         xch     a,r0
72 _endasm;
73 }