* device/lib/Makefile.in (Z80SOURCES): enabled float support
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 6 Aug 2006 18:26:33 +0000 (18:26 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 6 Aug 2006 18:26:33 +0000 (18:26 +0000)
* sim/ucsim/z80.src/inst.cc (inst_rst): generate breakpoint on RST8,ACC==0
* src/ds390/gen.c (shiftRLong),
* src/hc08/gen.c (shiftLLong, shiftRLong): fixed bug 1533966
* src/mcs51/gen.c (sameReg): changed to sameByte,
  (xch_a_aopGet): new,
  (shiftL2Left2Result, shiftR2Left2Result, shiftRLeftOrResult,
   shiftLLong, shiftRLong): fixed bug 1533966
* src/z80/gen.c (shiftR2Left2Result, shiftL2Left2Result, genlshTwo,
  genLeftShiftLiteral, genrshTwo, genRightShiftLiteral): fixed bug 1533966
* support/regression/Makefile.in: disabled z80, enabled ucz80
* support/regression/tests/float_trans.c: enabled test for z80 and host
* support/regression/tests/shifts2.c: new, for testing bug 1533966

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

ChangeLog
device/lib/Makefile.in
sim/ucsim/z80.src/inst.cc
src/ds390/gen.c
src/hc08/gen.c
src/mcs51/gen.c
src/z80/gen.c
support/regression/Makefile.in
support/regression/tests/float_trans.c
support/regression/tests/shifts2.c [new file with mode: 0644]

index a367e2b980d85d0e449e36b18ad9d41465def1d9..55798d6259146dbb1d6558fef1f7ad095a804d7d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2006-08-06 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * device/lib/Makefile.in (Z80SOURCES): enabled float support
+       * sim/ucsim/z80.src/inst.cc (inst_rst): generate breakpoint on RST8,ACC==0
+       * src/ds390/gen.c (shiftRLong),
+       * src/hc08/gen.c (shiftLLong, shiftRLong): fixed bug 1533966
+       * src/mcs51/gen.c (sameReg): changed to sameByte,
+         (xch_a_aopGet): new,
+         (shiftL2Left2Result, shiftR2Left2Result, shiftRLeftOrResult, shiftLLong,
+          shiftRLong): fixed bug 1533966
+       * src/z80/gen.c (shiftR2Left2Result, shiftL2Left2Result, genlshTwo,
+         genLeftShiftLiteral, genrshTwo, genRightShiftLiteral): fixed bug 1533966
+       * support/regression/Makefile.in: disabled z80, enabled ucz80
+       * support/regression/tests/float_trans.c: enabled test for z80 and host
+       * support/regression/tests/shifts2.c: new, for testing bug 1533966
+
 2006-08-01 Borut Razem <borut.razem AT siol.net>
 
        * src/mcs51/gen.c, src/dc390/gen.c: fixed warning:
index b3aa8b28519ee7ff85ab5aa703e70680a089004e..50522964a0d9117016e93c22a9b28c03bc6b16fd 100644 (file)
@@ -66,65 +66,71 @@ OPT_DISABLE_PIC16 = @OPT_DISABLE_PIC16@
 OPT_DISABLE_XA51  = @OPT_DISABLE_XA51@
 OPT_DISABLE_Z80   = @OPT_DISABLE_Z80@
 
-SOURCES                = _atof.c _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \
-                 _decdptr.c _divsint.c _divslong.c _divuint.c \
-                 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
-                 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
-                 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fscmp.c _fsmul.c \
-                 _fsneq.c _fssub.c _gptrget.c _gptrgetc.c _gptrput.c \
-                 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
-                 _islower.c _isprint.c _ispunct.c _isspace.c \
-                 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
-                 _slong2fs.c \
-                 _memcmp.c _memcpy.c _memmove.c _memset.c \
-                 _modsint.c _modslong.c _moduint.c _modulong.c \
-                 _mulint.c _mullong.c \
-                 abs.c labs.c \
-                 _ser.c _setjmp.c \
-                 _spx.c _startup.c \
-                 _strcat.c _strchr.c _strcmp.c _strcpy.c \
-                 _strcspn.c _strlen.c _strncat.c _strncmp.c \
-                 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
-                 _strstr.c _strtok.c \
-                 _uchar2fs.c _uint2fs.c _ulong2fs.c \
-                 calloc.c malloc.c realloc.c free.c \
-                 serial.c ser_ir.c printfl.c \
-                 printf_large.c sprintf.c vprintf.c puts.c gets.c \
-                 printf_fast.c printf_fast_f.c printf_tiny.c \
-                 assert.c time.c bpx.c \
-                 _fsget1arg.c _fsget2args.c _fsnormalize.c \
-                 _fsreturnval.c _fsrshift.c _fsswapargs.c _logexpf.c \
-                 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
-                 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
-                 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
-                 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
+SOURCES =      _autobaud.c _bp.c _decdptr.c \
+               _gptrget.c _gptrgetc.c _gptrput.c \
+               _ser.c _setjmp.c \
+               serial.c ser_ir.c \
+               _atof.c _atoi.c _atol.c _itoa.c _ltoa.c \
+               _schar2fs.c _sint2fs.c _slong2fs.c \
+               _uchar2fs.c _uint2fs.c _ulong2fs.c \
+               _fs2schar.c _fs2sint.c _fs2slong.c \
+               _fs2uchar.c _fs2uint.c _fs2ulong.c \
+               _fsadd.c _fsdiv.c _fsmul.c _fssub.c \
+               _fseq.c _fsgt.c _fslt.c _fsneq.c \
+               _divsint.c _divslong.c _divuint.c _divulong.c \
+               _modsint.c _modslong.c _moduint.c _modulong.c \
+               _mulint.c _mullong.c \
+               abs.c labs.c \
+               _iscntrl.c _isdigit.c _isgraph.c \
+               _isprint.c _ispunct.c _isspace.c \
+               _islower.c _isupper.c _isxdigit.c \
+               _spx.c _startup.c \
+               _strcat.c _strchr.c _strcmp.c _strcpy.c \
+               _strcspn.c _strlen.c _strncat.c _strncmp.c \
+               _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
+               _strstr.c _strtok.c \
+               _memcmp.c _memcpy.c _memmove.c _memset.c \
+               calloc.c malloc.c realloc.c free.c \
+               printf_large.c sprintf.c vprintf.c puts.c gets.c \
+               printf_fast.c printf_fast_f.c printf_tiny.c printfl.c \
+               assert.c time.c bpx.c \
+               _fscmp.c _fsget1arg.c _fsget2args.c _fsnormalize.c \
+               _fsreturnval.c _fsrshift.c _fsswapargs.c _logexpf.c \
+               fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
+               cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
+               asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
+               sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
 
 OBJECTS                = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
 
-Z80SOURCES      = _atof.c _atoi.c \
-                 _iscntrl.c _isdigit.c _isgraph.c \
-                 _islower.c _isprint.c _ispunct.c _isspace.c \
-                 _isupper.c _isxdigit.c \
-                 _memcmp.c _memcpy.c _memmove.c _memset.c \
-                 _startup.c \
-                 _strcat.c _strchr.c _strcmp.c _strcpy.c \
-                 _strcspn.c _strlen.c _strncat.c _strncmp.c \
-                 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
-                 _strstr.c _strtok.c \
-                 assert.c \
-                 _modslong.c _modulong.c \
-                 _mullong.c \
-                 abs.c labs.c \
-                 _divslong.c _divulong.c \
-                 calloc.c malloc.c realloc.c free.c \
-                 printf_large.c sprintf.c vprintf.c puts.c gets.c \
-                 _fs2schar.c _fs2sint.c _fs2slong.c \
-                 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
-                 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
-                 _fsneq.c _fssub.c \
-                 _uchar2fs.c _uint2fs.c \
-                 _ulong2fs.c \
-                 _slong2fs.c _sint2fs.c _schar2fs.c
+Z80SOURCES =   \
+               _atof.c _atoi.c _atol.c _itoa.c _ltoa.c \
+               _schar2fs.c _sint2fs.c _slong2fs.c \
+               _uchar2fs.c _uint2fs.c _ulong2fs.c \
+               _fs2schar.c _fs2sint.c _fs2slong.c \
+               _fs2uchar.c _fs2uint.c _fs2ulong.c \
+               _fsadd.c _fsdiv.c _fsmul.c _fssub.c \
+               _fseq.c _fsgt.c _fslt.c _fsneq.c \
+               _divslong.c _divulong.c \
+               _modslong.c _modulong.c \
+               _mullong.c \
+               abs.c labs.c \
+               _iscntrl.c _isdigit.c _isgraph.c \
+               _isprint.c _ispunct.c _isspace.c \
+               _islower.c _isupper.c _isxdigit.c \
+               _startup.c \
+               _strcat.c _strchr.c _strcmp.c _strcpy.c \
+               _strcspn.c _strlen.c _strncat.c _strncmp.c \
+               _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
+               _strstr.c _strtok.c \
+               _memcmp.c _memcpy.c _memmove.c _memset.c \
+               calloc.c malloc.c realloc.c free.c \
+               printf_large.c sprintf.c vprintf.c puts.c gets.c \
+               assert.c time.c \
+               fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
+               cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
+               asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
+               sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
 
 Z80OBJECTS      = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
 
@@ -156,32 +162,33 @@ XA51SOURCES      = _atof.c _atoi.c _atol.c _schar2fs.c \
 
 XA51OBJECTS      = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
 
-HC08SOURCES    = _atof.c _atoi.c _atol.c _schar2fs.c \
-                 _divsint.c _divslong.c \
-                 _fs2schar.c _fs2sint.c _fs2slong.c \
-                 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
-                 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
-                 _fsneq.c _fssub.c \
-                 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
-                 _islower.c _isprint.c _ispunct.c _isspace.c \
-                 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
-                 _slong2fs.c \
-                 _memcmp.c _memcpy.c _memmove.c _memset.c \
-                 _modsint.c _modslong.c _moduint.c _modulong.c \
-                 abs.c labs.c \
-                 _spx.c _startup.c \
-                 _strcat.c _strchr.c _strcmp.c _strcpy.c \
-                 _strcspn.c _strlen.c _strncat.c _strncmp.c \
-                 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
-                 _strstr.c _strtok.c \
-                 _uchar2fs.c _uint2fs.c _ulong2fs.c \
-                 calloc.c malloc.c realloc.c free.c \
-                 printf_large.c sprintf.c vprintf.c \
-                 assert.c time.c \
-                 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
-                 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
-                 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
-                 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
+HC08SOURCES =  \
+               _atof.c _atoi.c _atol.c _itoa.c _ltoa.c \
+               _schar2fs.c _sint2fs.c _slong2fs.c \
+               _uchar2fs.c _uint2fs.c _ulong2fs.c \
+               _fs2schar.c _fs2sint.c _fs2slong.c \
+               _fs2uchar.c _fs2uint.c _fs2ulong.c \
+               _fsadd.c _fsdiv.c _fsmul.c _fssub.c \
+               _fseq.c _fsgt.c _fslt.c _fsneq.c \
+               _divsint.c _divslong.c \
+               _modsint.c _modslong.c _moduint.c _modulong.c \
+               abs.c labs.c \
+               _iscntrl.c _isdigit.c _isgraph.c \
+               _isprint.c _ispunct.c _isspace.c \
+               _islower.c _isupper.c _isxdigit.c \
+               _spx.c _startup.c \
+               _strcat.c _strchr.c _strcmp.c _strcpy.c \
+               _strcspn.c _strlen.c _strncat.c _strncmp.c \
+               _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
+               _strstr.c _strtok.c \
+               _memcmp.c _memcpy.c _memmove.c _memset.c \
+               calloc.c malloc.c realloc.c free.c \
+               printf_large.c sprintf.c vprintf.c puts.c gets.c \
+               assert.c time.c \
+               fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
+               cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
+               asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
+               sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
 
 HC08OBJECTS    = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
 
index 69be604f84efd359a724704005cd12bec74bad89..3cb181df2ff41744dfd0ea62bfbd32b82202dc3f 100644 (file)
@@ -955,7 +955,8 @@ cl_z80::inst_rst(t_mem code)
       //PC = 0x08;
       switch (regs.A) {
         case 0:
-          ::exit(0);
+          return(resBREAKPOINT);
+//          ::exit(0);
         break;
 
         case 1:
index 12fd021817d126fa3762c67664f822ae1c243fb4..337f3cff069fd0f122b33dc8f7a12c0bf8d0e7b9 100644 (file)
@@ -9626,12 +9626,13 @@ static void
 shiftRLong (operand * left, int offl,
             operand * result, int sign)
 {
-  int isSameRegs=sameRegs(AOP(left),AOP(result));
+  bool overlapping = regsInCommon (left, result) || operandsEqu(left, result);
 
-  if (isSameRegs && offl>1) {
-    // we are in big trouble, but this shouldn't happen
-    werror(E_INTERNAL_ERROR, __FILE__, __LINE__);
-  }
+  if (overlapping && offl>1)
+    {
+      // we are in big trouble, but this shouldn't happen
+      werror(E_INTERNAL_ERROR, __FILE__, __LINE__);
+    }
 
   MOVA (aopGet (left, MSB32, FALSE, FALSE, NULL));
 
@@ -9662,28 +9663,44 @@ shiftRLong (operand * left, int offl,
 
   emitcode ("rrc", "a");
 
-  if (isSameRegs && offl==MSB16) {
-    emitcode ("xch",
-              "a,%s",aopGet (left, MSB24, FALSE, FALSE, DP2_RESULT_REG));
-  } else {
-    aopPut (result, "a", MSB32);
-    MOVA (aopGet (left, MSB24, FALSE, FALSE, NULL));
-  }
+  if (overlapping && offl==MSB16)
+    {
+      emitcode ("xch", "a,%s", aopGet (left, MSB24, FALSE, FALSE, DP2_RESULT_REG));
+    }
+  else
+    {
+      aopPut (result, "a", MSB32 - offl);
+      MOVA (aopGet (left, MSB24, FALSE, FALSE, NULL));
+    }
 
   emitcode ("rrc", "a");
-  if (isSameRegs && offl==1) {
-    emitcode ("xch", "a,%s",
-              aopGet (left, MSB16, FALSE, FALSE, DP2_RESULT_REG));
-  } else {
-    aopPut (result, "a", MSB24);
-    MOVA (aopGet (left, MSB16, FALSE, FALSE, NULL));
-  }
-  emitcode ("rrc", "a");
-  aopPut (result, "a", MSB16 - offl);
 
-  if (offl == LSB)
+  if (overlapping && offl==MSB16)
+    {
+      emitcode ("xch", "a,%s", aopGet (left, MSB16, FALSE, FALSE, DP2_RESULT_REG));
+    }
+  else
+    {
+      aopPut (result, "a", MSB24 - offl);
+      MOVA (aopGet (left, MSB16, FALSE, FALSE, NULL));
+    }
+
+  emitcode ("rrc", "a");
+  if (offl != LSB)
+    {
+      aopPut (result, "a", MSB16 - offl);
+    }
+  else
     {
-      MOVA (aopGet (left, LSB, FALSE, FALSE, NULL));
+      if (overlapping && offl==MSB16)
+        {
+          emitcode ("xch", "a,%s", aopGet (left, LSB, FALSE, FALSE, DP2_RESULT_REG));
+        }
+      else
+        {
+          aopPut (result, "a", MSB16 - offl);
+          MOVA (aopGet (left, LSB, FALSE, FALSE, NULL));
+        }
       emitcode ("rrc", "a");
       aopPut (result, "a", LSB);
     }
index d1fdc98d073557aef1c5959f8de26a8d71aa5355..2897a99541cdfeaecc10c23c2eb0e211f37dce2e 100644 (file)
@@ -27,8 +27,8 @@
 
 -------------------------------------------------------------------------*/
 
-#define D(x)
-//#define D(x) x
+//#define D(x)
+#define D(x) x
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -6309,7 +6309,7 @@ genlshTwo (operand * result, operand * left, int shCount)
 
 /*-----------------------------------------------------------------*/
 /* shiftLLong - shift left one long from left to result            */
-/* offl = LSB or MSB16                                             */
+/* offr = LSB or MSB16                                             */
 /*-----------------------------------------------------------------*/
 static void
 shiftLLong (operand * left, operand * result, int offr)
@@ -6326,10 +6326,10 @@ shiftLLong (operand * left, operand * result, int offr)
   loadRegFromAop (hc08_reg_xa, AOP (left), LSB);
   rmwWithReg ("lsl", hc08_reg_a);
   rmwWithReg ("rol", hc08_reg_x);
-  storeRegToAop (hc08_reg_xa, AOP (result), offr);
 
   if (offr==LSB)
     {
+      storeRegToAop (hc08_reg_xa, AOP (result), offr);
       loadRegFromAop (hc08_reg_xa, AOP (left), MSB24);
       rmwWithReg ("rol", hc08_reg_a);
       rmwWithReg ("rol", hc08_reg_x);
@@ -6337,7 +6337,9 @@ shiftLLong (operand * left, operand * result, int offr)
     }
   else if (offr==MSB16)
     {
+      storeRegToAop (hc08_reg_a, AOP (result), offr);
       loadRegFromAop (hc08_reg_a, AOP (left), MSB24);
+      storeRegToAop (hc08_reg_x, AOP (result), offr+1);
       rmwWithReg ("rol", hc08_reg_a);
       storeRegToAop (hc08_reg_a, AOP (result), offr+2);
       storeConstToAop (zero, AOP (result), 0);
@@ -6658,6 +6660,7 @@ shiftRLong (operand * left, int offl,
         rmwWithReg ("lsr", hc08_reg_x);
       rmwWithReg ("ror", hc08_reg_a);
       storeRegToAop (hc08_reg_xa, AOP (result), MSB24);
+      loadRegFromAop (hc08_reg_xa, AOP (left), LSB);
     }
   else if (offl==MSB16)
     {
@@ -6666,15 +6669,27 @@ shiftRLong (operand * left, int offl,
         rmwWithReg ("asr", hc08_reg_a);
       else
         rmwWithReg ("lsr", hc08_reg_a);
+      loadRegFromAop (hc08_reg_x, AOP (left), MSB24);
       storeRegToAop (hc08_reg_a, AOP (result), MSB24);
-      storeRegSignToUpperAop (hc08_reg_a, AOP (result), MSB32, sign);
+      loadRegFromAop (hc08_reg_a, AOP (left), MSB16);
     }
 
-  loadRegFromAop (hc08_reg_xa, AOP (left), offl);
   rmwWithReg ("ror", hc08_reg_x);
   rmwWithReg ("ror", hc08_reg_a);
   storeRegToAop (hc08_reg_xa, AOP (result), LSB);
 
+  if (offl==MSB16)
+    {
+      if (sign)
+        {
+          loadRegFromAop (hc08_reg_a, AOP (left), MSB24);
+          storeRegSignToUpperAop (hc08_reg_a, AOP (result), MSB32, sign);
+        }
+      else
+        {
+          storeConstToAop (zero, AOP (result), MSB32);
+        }
+    }
 
   pullOrFreeReg (hc08_reg_x, needpulx);
   pullOrFreeReg (hc08_reg_a, needpula);
index f2b156b405c9fe6806eadba0b10e8cb20a0b8b6f..53b528eeff26b71aeff9d60aed34e687a9803a05 100644 (file)
@@ -849,11 +849,14 @@ operandsEqu (operand * op1, operand * op2)
 }
 
 /*-----------------------------------------------------------------*/
-/* sameReg - two asmops have the same register at given offsets    */
+/* sameByte - two asmops have the same address at given offsets    */
 /*-----------------------------------------------------------------*/
 static bool
-sameReg (asmop * aop1, int off1, asmop * aop2, int off2)
+sameByte (asmop * aop1, int off1, asmop * aop2, int off2)
 {
+  if (aop1 == aop2 && off1 == off2)
+    return TRUE;
+
   if (aop1->type != AOP_REG && aop1->type != AOP_CRY)
     return FALSE;
 
@@ -1874,6 +1877,32 @@ toBoolean (operand * oper)
 }
 
 
+/*-------------------------------------------------------------------*/
+/* xch_a_aopGet - for exchanging acc with value of the aop           */
+/*-------------------------------------------------------------------*/
+static char *
+xch_a_aopGet (operand * oper, int offset, bool bit16, bool dname)
+{
+  char * l;
+
+  if (aopGetUsesAcc (oper, offset))
+    {
+      emitcode("mov", "b,a");
+      MOVA (aopGet (oper, offset, bit16, dname));
+      emitcode("xch", "a,b");
+      aopPut (oper, "a", offset);
+      emitcode("xch", "a,b");
+      l = "b";
+    }
+  else
+    {
+      l = aopGet (oper, offset, bit16, dname);
+      emitcode("xch", "a,%s", l);
+    }
+  return l;
+}
+
+
 /*-----------------------------------------------------------------*/
 /* genNot - generate code for ! operation                          */
 /*-----------------------------------------------------------------*/
@@ -3439,7 +3468,6 @@ genFunction (iCode * ic)
         }
     }
 
-
   if (fReentrant)
     {
       if (options.useXstack)
@@ -8323,8 +8351,8 @@ shiftL2Left2Result (operand * left, int offl,
     {
       /* don't crash result[offr] */
       MOVA (aopGet (left, offl, FALSE, FALSE));
-      emitcode ("xch", "a,%s", aopGet (left, offl + MSB16, FALSE, FALSE));
-      x = aopGet (result, offr, FALSE, FALSE);
+      x = xch_a_aopGet (left, offl + MSB16, FALSE, FALSE);
+      usedB = !strncmp(x, "b", 1);
     }
   else if (aopGetUsesAcc (result, offr))
     {
@@ -8375,8 +8403,8 @@ shiftR2Left2Result (operand * left, int offl,
     {
       /* don't crash result[offr] */
       MOVA (aopGet (left, offl, FALSE, FALSE));
-      emitcode ("xch", "a,%s", aopGet (left, offl + MSB16, FALSE, FALSE));
-      x = aopGet (result, offr, FALSE, FALSE);
+      x = xch_a_aopGet (left, offl + MSB16, FALSE, FALSE);
+      usedB = !strncmp(x, "b", 1);
     }
   else if (aopGetUsesAcc (result, offr))
     {
@@ -8445,7 +8473,16 @@ shiftRLeftOrResult (operand * left, int offl,
   /* shift right accumulator */
   AccRsh (shCount);
   /* or with result */
-  emitcode ("orl", "a,%s", aopGet (result, offr, FALSE, FALSE));
+  if (aopGetUsesAcc(result, offr))
+    {
+      emitcode ("xch", "a,b");
+      MOVA (aopGet (result, offr, FALSE, FALSE));
+      emitcode ("orl", "a,b");
+    }
+  else
+    {
+      emitcode ("orl", "a,%s", aopGet (result, offr, FALSE, FALSE));
+    }
   /* back to result */
   aopPut (result, "a", offr);
 }
@@ -8515,8 +8552,7 @@ shiftLLong (operand * left, operand * result, int offr)
       emitcode ("add", "a,acc");
       if (sameRegs (AOP (left), AOP (result)) &&
           size >= MSB16 + offr && offr != LSB)
-        emitcode ("xch", "a,%s",
-                  aopGet (left, LSB + offr, FALSE, FALSE));
+        xch_a_aopGet (left, LSB + offr, FALSE, FALSE);
       else
         aopPut (result, "a", LSB + offr);
     }
@@ -8531,8 +8567,7 @@ shiftLLong (operand * left, operand * result, int offr)
       emitcode ("rlc", "a");
       if (sameRegs (AOP (left), AOP (result)) &&
           size >= MSB24 + offr && offr != LSB)
-        emitcode ("xch", "a,%s",
-                  aopGet (left, MSB16 + offr, FALSE, FALSE));
+        xch_a_aopGet (left, MSB16 + offr, FALSE, FALSE);
       else
         aopPut (result, "a", MSB16 + offr);
     }
@@ -8547,8 +8582,7 @@ shiftLLong (operand * left, operand * result, int offr)
       emitcode ("rlc", "a");
       if (sameRegs (AOP (left), AOP (result)) &&
           size >= MSB32 + offr && offr != LSB)
-        emitcode ("xch", "a,%s",
-                  aopGet (left, MSB24 + offr, FALSE, FALSE));
+        xch_a_aopGet (left, MSB24 + offr, FALSE, FALSE);
       else
         aopPut (result, "a", MSB24 + offr);
     }
@@ -8883,9 +8917,9 @@ static void
 shiftRLong (operand * left, int offl,
             operand * result, int sign)
 {
-  bool useSameRegs = regsInCommon (left, result);
+  bool overlapping = regsInCommon (left, result) || operandsEqu(left, result);
 
-  if (useSameRegs && offl>1)
+  if (overlapping && offl>1)
     {
       // we are in big trouble, but this shouldn't happen
       werror(E_INTERNAL_ERROR, __FILE__, __LINE__);
@@ -8900,9 +8934,9 @@ shiftRLong (operand * left, int offl,
         {
           emitcode ("rlc", "a");
           emitcode ("subb", "a,acc");
-          if (useSameRegs && sameReg (AOP (left), MSB32, AOP (result), MSB32))
+          if (overlapping && sameByte (AOP (left), MSB32, AOP (result), MSB32))
             {
-              emitcode ("xch", "a,%s", aopGet (left, MSB32, FALSE, FALSE));
+              xch_a_aopGet (left, MSB32, FALSE, FALSE);
             }
           else
             {
@@ -8912,7 +8946,16 @@ shiftRLong (operand * left, int offl,
         }
       else
         {
-          aopPut (result, zero, MSB32);
+          if (aopPutUsesAcc (result, zero, MSB32))
+            {
+              emitcode("xch", "a,b");
+              aopPut (result, zero, MSB32);
+              emitcode("xch", "a,b");
+            }
+          else
+            {
+              aopPut (result, zero, MSB32);
+            }
         }
     }
 
@@ -8927,28 +8970,29 @@ shiftRLong (operand * left, int offl,
 
   emitcode ("rrc", "a");
 
-  if (useSameRegs && offl==MSB16 &&
-      sameReg (AOP (left), MSB24, AOP (result), MSB32-offl))
+  if (overlapping && offl==MSB16 &&
+      sameByte (AOP (left), MSB24, AOP (result), MSB32-offl))
     {
-      emitcode ("xch", "a,%s",aopGet (left, MSB24, FALSE, FALSE));
+      xch_a_aopGet (left, MSB24, FALSE, FALSE);
     }
   else
     {
-      aopPut (result, "a", MSB32-offl);
+      aopPut (result, "a", MSB32 - offl);
       MOVA (aopGet (left, MSB24, FALSE, FALSE));
     }
 
   emitcode ("rrc", "a");
-  if (useSameRegs && offl==1 &&
-      sameReg (AOP (left), MSB16, AOP (result), MSB24-offl))
+  if (overlapping && offl==MSB16 &&
+      sameByte (AOP (left), MSB16, AOP (result), MSB24-offl))
     {
-      emitcode ("xch", "a,%s",aopGet (left, MSB16, FALSE, FALSE));
+      xch_a_aopGet (left, MSB16, FALSE, FALSE);
     }
   else
     {
-      aopPut (result, "a", MSB24-offl);
+      aopPut (result, "a", MSB24 - offl);
       MOVA (aopGet (left, MSB16, FALSE, FALSE));
     }
+
   emitcode ("rrc", "a");
   if (offl != LSB)
     {
@@ -8956,10 +9000,10 @@ shiftRLong (operand * left, int offl,
     }
   else
     {
-      if (useSameRegs &&
-          sameReg (AOP (left), LSB, AOP (result), MSB16-offl))
+      if (overlapping &&
+          sameByte (AOP (left), LSB, AOP (result), MSB16-offl))
         {
-          emitcode ("xch", "a,%s",aopGet (left, LSB, FALSE, FALSE));
+          xch_a_aopGet (left, LSB, FALSE, FALSE);
         }
       else
         {
index 30d500eb8eed3f0427ca013ffa2b9fd4b18c9548..fa56bcc986354e41f762ef2ee4a3e23abd758b69 100644 (file)
@@ -5707,6 +5707,9 @@ shiftR2Left2Result (operand * left, int offl,
   movLeft2Result (left, offl, result, offr, 0);
   movLeft2Result (left, offl + 1, result, offr + 1, 0);
 
+  if (shCount == 0)
+    return;
+
   /*  if (AOP(result)->type == AOP_REG) { */
 
   tlbl = newiTempLabel (NULL);
@@ -5753,6 +5756,9 @@ shiftL2Left2Result (operand * left, int offl,
       movLeft2Result (left, offl + 1, result, offr + 1, 0);
     }
 
+  if (shCount == 0)
+    return;
+
   if (getPairId (AOP (result)) == PAIR_HL)
     {
       while (shCount--)
@@ -5956,7 +5962,7 @@ shiftL1Left2Result (operand * left, int offl,
 
 
 /*-----------------------------------------------------------------*/
-/* genlshTwo - left shift two bytes by known amount != 0           */
+/* genlshTwo - left shift two bytes by known amount                */
 /*-----------------------------------------------------------------*/
 static void
 genlshTwo (operand * result, operand * left, int shCount)
@@ -5974,8 +5980,8 @@ genlshTwo (operand * result, operand * left, int shCount)
           if (shCount)
             {
               movLeft2Result (left, LSB, result, MSB16, 0);
-              aopPut (AOP (result), "!zero", 0);
               shiftL1Left2Result (left, LSB, result, MSB16, shCount);
+              aopPut (AOP (result), "!zero", LSB);
             }
           else
             {
@@ -5988,7 +5994,7 @@ genlshTwo (operand * result, operand * left, int shCount)
           aopPut (AOP (result), "!zero", LSB);
         }
     }
-  /*  1 <= shCount <= 7 */
+  /*  0 <= shCount <= 7 */
   else
     {
       if (size == 1)
@@ -6031,12 +6037,8 @@ genLeftShiftLiteral (operand * left,
   size = getSize (operandType (result));
 
   /* I suppose that the left size >= result size */
-  if (shCount == 0)
-    {
-      wassert (0);
-    }
 
-  else if (shCount >= (size * 8))
+  if (shCount >= (size * 8))
     {
       while (size--)
         {
@@ -6231,7 +6233,7 @@ shiftR1Left2Result (operand * left, int offl,
 }
 
 /*-----------------------------------------------------------------*/
-/* genrshTwo - right shift two bytes by known amount != 0          */
+/* genrshTwo - right shift two bytes by known amount               */
 /*-----------------------------------------------------------------*/
 static void
 genrshTwo (operand * result, operand * left,
@@ -6264,7 +6266,7 @@ genrshTwo (operand * result, operand * left,
           aopPut (AOP (result), "!zero", 1);
         }
     }
-  /*  1 <= shCount <= 7 */
+  /*  0 <= shCount <= 7 */
   else
     {
       shiftR2Left2Result (left, LSB, result, LSB, shCount, sign);
@@ -6292,12 +6294,8 @@ genRightShiftLiteral (operand * left,
   size = getSize (operandType (result));
 
   /* I suppose that the left size >= result size */
-  if (shCount == 0)
-    {
-      wassert (0);
-    }
 
-  else if (shCount >= (size * 8)) {
+  if (shCount >= (size * 8)) {
     const char *s;
     if (!SPEC_USIGN(getSpec(operandType(left)))) {
       _moveA(aopGet (AOP (left), 0, FALSE));
index ab3c6f5f44c4409e4729248672fa33e02f17064d..3378a7b0cb174e5c49897a22ec357fb9e715ab1a 100644 (file)
@@ -69,7 +69,7 @@ GENERATE_CASES = $(srcdir)/generate-cases.py
 # Each directory under ports/ is used as a port name.  Each port is tested.
 # Each port must have a spec.mk which describes how to build the object
 # files and how to run the emulator.
-ALL_PORTS = $(filter-out .svn xa51 ucz80 gbz80 pic16,$(notdir $(wildcard $(PORTS_DIR)/*)))
+ALL_PORTS = $(filter-out .svn xa51 z80 gbz80 pic16,$(notdir $(wildcard $(PORTS_DIR)/*)))
 
 # These  ports will be cleaned with 'make clean'
 CLEAN_PORTS = $(filter-out .svn,$(notdir $(wildcard $(PORTS_DIR)/*)))
index 6431baf664888cd93c85eb2005dc40a37449a0d6..c068b14234fc6bccd585b79a6ae63a50951095fe 100644 (file)
 void
 testTrans(void)
 {
-#if !defined(SDCC_z80) && !PORT_HOST
-# ifdef SQRTF
-      ASSERT(fabsf (sqrtf (5.0)     -   2.23606801) < 0.00001);
-# endif
-# ifdef LOGF
+#ifdef SQRTF
+    ASSERT(fabsf (sqrtf (5.0)     -   2.23606801) < 0.00001);
+#endif
+#ifdef LOGF
     ASSERT(fabsf (logf (124.0)    -   4.82028150) < 0.00001);
     ASSERT(fabsf (log10f (124.0)  -   2.09342169) < 0.00001);
+#endif
+#ifdef POWF
+  /*  too big for small model */
+# ifndef SDCC_MODEL_SMALL
+    ASSERT(fabsf (powf (1.5, 2.0) -   2.24999976) < 0.00001);
 # endif
-# ifdef POWF
-    /*  too big for small modell */
-#   ifndef SDCC_MODEL_SMALL
-      ASSERT(fabsf (powf (1.5, 2.0) -   2.24999976) < 0.00001);
-#   endif
-# endif
-# ifdef TANF
+#endif
+#ifdef TANF
     ASSERT(fabsf (tanf (1.6)      - -34.23250579) < 0.00001);
-# endif
 #endif
 }
diff --git a/support/regression/tests/shifts2.c b/support/regression/tests/shifts2.c
new file mode 100644 (file)
index 0000000..3708e57
--- /dev/null
@@ -0,0 +1,92 @@
+/** extended tests for shift operations, added by\r
+    Frieder Ferlemann to check for bugs related to bug 1533966\r
+\r
+    size: 8,16,32\r
+    right: 0,1\r
+    vol: 0,1\r
+    sign: u,\r
+*/\r
+#include <testfwk.h>\r
+#ifdef __sun__\r
+#  include <inttypes.h>\r
+#else\r
+#  include <stdint.h>\r
+#endif\r
+\r
+#define SIZE    ({size})\r
+#define RIGHT   ({right})\r
+#define VOL     ({vol})\r
+\r
+#if SIZE == 8\r
+#  define TYPE {sign}int8_t\r
+#  define TEST_VECT 0xa4\r
+#endif\r
+\r
+#if SIZE == 16\r
+#  define TYPE {sign}int16_t\r
+#  define TEST_VECT 0xa8ce\r
+#endif\r
+\r
+#if SIZE == 32\r
+#  define TYPE {sign}int32_t\r
+#  define TEST_VECT 0xa8b5c4d6\r
+#endif\r
+\r
+#if RIGHT == 0\r
+#  define SHIFT(x,y) (TYPE)((TYPE)(x)<<(y))\r
+#else\r
+#  define SHIFT(x,y) (TYPE)((TYPE)(x)>>(y))\r
+#endif\r
+\r
+#if VOL == 0\r
+  volatile TYPE s = TEST_VECT;\r
+           TYPE t;\r
+  #define TESTSHIFT(x) t=s; t = SHIFT (t,(x)); ASSERT( t == SHIFT (TEST_VECT, (x)));\r
+#else\r
+  volatile TYPE t = TEST_VECT;\r
+  #define TESTSHIFT(x) t=TEST_VECT; t = SHIFT (t,(x)); ASSERT( t == SHIFT (TEST_VECT, (x)));\r
+#endif\r
+\r
+static void\r
+testShift(void)\r
+{\r
+    TESTSHIFT(0);\r
+    TESTSHIFT(1);\r
+    TESTSHIFT(2);\r
+    TESTSHIFT(3);\r
+    TESTSHIFT(4);\r
+    TESTSHIFT(5);\r
+    TESTSHIFT(6);\r
+    TESTSHIFT(7);\r
+\r
+#if SIZE >= 16\r
+    TESTSHIFT(8);\r
+    TESTSHIFT(9);\r
+    TESTSHIFT(10);\r
+    TESTSHIFT(11);\r
+    TESTSHIFT(12);\r
+    TESTSHIFT(13);\r
+    TESTSHIFT(14);\r
+    TESTSHIFT(15);\r
+#endif\r
+\r
+#if SIZE >= 32\r
+    TESTSHIFT(16);\r
+    TESTSHIFT(17);\r
+    TESTSHIFT(18);\r
+    TESTSHIFT(19);\r
+    TESTSHIFT(20);\r
+    TESTSHIFT(21);\r
+    TESTSHIFT(22);\r
+    TESTSHIFT(23);\r
+\r
+    TESTSHIFT(24);\r
+    TESTSHIFT(25);\r
+    TESTSHIFT(26);\r
+    TESTSHIFT(27);\r
+    TESTSHIFT(28);\r
+    TESTSHIFT(29);\r
+    TESTSHIFT(30);\r
+    TESTSHIFT(31);\r
+#endif\r
+}\r