Skip to content

Commit

Permalink
Fixed a bug in FSTP
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Aug 8, 2024
1 parent 3a68109 commit e2bc67d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib86cpu/core/emitter/x64/jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5402,8 +5402,6 @@ lc86_jit::fstp(decoded_instr *instr)
gen_set_host_fpu_ctx();
MOV(EDX, EAX);
MOV(MEMD32(RSP, LOCAL_VARS_off(4)), EAX);
INC(EBX);
AND(EBX, 7);
TEST(MEMD64(RSP, LOCAL_VARS_off(0)), 0);
BR_NE(stack_fault);
MOV(EAX, sizeof(uint80_t));
Expand All @@ -5422,7 +5420,6 @@ lc86_jit::fstp(decoded_instr *instr)
MUL(DX);
FSTP(MEMSD80(RCX, RAX, 0, CPU_CTX_R0));
gen_fpu_exp_post_check();
ST_R16(FPU_DATA_FTOP, BX);
gen_update_fpu_ptr<false>(instr);
},
[this, instr](const op_info rm)
Expand Down Expand Up @@ -5454,10 +5451,14 @@ lc86_jit::fstp(decoded_instr *instr)
LIB86CPU_ABORT();
}

ST_R16(FPU_DATA_FTOP, BX);
gen_update_fpu_ptr<true>(instr);
});

if (!(instr->i.raw.modrm.reg == 2)) {
INC(EBX);
AND(EBX, 7);
ST_R16(FPU_DATA_FTOP, BX);
}
RESTORE_FPU_CTX();
MOV(EDX, MEMD32(RSP, LOCAL_VARS_off(4)));
CALL_F(&fpu_update_tag<false>);
Expand Down

0 comments on commit e2bc67d

Please sign in to comment.