1 /*-------------------------------------------------------------------------
2 _gptrgetc.c - get value for a generic pointer (used with --xram-movc)
4 Copyright (c) 1999, Sandeep Dutta . sandeep.dutta@usa.net
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this library; see the file COPYING. If not, write to the
18 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 As a special exception, if you link this library with other files,
22 some of which are compiled with SDCC, to produce an executable,
23 this library does not by itself cause the resulting executable to
24 be covered by the GNU General Public License. This exception does
25 not however invalidate any other reasons why the executable file
26 might be covered by the GNU General Public License.
27 -------------------------------------------------------------------------*/
30 /* the return value is expected to be in acc, and not in the standard
31 * location dpl. Therefore we choose return type void here: */
36 _gptrgetc (char *gptr
) __naked
38 /* This is the new version with pointers up to 16 bits.
39 B cannot be trashed */
41 gptr
; /* hush the compiler */
46 ; depending on the pointer type acc
. to SDCCsymt
.h
48 jb _B_7
,codeptr$
; >0x80 code
; 3
49 jnb _B_6
,xdataptr$
; <0x40 far
; 3
51 mov dph
,r0
; save r0 independent of regbank
; 2
52 mov r0
,dpl
; use only low order address
; 2
54 jb _B_5
,pdataptr$
; >0x60 pdata
; 3
56 ; Pointer to data space
59 mov r0
,dph
; restore r0
; 2
60 mov dph
,#0 ; restore dph ; 2
63 ; pointer to external stack
or pdata
67 mov r0
,dph
; restore r0
; 2
68 mov dph
,#0 ; restore dph ; 2
71 ; pointer to xternal data
72 ; pointer to code area
87 _gptrgetc (char *gptr
) __naked
89 gptr
; /* hush the compiler */
96 ; depending on the pointer type acc
. to SDCCsymt
.h
106 dec a
; 4 skip generic pointer
110 ; any other value
for type
115 ; Pointer to data space
118 mov r0
,dpl
; use only low order address
122 ; pointer to xternal data
123 ; pointer to code area
130 ; pointer to xternal stack