what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-unsigned char _gptrget ()
+#define P2_PAGES_PDATA 0 /* not all devices use P2 to page pdata memory */
+
+/* the return value is expected to be in acc, and not in the standard
+ * location dpl. Therefore we choose return type void here: */
+void
+_gptrget (char *gptr)
{
+ gptr; /* hush the compiler */
+
_asm
; save values passed
- xch a,r0
- push acc
;
; depending on the pointer type acc. to SDCCsymt.h
;
dec a
jz 00003$ ; 2 code
dec a
- jz 00004$
+ jz 00004$ ; 3 pdata
dec a ; 4 skip generic pointer
dec a
jz 00001$ ; 5 idata
; Pointer to data space
;
00001$:
+ push ar0
+ ;
mov r0,dpl ; use only low order address
mov a,@r0
+ ;
+ pop ar0
+ ;
sjmp 00005$
;
; pointer to xternal data
movc a,@a+dptr
sjmp 00005$
;
-; pointer to xternal stack
+; pointer to xternal stack or pdata
;
00004$:
+#if P2_PAGES_PDATA
+ mov dph,p2 ; p2 holds high byte for pdata access
+ movx a,@dptr
+#else
+ push ar0
mov r0,dpl
movx a,@r0
+ pop ar0
+#endif
+
;
-; restore and return
+; return
;
00005$:
- mov r0,a
- pop acc
- xch a,r0
_endasm ;
-
}
#ifdef SDCC_ds390
-unsigned int _gptrgetWord ()
+/* the return value is expected to be in acc/_ap, and not in the standard
+ * location dpl/dph. Therefore we choose return type void here: */
+void
+_gptrgetWord (unsigned *gptr)
{
+ gptr; /* hush the compiler */
+
_asm
;
; depending on the pointer type acc. to SDCCsymt.h
dec a
jz 00003$ ; 2 code
dec a
- jz 00004$
+ jz 00004$ ; 3 pdata
dec a ; 4 skip generic pointer
dec a
jz 00001$ ; 5 idata