* device/include/float.h: added __INFINITY
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 20 May 2008 13:54:51 +0000 (13:54 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 20 May 2008 13:54:51 +0000 (13:54 +0000)
* 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

13 files changed:
ChangeLog
device/include/float.h
device/lib/_fsadd.c
device/lib/_fsdiv.c
device/lib/_fseq.c
device/lib/_fsmul.c
device/lib/_fsneq.c
sim/ucsim/s51.src/uc89c51r.cc
sim/ucsim/s51.src/uc89c51rcl.h
sim/ucsim/sim.src/hwcl.h
src/mcs51/gen.c
support/regression/ports/mcs51-xstack-auto/spec.mk
support/regression/tests/snprintf.c

index 7f37a001807a795d4b2bd45ca241566e60a72a23..13a87a3b7bcffcbe224e0760e9ed740e0eac3767 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-05-20 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * 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 <pkk AT spth.de>
 
        * src/SDCCpeeph.c (callFuncByName):
index 05ad4be7be6bd29618073793337e97cb0dfe6274..b31679bced10cea40910f3a40de507852c9dec9c 100644 (file)
@@ -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)
index 567582e81e158845d820ca6599513932cc98c3e6..cb179c5e9644ccf75724580ac0226e478ab1b720 100644 (file)
@@ -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);
 }
 
index 5a1a21a744387cdceb947e01f97f4fd461f0dea8..7bf1c48f010293a75054c269f0f63a06bcb0ac53 100644 (file)
@@ -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
index 5c3b02746d8b9029d037bd40a391a8a9c8772aae..b4871ba1a00b9526f1f47466e257f2ed6d10eb8b 100644 (file)
@@ -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);
 }
 
index 97f46e947ba7f51f68aa672b1ea66f4a979d53f4..1f36d603d97830dabfec4971afcb8d40ea97b06f 100644 (file)
@@ -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
index 56112a0eac873efd79ba3be2ecc2e0872b34724e..4b675d02f8a5d2bffb0f54c94b33189865e617cc 100644 (file)
@@ -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);
 }
 
index f29e51d64202555a5de223b7f2bfccdb269c7661..b1b72e8dbf202c63ccd6bcc35e910236db976f16 100644 (file)
@@ -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);
 }
 
 
index 280756314b12e99741b458e589dfce265378e926..164cb9f272db00bfe57e868ecddeb053f00700a3 100644 (file)
@@ -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);
index 39f3b68e83db86fafd48ac9e845fb303d51f13e2..70917db6b98061f4ecf177731d754a2ab298721c 100644 (file)
@@ -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);
index 9ce6403ede17a2a7f1631b703a81a95e75d53b83..88afbc53f0d2297e9640f982e0b6bde0f37998d5 100644 (file)
@@ -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");
     }
 
index efbea3c3a0c2c5cbd363b2d843060806d97ef7d7..3281a8a4383e672b70d33d6c5caf63a8351d9951 100644 (file)
@@ -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 \
index 6ed6972d2d55f01e26dad02258b3a9cd34e854bf..c06d32546d9b684a57cc0df7acf9b73daa0e438e 100644 (file)
@@ -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",   "<NO FLOAT>"},
                #else
                {1.0,   "%f",   "1.000000"},