about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2015-11-10 14:58:49 +0100
committerAjax <commial@gmail.com>2015-11-10 14:58:49 +0100
commit206d16bad7f4a98b1be30ac9db0c4798e363c550 (patch)
tree8867491a556c01d2659c2ab6ba8804100a9188ac
parent4807c50299bdaa0b62c5a4b56400c3aacc7f6195 (diff)
downloadmiasm-206d16bad7f4a98b1be30ac9db0c4798e363c550.tar.gz
miasm-206d16bad7f4a98b1be30ac9db0c4798e363c550.zip
x86/TCC: add `fxam`
-rw-r--r--miasm2/ir/translators/C.py1
-rw-r--r--miasm2/jitter/vm_mngr.c59
-rw-r--r--miasm2/jitter/vm_mngr.h4
3 files changed, 63 insertions, 1 deletions
diff --git a/miasm2/ir/translators/C.py b/miasm2/ir/translators/C.py
index 96be6bd0..a2beee54 100644
--- a/miasm2/ir/translators/C.py
+++ b/miasm2/ir/translators/C.py
@@ -67,6 +67,7 @@ class TranslatorC(Translator):
                   expr.op.endswith("_to_double")   or
                   expr.op.startswith("access_")    or
                   expr.op.startswith("load_")      or
+                  expr.op.startswith("fxam_c")     or
                   expr.op in ["-", "ftan", "frndint", "f2xm1",
                               "fsin", "fsqrt", "fabs", "fcos", "fchs"]):
                 return "%s(%s)" % (expr.op, self.from_expr(expr.args[0]))
diff --git a/miasm2/jitter/vm_mngr.c b/miasm2/jitter/vm_mngr.c
index d0171c17..a2c29127 100644
--- a/miasm2/jitter/vm_mngr.c
+++ b/miasm2/jitter/vm_mngr.c
@@ -1277,6 +1277,65 @@ unsigned int fcom_c3(double a, double b)
 	return 0;
 }
 
+unsigned int 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 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 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;
+	}
+}
 
 unsigned int double_to_mem_32(double d)
 {
diff --git a/miasm2/jitter/vm_mngr.h b/miasm2/jitter/vm_mngr.h
index dd0bad0f..175f000c 100644
--- a/miasm2/jitter/vm_mngr.h
+++ b/miasm2/jitter/vm_mngr.h
@@ -375,7 +375,9 @@ unsigned int fcom_c0(double a, double b);
 unsigned int fcom_c1(double a, double b);
 unsigned int fcom_c2(double a, double b);
 unsigned int fcom_c3(double a, double b);
-
+unsigned int fxam_c0(double a);
+unsigned int fxam_c2(double a);
+unsigned int fxam_c3(double a);
 
 
 double mem_32_to_double(unsigned int m);