Skip to content

Commit

Permalink
FNCLEX
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Feb 2, 2024
1 parent 333f171 commit bb9c5b1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib86cpu/core/emitter/x64/jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions lib86cpu/core/emitter/x64/jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions lib86cpu/core/translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bb9c5b1

Please sign in to comment.