diff options
| author | serpilliere <serpilliere@users.noreply.github.com> | 2018-09-05 14:15:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-05 14:15:17 +0200 |
| commit | e61116884ac7879db08313542c6c28a8b00297c5 (patch) | |
| tree | 50b838fca121133dc68f9173180f73d4abaeb028 /miasm2/expression/expression.py | |
| parent | 1e994249defba6024c48796443a66889466b5326 (diff) | |
| parent | ecf6cac84d3330c923a6c65bb424e2911f9065a6 (diff) | |
| download | miasm-e61116884ac7879db08313542c6c28a8b00297c5.tar.gz miasm-e61116884ac7879db08313542c6c28a8b00297c5.zip | |
Merge pull request #839 from commial/feature/more-float
Feature/more float
Diffstat (limited to 'miasm2/expression/expression.py')
| -rw-r--r-- | miasm2/expression/expression.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/miasm2/expression/expression.py b/miasm2/expression/expression.py index 69739990..c4b3cca1 100644 --- a/miasm2/expression/expression.py +++ b/miasm2/expression/expression.py @@ -1925,6 +1925,40 @@ def expr_is_NaN(expr): ExprInt(0, 1))) +def expr_is_infinite(expr): + """Return 1 or 0 on 1 bit if expr represent an infinite value according to + IEEE754 + """ + info = size_to_IEEE754_info[expr.size] + exponent = expr[info["significand"]: info["significand"] + info["exponent"]] + + # exponent is full of 1s and significand is NULL + return ExprCond(exponent - ExprInt(-1, exponent.size), + ExprInt(0, 1), + ExprCond(expr[:info["significand"]], ExprInt(0, 1), + ExprInt(1, 1))) + + +def expr_is_IEEE754_zero(expr): + """Return 1 or 0 on 1 bit if expr represent a zero value according to + IEEE754 + """ + info = size_to_IEEE754_info[expr.size] + # Sign is the msb + expr_no_sign = expr[:expr.size - 1] + return ExprCond(expr_no_sign, ExprInt(0, 1), ExprInt(1, 1)) + + +def expr_is_IEEE754_denormal(expr): + """Return 1 or 0 on 1 bit if expr represent a denormalized value according + to IEEE754 + """ + info = size_to_IEEE754_info[expr.size] + exponent = expr[info["significand"]: info["significand"] + info["exponent"]] + # exponent is full of 0s + return ExprCond(exponent, ExprInt(0, 1), ExprInt(1, 1)) + + def expr_is_qNaN(expr): """Return 1 or 0 on 1 bit if expr represent a qNaN (quiet) value according to IEEE754 |