diff options
| author | Camille Mougey <commial@gmail.com> | 2015-07-30 08:31:34 +0200 |
|---|---|---|
| committer | Camille Mougey <commial@gmail.com> | 2015-07-30 08:31:34 +0200 |
| commit | ea4ca3425e49c59fa4cb9b5b5b91cc9431dcb843 (patch) | |
| tree | dda7deef86d31ed01361eca60719f81ef2db79a5 /miasm2/expression | |
| parent | 817fc666eac74c802d4d592f50a3872a3197f4a5 (diff) | |
| parent | 5802dfd9ff93f755b648ff4a3ba236a80c121fb3 (diff) | |
| download | miasm-ea4ca3425e49c59fa4cb9b5b5b91cc9431dcb843.tar.gz miasm-ea4ca3425e49c59fa4cb9b5b5b91cc9431dcb843.zip | |
Merge pull request #199 from serpilliere/fix_x86_sem
Fix x86 sem
Diffstat (limited to 'miasm2/expression')
| -rw-r--r-- | miasm2/expression/expression_helper.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/miasm2/expression/expression_helper.py b/miasm2/expression/expression_helper.py index 3555530a..196ad5cd 100644 --- a/miasm2/expression/expression_helper.py +++ b/miasm2/expression/expression_helper.py @@ -533,3 +533,22 @@ class ExprRandom(object): cls.generated_elements = {} return got + +def _expr_cmp_gen(arg1, arg2): + return (arg2 - arg1) ^ ((arg2 ^ arg1) & ((arg2 - arg1) ^ arg2)) + +def expr_cmpu(arg1, arg2): + """ + Returns a one bit long Expression: + * 1 if @arg1 is strictly greater than @arg2 (unsigned) + * 0 otherwise. + """ + return (_expr_cmp_gen(arg1, arg2) ^ arg2 ^ arg1).msb() + +def expr_cmps(arg1, arg2): + """ + Returns a one bit long Expression: + * 1 if @arg1 is strictly greater than @arg2 (signed) + * 0 otherwise. + """ + return _expr_cmp_gen(arg1, arg2).msb() |