Use only 3 bytes of generic pointers in comparisons
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 26 Sep 2000 20:19:22 +0000 (20:19 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 26 Sep 2000 20:19:22 +0000 (20:19 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@407 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/ds390/gen.c
src/ds390/peeph.def

index 527200a4bd3693baa95b40a9ac37a5e7248bd540..0f44e8d83cb7c04b579fc6b0911de0289a7801a2 100644 (file)
@@ -1307,6 +1307,17 @@ static void toBoolean(operand *oper)
     int size = AOP_SIZE(oper) - 1;
     int offset = 1;
 
+    /* The generic part of a generic pointer should
+     * not participate in it's truth value.
+     *
+     * i.e. 0x10000000 is zero.
+     */
+    if (opIsGptr(oper))
+    {
+       D(emitcode(";", "toBoolean: generic ptr special case."););
+               size--;
+    }
+
     if (AOP_NEEDSACC(oper))
     {
         emitcode("push", "b");
@@ -3919,8 +3930,19 @@ static void gencjneshort(operand *left, operand *right, symbol *lbl)
         right = left;
         left = t;
     }
+    
     if(AOP_TYPE(right) == AOP_LIT)
         lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
+        
+    if (opIsGptr(left) || opIsGptr(right))
+    {
+        /* We are comparing a generic pointer to something.
+         * Exclude the generic type byte from the comparison.
+         */
+        size--;
+        D(emitcode(";", "cjneshort: generic ptr special case.");) 
+    }
+         
 
     /* if the right side is a literal then anything goes */
     if (AOP_TYPE(right) == AOP_LIT &&
index b089c32a901a31fa4cf78a21f8f94b44c3fb2170..4af9bbf4020062c5c75fd943fb6249be8d388582 100644 (file)
@@ -1062,11 +1062,11 @@ replace {
 // saves 2 bytes, ?? cycles.
 replace {
         mov  dpl,#%1
-        mov  dph,#(%1 >> 8)
-       mov  dpx,#(%1 >> 16)
+        mov  dph,#%2
+       mov  dpx,#%3
 } by {
         ; Peephole 182a   used 24 bit load of dptr
-        mov  dptr,#%1
+        mov  dptr,#((%3 << 16) + (%2 << 8) + %1)
 } if 24bitMode
 
 // saving 3 byte, 2 cycles, return(float_constant) profits here