From a8a7fc8a514bc79114c6d76d6a6aeb885387478c Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Tue, 20 May 2008 13:54:51 +0000 Subject: [PATCH] * device/include/float.h: added __INFINITY * device/lib/_fsadd.c: handle overflows * device/lib/_fsmul.c, * device/lib/_fsdiv.c: use __INFINITY * device/lib/_fseq.c, * device/lib/_fsneq.c: handle -0.0 * sim/ucsim/s51.src/uc89c51r.cc, * sim/ucsim/s51.src/uc89c51rcl.h: bugfix auxr should be auxr1 * sim/ucsim/sim.src/hwcl.h: */* confuses VC * src/mcs51/gen.c (genSend): fixed bug with --xstack * support/regression/ports/mcs51-xstack-auto/spec.mk: print floats * support/regression/tests/snprintf.c: test bug with --xstack git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5164 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 15 +++++++++++++++ device/include/float.h | 1 + device/lib/_fsadd.c | 14 +++++++++----- device/lib/_fsdiv.c | 2 +- device/lib/_fseq.c | 2 ++ device/lib/_fsmul.c | 2 +- device/lib/_fsneq.c | 10 ++-------- sim/ucsim/s51.src/uc89c51r.cc | 8 ++++---- sim/ucsim/s51.src/uc89c51rcl.h | 2 +- sim/ucsim/sim.src/hwcl.h | 6 +++--- src/mcs51/gen.c | 6 +++++- .../regression/ports/mcs51-xstack-auto/spec.mk | 2 +- support/regression/tests/snprintf.c | 2 +- 13 files changed, 46 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f37a001..13a87a3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-05-20 Maarten Brock + + * device/include/float.h: added __INFINITY + * device/lib/_fsadd.c: handle overflows + * device/lib/_fsmul.c, + * device/lib/_fsdiv.c: use __INFINITY + * device/lib/_fseq.c, + * device/lib/_fsneq.c: handle -0.0 + * sim/ucsim/s51.src/uc89c51r.cc, + * sim/ucsim/s51.src/uc89c51rcl.h: bugfix auxr should be auxr1 + * sim/ucsim/sim.src/hwcl.h: */* confuses VC + * src/mcs51/gen.c (genSend): fixed bug with --xstack + * support/regression/ports/mcs51-xstack-auto/spec.mk: print floats + * support/regression/tests/snprintf.c: test bug with --xstack + 2008-05-19 Philipp Klaus Krause * src/SDCCpeeph.c (callFuncByName): diff --git a/device/include/float.h b/device/include/float.h index 05ad4be7..b31679bc 100644 --- a/device/include/float.h +++ b/device/include/float.h @@ -41,6 +41,7 @@ /* the following deal with IEEE single-precision numbers */ #define EXCESS 126 #define SIGNBIT ((unsigned long)0x80000000) +#define __INFINITY ((unsigned long)0x7F800000) #define HIDDEN (unsigned long)(1ul << 23) #define SIGN(fp) (((unsigned long)(fp) >> (8*sizeof(fp)-1)) & 1) #define EXP(fp) (((unsigned long)(fp) >> 23) & (unsigned int) 0x00FF) diff --git a/device/lib/_fsadd.c b/device/lib/_fsadd.c index 567582e8..cb179c5e 100644 --- a/device/lib/_fsadd.c +++ b/device/lib/_fsadd.c @@ -162,7 +162,7 @@ float __fsadd (float a1, float a2) volatile long mant1, mant2; volatile union float_long fl1, fl2; volatile int exp1, exp2; - volatile unsigned long sign = 0; + char sign = 0; fl1.f = a1; fl2.f = a2; @@ -203,7 +203,7 @@ float __fsadd (float a1, float a2) if (mant1 < 0) { mant1 = -mant1; - sign = SIGNBIT; + sign = 1; } else if (!mant1) return (0); @@ -218,7 +218,7 @@ float __fsadd (float a1, float a2) while (mant1 & 0xff000000) { if (mant1&1) mant1 += 2; - mant1 >>= 1 ; + mant1 >>= 1; exp1++; } @@ -226,8 +226,12 @@ float __fsadd (float a1, float a2) mant1 &= ~HIDDEN; /* pack up and go home */ - fl1.l = PACK (sign, (unsigned long) exp1, mant1); - + if (exp1 >= 0x100) + fl1.l = (sign ? SIGNBIT : 0) | __INFINITY; + else if (exp1 < 0) + fl1.l = 0; + else + fl1.l = PACK (sign ? SIGNBIT : 0 , exp1, mant1); return (fl1.f); } diff --git a/device/lib/_fsdiv.c b/device/lib/_fsdiv.c index 5a1a21a7..7bf1c48f 100644 --- a/device/lib/_fsdiv.c +++ b/device/lib/_fsdiv.c @@ -328,7 +328,7 @@ float __fsdiv (float a1, float a2) /* pack up and go home */ if (exp >= 0x100) - fl1.l = (sign ? SIGNBIT : 0) | 0x7F800000; + fl1.l = (sign ? SIGNBIT : 0) | __INFINITY; else if (exp < 0) fl1.l = 0; else diff --git a/device/lib/_fseq.c b/device/lib/_fseq.c index 5c3b0274..b4871ba1 100644 --- a/device/lib/_fseq.c +++ b/device/lib/_fseq.c @@ -79,6 +79,8 @@ __fseq (float a1, float a2) if (fl1.l == fl2.l) return (1); + if (((fl1.l | fl2.l) & 0x7FFFFFFF) == 0) + return (1); return (0); } diff --git a/device/lib/_fsmul.c b/device/lib/_fsmul.c index 97f46e94..1f36d603 100644 --- a/device/lib/_fsmul.c +++ b/device/lib/_fsmul.c @@ -271,7 +271,7 @@ float __fsmul (float a1, float a2) { /* pack up and go home */ if (exp >= 0x100) - fl1.l = (sign ? SIGNBIT : 0) | 0x7F800000; + fl1.l = (sign ? SIGNBIT : 0) | __INFINITY; else if (exp < 0) fl1.l = 0; else diff --git a/device/lib/_fsneq.c b/device/lib/_fsneq.c index 56112a0e..4b675d02 100644 --- a/device/lib/_fsneq.c +++ b/device/lib/_fsneq.c @@ -74,16 +74,10 @@ char __fsneq (float a1, float a2) fl1.f = a1; fl2.f = a2; -#if 0 - if (fl1.l<0 && fl2.l<0) - { - fl1.l ^= SIGNBIT; - fl2.l ^= SIGNBIT; - } -#endif - if (fl1.l == fl2.l) return (0); + if (((fl1.l | fl2.l) & 0x7FFFFFFF) == 0) + return (0); return (1); } diff --git a/sim/ucsim/s51.src/uc89c51r.cc b/sim/ucsim/s51.src/uc89c51r.cc index f29e51d6..b1b72e8d 100644 --- a/sim/ucsim/s51.src/uc89c51r.cc +++ b/sim/ucsim/s51.src/uc89c51r.cc @@ -2,7 +2,7 @@ * Simulator of microcontrollers (uc89c51r.cc) * * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. - * + * * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu * */ @@ -144,15 +144,15 @@ cl_89c51r_dummy_hw::init(void) fprintf(stderr, "No SFR to register %s[%d] into\n", id_string, id); } //auxr= sfr->register_hw(AUXR, this, 0); - register_cell(sfr, AUXR, &auxr, wtd_restore); + register_cell(sfr, AUXR1, &auxr1, wtd_restore); return(0); } void cl_89c51r_dummy_hw::write(class cl_memory_cell *cell, t_mem *val) { - if (cell == auxr) - auxr->set_bit0(0x04); + if (cell == auxr1) + auxr1->set_bit0(0x04); } diff --git a/sim/ucsim/s51.src/uc89c51rcl.h b/sim/ucsim/s51.src/uc89c51rcl.h index 28075631..164cb9f2 100644 --- a/sim/ucsim/s51.src/uc89c51rcl.h +++ b/sim/ucsim/s51.src/uc89c51rcl.h @@ -60,7 +60,7 @@ public: class cl_89c51r_dummy_hw: public cl_hw { protected: - class cl_memory_cell *auxr; + class cl_memory_cell *auxr1; public: cl_89c51r_dummy_hw(class cl_uc *auc); virtual int init(void); diff --git a/sim/ucsim/sim.src/hwcl.h b/sim/ucsim/sim.src/hwcl.h index 39f3b68e..70917db6 100644 --- a/sim/ucsim/sim.src/hwcl.h +++ b/sim/ucsim/sim.src/hwcl.h @@ -109,7 +109,7 @@ public: virtual class cl_hw *make_partner(enum hw_cath cath, int id); virtual t_mem read(class cl_memory_cell *cell) { return(cell->get()); } - virtual void write(class cl_memory_cell */*cell*/, t_mem */*val*/) {} + virtual void write(class cl_memory_cell * /*cell*/, t_mem * /*val*/) {} virtual void set_cmd(class cl_cmdline *cmdline, class cl_console_base *con); virtual class cl_memory_cell *register_cell(class cl_address_space *mem, @@ -126,8 +126,8 @@ public: virtual int tick(int cycles); virtual void reset(void) {} - virtual void happen(class cl_hw */*where*/, enum hw_event /*he*/, - void */*params*/) {} + virtual void happen(class cl_hw * /*where*/, enum hw_event /*he*/, + void * /*params*/) {} virtual void inform_partners(enum hw_event he, void *params); virtual void print_info(class cl_console_base *con); diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 9ce6403e..88afbc53 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -2831,9 +2831,13 @@ static void genSend(set *sendSet) } } - if (bit_count) + if (options.useXstack || bit_count) { saveRegisters (setFirstItem (sendSet)); + } + + if (bit_count) + { emitcode ("mov", "bits,b"); } diff --git a/support/regression/ports/mcs51-xstack-auto/spec.mk b/support/regression/ports/mcs51-xstack-auto/spec.mk index efbea3c3..3281a8a4 100644 --- a/support/regression/ports/mcs51-xstack-auto/spec.mk +++ b/support/regression/ports/mcs51-xstack-auto/spec.mk @@ -8,7 +8,7 @@ LIBSRCDIR = $(top_srcdir)/device/lib LIBBUILDDIR = $(top_builddir)/device/lib LIBDIR = $(PORT_CASES_DIR)/lib -LIBSDCCFLAGS+= --stack-auto --xstack --std-c99 +LIBSDCCFLAGS+= --stack-auto --xstack --std-c99 -DUSE_FLOATS=1 SDCCFLAGS += --stack-auto --xstack --std-sdcc99 SOURCES = _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \ diff --git a/support/regression/tests/snprintf.c b/support/regression/tests/snprintf.c index 6ed6972d..c06d3254 100644 --- a/support/regression/tests/snprintf.c +++ b/support/regression/tests/snprintf.c @@ -98,7 +98,7 @@ } static const cases[]={ // arg, fmt, result // ... there should be more ... - #if defined(SDCC) && !defined(SDCC_ds390) + #if defined(SDCC) && !defined(SDCC_ds390) && !(defined(SDCC_mcs51) && defined(SDCC_USE_XSTACK)) {1.0, "%f", ""}, #else {1.0, "%f", "1.000000"}, -- 2.30.2