diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-09-11 18:04:40 +0200 |
|---|---|---|
| committer | Theofilos Augoustis <theofilos.augoustis@gmail.com> | 2025-10-09 15:26:04 +0000 |
| commit | 5f6c47f92584e590f6587f25bea8041018861f9f (patch) | |
| tree | ed627b65fa2038ad963f5d6c0c3856ea5ec6e069 /miasm/arch/x86/sem.py | |
| parent | 58b6c254a94a54cf24f4334a33b2c4bb325768f6 (diff) | |
| download | focaccia-miasm-5f6c47f92584e590f6587f25bea8041018861f9f.tar.gz focaccia-miasm-5f6c47f92584e590f6587f25bea8041018861f9f.zip | |
Add TZCNT instruction
Diffstat (limited to 'miasm/arch/x86/sem.py')
| -rw-r--r-- | miasm/arch/x86/sem.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/miasm/arch/x86/sem.py b/miasm/arch/x86/sem.py index ce5d758a..d19290b6 100644 --- a/miasm/arch/x86/sem.py +++ b/miasm/arch/x86/sem.py @@ -4451,6 +4451,21 @@ def blsr(_, instr, dst, src): e.append(m2_expr.ExprAssign(dst, result)) return e, [] +def tzcnt(ir, instr, dst, src): + e = [] + + operand_size = m2_expr.ExprInt(dst.size, dst.size) + + result = m2_expr.ExprCond(src, m2_expr.ExprOp("cnttrailzeros", src), operand_size) + + e.append(m2_expr.ExprAssign(cf, m2_expr.ExprCond(m2_expr.ExprOp("FLAG_EQ_CMP", result, operand_size), + m2_expr.ExprInt(1, 1), + m2_expr.ExprInt(0, 1)))) + + e += update_flag_zf(result) + e.append(m2_expr.ExprAssign(dst, result)) + return e, [] + def bzhi(_, instr, dst, src1, src2): e = [] @@ -5611,6 +5626,7 @@ mnemo_func = {'mov': mov, "bextr": bextr, "blsmsk": blsmsk, "blsr": blsr, + "tzcnt": tzcnt, "bzhi": bzhi, # |