about summary refs log tree commit diff stats
path: root/miasm2/jitter/op_semantics.c
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2018-08-30 14:42:08 +0200
committerAjax <commial@gmail.com>2018-09-03 19:07:21 +0200
commitecf6cac84d3330c923a6c65bb424e2911f9065a6 (patch)
treed1f859ada761e3abe2391b161661d84d6eacff16 /miasm2/jitter/op_semantics.c
parent579d439700d1944f067a2c28d4aa9ea6736d631a (diff)
downloadmiasm-ecf6cac84d3330c923a6c65bb424e2911f9065a6.tar.gz
miasm-ecf6cac84d3330c923a6c65bb424e2911f9065a6.zip
Add support for more FP operations, expand fxam
Diffstat (limited to 'miasm2/jitter/op_semantics.c')
-rw-r--r--miasm2/jitter/op_semantics.c102
1 files changed, 6 insertions, 96 deletions
diff --git a/miasm2/jitter/op_semantics.c b/miasm2/jitter/op_semantics.c
index c3e11189..a0c2316e 100644
--- a/miasm2/jitter/op_semantics.c
+++ b/miasm2/jitter/op_semantics.c
@@ -582,49 +582,26 @@ uint64_t fpu_fsqrt64(uint64_t a)
 	return *((uint64_t*)&b);
 }
 
-double fpu_fabs(double a)
+uint64_t fpu_fabs64(uint64_t a)
 {
 	double b;
-	b = abs(a);
+	b = abs(*((double*)&a));
 #ifdef DEBUG_MIASM_DOUBLE
 	dump_float();
 	printf("%e abs %e\n", a, b);
 #endif
-	return b;
+	return *((uint64_t*)&b);
 }
 
-double fpu_fprem(double a, double b)
+uint64_t fpu_fprem64(uint64_t a, uint64_t b)
 {
 	double c;
-	c = fmod(a, b);
+	c = fmod(*((double*)&a), *((double*)&b));
 #ifdef DEBUG_MIASM_DOUBLE
 	dump_float();
 	printf("%e %% %e -> %e\n", a, b, c);
 #endif
-	return c;
-}
-
-unsigned int fpu_fprem_lsb(double a, double b)
-{
-	// Inspired from qemu/fpu_helper.c
-	double c;
-	signed long long int q;
-	c = a / b; /* ST0 / ST1 */
-	/* round dblq towards zero */
-	c = (c < 0.0) ? ceil(c) : floor(c);
-
-	/* convert dblq to q by truncating towards zero */
-	if (c < 0.0) {
-	    q = (signed long long int)(-c);
-	} else {
-	    q = (signed long long int)c;
-	}
-#ifdef DEBUG_MIASM_DOUBLE
-	dump_float();
-	printf("%e %% %e -> %d %d %d\n", a, b, q & 0x4,
-	       q & 0x2, q & 0x1);
-#endif
-	return q;
+	return *((uint64_t*)&c);
 }
 
 double fpu_fchs(double a)
@@ -688,73 +665,6 @@ unsigned int fpu_fcom_c3(double a, double b)
 	return 0;
 }
 
-unsigned int fpu_fxam_c0(double a)
-{
-	switch(fpclassify(a)) {
-		case FP_NAN:
-			return 1;
-		case FP_NORMAL:
-			return 0;
-		case FP_INFINITE:
-			return 1;
-		case FP_ZERO:
-			return 0;
-		case FP_SUBNORMAL:
-			return 0;
-		default:
-			// ClassEmpty
-			// ClassUnsupported
-			return 0;
-	}
-}
-
-unsigned int fpu_fxam_c1(double a)
-{
-	if ((a < 0) || isnan(a))
-		return 1;
-	return 0;
-}
-
-unsigned int fpu_fxam_c2(double a)
-{
-	switch(fpclassify(a)) {
-		case FP_NAN:
-			return 0;
-		case FP_NORMAL:
-			return 1;
-		case FP_INFINITE:
-			return 1;
-		case FP_ZERO:
-			return 0;
-		case FP_SUBNORMAL:
-			return 1;
-		default:
-			// ClassEmpty
-			// ClassUnsupported
-			return 0;
-	}
-}
-
-unsigned int fpu_fxam_c3(double a)
-{
-	switch(fpclassify(a)) {
-		case FP_NAN:
-			return 0;
-		case FP_NORMAL:
-			return 0;
-		case FP_INFINITE:
-			return 0;
-		case FP_ZERO:
-			return 1;
-		case FP_SUBNORMAL:
-			return 1;
-		default:
-			// ClassEmpty
-			// ClassUnsupported
-			return 0;
-	}
-}
-
 uint64_t sint_to_fp_64(int64_t a)
 {
 	double result = (double) a;