Index: uspace/softfloat/generic/add.c
===================================================================
--- uspace/softfloat/generic/add.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
+++ uspace/softfloat/generic/add.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
@@ -0,0 +1,259 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup softfloat	
+ * @{
+ */
+/** @file
+ */
+
+#include<sftypes.h>
+#include<add.h>
+#include<comparison.h>
+
+/** Add two Float32 numbers with same signs
+ */
+float32 addFloat32(float32 a, float32 b)
+{
+	int expdiff;
+	uint32_t exp1, exp2,frac1, frac2;
+	
+	expdiff = a.parts.exp - b.parts.exp;
+	if (expdiff < 0) {
+		if (isFloat32NaN(b)) {
+			/* TODO: fix SigNaN */
+			if (isFloat32SigNaN(b)) {
+			};
+
+			return b;
+		};
+		
+		if (b.parts.exp == FLOAT32_MAX_EXPONENT) { 
+			return b;
+		}
+		
+		frac1 = b.parts.fraction;
+		exp1 = b.parts.exp;
+		frac2 = a.parts.fraction;
+		exp2 = a.parts.exp;
+		expdiff *= -1;
+	} else {
+		if ((isFloat32NaN(a)) || (isFloat32NaN(b))) {
+			/* TODO: fix SigNaN */
+			if (isFloat32SigNaN(a) || isFloat32SigNaN(b)) {
+			};
+			return (isFloat32NaN(a)?a:b);
+		};
+		
+		if (a.parts.exp == FLOAT32_MAX_EXPONENT) { 
+			return a;
+		}
+		
+		frac1 = a.parts.fraction;
+		exp1 = a.parts.exp;
+		frac2 = b.parts.fraction;
+		exp2 = b.parts.exp;
+	};
+	
+	if (exp1 == 0) {
+		/* both are denormalized */
+		frac1 += frac2;
+		if (frac1 & FLOAT32_HIDDEN_BIT_MASK ) {
+			/* result is not denormalized */
+			a.parts.exp = 1;
+		};
+		a.parts.fraction = frac1;
+		return a;
+	};
+	
+	frac1 |= FLOAT32_HIDDEN_BIT_MASK; /* add hidden bit */
+
+	if (exp2 == 0) {
+		/* second operand is denormalized */
+		--expdiff;
+	} else {
+		/* add hidden bit to second operand */
+		frac2 |= FLOAT32_HIDDEN_BIT_MASK; 
+	};
+	
+	/* create some space for rounding */
+	frac1 <<= 6;
+	frac2 <<= 6;
+	
+	if (expdiff < (FLOAT32_FRACTION_SIZE + 2) ) {
+		frac2 >>= expdiff;
+		frac1 += frac2;
+	} else {
+		a.parts.exp = exp1;
+		a.parts.fraction = (frac1 >> 6) & (~(FLOAT32_HIDDEN_BIT_MASK));
+		return a;
+	}
+	
+	if (frac1 & (FLOAT32_HIDDEN_BIT_MASK << 7) ) {
+		++exp1;
+		frac1 >>= 1;
+	};
+	
+	/* rounding - if first bit after fraction is set then round up */
+	frac1 += (0x1 << 5);
+	
+	if (frac1 & (FLOAT32_HIDDEN_BIT_MASK << 7)) { 
+		/* rounding overflow */
+		++exp1;
+		frac1 >>= 1;
+	};
+	
+	
+	if ((exp1 == FLOAT32_MAX_EXPONENT ) || (exp2 > exp1)) {
+			/* overflow - set infinity as result */
+			a.parts.exp = FLOAT32_MAX_EXPONENT;
+			a.parts.fraction = 0;
+			return a;
+			}
+	
+	a.parts.exp = exp1;
+	
+	/*Clear hidden bit and shift */
+	a.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)) ; 
+	return a;
+}
+
+
+/** Add two Float64 numbers with same signs
+ */
+float64 addFloat64(float64 a, float64 b)
+{
+	int expdiff;
+	uint32_t exp1, exp2;
+	uint64_t frac1, frac2;
+	
+	expdiff = ((int )a.parts.exp) - b.parts.exp;
+	if (expdiff < 0) {
+		if (isFloat64NaN(b)) {
+			/* TODO: fix SigNaN */
+			if (isFloat64SigNaN(b)) {
+			};
+
+			return b;
+		};
+		
+		/* b is infinity and a not */	
+		if (b.parts.exp == FLOAT64_MAX_EXPONENT ) { 
+			return b;
+		}
+		
+		frac1 = b.parts.fraction;
+		exp1 = b.parts.exp;
+		frac2 = a.parts.fraction;
+		exp2 = a.parts.exp;
+		expdiff *= -1;
+	} else {
+		if (isFloat64NaN(a)) {
+			/* TODO: fix SigNaN */
+			if (isFloat64SigNaN(a) || isFloat64SigNaN(b)) {
+			};
+			return a;
+		};
+		
+		/* a is infinity and b not */
+		if (a.parts.exp == FLOAT64_MAX_EXPONENT ) { 
+			return a;
+		}
+		
+		frac1 = a.parts.fraction;
+		exp1 = a.parts.exp;
+		frac2 = b.parts.fraction;
+		exp2 = b.parts.exp;
+	};
+	
+	if (exp1 == 0) {
+		/* both are denormalized */
+		frac1 += frac2;
+		if (frac1 & FLOAT64_HIDDEN_BIT_MASK) { 
+			/* result is not denormalized */
+			a.parts.exp = 1;
+		};
+		a.parts.fraction = frac1;
+		return a;
+	};
+	
+	/* add hidden bit - frac1 is sure not denormalized */
+	frac1 |= FLOAT64_HIDDEN_BIT_MASK;
+
+	/* second operand ... */
+	if (exp2 == 0) {
+		/* ... is denormalized */
+		--expdiff;	
+	} else {
+		/* is not denormalized */
+		frac2 |= FLOAT64_HIDDEN_BIT_MASK;
+	};
+	
+	/* create some space for rounding */
+	frac1 <<= 6;
+	frac2 <<= 6;
+	
+	if (expdiff < (FLOAT64_FRACTION_SIZE + 2) ) {
+		frac2 >>= expdiff;
+		frac1 += frac2;
+	} else {
+		a.parts.exp = exp1;
+		a.parts.fraction = (frac1 >> 6) & (~(FLOAT64_HIDDEN_BIT_MASK));
+		return a;
+	}
+	
+	if (frac1 & (FLOAT64_HIDDEN_BIT_MASK << 7) ) {
+		++exp1;
+		frac1 >>= 1;
+	};
+	
+	/* rounding - if first bit after fraction is set then round up */
+	frac1 += (0x1 << 5); 
+	
+	if (frac1 & (FLOAT64_HIDDEN_BIT_MASK << 7)) { 
+		/* rounding overflow */
+		++exp1;
+		frac1 >>= 1;
+	};
+	
+	if ((exp1 == FLOAT64_MAX_EXPONENT ) || (exp2 > exp1)) {
+			/* overflow - set infinity as result */
+			a.parts.exp = FLOAT64_MAX_EXPONENT;
+			a.parts.fraction = 0;
+			return a;
+			}
+	
+	a.parts.exp = exp1;
+	/*Clear hidden bit and shift */
+	a.parts.fraction = ( (frac1 >> 6 ) & (~FLOAT64_HIDDEN_BIT_MASK));
+	
+	return a;
+}
+
+/** @}
+ */
Index: uspace/softfloat/generic/common.c
===================================================================
--- uspace/softfloat/generic/common.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
+++ uspace/softfloat/generic/common.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup softfloat	
+ * @{
+ */
+/** @file
+ */
+
+#include<sftypes.h>
+#include<common.h>
+
+/* Table for fast leading zeroes counting */
+char zeroTable[256] = {
+	8, 7, 7, 6, 6, 6, 6, 4, 4, 4, 4, 4, 4, 4, 4, \
+	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \
+	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
+	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
+	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
+	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
+	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
+	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+
+
+/** Take fraction shifted by 10 bits to left, round it, normalize it and detect exceptions
+ * @param cexp exponent with bias
+ * @param cfrac fraction shifted 10 places left with added hidden bit
+ * @param sign
+ * @return valied float64
+ */
+float64 finishFloat64(int32_t cexp, uint64_t cfrac, char sign)
+{
+	float64 result;
+
+	result.parts.sign = sign;
+
+	/* find first nonzero digit and shift result and detect possibly underflow */
+	while ((cexp > 0) && (cfrac) && (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1 ) )))) {
+		cexp--; 
+		cfrac <<= 1;
+			/* TODO: fix underflow */
+	};
+	
+	if ((cexp < 0) || ( cexp == 0 && (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1)))))) {
+		/* FIXME: underflow */
+		result.parts.exp = 0;
+		if ((cexp + FLOAT64_FRACTION_SIZE + 1) < 0) { /* +1 is place for rounding */
+			result.parts.fraction = 0;
+			return result;
+		}
+		
+		while (cexp < 0) {
+			cexp++;
+			cfrac >>= 1;
+		}
+	
+		cfrac += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3)); 
+		
+		if (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1)))) {
+			
+			result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2) ) & (~FLOAT64_HIDDEN_BIT_MASK)); 
+			return result;
+		}	
+	} else {
+		cfrac += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3)); 
+	}
+	
+	++cexp;
+
+	if (cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1 ))) {
+		++cexp;
+		cfrac >>= 1;
+	}	
+
+	/* check overflow */
+	if (cexp >= FLOAT64_MAX_EXPONENT ) {
+		/* FIXME: overflow, return infinity */
+		result.parts.exp = FLOAT64_MAX_EXPONENT;
+		result.parts.fraction = 0;
+		return result;
+	}
+
+	result.parts.exp = (uint32_t)cexp;
+	
+	result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2 ) ) & (~FLOAT64_HIDDEN_BIT_MASK)); 
+	
+	return result;	
+}
+
+/** Counts leading zeroes in 64bit unsigned integer
+ * @param i 
+ */
+int countZeroes64(uint64_t i)
+{
+	int j;
+	for (j =0; j < 64; j += 8) {
+		if ( i & (0xFFll << (56 - j))) {
+			return (j + countZeroes8(i >> (56 - j)));
+		}
+	}
+
+	return 64;
+}
+
+/** Counts leading zeroes in 32bit unsigned integer
+ * @param i 
+ */
+int countZeroes32(uint32_t i)
+{
+	int j;
+	for (j =0; j < 32; j += 8) {
+		if ( i & (0xFF << (24 - j))) {
+			return (j + countZeroes8(i >> (24 - j)));
+		}
+	}
+
+	return 32;
+}
+
+/** Counts leading zeroes in byte
+ * @param i 
+ */
+int countZeroes8(uint8_t i)
+{
+	return zeroTable[i];
+}
+
+/** Round and normalize number expressed by exponent and fraction with first bit (equal to hidden bit) at 30. bit
+ * @param exp exponent 
+ * @param fraction part with hidden bit shifted to 30. bit
+ */
+void roundFloat32(int32_t *exp, uint32_t *fraction)
+{
+	/* rounding - if first bit after fraction is set then round up */
+	(*fraction) += (0x1 << 6);
+	
+	if ((*fraction) & (FLOAT32_HIDDEN_BIT_MASK << 8)) { 
+		/* rounding overflow */
+		++(*exp);
+		(*fraction) >>= 1;
+	};
+	
+	if (((*exp) >= FLOAT32_MAX_EXPONENT ) || ((*exp) < 0)) {
+		/* overflow - set infinity as result */
+		(*exp) = FLOAT32_MAX_EXPONENT;
+		(*fraction) = 0;
+		return;
+	}
+
+	return;
+}
+
+/** Round and normalize number expressed by exponent and fraction with first bit (equal to hidden bit) at 62. bit
+ * @param exp exponent 
+ * @param fraction part with hidden bit shifted to 62. bit
+ */
+void roundFloat64(int32_t *exp, uint64_t *fraction)
+{
+	/* rounding - if first bit after fraction is set then round up */
+	(*fraction) += (0x1 << 9);
+	
+	if ((*fraction) & (FLOAT64_HIDDEN_BIT_MASK << 11)) { 
+		/* rounding overflow */
+		++(*exp);
+		(*fraction) >>= 1;
+	};
+	
+	if (((*exp) >= FLOAT64_MAX_EXPONENT ) || ((*exp) < 0)) {
+		/* overflow - set infinity as result */
+		(*exp) = FLOAT64_MAX_EXPONENT;
+		(*fraction) = 0;
+		return;
+	}
+
+	return;
+}
+
+/** @}
+ */
+
Index: uspace/softfloat/generic/comparison.c
===================================================================
--- uspace/softfloat/generic/comparison.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
+++ uspace/softfloat/generic/comparison.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup softfloat	
+ * @{
+ */
+/** @file
+ */
+
+#include<sftypes.h>
+#include<comparison.h>
+
+inline int isFloat32NaN(float32 f)
+{	/* NaN : exp = 0xff and nonzero fraction */
+	return ((f.parts.exp==0xFF)&&(f.parts.fraction));
+}
+
+inline int isFloat64NaN(float64 d)
+{	/* NaN : exp = 0x7ff and nonzero fraction */
+	return ((d.parts.exp==0x7FF)&&(d.parts.fraction));
+}
+
+inline int isFloat32SigNaN(float32 f)
+{	/* SigNaN : exp = 0xff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
+	return ((f.parts.exp==0xFF)&&(f.parts.fraction<0x400000)&&(f.parts.fraction));
+}
+
+inline int isFloat64SigNaN(float64 d)
+{	/* SigNaN : exp = 0x7ff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
+	return ((d.parts.exp==0x7FF)&&(d.parts.fraction)&&(d.parts.fraction<0x8000000000000ll));
+}
+
+inline int isFloat32Infinity(float32 f) 
+{
+	return ((f.parts.exp==0xFF)&&(f.parts.fraction==0x0));
+}
+
+inline int isFloat64Infinity(float64 d) 
+{
+	return ((d.parts.exp==0x7FF)&&(d.parts.fraction==0x0));
+}
+
+inline int isFloat32Zero(float32 f)
+{
+	return (((f.binary) & 0x7FFFFFFF) == 0);
+}
+
+inline int isFloat64Zero(float64 d)
+{
+	return (((d.binary) & 0x7FFFFFFFFFFFFFFFll) == 0);
+}
+
+/**
+ * @return 1, if both floats are equal - but NaNs are not recognized 
+ */
+inline int isFloat32eq(float32 a, float32 b)
+{
+	return ((a.binary==b.binary)||(((a.binary| b.binary)&0x7FFFFFFF)==0)); /* a equals to b or both are zeros (with any sign) */
+}
+
+/**
+ * @return 1, if a<b - but NaNs are not recognized 
+ */
+inline int isFloat32lt(float32 a, float32 b) 
+{
+	if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
+		return 0; /* +- zeroes */
+	};
+	
+	if ((a.parts.sign)&&(b.parts.sign)) {
+		/*if both are negative, smaller is that with greater binary value*/
+		return (a.binary>b.binary);
+		};
+	
+	/* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/
+	a.parts.sign=!a.parts.sign;
+	b.parts.sign=!b.parts.sign;
+	return (a.binary<b.binary);
+			
+}
+
+/**
+ * @return 1, if a>b - but NaNs are not recognized 
+ */
+inline int isFloat32gt(float32 a, float32 b) 
+{
+	if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
+		return 0; /* zeroes are equal with any sign */
+	};
+	
+	if ((a.parts.sign)&&(b.parts.sign)) {
+		/*if both are negative, greater is that with smaller binary value*/
+		return (a.binary<b.binary);
+		};
+	
+	/* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/
+	a.parts.sign=!a.parts.sign;
+	b.parts.sign=!b.parts.sign;
+	return (a.binary>b.binary);
+			
+}
+
+/** @}
+ */
Index: uspace/softfloat/generic/conversion.c
===================================================================
--- uspace/softfloat/generic/conversion.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
+++ uspace/softfloat/generic/conversion.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
@@ -0,0 +1,593 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup softfloat	
+ * @{
+ */
+/** @file
+ */
+
+#include "sftypes.h"
+#include "conversion.h"
+#include "comparison.h"
+#include "common.h"
+
+float64 convertFloat32ToFloat64(float32 a) 
+{
+	float64 result;
+	uint64_t frac;
+	
+	result.parts.sign = a.parts.sign;
+	result.parts.fraction = a.parts.fraction;
+	result.parts.fraction <<= (FLOAT64_FRACTION_SIZE - FLOAT32_FRACTION_SIZE );
+	
+	if ((isFloat32Infinity(a))||(isFloat32NaN(a))) {
+		result.parts.exp = 0x7FF;
+		/* TODO; check if its correct for SigNaNs*/
+		return result;
+	};
+	
+	result.parts.exp = a.parts.exp + ( (int)FLOAT64_BIAS - FLOAT32_BIAS );
+	if (a.parts.exp == 0) {
+		/* normalize denormalized numbers */
+
+		if (result.parts.fraction == 0ll) { /* fix zero */
+			result.parts.exp = 0ll;
+			return result;
+		}
+			
+		frac = result.parts.fraction;
+		
+		while (!(frac & (0x10000000000000ll))) {
+			frac <<= 1;
+			--result.parts.exp;
+		};
+		
+		++result.parts.exp;
+		result.parts.fraction = frac;
+	};
+	
+	return result;
+	
+}
+
+float32 convertFloat64ToFloat32(float64 a) 
+{
+	float32 result;
+	int32_t exp;
+	uint64_t frac;
+	
+	result.parts.sign = a.parts.sign;
+	
+	if (isFloat64NaN(a)) {
+		
+		result.parts.exp = 0xFF;
+		
+		if (isFloat64SigNaN(a)) {
+			result.parts.fraction = 0x400000; /* set first bit of fraction nonzero */
+			return result;
+		}
+	
+		result.parts.fraction = 0x1; /* fraction nonzero but its first bit is zero */
+		return result;
+	};
+
+	if (isFloat64Infinity(a)) {
+		result.parts.fraction = 0;
+		result.parts.exp = 0xFF;
+		return result;
+	};
+
+	exp = (int)a.parts.exp - FLOAT64_BIAS + FLOAT32_BIAS;
+	
+	if (exp >= 0xFF) {
+		/*FIXME: overflow*/
+		result.parts.fraction = 0;
+		result.parts.exp = 0xFF;
+		return result;
+		
+	} else if (exp <= 0 ) {
+		
+		/* underflow or denormalized */
+		
+		result.parts.exp = 0;
+		
+		exp *= -1;	
+		if (exp > FLOAT32_FRACTION_SIZE ) {
+			/* FIXME: underflow */
+			result.parts.fraction = 0;
+			return result;
+		};
+		
+		/* denormalized */
+		
+		frac = a.parts.fraction; 
+		frac |= 0x10000000000000ll; /* denormalize and set hidden bit */
+		
+		frac >>= (FLOAT64_FRACTION_SIZE - FLOAT32_FRACTION_SIZE + 1);
+		
+		while (exp > 0) {
+			--exp;
+			frac >>= 1;
+		};
+		result.parts.fraction = frac;
+		
+		return result;
+	};
+
+	result.parts.exp = exp;
+	result.parts.fraction = a.parts.fraction >> (FLOAT64_FRACTION_SIZE - FLOAT32_FRACTION_SIZE);
+	return result;
+}
+
+
+/** Helping procedure for converting float32 to uint32
+ * @param a floating point number in normalized form (no NaNs or Inf are checked )
+ * @return unsigned integer
+ */
+static uint32_t _float32_to_uint32_helper(float32 a)
+{
+	uint32_t frac;
+	
+	if (a.parts.exp < FLOAT32_BIAS) {
+		/*TODO: rounding*/
+		return 0;
+	}
+	
+	frac = a.parts.fraction;
+	
+	frac |= FLOAT32_HIDDEN_BIT_MASK;
+	/* shift fraction to left so hidden bit will be the most significant bit */
+	frac <<= 32 - FLOAT32_FRACTION_SIZE - 1; 
+
+	frac >>= 32 - (a.parts.exp - FLOAT32_BIAS) - 1;
+	if ((a.parts.sign == 1) && (frac != 0)) {
+		frac = ~frac;
+		++frac;
+	}
+	
+	return frac;
+}
+
+/* Convert float to unsigned int32
+ * FIXME: Im not sure what to return if overflow/underflow happens 
+ * 	- now its the biggest or the smallest int
+ */ 
+uint32_t float32_to_uint32(float32 a)
+{
+	if (isFloat32NaN(a)) {
+		return MAX_UINT32;
+	}
+	
+	if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS)))  {
+		if (a.parts.sign) {
+			return MIN_UINT32;
+		}
+		return MAX_UINT32;
+	}
+	
+	return _float32_to_uint32_helper(a);	
+}
+
+/* Convert float to signed int32
+ * FIXME: Im not sure what to return if overflow/underflow happens 
+ * 	- now its the biggest or the smallest int
+ */ 
+int32_t float32_to_int32(float32 a)
+{
+	if (isFloat32NaN(a)) {
+		return MAX_INT32;
+	}
+	
+	if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS)))  {
+		if (a.parts.sign) {
+			return MIN_INT32;
+		}
+		return MAX_INT32;
+	}
+	return _float32_to_uint32_helper(a);
+}	
+
+
+/** Helping procedure for converting float64 to uint64
+ * @param a floating point number in normalized form (no NaNs or Inf are checked )
+ * @return unsigned integer
+ */
+static uint64_t _float64_to_uint64_helper(float64 a)
+{
+	uint64_t frac;
+	
+	if (a.parts.exp < FLOAT64_BIAS) {
+		/*TODO: rounding*/
+		return 0;
+	}
+	
+	frac = a.parts.fraction;
+	
+	frac |= FLOAT64_HIDDEN_BIT_MASK;
+	/* shift fraction to left so hidden bit will be the most significant bit */
+	frac <<= 64 - FLOAT64_FRACTION_SIZE - 1; 
+
+	frac >>= 64 - (a.parts.exp - FLOAT64_BIAS) - 1;
+	if ((a.parts.sign == 1) && (frac != 0)) {
+		frac = ~frac;
+		++frac;
+	}
+	
+	return frac;
+}
+
+/* Convert float to unsigned int64
+ * FIXME: Im not sure what to return if overflow/underflow happens 
+ * 	- now its the biggest or the smallest int
+ */ 
+uint64_t float64_to_uint64(float64 a)
+{
+	if (isFloat64NaN(a)) {
+		return MAX_UINT64;
+	}
+	
+	if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS)))  {
+		if (a.parts.sign) {
+			return MIN_UINT64;
+		}
+		return MAX_UINT64;
+	}
+	
+	return _float64_to_uint64_helper(a);	
+}
+
+/* Convert float to signed int64
+ * FIXME: Im not sure what to return if overflow/underflow happens 
+ * 	- now its the biggest or the smallest int
+ */ 
+int64_t float64_to_int64(float64 a)
+{
+	if (isFloat64NaN(a)) {
+		return MAX_INT64;
+	}
+	
+	if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS)))  {
+		if (a.parts.sign) {
+			return MIN_INT64;
+		}
+		return MAX_INT64;
+	}
+	return _float64_to_uint64_helper(a);
+}	
+
+
+
+
+
+/** Helping procedure for converting float32 to uint64
+ * @param a floating point number in normalized form (no NaNs or Inf are checked )
+ * @return unsigned integer
+ */
+static uint64_t _float32_to_uint64_helper(float32 a)
+{
+	uint64_t frac;
+	
+	if (a.parts.exp < FLOAT32_BIAS) {
+		/*TODO: rounding*/
+		return 0;
+	}
+	
+	frac = a.parts.fraction;
+	
+	frac |= FLOAT32_HIDDEN_BIT_MASK;
+	/* shift fraction to left so hidden bit will be the most significant bit */
+	frac <<= 64 - FLOAT32_FRACTION_SIZE - 1; 
+
+	frac >>= 64 - (a.parts.exp - FLOAT32_BIAS) - 1;
+	if ((a.parts.sign == 1) && (frac != 0)) {
+		frac = ~frac;
+		++frac;
+	}
+	
+	return frac;
+}
+
+/* Convert float to unsigned int64
+ * FIXME: Im not sure what to return if overflow/underflow happens 
+ * 	- now its the biggest or the smallest int
+ */ 
+uint64_t float32_to_uint64(float32 a)
+{
+	if (isFloat32NaN(a)) {
+		return MAX_UINT64;
+	}
+	
+	if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS)))  {
+		if (a.parts.sign) {
+			return MIN_UINT64;
+		}
+		return MAX_UINT64;
+	}
+	
+	return _float32_to_uint64_helper(a);	
+}
+
+/* Convert float to signed int64
+ * FIXME: Im not sure what to return if overflow/underflow happens 
+ * 	- now its the biggest or the smallest int
+ */ 
+int64_t float32_to_int64(float32 a)
+{
+	if (isFloat32NaN(a)) {
+		return MAX_INT64;
+	}
+	
+	if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS)))  {
+		if (a.parts.sign) {
+			return (MIN_INT64);
+		}
+		return MAX_INT64;
+	}
+	return _float32_to_uint64_helper(a);
+}	
+
+
+/* Convert float64 to unsigned int32
+ * FIXME: Im not sure what to return if overflow/underflow happens 
+ * 	- now its the biggest or the smallest int
+ */ 
+uint32_t float64_to_uint32(float64 a)
+{
+	if (isFloat64NaN(a)) {
+		return MAX_UINT32;
+	}
+	
+	if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS)))  {
+		if (a.parts.sign) {
+			return MIN_UINT32;
+		}
+		return MAX_UINT32;
+	}
+	
+	return (uint32_t)_float64_to_uint64_helper(a);	
+}
+
+/* Convert float64 to signed int32
+ * FIXME: Im not sure what to return if overflow/underflow happens 
+ * 	- now its the biggest or the smallest int
+ */ 
+int32_t float64_to_int32(float64 a)
+{
+	if (isFloat64NaN(a)) {
+		return MAX_INT32;
+	}
+	
+	if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS)))  {
+		if (a.parts.sign) {
+			return MIN_INT32;
+		}
+		return MAX_INT32;
+	}
+	return (int32_t)_float64_to_uint64_helper(a);
+}	
+
+/** Convert unsigned integer to float32
+ *
+ *
+ */
+float32 uint32_to_float32(uint32_t i)
+{
+	int counter;
+	int32_t exp;
+	float32 result;
+	
+	result.parts.sign = 0;
+	result.parts.fraction = 0;
+
+	counter = countZeroes32(i);
+
+	exp = FLOAT32_BIAS + 32 - counter - 1;
+	
+	if (counter == 32) {
+		result.binary = 0;
+		return result;
+	}
+	
+	if (counter > 0) {
+		i <<= counter - 1;
+	} else {
+		i >>= 1;
+	}
+
+	roundFloat32(&exp, &i);
+
+	result.parts.fraction = i >> 7;
+	result.parts.exp = exp;
+
+	return result;
+}
+
+float32 int32_to_float32(int32_t i) 
+{
+	float32 result;
+
+	if (i < 0) {
+		result = uint32_to_float32((uint32_t)(-i));
+	} else {
+		result = uint32_to_float32((uint32_t)i);
+	}
+	
+	result.parts.sign = i < 0;
+
+ 	return result;
+}
+
+
+float32 uint64_to_float32(uint64_t i) 
+{
+	int counter;
+	int32_t exp;
+	uint32_t j;
+	float32 result;
+	
+	result.parts.sign = 0;
+	result.parts.fraction = 0;
+
+	counter = countZeroes64(i);
+
+	exp = FLOAT32_BIAS + 64 - counter - 1;
+	
+	if (counter == 64) {
+		result.binary = 0;
+		return result;
+	}
+	
+	/* Shift all to the first 31 bits (31. will be hidden 1)*/
+	if (counter > 33) {
+		i <<= counter - 1 - 32;
+	} else {
+		i >>= 1 + 32 - counter;
+	}
+	
+	j = (uint32_t)i;
+	roundFloat32(&exp, &j);
+
+	result.parts.fraction = j >> 7;
+	result.parts.exp = exp;
+	return result;
+}
+
+float32 int64_to_float32(int64_t i) 
+{
+	float32 result;
+
+	if (i < 0) {
+		result = uint64_to_float32((uint64_t)(-i));
+	} else {
+		result = uint64_to_float32((uint64_t)i);
+	}
+	
+	result.parts.sign = i < 0;
+
+ 	return result;
+}
+
+/** Convert unsigned integer to float64
+ *
+ *
+ */
+float64 uint32_to_float64(uint32_t i)
+{
+	int counter;
+	int32_t exp;
+	float64 result;
+	uint64_t frac;
+	
+	result.parts.sign = 0;
+	result.parts.fraction = 0;
+
+	counter = countZeroes32(i);
+
+	exp = FLOAT64_BIAS + 32 - counter - 1;
+	
+	if (counter == 32) {
+		result.binary = 0;
+		return result;
+	}
+	
+	frac = i;
+	frac <<= counter + 32 - 1; 
+
+	roundFloat64(&exp, &frac);
+
+	result.parts.fraction = frac >> 10;
+	result.parts.exp = exp;
+
+	return result;
+}
+
+float64 int32_to_float64(int32_t i) 
+{
+	float64 result;
+
+	if (i < 0) {
+		result = uint32_to_float64((uint32_t)(-i));
+	} else {
+		result = uint32_to_float64((uint32_t)i);
+	}
+	
+	result.parts.sign = i < 0;
+
+ 	return result;
+}
+
+
+float64 uint64_to_float64(uint64_t i) 
+{
+	int counter;
+	int32_t exp;
+	float64 result;
+	
+	result.parts.sign = 0;
+	result.parts.fraction = 0;
+
+	counter = countZeroes64(i);
+
+	exp = FLOAT64_BIAS + 64 - counter - 1;
+	
+	if (counter == 64) {
+		result.binary = 0;
+		return result;
+	}
+	
+	if (counter > 0) {
+		i <<= counter - 1;
+	} else {
+		i >>= 1;
+	}
+
+	roundFloat64(&exp, &i);
+
+	result.parts.fraction = i >> 10;
+	result.parts.exp = exp;
+	return result;
+}
+
+float64 int64_to_float64(int64_t i) 
+{
+	float64 result;
+
+	if (i < 0) {
+		result = uint64_to_float64((uint64_t)(-i));
+	} else {
+		result = uint64_to_float64((uint64_t)i);
+	}
+	
+	result.parts.sign = i < 0;
+
+ 	return result;
+}
+
+/** @}
+ */
Index: uspace/softfloat/generic/div.c
===================================================================
--- uspace/softfloat/generic/div.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
+++ uspace/softfloat/generic/div.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
@@ -0,0 +1,364 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup softfloat	
+ * @{
+ */
+/** @file
+ */
+
+#include<sftypes.h>
+#include<add.h>
+#include<div.h>
+#include<comparison.h>
+#include<mul.h>
+#include<common.h>
+
+
+float32 divFloat32(float32 a, float32 b) 
+{
+	float32 result;
+	int32_t aexp, bexp, cexp;
+	uint64_t afrac, bfrac, cfrac;
+	
+	result.parts.sign = a.parts.sign ^ b.parts.sign;
+	
+	if (isFloat32NaN(a)) {
+		if (isFloat32SigNaN(a)) {
+			/*FIXME: SigNaN*/
+		}
+		/*NaN*/
+		return a;
+	}
+	
+	if (isFloat32NaN(b)) {
+		if (isFloat32SigNaN(b)) {
+			/*FIXME: SigNaN*/
+		}
+		/*NaN*/
+		return b;
+	}
+	
+	if (isFloat32Infinity(a)) {
+		if (isFloat32Infinity(b)) {
+			/*FIXME: inf / inf */
+			result.binary = FLOAT32_NAN;
+			return result;
+		}
+		/* inf / num */
+		result.parts.exp = a.parts.exp;
+		result.parts.fraction = a.parts.fraction;
+		return result;
+	}
+
+	if (isFloat32Infinity(b)) {
+		if (isFloat32Zero(a)) {
+			/* FIXME 0 / inf */
+			result.parts.exp = 0;
+			result.parts.fraction = 0;
+			return result;
+		}
+		/* FIXME: num / inf*/
+		result.parts.exp = 0;
+		result.parts.fraction = 0;
+		return result;
+	}
+	
+	if (isFloat32Zero(b)) {
+		if (isFloat32Zero(a)) {
+			/*FIXME: 0 / 0*/
+			result.binary = FLOAT32_NAN;
+			return result;
+		}
+		/* FIXME: division by zero */
+		result.parts.exp = 0;
+		result.parts.fraction = 0;
+		return result;
+	}
+
+	
+	afrac = a.parts.fraction;
+	aexp = a.parts.exp;
+	bfrac = b.parts.fraction;
+	bexp = b.parts.exp;
+	
+	/* denormalized numbers */
+	if (aexp == 0) {
+		if (afrac == 0) {
+		result.parts.exp = 0;
+		result.parts.fraction = 0;
+		return result;
+		}
+		/* normalize it*/
+		
+		afrac <<= 1;
+			/* afrac is nonzero => it must stop */	
+		while (! (afrac & FLOAT32_HIDDEN_BIT_MASK) ) {
+			afrac <<= 1;
+			aexp--;
+		}
+	}
+
+	if (bexp == 0) {
+		bfrac <<= 1;
+			/* bfrac is nonzero => it must stop */	
+		while (! (bfrac & FLOAT32_HIDDEN_BIT_MASK) ) {
+			bfrac <<= 1;
+			bexp--;
+		}
+	}
+
+	afrac =	(afrac | FLOAT32_HIDDEN_BIT_MASK ) << (32 - FLOAT32_FRACTION_SIZE - 1 );
+	bfrac =	(bfrac | FLOAT32_HIDDEN_BIT_MASK ) << (32 - FLOAT32_FRACTION_SIZE );
+
+	if ( bfrac <= (afrac << 1) ) {
+		afrac >>= 1;
+		aexp++;
+	}
+	
+	cexp = aexp - bexp + FLOAT32_BIAS - 2;
+	
+	cfrac = (afrac << 32) / bfrac;
+	if ((  cfrac & 0x3F ) == 0) { 
+		cfrac |= ( bfrac * cfrac != afrac << 32 );
+	}
+	
+	/* pack and round */
+	
+	/* find first nonzero digit and shift result and detect possibly underflow */
+	while ((cexp > 0) && (cfrac) && (!(cfrac & (FLOAT32_HIDDEN_BIT_MASK << 7 )))) {
+		cexp--;
+		cfrac <<= 1;
+			/* TODO: fix underflow */
+	};
+	
+	cfrac += (0x1 << 6); /* FIXME: 7 is not sure*/
+	
+	if (cfrac & (FLOAT32_HIDDEN_BIT_MASK << 7)) {
+		++cexp;
+		cfrac >>= 1;
+		}	
+
+	/* check overflow */
+	if (cexp >= FLOAT32_MAX_EXPONENT ) {
+		/* FIXME: overflow, return infinity */
+		result.parts.exp = FLOAT32_MAX_EXPONENT;
+		result.parts.fraction = 0;
+		return result;
+	}
+
+	if (cexp < 0) {
+		/* FIXME: underflow */
+		result.parts.exp = 0;
+		if ((cexp + FLOAT32_FRACTION_SIZE) < 0) {
+			result.parts.fraction = 0;
+			return result;
+		}
+		cfrac >>= 1;
+		while (cexp < 0) {
+			cexp ++;
+			cfrac >>= 1;
+		}
+		
+	} else {
+		result.parts.exp = (uint32_t)cexp;
+	}
+	
+	result.parts.fraction = ((cfrac >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)); 
+	
+	return result;	
+}
+
+float64 divFloat64(float64 a, float64 b) 
+{
+	float64 result;
+	int64_t aexp, bexp, cexp;
+	uint64_t afrac, bfrac, cfrac; 
+	uint64_t remlo, remhi;
+	
+	result.parts.sign = a.parts.sign ^ b.parts.sign;
+	
+	if (isFloat64NaN(a)) {
+		
+		if (isFloat64SigNaN(b)) {
+			/*FIXME: SigNaN*/
+			return b;
+		}
+		
+		if (isFloat64SigNaN(a)) {
+			/*FIXME: SigNaN*/
+		}
+		/*NaN*/
+		return a;
+	}
+	
+	if (isFloat64NaN(b)) {
+		if (isFloat64SigNaN(b)) {
+			/*FIXME: SigNaN*/
+		}
+		/*NaN*/
+		return b;
+	}
+	
+	if (isFloat64Infinity(a)) {
+		if (isFloat64Infinity(b) || isFloat64Zero(b)) {
+			/*FIXME: inf / inf */
+			result.binary = FLOAT64_NAN;
+			return result;
+		}
+		/* inf / num */
+		result.parts.exp = a.parts.exp;
+		result.parts.fraction = a.parts.fraction;
+		return result;
+	}
+
+	if (isFloat64Infinity(b)) {
+		if (isFloat64Zero(a)) {
+			/* FIXME 0 / inf */
+			result.parts.exp = 0;
+			result.parts.fraction = 0;
+			return result;
+		}
+		/* FIXME: num / inf*/
+		result.parts.exp = 0;
+		result.parts.fraction = 0;
+		return result;
+	}
+	
+	if (isFloat64Zero(b)) {
+		if (isFloat64Zero(a)) {
+			/*FIXME: 0 / 0*/
+			result.binary = FLOAT64_NAN;
+			return result;
+		}
+		/* FIXME: division by zero */
+		result.parts.exp = 0;
+		result.parts.fraction = 0;
+		return result;
+	}
+
+	
+	afrac = a.parts.fraction;
+	aexp = a.parts.exp;
+	bfrac = b.parts.fraction;
+	bexp = b.parts.exp;
+	
+	/* denormalized numbers */
+	if (aexp == 0) {
+		if (afrac == 0) {
+			result.parts.exp = 0;
+			result.parts.fraction = 0;
+			return result;
+		}
+		/* normalize it*/
+		
+		aexp++;
+			/* afrac is nonzero => it must stop */	
+		while (! (afrac & FLOAT64_HIDDEN_BIT_MASK) ) {
+			afrac <<= 1;
+			aexp--;
+		}
+	}
+
+	if (bexp == 0) {
+		bexp++;
+			/* bfrac is nonzero => it must stop */	
+		while (! (bfrac & FLOAT64_HIDDEN_BIT_MASK) ) {
+			bfrac <<= 1;
+			bexp--;
+		}
+	}
+
+	afrac =	(afrac | FLOAT64_HIDDEN_BIT_MASK ) << (64 - FLOAT64_FRACTION_SIZE - 2 );
+	bfrac =	(bfrac | FLOAT64_HIDDEN_BIT_MASK ) << (64 - FLOAT64_FRACTION_SIZE - 1);
+
+	if ( bfrac <= (afrac << 1) ) {
+		afrac >>= 1;
+		aexp++;
+	}
+	
+	cexp = aexp - bexp + FLOAT64_BIAS - 2; 
+	
+	cfrac = divFloat64estim(afrac, bfrac);
+	
+	if ((  cfrac & 0x1FF ) <= 2) { /*FIXME:?? */
+		mul64integers( bfrac, cfrac, &remlo, &remhi);
+		/* (__u128)afrac << 64 - ( ((__u128)remhi<<64) + (__u128)remlo )*/	
+		remhi = afrac - remhi - ( remlo > 0);
+		remlo = - remlo;
+		
+		while ((int64_t) remhi < 0) {
+			cfrac--;
+			remlo += bfrac;
+			remhi += ( remlo < bfrac );
+		}
+		cfrac |= ( remlo != 0 );
+	}
+	
+	/* round and shift */
+	result = finishFloat64(cexp, cfrac, result.parts.sign);
+	return result;
+
+}
+
+uint64_t divFloat64estim(uint64_t a, uint64_t b)
+{
+	uint64_t bhi;
+	uint64_t remhi, remlo;
+	uint64_t result;
+	
+	if ( b <= a ) {
+		return 0xFFFFFFFFFFFFFFFFull;
+	}
+	
+	bhi = b >> 32;
+	result = ((bhi << 32) <= a) ?( 0xFFFFFFFFull << 32) : ( a / bhi) << 32;
+	mul64integers(b, result, &remlo, &remhi);
+	
+	remhi = a - remhi - (remlo > 0);
+	remlo = - remlo;
+
+	b <<= 32;
+	while ( (int64_t) remhi < 0 ) {
+			result -= 0x1ll << 32;	
+			remlo += b;
+			remhi += bhi + ( remlo < b );
+		}
+	remhi = (remhi << 32) | (remlo >> 32);
+	if (( bhi << 32) <= remhi) {
+		result |= 0xFFFFFFFF;
+	} else {
+		result |= remhi / bhi;
+	}
+	
+	
+	return result;
+}
+
+/** @}
+ */
Index: uspace/softfloat/generic/mul.c
===================================================================
--- uspace/softfloat/generic/mul.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
+++ uspace/softfloat/generic/mul.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
@@ -0,0 +1,294 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup softfloat	
+ * @{
+ */
+/** @file
+ */
+
+#include<sftypes.h>
+#include<mul.h>
+#include<comparison.h>
+#include<common.h>
+
+/** Multiply two 32 bit float numbers
+ *
+ */
+float32 mulFloat32(float32 a, float32 b)
+{
+	float32 result;
+	uint64_t frac1, frac2;
+	int32_t exp;
+
+	result.parts.sign = a.parts.sign ^ b.parts.sign;
+	
+	if (isFloat32NaN(a) || isFloat32NaN(b) ) {
+		/* TODO: fix SigNaNs */
+		if (isFloat32SigNaN(a)) {
+			result.parts.fraction = a.parts.fraction;
+			result.parts.exp = a.parts.exp;
+			return result;
+		};
+		if (isFloat32SigNaN(b)) { /* TODO: fix SigNaN */
+			result.parts.fraction = b.parts.fraction;
+			result.parts.exp = b.parts.exp;
+			return result;
+		};
+		/* set NaN as result */
+		result.binary = FLOAT32_NAN;
+		return result;
+	};
+		
+	if (isFloat32Infinity(a)) { 
+		if (isFloat32Zero(b)) {
+			/* FIXME: zero * infinity */
+			result.binary = FLOAT32_NAN;
+			return result;
+		}
+		result.parts.fraction = a.parts.fraction;
+		result.parts.exp = a.parts.exp;
+		return result;
+	}
+
+	if (isFloat32Infinity(b)) { 
+		if (isFloat32Zero(a)) {
+			/* FIXME: zero * infinity */
+			result.binary = FLOAT32_NAN;
+			return result;
+		}
+		result.parts.fraction = b.parts.fraction;
+		result.parts.exp = b.parts.exp;
+		return result;
+	}
+
+	/* exp is signed so we can easy detect underflow */
+	exp = a.parts.exp + b.parts.exp;
+	exp -= FLOAT32_BIAS;
+	
+	if (exp >= FLOAT32_MAX_EXPONENT) {
+		/* FIXME: overflow */
+		/* set infinity as result */
+		result.binary = FLOAT32_INF;
+		result.parts.sign = a.parts.sign ^ b.parts.sign;
+		return result;
+	};
+	
+	if (exp < 0) { 
+		/* FIXME: underflow */
+		/* return signed zero */
+		result.parts.fraction = 0x0;
+		result.parts.exp = 0x0;
+		return result;
+	};
+	
+	frac1 = a.parts.fraction;
+	if (a.parts.exp > 0) {
+		frac1 |= FLOAT32_HIDDEN_BIT_MASK;
+	} else {
+		++exp;
+	};
+	
+	frac2 = b.parts.fraction;
+
+	if (b.parts.exp > 0) {
+		frac2 |= FLOAT32_HIDDEN_BIT_MASK;
+	} else {
+		++exp;
+	};
+
+	frac1 <<= 1; /* one bit space for rounding */
+
+	frac1 = frac1 * frac2;
+/* round and return */
+	
+	while ((exp < FLOAT32_MAX_EXPONENT) && (frac1 >= ( 1 << (FLOAT32_FRACTION_SIZE + 2)))) { 
+		/* 23 bits of fraction + one more for hidden bit (all shifted 1 bit left)*/
+		++exp;
+		frac1 >>= 1;
+	};
+
+	/* rounding */
+	/* ++frac1; FIXME: not works - without it is ok */
+	frac1 >>= 1; /* shift off rounding space */
+	
+	if ((exp < FLOAT32_MAX_EXPONENT) && (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 1)))) {
+		++exp;
+		frac1 >>= 1;
+	};
+
+	if (exp >= FLOAT32_MAX_EXPONENT ) {	
+		/* TODO: fix overflow */
+		/* return infinity*/
+		result.parts.exp = FLOAT32_MAX_EXPONENT;
+		result.parts.fraction = 0x0;
+		return result;
+	}
+	
+	exp -= FLOAT32_FRACTION_SIZE;
+
+	if (exp <= FLOAT32_FRACTION_SIZE) { 
+		/* denormalized number */
+		frac1 >>= 1; /* denormalize */
+		while ((frac1 > 0) && (exp < 0)) {
+			frac1 >>= 1;
+			++exp;
+		};
+		if (frac1 == 0) {
+			/* FIXME : underflow */
+		result.parts.exp = 0;
+		result.parts.fraction = 0;
+		return result;
+		};
+	};
+	result.parts.exp = exp; 
+	result.parts.fraction = frac1 & ( (1 << FLOAT32_FRACTION_SIZE) - 1);
+	
+	return result;	
+	
+}
+
+/** Multiply two 64 bit float numbers
+ *
+ */
+float64 mulFloat64(float64 a, float64 b)
+{
+	float64 result;
+	uint64_t frac1, frac2;
+	int32_t exp;
+
+	result.parts.sign = a.parts.sign ^ b.parts.sign;
+	
+	if (isFloat64NaN(a) || isFloat64NaN(b) ) {
+		/* TODO: fix SigNaNs */
+		if (isFloat64SigNaN(a)) {
+			result.parts.fraction = a.parts.fraction;
+			result.parts.exp = a.parts.exp;
+			return result;
+		};
+		if (isFloat64SigNaN(b)) { /* TODO: fix SigNaN */
+			result.parts.fraction = b.parts.fraction;
+			result.parts.exp = b.parts.exp;
+			return result;
+		};
+		/* set NaN as result */
+		result.binary = FLOAT64_NAN;
+		return result;
+	};
+		
+	if (isFloat64Infinity(a)) { 
+		if (isFloat64Zero(b)) {
+			/* FIXME: zero * infinity */
+			result.binary = FLOAT64_NAN;
+			return result;
+		}
+		result.parts.fraction = a.parts.fraction;
+		result.parts.exp = a.parts.exp;
+		return result;
+	}
+
+	if (isFloat64Infinity(b)) { 
+		if (isFloat64Zero(a)) {
+			/* FIXME: zero * infinity */
+			result.binary = FLOAT64_NAN;
+			return result;
+		}
+		result.parts.fraction = b.parts.fraction;
+		result.parts.exp = b.parts.exp;
+		return result;
+	}
+
+	/* exp is signed so we can easy detect underflow */
+	exp = a.parts.exp + b.parts.exp - FLOAT64_BIAS;
+	
+	frac1 = a.parts.fraction;
+
+	if (a.parts.exp > 0) {
+		frac1 |= FLOAT64_HIDDEN_BIT_MASK;
+	} else {
+		++exp;
+	};
+	
+	frac2 = b.parts.fraction;
+
+	if (b.parts.exp > 0) {
+		frac2 |= FLOAT64_HIDDEN_BIT_MASK;
+	} else {
+		++exp;
+	};
+
+	frac1 <<= (64 - FLOAT64_FRACTION_SIZE - 1);
+	frac2 <<= (64 - FLOAT64_FRACTION_SIZE - 2);
+
+	mul64integers(frac1, frac2, &frac1, &frac2);
+
+	frac2 |= (frac1 != 0);
+	if (frac2 & (0x1ll << 62)) {
+		frac2 <<= 1;
+		exp--;
+	}
+
+	result = finishFloat64(exp, frac2, result.parts.sign);
+	return result;
+}
+
+/** Multiply two 64 bit numbers and return result in two parts
+ * @param a first operand
+ * @param b second operand
+ * @param lo lower part from result
+ * @param hi higher part of result
+ */
+void mul64integers(uint64_t a,uint64_t b, uint64_t *lo, uint64_t *hi)
+{
+	uint64_t low, high, middle1, middle2;
+	uint32_t alow, blow;
+
+	alow = a & 0xFFFFFFFF;
+	blow = b & 0xFFFFFFFF;
+	
+	a >>= 32;
+	b >>= 32;
+	
+	low = ((uint64_t)alow) * blow;
+	middle1 = a * blow;
+	middle2 = alow * b;
+	high = a * b;
+
+	middle1 += middle2;
+	high += (((uint64_t)(middle1 < middle2)) << 32) + (middle1 >> 32);
+	middle1 <<= 32;
+	low += middle1;
+	high += (low < middle1);
+	*lo = low;
+	*hi = high;
+	
+	return;
+}
+
+/** @}
+ */
Index: uspace/softfloat/generic/other.c
===================================================================
--- uspace/softfloat/generic/other.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
+++ uspace/softfloat/generic/other.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup softfloat	
+ * @{
+ */
+/** @file
+ */
+
+
+/** @}
+ */
Index: uspace/softfloat/generic/softfloat.c
===================================================================
--- uspace/softfloat/generic/softfloat.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
+++ uspace/softfloat/generic/softfloat.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
@@ -0,0 +1,499 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup softfloat generic
+ * @ingroup sfl
+ * @brief Architecture independent parts of FPU software emulation library.
+ * @{
+ */
+/** @file
+ */
+
+#include<softfloat.h>
+#include<sftypes.h>
+
+#include<add.h>
+#include<sub.h>
+#include<mul.h>
+#include<div.h>
+
+#include<conversion.h>
+#include<comparison.h>
+#include<other.h>
+
+#include<functions.h>
+
+/* Arithmetic functions */
+
+float __addsf3(float a, float b)
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	if (fa.parts.sign != fb.parts.sign) {
+		if (fa.parts.sign) {
+			fa.parts.sign = 0;
+			return subFloat32(fb, fa).f;
+		};
+		fb.parts.sign = 0;
+		return subFloat32(fa, fb).f;
+	}
+	return addFloat32(fa, fb).f;
+}
+
+double __adddf3(double a, double b)
+{
+	float64 da, db;
+	da.d = a;
+	db.d = b;
+	if (da.parts.sign != db.parts.sign) {
+		if (da.parts.sign) {
+			da.parts.sign = 0;
+			return subFloat64(db, da).d;
+		};
+		db.parts.sign = 0;
+		return subFloat64(da, db).d;
+	}
+	return addFloat64(da, db).d;
+}
+
+float __subsf3(float a, float b)
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	if (fa.parts.sign != fb.parts.sign) {
+		fb.parts.sign = !fb.parts.sign;
+		return addFloat32(fa, fb).f;
+	}
+	return subFloat32(fa, fb).f;
+}
+
+double __subdf3(double a, double b)
+{
+	float64 da, db;
+	da.d = a;
+	db.d = b;
+	if (da.parts.sign != db.parts.sign) {
+		db.parts.sign = !db.parts.sign;
+		return addFloat64(da, db).d;
+	}
+	return subFloat64(da, db).d;
+}
+
+float __mulsf3(float a, float b) 
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	return 	mulFloat32(fa, fb).f;
+}
+
+double __muldf3(double a, double b) 
+{
+	float64 da, db;
+	da.d = a;
+	db.d = b;
+	return 	mulFloat64(da, db).d;
+}
+
+float __divsf3(float a, float b) 
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	return 	divFloat32(fa, fb).f;
+}
+
+double __divdf3(double a, double b) 
+{
+	float64 da, db;
+	da.d = a;
+	db.d = b;
+	return 	divFloat64(da, db).d;
+}
+
+float __negsf2(float a)
+{
+	float32 fa;
+	fa.f = a;
+	fa.parts.sign = !fa.parts.sign;
+	return fa.f;
+}
+
+double __negdf2(double a)
+{
+	float64 fa;
+	fa.d = a;
+	fa.parts.sign = !fa.parts.sign;
+	return fa.d;
+}
+
+/* Conversion functions */
+
+double __extendsfdf2(float a) 
+{
+	float32 fa;
+	fa.f = a;
+	return convertFloat32ToFloat64(fa).d;
+}
+
+float __truncdfsf2(double a) 
+{
+	float64 da;
+	da.d = a;
+	return convertFloat64ToFloat32(da).f;
+}
+
+int __fixsfsi(float a)
+{
+	float32 fa;
+	fa.f = a;
+	
+	return float32_to_int(fa);
+}
+int __fixdfsi(double a)
+{
+	float64 da;
+	da.d = a;
+	
+	return float64_to_int(da);
+}
+ 
+long __fixsfdi(float a)
+{
+	float32 fa;
+	fa.f = a;
+	
+	return float32_to_long(fa);
+}
+long __fixdfdi(double a)
+{
+	float64 da;
+	da.d = a;
+	
+	return float64_to_long(da);
+}
+ 
+long long __fixsfti(float a)
+{
+	float32 fa;
+	fa.f = a;
+	
+	return float32_to_longlong(fa);
+}
+long long __fixdfti(double a)
+{
+	float64 da;
+	da.d = a;
+	
+	return float64_to_longlong(da);
+}
+
+unsigned int __fixunssfsi(float a)
+{
+	float32 fa;
+	fa.f = a;
+	
+	return float32_to_uint(fa);
+}
+unsigned int __fixunsdfsi(double a)
+{
+	float64 da;
+	da.d = a;
+	
+	return float64_to_uint(da);
+}
+ 
+unsigned long __fixunssfdi(float a)
+{
+	float32 fa;
+	fa.f = a;
+	
+	return float32_to_ulong(fa);
+}
+unsigned long __fixunsdfdi(double a)
+{
+	float64 da;
+	da.d = a;
+	
+	return float64_to_ulong(da);
+}
+ 
+unsigned long long __fixunssfti(float a)
+{
+	float32 fa;
+	fa.f = a;
+	
+	return float32_to_ulonglong(fa);
+}
+unsigned long long __fixunsdfti(double a)
+{
+	float64 da;
+	da.d = a;
+	
+	return float64_to_ulonglong(da);
+}
+ 
+float __floatsisf(int i)
+{
+	float32 fa;
+	
+	fa = int_to_float32(i);
+	return fa.f;
+}
+double __floatsidf(int i)
+{
+	float64 da;
+	
+	da = int_to_float64(i);
+	return da.d;
+}
+ 
+float __floatdisf(long i)
+{
+	float32 fa;
+	
+	fa = long_to_float32(i);
+	return fa.f;
+}
+double __floatdidf(long i)
+{
+	float64 da;
+	
+	da = long_to_float64(i);
+	return da.d;
+}
+ 
+float __floattisf(long long i)
+{
+	float32 fa;
+	
+	fa = longlong_to_float32(i);
+	return fa.f;
+}
+double __floattidf(long long i)
+{
+	float64 da;
+	
+	da = longlong_to_float64(i);
+	return da.d;
+}
+
+float __floatunsisf(unsigned int i)
+{
+	float32 fa;
+	
+	fa = uint_to_float32(i);
+	return fa.f;
+}
+double __floatunsidf(unsigned int i)
+{
+	float64 da;
+	
+	da = uint_to_float64(i);
+	return da.d;
+}
+ 
+float __floatundisf(unsigned long i)
+{
+	float32 fa;
+	
+	fa = ulong_to_float32(i);
+	return fa.f;
+}
+double __floatundidf(unsigned long i)
+{
+	float64 da;
+	
+	da = ulong_to_float64(i);
+	return da.d;
+}
+ 
+float __floatuntisf(unsigned long long i)
+{
+	float32 fa;
+	
+	fa = ulonglong_to_float32(i);
+	return fa.f;
+}
+double __floatuntidf(unsigned long long i)
+{
+	float64 da;
+	
+	da = ulonglong_to_float64(i);
+	return da.d;
+}
+
+/* Comparison functions */
+/* Comparison functions */
+
+/* a<b .. -1
+ * a=b ..  0
+ * a>b ..  1
+ * */
+
+int __cmpsf2(float a, float b) 
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) {
+		return 1; /* no special constant for unordered - maybe signaled? */
+	};
+
+	
+	if (isFloat32eq(fa, fb)) {
+		return 0;
+	};
+	
+	if (isFloat32lt(fa, fb)) {
+		return -1;
+		};
+	return 1;
+}
+
+int __unordsf2(float a, float b) 
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	return ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) );
+}
+
+/** 
+ * @return zero, if neither argument is a NaN and are equal
+ * */
+int __eqsf2(float a, float b) 
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) {
+		/* TODO: sigNaNs*/
+		return 1;
+		};
+	return isFloat32eq(fa, fb) - 1;
+}
+
+/* strange behavior, but it was in gcc documentation */
+int __nesf2(float a, float b) 
+{
+	return __eqsf2(a, b);
+}
+
+/* return value >= 0 if a>=b and neither is NaN */
+int __gesf2(float a, float b)
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) {
+		/* TODO: sigNaNs*/
+		return -1;
+		};
+	
+	if (isFloat32eq(fa, fb)) {
+		return 0;
+	};
+	
+	if (isFloat32gt(fa, fb)) {
+		return 1;
+		};
+	
+	return -1;
+}
+
+/** Return negative value, if a<b and neither is NaN*/
+int __ltsf2(float a, float b)
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) {
+		/* TODO: sigNaNs*/
+		return 1;
+		};
+	if (isFloat32lt(fa, fb)) {
+		return -1;
+		};
+	return 0;
+}
+
+/* return value <= 0 if a<=b and neither is NaN */
+int __lesf2(float a, float b)
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) {
+		/* TODO: sigNaNs*/
+		return 1;
+		};
+	
+	if (isFloat32eq(fa, fb)) {
+		return 0;
+	};
+	
+	if (isFloat32lt(fa, fb)) {
+		return -1;
+		};
+	
+	return 1;
+}
+
+/** Return positive value, if a>b and neither is NaN*/
+int __gtsf2(float a, float b)
+{
+	float32 fa, fb;
+	fa.f = a;
+	fb.f = b;
+	if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) {
+		/* TODO: sigNaNs*/
+		return -1;
+		};
+	if (isFloat32gt(fa, fb)) {
+		return 1;
+		};
+	return 0;
+}
+
+/* Other functions */
+
+float __powisf2(float a, int b)
+{
+/* TODO: */
+	float32 fa;
+	fa.binary = FLOAT32_NAN;
+	return fa.f;
+}
+
+
+/** @}
+ */
+
Index: uspace/softfloat/generic/sub.c
===================================================================
--- uspace/softfloat/generic/sub.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
+++ uspace/softfloat/generic/sub.c	(revision 0166e99928c90c6d2e990c69a7aaf84a6f93c6c0)
@@ -0,0 +1,265 @@
+/*
+ * Copyright (C) 2005 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ /** @addtogroup softfloat	
+ * @{
+ */
+/** @file
+ */
+
+#include<sftypes.h>
+#include<sub.h>
+#include<comparison.h>
+
+/** Subtract two float32 numbers with same signs
+ */
+float32 subFloat32(float32 a, float32 b)
+{
+	int expdiff;
+	uint32_t exp1, exp2, frac1, frac2;
+	float32 result;
+
+	result.f = 0;
+	
+	expdiff = a.parts.exp - b.parts.exp;
+	if ((expdiff < 0 ) || ((expdiff == 0) && (a.parts.fraction < b.parts.fraction))) {
+		if (isFloat32NaN(b)) {
+			/* TODO: fix SigNaN */
+			if (isFloat32SigNaN(b)) {
+			};
+			return b;
+		};
+		
+		if (b.parts.exp == FLOAT32_MAX_EXPONENT) { 
+			b.parts.sign = !b.parts.sign; /* num -(+-inf) = -+inf */
+			return b;
+		}
+		
+		result.parts.sign = !a.parts.sign; 
+		
+		frac1 = b.parts.fraction;
+		exp1 = b.parts.exp;
+		frac2 = a.parts.fraction;
+		exp2 = a.parts.exp;
+		expdiff *= -1;
+	} else {
+		if (isFloat32NaN(a)) {
+			/* TODO: fix SigNaN */
+			if (isFloat32SigNaN(a) || isFloat32SigNaN(b)) {
+			};
+			return a;
+		};
+		
+		if (a.parts.exp == FLOAT32_MAX_EXPONENT) { 
+			if (b.parts.exp == FLOAT32_MAX_EXPONENT) {
+				/* inf - inf => nan */
+				/* TODO: fix exception */
+				result.binary = FLOAT32_NAN;
+				return result;
+			};
+			return a;
+		}
+		
+		result.parts.sign = a.parts.sign;
+		
+		frac1 = a.parts.fraction;
+		exp1 = a.parts.exp;
+		frac2 = b.parts.fraction;
+		exp2 = b.parts.exp;	
+	};
+	
+	if (exp1 == 0) {
+		/* both are denormalized */
+		result.parts.fraction = frac1-frac2;
+		if (result.parts.fraction > frac1) {
+			/* TODO: underflow exception */
+			return result;
+		};
+		result.parts.exp = 0;
+		return result;
+	};
+
+	/* add hidden bit */
+	frac1 |= FLOAT32_HIDDEN_BIT_MASK; 
+	
+	if (exp2 == 0) {
+		/* denormalized */
+		--expdiff;	
+	} else {
+		/* normalized */
+		frac2 |= FLOAT32_HIDDEN_BIT_MASK;
+	};
+	
+	/* create some space for rounding */
+	frac1 <<= 6;
+	frac2 <<= 6;
+	
+	if (expdiff > FLOAT32_FRACTION_SIZE + 1) {
+	     goto done;	
+	     };
+	
+	frac1 = frac1 - (frac2 >> expdiff);
+done:
+	/* TODO: find first nonzero digit and shift result and detect possibly underflow */
+	while ((exp1 > 0) && (!(frac1 & (FLOAT32_HIDDEN_BIT_MASK << 6 )))) {
+		--exp1;
+		frac1 <<= 1;
+			/* TODO: fix underflow - frac1 == 0 does not necessary means underflow... */
+	};
+	
+	/* rounding - if first bit after fraction is set then round up */
+	frac1 += 0x20;
+
+	if (frac1 & (FLOAT32_HIDDEN_BIT_MASK << 7)) {
+		++exp1;
+		frac1 >>= 1;
+	};
+	
+	/*Clear hidden bit and shift */
+	result.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)); 
+	result.parts.exp = exp1;
+	
+	return result;
+}
+
+/** Subtract two float64 numbers with same signs
+ */
+float64 subFloat64(float64 a, float64 b)
+{
+	int expdiff;
+	uint32_t exp1, exp2;
+	uint64_t frac1, frac2;
+	float64 result;
+
+	result.d = 0;
+	
+	expdiff = a.parts.exp - b.parts.exp;
+	if ((expdiff < 0 ) || ((expdiff == 0) && (a.parts.fraction < b.parts.fraction))) {
+		if (isFloat64NaN(b)) {
+			/* TODO: fix SigNaN */
+			if (isFloat64SigNaN(b)) {
+			};
+			return b;
+		};
+		
+		if (b.parts.exp == FLOAT64_MAX_EXPONENT) { 
+			b.parts.sign = !b.parts.sign; /* num -(+-inf) = -+inf */
+			return b;
+		}
+		
+		result.parts.sign = !a.parts.sign; 
+		
+		frac1 = b.parts.fraction;
+		exp1 = b.parts.exp;
+		frac2 = a.parts.fraction;
+		exp2 = a.parts.exp;
+		expdiff *= -1;
+	} else {
+		if (isFloat64NaN(a)) {
+			/* TODO: fix SigNaN */
+			if (isFloat64SigNaN(a) || isFloat64SigNaN(b)) {
+			};
+			return a;
+		};
+		
+		if (a.parts.exp == FLOAT64_MAX_EXPONENT) { 
+			if (b.parts.exp == FLOAT64_MAX_EXPONENT) {
+				/* inf - inf => nan */
+				/* TODO: fix exception */
+				result.binary = FLOAT64_NAN;
+				return result;
+			};
+			return a;
+		}
+		
+		result.parts.sign = a.parts.sign;
+		
+		frac1 = a.parts.fraction;
+		exp1 = a.parts.exp;
+		frac2 = b.parts.fraction;
+		exp2 = b.parts.exp;	
+	};
+	
+	if (exp1 == 0) {
+		/* both are denormalized */
+		result.parts.fraction = frac1 - frac2;
+		if (result.parts.fraction > frac1) {
+			/* TODO: underflow exception */
+			return result;
+		};
+		result.parts.exp = 0;
+		return result;
+	};
+
+	/* add hidden bit */
+	frac1 |= FLOAT64_HIDDEN_BIT_MASK; 
+	
+	if (exp2 == 0) {
+		/* denormalized */
+		--expdiff;	
+	} else {
+		/* normalized */
+		frac2 |= FLOAT64_HIDDEN_BIT_MASK;
+	};
+	
+	/* create some space for rounding */
+	frac1 <<= 6;
+	frac2 <<= 6;
+	
+	if (expdiff > FLOAT64_FRACTION_SIZE + 1) {
+	     goto done;	
+	     };
+	
+	frac1 = frac1 - (frac2 >> expdiff);
+done:
+	/* TODO: find first nonzero digit and shift result and detect possibly underflow */
+	while ((exp1 > 0) && (!(frac1 & (FLOAT64_HIDDEN_BIT_MASK << 6 )))) {
+		--exp1;
+		frac1 <<= 1;
+			/* TODO: fix underflow - frac1 == 0 does not necessary means underflow... */
+	};
+	
+	/* rounding - if first bit after fraction is set then round up */
+	frac1 += 0x20;
+
+	if (frac1 & (FLOAT64_HIDDEN_BIT_MASK << 7)) {
+		++exp1;
+		frac1 >>= 1;
+	};
+	
+	/*Clear hidden bit and shift */
+	result.parts.fraction = ((frac1 >> 6) & (~FLOAT64_HIDDEN_BIT_MASK)); 
+	result.parts.exp = exp1;
+	
+	return result;
+}
+
+
+ /** @}
+ */
+
