diff --git a/lib86cpu/core/emitter/x64/jit.cpp b/lib86cpu/core/emitter/x64/jit.cpp index f2e24a0..1e401fe 100644 --- a/lib86cpu/core/emitter/x64/jit.cpp +++ b/lib86cpu/core/emitter/x64/jit.cpp @@ -5196,6 +5196,19 @@ lc86_jit::fldcw(decoded_instr *instr) } } +void +lc86_jit::fnclex(decoded_instr *instr) +{ + if (m_cpu->cpu_ctx.hflags & (HFLG_CR0_EM | HFLG_CR0_TS)) { + RAISEin0_t(EXP_NM); + } + else { + LD_R16(AX, CPU_CTX_FSTATUS); + AND(AX, ~(FPU_FLG_SF | FPU_FLG_ES | FPU_FLG_BSY | FPU_EXP_ALL)); + ST_R16(CPU_CTX_FSTATUS, AX); + } +} + void lc86_jit::fninit(decoded_instr *instr) { diff --git a/lib86cpu/core/emitter/x64/jit.h b/lib86cpu/core/emitter/x64/jit.h index 79ea56a..a5a6472 100644 --- a/lib86cpu/core/emitter/x64/jit.h +++ b/lib86cpu/core/emitter/x64/jit.h @@ -76,6 +76,7 @@ class lc86_jit : public Target { void enter(decoded_instr *instr); void fld(decoded_instr *instr); void fldcw(decoded_instr *instr); + void fnclex(decoded_instr *instr); void fninit(decoded_instr *instr); void fnstcw(decoded_instr *instr); void fnstsw(decoded_instr *instr); diff --git a/lib86cpu/core/translate.cpp b/lib86cpu/core/translate.cpp index fb4a223..e561a2a 100644 --- a/lib86cpu/core/translate.cpp +++ b/lib86cpu/core/translate.cpp @@ -1158,6 +1158,10 @@ cpu_translate(cpu_t *cpu) cpu->jit->fldcw(&instr); break; + case ZYDIS_MNEMONIC_FNCLEX: + cpu->jit->fnclex(&instr); + break; + case ZYDIS_MNEMONIC_FNINIT: cpu->jit->fninit(&instr); break;