1 /*-------------------------------------------------------------------------
3 _gptrget.c :- get value for a generic pointer (used with --xram-movc)
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 -------------------------------------------------------------------------*/
27 /* the return value is expected to be in acc, and not in the standard
28 * location dpl. Therefore we choose return type void here: */
33 _gptrgetc (char *gptr) _naked
35 /* This is the new version with pointers up to 16 bits.
36 B cannot be trashed */
38 gptr; /* hush the compiler */
43 ; depending on the pointer type acc. to SDCCsymt.h
45 jb _B_7,codeptr$ ; >0x80 code ; 3
46 jnb _B_6,xdataptr$ ; <0x40 far ; 3
48 mov dph,r0 ; save r0 independant of regbank ; 2
49 mov r0,dpl ; use only low order address ; 2
51 jb _B_5,pdataptr$ ; >0x60 pdata ; 3
53 ; Pointer to data space
56 mov r0,dph ; restore r0 ; 2
57 mov dph,#0 ; restore dph ; 2
60 ; pointer to external stack or pdata
64 mov r0,dph ; restore r0 ; 2
65 mov dph,#0 ; restore dph ; 2
68 ; pointer to xternal data
69 ; pointer to code area
84 _gptrgetc (char *gptr) _naked
86 gptr; /* hush the compiler */
93 ; depending on the pointer type acc. to SDCCsymt.h
103 dec a ; 4 skip generic pointer
107 ; any other value for type
112 ; Pointer to data space
115 mov r0,dpl ; use only low order address
119 ; pointer to xternal data
120 ; pointer to code area
127 ; pointer to xternal stack