* device/lib/_gptrput.c,
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 7 May 2007 16:32:16 +0000 (16:32 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 7 May 2007 16:32:16 +0000 (16:32 +0000)
* device/lib/_gptrget.c: removed old code,
 (_gptrgetWord),
* src/ds390/gen.c (genGenPointerGet): fixed bug 1714204
* support/regression/tests/bug1714204.c: new, added

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4793 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
device/lib/_gptrget.c
device/lib/_gptrput.c
src/ds390/gen.c
support/regression/tests/bug1714204.c [new file with mode: 0644]

index 9c7ede7d8d94eeacf6209210fe2a8021d8b0f55c..291934cad4da9c90d97e6bde35d53208a54509b6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-05-07 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * device/lib/_gptrput.c,
+       * device/lib/_gptrget.c: removed old code,
+        (_gptrgetWord),
+       * src/ds390/gen.c (genGenPointerGet): fixed bug 1714204
+       * support/regression/tests/bug1714204.c: new, added
+
 2007-05-06 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
 
        * support/regression/tests/regtrack.c: test was never executed
index d7711e4319caa5e46e37cf78c3edb3aad1137846..a3e4ee13e391963a0507d8aa8050eac3077132a5 100644 (file)
@@ -158,7 +158,7 @@ _gptrget (char *gptr) __naked
      __endasm;
 }
 
-#elif 1
+#else
 
 void
 _gptrget (char *gptr) __naked
@@ -211,90 +211,15 @@ _gptrget (char *gptr) __naked
      __endasm;
 }
 
-#else
-
-void
-_gptrget (char *gptr) __naked
-{
-/* This is the old version with pointers up to 16 bits. */
-
-    gptr; /* hush the compiler */
-
-    __asm
-    ;
-    ;   depending on the pointer type acc. to SDCCsymt.h
-    ;
-        mov     a,b                                     ; 2
-        jz      00001$  ; 0 near                        ; 2
-        dec     a                                       ; 1
-        jz      00002$  ; 1 far                         ; 2
-        dec     a                                       ; 1
-        jz      00003$  ; 2 code                        ; 2
-        dec     a                                       ; 1
-        jz      00004$  ; 3 pdata                       ; 2
-        dec     a       ; 4 skip generic pointer        ; 1
-        dec     a                                       ; 1
-        jz      00001$  ; 5 idata                       ; 2
-    ;
-    ;   any other value for type
-    ;   return xFF
-        mov     a,#0xff                                 ; 2
-        ret                                             ; 1
-    ;
-    ;   Pointer to data space
-    ;
- 00001$:
-        push    ar0                                     ; 2
-        ;
-        mov     r0,dpl     ; use only low order address ; 2
-        mov     a,@r0                                   ; 1
-        ;
-        pop     ar0                                     ; 2
-        ;
-        ret                                             ; 1
-    ;
-    ;   pointer to xternal data
-    ;
- 00002$:
-        movx    a,@dptr                                 ; 1
-        ret                                             ; 1
-;
-;   pointer to code area
-;
- 00003$:
-        ; clr     a  is already 0
-        movc    a,@a+dptr                               ; 1
-        ret                                             ; 1
-;
-;   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
-#else
-        push    ar0                                     ; 2
-        mov     r0,dpl                                  ; 2
-        movx    a,@r0                                   ; 1
-        pop     ar0                                     ; 2
-#endif
-        ret                                             ; 1
-                                                        ;===
-                                                        ;40 bytes
-     __endasm;
-}
 #endif
 
 #ifdef SDCC_ds390
 /* 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: */
 
-#if 1
-
 void
 _gptrgetWord (unsigned *gptr)
 {
-/* This is the new version */
     gptr; /* hush the compiler */
 
     __asm
@@ -352,88 +277,9 @@ _gptrgetWord (unsigned *gptr)
         mov     r0,dph ; restore r0
         mov     dph,#0 ; restore dph
  00006$:
+        xch     a,_ap
     __endasm;
 
 }
 
-#else
-
-void
-_gptrgetWord (unsigned *gptr)
-{
-    gptr; /* hush the compiler */
-
-    __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$  ; 3 pdata
-        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
-
 #endif
index eced890cf43b08d5b13b03825386324827e845c9..61123537d40c3b1c9ce7abf6f8341d5673aac0b1 100644 (file)
@@ -133,7 +133,7 @@ _gptrput (char *gptr, char c) __naked
     __endasm;
 }
 
-#elif 1
+#else
 
 void
 _gptrput (char *gptr, char c) __naked
@@ -182,75 +182,10 @@ _gptrput (char *gptr, char c) __naked
     __endasm;
 }
 
-#else
-
-void
-_gptrput (char *gptr, char c) __naked
-{
-/* This is the old version with pointers up to 16 bits. */
-
-    gptr; c; /* hush the compiler */
-
-    __asm
-        ar0 = 0x00
-        push     acc                                    ; 2
-    ;
-    ;   depending on the pointer type acc. to SDCCsymt.h
-    ;
-        mov     a,b                                     ; 2
-        jz      00001$  ; 0 near                        ; 2
-        dec     a                                       ; 1
-        jz      00002$  ; 1 far                         ; 2
-        dec     a                                       ; 1
-        jz      00003$  ; 2 code                        ; 2
-        dec     a                                       ; 1
-        jz      00004$  ; 3 pdata                       ; 2
-        dec     a       ; 4 skip generic pointer        ; 1
-        dec     a                                       ; 1
-        jz      00001$  ; 5 idata                       ; 2
-
- 00003$:
-        pop     acc    ; do nothing                     ; 2
-        ret                                             ; 1
-;
-;       store into near space
-;
- 00001$:
-        pop     acc                                     ; 2
-        push    ar0                                     ; 2
-        mov     r0,dpl                                  ; 2
-        mov     @r0,a                                   ; 1
-        pop     ar0                                     ; 2
-        ret                                             ; 1
-
- 00002$:
-        pop     acc                                     ; 2
-        movx    @dptr,a                                 ; 1
-        ret                                             ; 1
-
- 00004$:
-#if USE_PDATA_PAGING_REGISTER
-        pop     acc
-        mov     dph,__XPAGE     ; __XPAGE (usually p2) holds high byte for pdata access
-        movx    @dptr,a
-#else
-        pop     acc                                     ; 2
-        push    ar0                                     ; 2
-        mov     r0,dpl                                  ; 2
-        movx    @r0,a                                   ; 1
-        pop     ar0                                     ; 2
-#endif
-        ret                                             ; 1
-                                                        ;===
-                                                        ;46 bytes
-    __endasm;
-}
 #endif
 
 #ifdef SDCC_ds390
 
-#if 1
-
 void
 _gptrputWord ()
 {
@@ -305,68 +240,4 @@ _gptrputWord ()
     __endasm;
 }
 
-#else
-
-void
-_gptrputWord ()
-{
-    __asm
-        push     acc
-    ;
-    ;   depending on the pointer type acc. to SDCCsymt.h
-    ;
-        mov     a,b
-        jz      00011$  ; 0 near
-        dec     a
-        jz      00012$  ; 1 far
-        dec     a
-        jz      00013$  ; 2 code
-        dec     a
-        jz      00014$  ; 3 pdata
-        dec     a       ; 4 skip generic pointer
-        dec     a
-        jz      00011$  ; 5 idata
-        pop     acc
-        sjmp    00016$
-;
-;       store into near space
-;
- 00011$:
-        pop     acc
-        push    ar0
-        mov     r0,dpl
-        mov     @r0,_ap
-        inc     r0
-        mov     @r0,a
-        sjmp    00015$
-
- 00012$:
-        mov     a, _ap
-        movx    @dptr,a
-        inc     dptr
-        pop     acc
-        movx    @dptr,a
-        sjmp    00016$
-
- 00013$:
-        pop     acc    ; do nothing
-        sjmp    00016$
-
- 00014$:
-        pop     acc
-        push    ar0
-        mov     r0,dpl
-        xch     a,_ap
-        movx    @r0,a
-        inc     r0
-        xch     a,_ap
-        movx    @r0, a
- 00015$:
-        inc     dptr
-        pop     ar0
- 00016$:
-    __endasm;
-}
-#endif
-
 #endif
index 3e1f045c6b281c484938575cbbaf465ddb0649ca..bbc1f5d681d9d459328b5f281050a833af3dbdd3 100644 (file)
@@ -9867,7 +9867,7 @@ genrshFour (operand * result, operand * left,
       _startLazyDPSEvaluation();
       if (shCount == 1)
         {
-            shiftRLong (left, MSB16, result, sign);
+          shiftRLong (left, MSB16, result, sign);
         }
       else if (shCount == 0)
         {
@@ -10997,8 +10997,8 @@ genGenPointerGet (operand * left,
                 // with the implementation of __gptrgetWord
                 // in device/lib/_gptrget.c
                 emitcode ("lcall", "__gptrgetWord");
-                aopPut (result, DP2_RESULT_REG, offset++);
                 aopPut (result, "a", offset++);
+                aopPut (result, DP2_RESULT_REG, offset++);
                 size--;
             }
             else
diff --git a/support/regression/tests/bug1714204.c b/support/regression/tests/bug1714204.c
new file mode 100644 (file)
index 0000000..8f8fed7
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+       bug 1714204
+*/
+
+#include <testfwk.h>
+
+typedef struct {
+       unsigned int w[2];
+} TEST_TYPE;
+
+unsigned char i1, i2, i3;
+
+void test(TEST_TYPE *p1, TEST_TYPE *p2, TEST_TYPE *p3)
+{
+       if (p2->w[i2] > ++p3->w[i3])
+               p1->w[i1] = p2->w[i2] + p3->w[i3];
+}
+
+void
+testBug(void)
+{
+       TEST_TYPE t1 = { { 1, 1 } };
+       TEST_TYPE t2 = { { 1, 1 } };
+       TEST_TYPE t3 = { { 1, 1 } };
+
+       i1 = i2 = i3 = 0;
+
+       test(&t1, &t2, &t3);
+
+       ASSERT (t1.w[0] == 1);
+}