+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:
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)
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))
//PC = 0x08;
switch (regs.A) {
case 0:
- ::exit(0);
+ return(resBREAKPOINT);
+// ::exit(0);
break;
case 1:
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));
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);
}
-------------------------------------------------------------------------*/
-#define D(x)
-//#define D(x) x
+//#define D(x)
+#define D(x) x
#include <stdio.h>
#include <stdlib.h>
/*-----------------------------------------------------------------*/
/* 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)
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);
}
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);
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)
{
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);
}
/*-----------------------------------------------------------------*/
-/* 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;
}
+/*-------------------------------------------------------------------*/
+/* 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 */
/*-----------------------------------------------------------------*/
}
}
-
if (fReentrant)
{
if (options.useXstack)
{
/* 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))
{
{
/* 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))
{
/* 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);
}
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);
}
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);
}
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);
}
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__);
{
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
{
}
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);
+ }
}
}
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)
{
}
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
{
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);
movLeft2Result (left, offl + 1, result, offr + 1, 0);
}
+ if (shCount == 0)
+ return;
+
if (getPairId (AOP (result)) == PAIR_HL)
{
while (shCount--)
/*-----------------------------------------------------------------*/
-/* 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)
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
{
aopPut (AOP (result), "!zero", LSB);
}
}
- /* 1 <= shCount <= 7 */
+ /* 0 <= shCount <= 7 */
else
{
if (size == 1)
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--)
{
}
/*-----------------------------------------------------------------*/
-/* genrshTwo - right shift two bytes by known amount != 0 */
+/* genrshTwo - right shift two bytes by known amount */
/*-----------------------------------------------------------------*/
static void
genrshTwo (operand * result, operand * left,
aopPut (AOP (result), "!zero", 1);
}
}
- /* 1 <= shCount <= 7 */
+ /* 0 <= shCount <= 7 */
else
{
shiftR2Left2Result (left, LSB, result, LSB, shCount, sign);
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));
# 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)/*)))
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
}
--- /dev/null
+/** 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