- 00002$:
- movx a,@dptr
- ret
-;
-; pointer to code area
-;
- 00003$:
- ; clr a is already 0
- movc a,@a+dptr
- ret
-;
-; pointer to xternal stack or pdata
-;
- 00004$:
-#if USE_PDATA_PAGING_REGISTER
- mov dph,__XPAGE ; __XPAGE (usually p2) holds high byte for pdata access
- movx a,@dptr
+ xdataptr$:
+ ; implementation for xram a16-a21 tied to P3
+ mov _P3,b ; 3
+
+ movx a,@dptr ; 1
+ ret ; 1
+ ;===
+ ;44 bytes
+ __endasm;
+}
+
+#elif defined DSDCC_MODEL_MEDIUM
+
+void
+_gptrget (char *gptr) __naked
+{
+/* This is the non-banked version with pointers up to 15 bits.
+ Assumes B is free to be used */
+
+ gptr; /* hush the compiler */
+
+ __asm
+ ;
+ ; depending on the pointer type acc. to SDCCsymt.h
+ ;
+ mov b,dph ; 3
+ jb _B_7,codeptr$ ; >0x80 code ; 3
+ jnb _B_6,xdataptr$ ; <0x40 far ; 3
+
+ mov b,r0 ; save r0 independant of regbank ; 2
+ mov r0,dpl ; use only low order address ; 2
+
+ jb _B_5,pdataptr$ ; >0x60 pdata ; 3
+ ;
+ ; Pointer to data space
+ ;
+ mov a,@r0 ; 1
+ mov r0,b ; restore r0 ; 2
+ ret ; 1
+ ;
+ ; pointer to xternal stack or pdata
+ ;
+ pdataptr$:
+ movx a,@r0 ; 1
+ mov r0,b ; restore r0 ; 2
+ ret ; 1
+ ;
+ ; pointer to code area, max 15 bits
+ ;
+ codeptr$:
+ ; 0x8000 <= dptr <= 0xFFFF
+ ; no need to AND dph and restore from B if hardware wraps code memory
+ anl dph,#0x7F ; 3
+ clr a ; 1
+ movc a,@a+dptr ; 1
+ mov dph,b ; 3
+ ret ; 1
+ ;
+ ; pointer to xternal data, max 14 bits
+ ;
+ xdataptr$:
+ ; 0 <= dptr <= 0x3FFF
+ movx a,@dptr ; 1
+ ret ; 1
+ ;===
+ ;35 bytes
+ __endasm;
+}
+