diff options
| -rw-r--r-- | miasm2/arch/x86/arch.py | 13 | ||||
| -rw-r--r-- | miasm2/arch/x86/sem.py | 30 | ||||
| -rw-r--r-- | test/arch/x86/arch.py | 9 |
3 files changed, 52 insertions, 0 deletions
diff --git a/miasm2/arch/x86/arch.py b/miasm2/arch/x86/arch.py index f0113dbb..9bc8b3cc 100644 --- a/miasm2/arch/x86/arch.py +++ b/miasm2/arch/x86/arch.py @@ -4029,6 +4029,19 @@ addop("psllw", [bs8(0x0f), bs8(0xf1), no_xmm_pref] + addop("psllw", [bs8(0x0f), bs8(0xf1), pref_66] + rmmod(xmm_reg, rm_arg_xmm), [xmm_reg, rm_arg_xmm]) + +addop("pmaxub", [bs8(0x0f), bs8(0xde), no_xmm_pref] + + rmmod(mm_reg, rm_arg_mm)) +addop("pmaxub", [bs8(0x0f), bs8(0xde), pref_66] + + rmmod(xmm_reg, rm_arg_xmm)) + +addop("pmaxuw", [bs8(0x0f), bs8(0x38), bs8(0x3e), pref_66] + + rmmod(xmm_reg, rm_arg_xmm)) + +addop("pmaxud", [bs8(0x0f), bs8(0x38), bs8(0x3f), pref_66] + + rmmod(xmm_reg, rm_arg_xmm)) + + mn_x86.bintree = factor_one_bit(mn_x86.bintree) # mn_x86.bintree = factor_fields_all(mn_x86.bintree) """ diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index 48114852..dd3f9bdd 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -3510,6 +3510,32 @@ def iret(ir, instr): return exprs, [] + +def pmaxu(ir, instr, a, b, size): + e = [] + for i in xrange(0, a.size, size): + op1 = a[i:i+size] + op2 = b[i:i+size] + res = op1 - op2 + # Compote CF in @res = @op1 - @op2 + ret = (((op1 ^ op2) ^ res) ^ ((op1 ^ res) & (op1 ^ op2))).msb() + + e.append(m2_expr.ExprAff(a[i:i+size], + m2_expr.ExprCond(ret, + b[i:i+size], + a[i:i+size]))) + return e, [] + +def pmaxub(ir, instr, a, b): + return pmaxu(ir, instr, a, b, 8) + +def pmaxuw(ir, instr, a, b): + return pmaxu(ir, instr, a, b, 16) + +def pmaxud(ir, instr, a, b): + return pmaxu(ir, instr, a, b, 32) + + mnemo_func = {'mov': mov, 'xchg': xchg, 'movzx': movzx, @@ -3932,6 +3958,10 @@ mnemo_func = {'mov': mov, "psllw" : psllw, "pslld" : pslld, "psllq" : psllq, + + "pmaxub" : pmaxub, + "pmaxuw" : pmaxuw, + "pmaxud" : pmaxud, } diff --git a/test/arch/x86/arch.py b/test/arch/x86/arch.py index 3dd91581..27b426e2 100644 --- a/test/arch/x86/arch.py +++ b/test/arch/x86/arch.py @@ -2653,6 +2653,15 @@ reg_tests = [ (m32, "00000000 PSLLW XMM2, XMMWORD PTR [EDX]", "660FF112"), + (m32, "00000000 PMAXUB MM2, QWORD PTR [EDX]", + "0FDE12"), + (m32, "00000000 PMAXUB XMM2, XMMWORD PTR [EDX]", + "660FDE12"), + + (m32, "00000000 PMAXUW XMM2, XMMWORD PTR [EDX]", + "660F383E12"), + (m32, "00000000 PMAXUD XMM2, XMMWORD PTR [EDX]", + "660F383F12"), ] |