c83cf7bdcd5edd8d3284a6403cb0006bbe639887
[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 acc. to SDCCsymt.h
35     ;
36         mov     a,b
37         jz      00001$  ; 0 near
38         dec     a
39         jz      00002$  ; 1 far
40         dec     a
41         jz      00003$  ; 2 code
42         dec     a
43         jz      00004$
44         dec     a       ; 4 skip generic pointer
45         dec     a
46         jz      00001$  ; 5 idata
47         pop     acc
48         sjmp    00005$
49 ;
50 ;       store into near space
51 ;
52  00001$:
53         pop     acc
54         mov     r0,dpl
55         mov     @r0,a
56         sjmp    00005$
57
58  00002$:
59         pop     acc
60         movx    @dptr,a
61         sjmp    00005$
62
63  00003$:
64         pop     acc    ; do nothing
65         sjmp    00005$
66
67  00004$:
68         pop     acc
69         mov     r0,dpl
70         movx    @r0,a
71  00005$:
72         xch     a,r0
73         pop     acc
74         xch     a,r0
75 _endasm;
76 }