From: kvigor Date: Tue, 26 Sep 2000 20:19:22 +0000 (+0000) Subject: Use only 3 bytes of generic pointers in comparisons X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=680458769f687a4d08223d76340f2d0c3b2f0886;p=fw%2Fsdcc Use only 3 bytes of generic pointers in comparisons git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@407 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 527200a4..0f44e8d8 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -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 && diff --git a/src/ds390/peeph.def b/src/ds390/peeph.def index b089c32a..4af9bbf4 100644 --- a/src/ds390/peeph.def +++ b/src/ds390/peeph.def @@ -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