about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorChristian Krinitsin <mail@krinitsin.com>2025-09-11 14:54:44 +0200
committerTheofilos Augoustis <theofilos.augoustis@gmail.com>2025-10-09 15:26:04 +0000
commit08c22a46cc54da3cf4670ae0f263182d24ccdd86 (patch)
tree1717c5fe18a450feabac68254537f39514c781db
parent89f6bfbae7ea6779d9424d8b1fd84843bf8ee23f (diff)
downloadmiasm-08c22a46cc54da3cf4670ae0f263182d24ccdd86.tar.gz
miasm-08c22a46cc54da3cf4670ae0f263182d24ccdd86.zip
Add BLSMSK instruction
-rw-r--r--miasm/arch/x86/arch.py1
-rw-r--r--miasm/arch/x86/sem.py18
-rw-r--r--test/arch/x86/arch.py3
3 files changed, 22 insertions, 0 deletions
diff --git a/miasm/arch/x86/arch.py b/miasm/arch/x86/arch.py
index 4a8af629..e63ce6cf 100644
--- a/miasm/arch/x86/arch.py
+++ b/miasm/arch/x86/arch.py
@@ -3786,6 +3786,7 @@ 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("bextr", [pref_0f38, bs8(0xf7), vex_reg] + rmmod(rmreg, rm_arg), [rmreg, rm_arg, vex_reg])
+addop("blsmsk", [pref_0f38, bs8(0xf3), vex_reg] + rmmod(bs("010"), rm_arg), [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 15db7424..c4120566 100644
--- a/miasm/arch/x86/sem.py
+++ b/miasm/arch/x86/sem.py
@@ -4417,6 +4417,23 @@ def bextr(_, instr, dst, src1, src2):
     e.append(m2_expr.ExprAssign(dst, result))
     return e, []
 
+def blsmsk(_, instr, dst, src):
+    e = []
+
+    tmp = src - m2_expr.ExprInt(1, src.size)
+    result = src ^ tmp
+
+    e += update_flag_nf(result)
+    e.append(m2_expr.ExprAssign(of, m2_expr.ExprInt(0, of.size)))
+    e.append(m2_expr.ExprAssign(zf, m2_expr.ExprInt(0, zf.size)))
+
+    e.append(m2_expr.ExprAssign(cf, m2_expr.ExprCond(src,
+                                                     m2_expr.ExprInt(0, 1),
+                                                     m2_expr.ExprInt(1, 1))))
+
+    e.append(m2_expr.ExprAssign(dst, result))
+    return e, []
+
 def pshufb(_, instr, dst, src):
     e = []
     if dst.size == 64:
@@ -5551,6 +5568,7 @@ mnemo_func = {'mov': mov,
               "blsi": blsi,
               "andn": andn,
               "bextr": bextr,
+              "blsmsk": blsmsk,
 
               #
               # MMX/AVX/SSE operations
diff --git a/test/arch/x86/arch.py b/test/arch/x86/arch.py
index 6d578dd9..7e44e903 100644
--- a/test/arch/x86/arch.py
+++ b/test/arch/x86/arch.py
@@ -2599,6 +2599,9 @@ reg_tests = [
     (m64, "00000000    BEXTR      RAX, RBX, RCX",
     "c4e2f0f7c3"),
 
+    (m64, "00000000    BLSMSK     RAX, RBX",
+    "c4e2f8f3d3"),
+
     #### MMX/SSE/AVX operations
     ####