From d0d1319aba1a3ae007786c03c49f0ca82b480365 Mon Sep 17 00:00:00 2001 From: spth Date: Fri, 3 Apr 2009 15:40:24 +0000 Subject: [PATCH] Fixed bugs #2728224, #2728218 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5424 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 9 +++++++++ src/z80/gen.c | 15 +++++++-------- src/z80/peeph-z80.def | 21 +++++++++++---------- support/regression/tests/memory.c | 4 ++++ 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94693ba9..4b529afb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-04-03 Philipp Klaus Krause + + * src/z80/gen.c: + Fixed bugs #2728224, #2728218. + src/z80/peeph-z80.def: + Workaround for bug #2728445. + support/regression/tests/memory.c: + Added test for memcmp(). + 2009-04-03 Philipp Klaus Krause * device/lib/z80/mul.s, diff --git a/src/z80/gen.c b/src/z80/gen.c index a6e3a247..fc94f60c 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -1543,10 +1543,10 @@ fetchPairLong (PAIR_ID pairId, asmop * aop, iCode *ic, int offset) } else { - /* Swapping register contents within register pair */ - if(!strcmp(aopGet (aop, offset, FALSE), _pairs[pairId].h)) + /* Operand resides (partially) in the pair */ + if(!strcmp(aopGet (aop, offset + 1, FALSE), _pairs[pairId].l)) { - emit2 ("ld a,%s",aopGet (aop, offset + 1, FALSE)); + emit2 ("ld a,%s", aopGet (aop, offset + 1, FALSE)); emit2 ("ld %s,%s", _pairs[pairId].l, aopGet (aop, offset, FALSE)); emit2 ("ld %s,a", _pairs[pairId].h); } @@ -5016,7 +5016,7 @@ gencjneshort (operand * left, operand * right, symbol * lbl) } else { - emit2 ("sub %s", aopGet (AOP (right), offset, FALSE)); + emit2 ("sub a,%s", aopGet (AOP (right), offset, FALSE)); emit2 ("jp NZ,!tlabel", lbl->key + 100); } offset++; @@ -5040,7 +5040,7 @@ gencjneshort (operand * left, operand * right, symbol * lbl) emit2 ("; direct compare"); _emitMove (_pairs[pair].l, aopGet (AOP (left), offset, FALSE)); _moveA (aopGet (AOP (right), offset, FALSE)); - emit2 ("sub %s", _pairs[pair].l); + emit2 ("sub a,%s", _pairs[pair].l); emit2 ("!shortjp NZ,!tlabel", lbl->key + 100); offset++; } @@ -6752,10 +6752,9 @@ genUnpackBits (operand * result, int pair) { /* signed bitfield */ symbol *tlbl = newiTempLabel (NULL); - - emit2 ("bit %d,a", blen - 1); + emit2 ("bit %d,a", blen - 1 - 8); emit2 ("jp Z,!tlabel", tlbl->key + 100); - emit2 ("or a,!immedbyte", (unsigned char) (0xff << blen)); + emit2 ("or a,!immedbyte", (unsigned char) (0xff << (blen - 8))); emitLabel (tlbl->key + 100); } emit2 ("ld h,a"); diff --git a/src/z80/peeph-z80.def b/src/z80/peeph-z80.def index 6d43c9b2..cf5a83d4 100644 --- a/src/z80/peeph-z80.def +++ b/src/z80/peeph-z80.def @@ -259,16 +259,17 @@ replace restart { ld b, %2 (%3) } if notVolatile(%1), notUsed(%1) -replace restart { - ld %1,a - ld %2,%3 - ld %4,%1 -} by { - ; peephole 0t loaded %4 from a instead of going through %1. - ld %1,a - ld %2,%3 - ld %4,a -} if notVolatile(%1), operandsNotRelated(%1 %3), operandsNotRelated(%1 %2) +// Bug #2728445 +//replace restart { +// ld %1,a +// ld %2,%3 +// ld %4,%1 +//} by { +// ; peephole 0t loaded %4 from a instead of going through %1. +// ld %1,a +// ld %2,%3 +// ld %4,a +//} if notVolatile(%1), operandsNotRelated(%1 %3), operandsNotRelated(%1 %2) replace restart { ld %1,a diff --git a/support/regression/tests/memory.c b/support/regression/tests/memory.c index 911900b9..77014fd3 100644 --- a/support/regression/tests/memory.c +++ b/support/regression/tests/memory.c @@ -22,6 +22,10 @@ void testmemory(void) ASSERT(destination[2] == source[2]); ASSERT(destination[3] == 23); + /* Test memcmp() */ + memcpy(destination, source, 4); + ASSERT(memcmp(destination, source, 4) == 0); + /* Test memmove() */ memcpy(destination, source, 4); memmove(destination, destination + 1, 3); -- 2.30.2