about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm/arch/x86/arch.py1
-rw-r--r--miasm/arch/x86/sem.py16
-rw-r--r--test/arch/x86/arch.py3
3 files changed, 20 insertions, 0 deletions
diff --git a/miasm/arch/x86/arch.py b/miasm/arch/x86/arch.py
index 763d6874..be7c5975 100644
--- a/miasm/arch/x86/arch.py
+++ b/miasm/arch/x86/arch.py
@@ -3779,6 +3779,7 @@ addop("fild", [bs8(0xdf)] + rmmod(d5, rm_arg_m64))
 addop("fincstp", [bs8(0xd9), bs8(0xf7)])
 
 addop("blsi", [pref_0f38, bs8(0xf3), vex_reg] + rmmod(bs("011"), rm_arg), [vex_reg, rm_arg])
+addop("andn", [pref_0f38, bs8(0xf2), vex_reg] + rmmod(rmreg, rm_arg), [rmreg, vex_reg, rm_arg])
 
 # addop("finit", [bs8(0x9b), bs8(0xdb), bs8(0xe3)])
 addop("fninit", [bs8(0xdb), bs8(0xe3)])
diff --git a/miasm/arch/x86/sem.py b/miasm/arch/x86/sem.py
index 549e2f79..46b7a019 100644
--- a/miasm/arch/x86/sem.py
+++ b/miasm/arch/x86/sem.py
@@ -4387,6 +4387,21 @@ def blsi(_, instr, dst, src):
     e.append(m2_expr.ExprAssign(dst, result))
     return e, []
 
+def andn(_, instr, dst, src1, src2):
+    e = []
+
+    arg1 = m2_expr.ExprInt(0, src1.size)
+    neg_src1 = arg1 - src1
+    result = neg_src1 & src2
+
+    e += update_flag_zf(result)
+    e += update_flag_nf(result)
+    e.append(m2_expr.ExprAssign(of, m2_expr.ExprInt(0, of.size)))
+    e.append(m2_expr.ExprAssign(cf, m2_expr.ExprInt(0, cf.size)))
+
+    e.append(m2_expr.ExprAssign(dst, result))
+    return e, []
+
 def pshufb(_, instr, dst, src):
     e = []
     if dst.size == 64:
@@ -5519,6 +5534,7 @@ mnemo_func = {'mov': mov,
 
               # BMI operations
               "blsi": blsi,
+              "andn": andn,
 
               #
               # MMX/AVX/SSE operations
diff --git a/test/arch/x86/arch.py b/test/arch/x86/arch.py
index dfb051fa..b61201bb 100644
--- a/test/arch/x86/arch.py
+++ b/test/arch/x86/arch.py
@@ -2593,6 +2593,9 @@ reg_tests = [
     (m64, "00000000    BLSI       EAX, R14D",
     "c4c278f3de"),
 
+    (m64, "00000000    ANDN       RAX, RBX, RCX",
+    "c4e2e0f2c1"),
+
     #### MMX/SSE/AVX operations
     ####