P2 not used any more (related to #850747, #785979)
[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 #define P2_PAGES_PDATA 0 /* not all devices use P2 to page pdata memory */
27
28 void
29 _gptrput (char *gptr, char c)
30 {
31     gptr; c; /* hush the compiler */
32
33     _asm
34         push     acc
35     ;
36     ;   depending on the pointer type acc. to SDCCsymt.h
37     ;
38         mov     a,b
39         jz      00001$  ; 0 near
40         dec     a
41         jz      00002$  ; 1 far
42         dec     a
43         jz      00003$  ; 2 code
44         dec     a
45         jz      00004$  ; 3 pdata
46         dec     a       ; 4 skip generic pointer
47         dec     a
48         jz      00001$  ; 5 idata
49
50  00003$:
51         pop     acc    ; do nothing
52         sjmp    00005$
53 ;  
54 ;       store into near space
55 ;
56  00001$:
57         pop     acc
58         push    ar0
59         mov     r0,dpl
60         mov     @r0,a
61         pop     ar0
62         sjmp    00005$
63
64  00002$:
65         pop     acc
66         movx    @dptr,a
67         sjmp    00005$
68
69  00004$:
70 #if P2_PAGES_PDATA
71         pop     acc
72         mov     dph,p2          ; p2 holds high byte for pdata access
73         movx    @dptr,a
74 #else
75         pop     acc
76         push    ar0
77         mov     r0,dpl
78         movx    @r0,a
79         pop     ar0
80 #endif  
81
82  00005$:
83 _endasm;
84 }
85
86 #ifdef SDCC_ds390
87 void
88 _gptrputWord ()
89 {
90     _asm
91         push     acc
92     ;
93     ;   depending on the pointer type acc. to SDCCsymt.h
94     ;
95         mov     a,b
96         jz      00011$  ; 0 near
97         dec     a
98         jz      00012$  ; 1 far
99         dec     a
100         jz      00013$  ; 2 code
101         dec     a
102         jz      00014$  ; 3 pdata
103         dec     a       ; 4 skip generic pointer
104         dec     a
105         jz      00011$  ; 5 idata
106         pop     acc
107         sjmp    00016$
108 ;
109 ;       store into near space
110 ;
111  00011$:
112         pop     acc
113         push    ar0
114         mov     r0,dpl
115         mov     @r0,_ap
116         inc     r0
117         mov     @r0,a
118         sjmp    00015$
119
120  00012$:
121         mov     a, _ap
122         movx    @dptr,a
123         inc     dptr
124         pop     acc
125         movx    @dptr,a
126         sjmp    00016$
127
128  00013$:
129         pop     acc    ; do nothing
130         sjmp    00016$
131
132  00014$:
133         pop     acc
134         push    ar0
135         mov     r0,dpl
136         xch     a,_ap
137         movx    @r0,a
138         inc     r0
139         xch     a,_ap
140         movx    @r0, a
141  00015$:        
142         inc     dptr
143         pop     ar0
144  00016$:        
145     _endasm;
146 }
147
148 #endif