1 /*-------------------------------------------------------------------------
3 _gptrget.c :- get value for a generic pointer
5 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
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
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.
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.
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 -------------------------------------------------------------------------*/
26 /* not all devices use P2 to page pdata memory, therefore __XPAGE was
27 introduced. On some targets __XPAGE itself is a paged SFR so it is
28 not safe for all platforms to set this. Furthermore some targets
29 can be configured to behave differently for movx @dptr vs. movx @Ri
30 (don't drive high byte of address bus for movx @Ri only) */
31 #define USE_PDATA_PAGING_REGISTER 0
33 /* the return value is expected to be in acc, and not in the standard
34 * location dpl. Therefore we choose return type void here: */
36 _gptrget (char *gptr) _naked
38 gptr; /* hush the compiler */
44 ; depending on the pointer type acc. to SDCCsymt.h
54 dec a ; 4 skip generic pointer
58 ; any other value for type
63 ; Pointer to data space
68 mov r0,dpl ; use only low order address
75 ; pointer to xternal data
81 ; pointer to code area
88 ; pointer to xternal stack or pdata
91 #if USE_PDATA_PAGING_REGISTER
92 mov dph,__XPAGE ; __XPAGE (usually p2) holds high byte for pdata access
105 /* the return value is expected to be in acc/_ap, and not in the standard
106 * location dpl/dph. Therefore we choose return type void here: */
108 _gptrgetWord (unsigned *gptr)
110 gptr; /* hush the compiler */
114 ; depending on the pointer type acc. to SDCCsymt.h
124 dec a ; 4 skip generic pointer
128 ; any other value for type
133 ; Pointer to data space
137 mov r0,dpl ; use only low order address
144 ; pointer to xternal data
153 ; pointer to code area
164 ; pointer to xternal stack