* device/include/float.h: added __INFINITY
[fw/sdcc] / device / include / float.h
index 328fccd89615195e043b7b8d75dcfb807da30146..b31679bced10cea40910f3a40de507852c9dec9c 100644 (file)
 /* the following deal with IEEE single-precision numbers */
 #define EXCESS         126
 #define SIGNBIT                ((unsigned long)0x80000000)
-#define HIDDEN         (unsigned long)(1 << 23)
-#define SIGN(fp)       ((fp >> (8*sizeof(fp)-1)) & 1)
-#define EXP(fp)                (((fp) >> 23) & (unsigned int) 0x00FF)
+#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)
 #define MANT(fp)       (((fp) & (unsigned long)0x007FFFFF) | HIDDEN)
 #define NORM            0xff000000
-#define PACK(s,e,m)    ((s) | ((e) << 23) | (m))
+#define PACK(s,e,m)    ((s) | ((unsigned long)(e) << 23) | (m))
 
-float _uchar2fs (unsigned char);
-float _schar2fs (signed char);
-float _uint2fs (unsigned int);
-float _sint2fs (signed int);
-float _ulong2fs (unsigned long);
-float _slong2fs (signed long);
-unsigned char _fs2uchar (float);
-signed char _fs2schar (float);
-unsigned int _fs2uint (float);
-signed int _fs2sint (float);
-unsigned long _fs2ulong (float);
-signed long _fs2slong (float);
+float __uchar2fs (unsigned char);
+float __schar2fs (signed char);
+float __uint2fs (unsigned int);
+float __sint2fs (signed int);
+float __ulong2fs (unsigned long);
+float __slong2fs (signed long);
+unsigned char __fs2uchar (float);
+signed char __fs2schar (float);
+unsigned int __fs2uint (float);
+signed int __fs2sint (float);
+unsigned long __fs2ulong (float);
+signed long __fs2slong (float);
 
-float _fsadd (float, float);
-float _fssub (float, float);
-float _fsmul (float, float);
-float _fsdiv (float, float);
+float __fsadd (float, float);
+float __fssub (float, float);
+float __fsmul (float, float);
+float __fsdiv (float, float);
 
-char _fslt (float, float);
-char _fseq (float, float);
-char _fsqt (float, float);
+char __fslt (float, float);
+char __fseq (float, float);
+char __fsgt (float, float);
 
-#endif
 
+#if defined(SDCC_FLOAT_LIB) && defined(SDCC_mcs51) && !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
 
+#define FLOAT_ASM_MCS51
 
+// This adds extra code for proper round-off, in
+// an attempt to match the results from gcc.
+#define FLOAT_FULL_ACCURACY
 
+// This adds about 66 bytes to the code size and
+// significantly speeds up shift operations more
+// than 8 bits (common when subtracting numbers
+// of significantly different magnitude and scaling
+// to fixed point)
+#define FLOAT_SHIFT_SPEEDUP
+
+#define sign_a  psw.1
+#define sign_b  psw.5
+#define exp_a dpl
+#define exp_b dph
+#endif // using mcs51 assembly
+
+
+#endif // __SDC51_FLOAT_H