Minor ds390 performance enhancement on generic pointer reads
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 4 Feb 2003 05:52:45 +0000 (05:52 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 4 Feb 2003 05:52:45 +0000 (05:52 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2214 4a8a32a2-be11-0410-ad9d-d568d2c75423

device/lib/_gptrget.c
src/ds390/gen.c

index 7eaca491f6e23c3a38c62a82276c3266f13703fa..ca8bc1bdb81758b1ce042c71de8ad56a1e412ed7 100644 (file)
@@ -84,3 +84,79 @@ unsigned char _gptrget ()
      _endasm ;
 
 }
+
+#ifdef SDCC_ds390
+unsigned int _gptrgetWord ()
+{
+    _asm
+    ;
+    ;   depending on the pointer type acc. to SDCCsymt.h
+    ;
+        mov     a,b
+        jz      00001$ ; 0 near
+       dec     a
+       jz      00002$  ; 1 far
+        dec     a
+        jz      00003$ ; 2 code
+       dec     a
+       jz      00004$
+       dec     a       ; 4 skip generic pointer
+       dec     a
+       jz      00001$  ; 5 idata
+    ;
+    ;   any other value for type
+    ;   return xFF
+       mov     a,#0xff
+       sjmp    00006$
+    ;
+    ;   Pointer to data space
+    ;
+ 00001$:
+        push   ar0
+       mov     r0,dpl     ; use only low order address
+       mov     _ap,@r0
+       inc     r0
+       mov     a,@r0
+       inc     dpl
+        sjmp    00005$
+    ;
+    ;   pointer to xternal data
+    ;
+ 00002$:
+        movx    a,@dptr
+       mov     _ap,a
+       inc     dptr
+       movx    a,@dptr
+        sjmp    00006$
+;
+;   pointer to code area
+;
+ 00003$:
+       ; clr     a  is already 0
+        movc    a,@a+dptr
+       mov     _ap,a
+       clr     a
+       inc     dptr
+       movc    a,@a+dptr
+        sjmp    00006$
+;
+;   pointer to xternal stack
+;
+ 00004$:
+       push    ar0
+       mov     r0,dpl
+        movx    a,@r0
+       mov     _ap,a
+       inc     r0
+       movx    a,@r0
+       inc     dpl
+;
+;   restore and return
+;
+00005$:
+    pop ar0
+00006$:        
+     _endasm ;
+
+}
+#endif
index ecf14b949e292db5ae3efc28e73d1703de44495d..e87d5855ccf18034aac3d953728d615003680457 100644 (file)
@@ -9510,29 +9510,32 @@ genGenPointerGet (operand * left,
 
   /* if bit then unpack */
   if (IS_BITVAR (retype) || IS_BITVAR (letype))
+  {
     genUnpackBits (result, "dptr", GPOINTER);
+  }
   else
     {
-      size = AOP_SIZE (result);
-      offset = 0;
+       size = AOP_SIZE (result);
+       offset = 0;
 
-      while (size--)
+       while (size--)
        {
-// Whoops; uncooked experimental code which was accidentally committed.
-// Kevin should either finish cooking this or yank it soon.
-#if 0
            if (size)
            {
-               emitcode("push", "b");
+               // Get two bytes at a time, results in _AP & A.
+               // dptr will be incremented ONCE by __gptrgetWord.
+               //
+               // Note: any change here must be coordinated
+               // with the implementation of __gptrgetWord
+               // in device/lib/_gptrget.c
                emitcode ("lcall", "__gptrgetWord");
-               aopPut (AOP (result), "b", offset++);
+               aopPut (AOP (result), DP2_RESULT_REG, offset++);
                aopPut (AOP (result), "a", offset++);
-               emitcode("pop", "b");
                size--;
            }
            else
-#endif         
            {
+               // Only one byte to get.
                emitcode ("lcall", "__gptrget");
                aopPut (AOP (result), "a", offset++);
            }