diff options
| author | Ajax <commial@gmail.com> | 2018-02-09 13:30:58 +0100 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2018-02-09 17:36:31 +0100 |
| commit | cb95c1f581cfded596cc38d8832361c053f3e4cd (patch) | |
| tree | 05ffcf71dc292c4fdf57a0f02700bf03bd9eedc5 /miasm2/arch/x86/sem.py | |
| parent | 649c7b519fc93e9ef5750d03dfcc3e91c2968a36 (diff) | |
| download | miasm-cb95c1f581cfded596cc38d8832361c053f3e4cd.tar.gz miasm-cb95c1f581cfded596cc38d8832361c053f3e4cd.zip | |
Add PAVGB/PAVGW instruction
0F E0 /r PAVGB mm1, mm2/m64 66 0F E0, /r PAVGB xmm1, xmm2/m128 0F E3 /r PAVGW mm1, mm2/m64 66 0F E3 /r PAVGW xmm1, xmm2/m128
Diffstat (limited to 'miasm2/arch/x86/sem.py')
| -rw-r--r-- | miasm2/arch/x86/sem.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index 51fcbe05..5a0f1b6b 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -3518,6 +3518,17 @@ def psadbw(ir, instr, dst, src): return [m2_expr.ExprAff(dst, m2_expr.ExprCompose(*out_dst))], [] +def _average(expr): + assert expr.is_op("avg") and len(expr.args) == 2 + + arg1 = expr.args[0].zeroExtend(expr.size * 2) + arg2 = expr.args[1].zeroExtend(expr.size * 2) + one = m2_expr.ExprInt(1, arg1.size) + # avg(unsigned) = (a + b + 1) >> 1, addition beeing at least on one more bit + return ((arg1 + arg2 + one) >> one)[:expr.size] + +pavgb = vec_vertical_instr('avg', 8, _average) +pavgw = vec_vertical_instr('avg', 16, _average) # Comparisons # @@ -4794,6 +4805,8 @@ mnemo_func = {'mov': mov, # SSE "pmaddwd": pmaddwd, "psadbw": psadbw, + "pavgb": pavgb, + "pavgw": pavgw, # Arithmetic (floating-point) # |