Skip to content

Commit

Permalink
Merge pull request #4890 from donmor/patch-3
Browse files Browse the repository at this point in the history
Fix #4888
  • Loading branch information
joncampbell123 authored Mar 11, 2024
2 parents 568efc5 + 53fe254 commit f8c2747
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/fpu/fpu_instructions_longdouble.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ static void FPU_FBST(PhysPt addr) {
#endif

static void FPU_FADD(Bitu op1, Bitu op2){
FPU_SyncCW();
fenv_t buf;
std::feholdexcept(&buf);
// HACK: Set the denormal flag according to whether the source or final result is a denormalized number.
// This is vital if we don't want certain DOS programs to mis-detect our FPU emulation as an IIT clone chip when cputype == 286
bool was_not_normal = isdenormal(fpu.regs_80[op1].v);
Expand Down Expand Up @@ -311,7 +312,8 @@ static void FPU_FCOS(void){
}

static void FPU_FSQRT(void){
FPU_SyncCW();
fenv_t buf;
std::feholdexcept(&buf);
fpu.regs_80[TOP].v = sqrtl(fpu.regs_80[TOP].v);
//flags and such :)
return;
Expand All @@ -330,35 +332,40 @@ static void FPU_FPTAN(void){
return;
}
static void FPU_FDIV(Bitu st, Bitu other){
FPU_SyncCW();
fenv_t buf;
std::feholdexcept(&buf);
fpu.regs_80[st].v = fpu.regs_80[st].v/fpu.regs_80[other].v;
//flags and such :)
return;
}

static void FPU_FDIVR(Bitu st, Bitu other){
FPU_SyncCW();
fenv_t buf;
std::feholdexcept(&buf);
fpu.regs_80[st].v = fpu.regs_80[other].v/fpu.regs_80[st].v;
// flags and such :)
return;
}

static void FPU_FMUL(Bitu st, Bitu other){
FPU_SyncCW();
fenv_t buf;
std::feholdexcept(&buf);
fpu.regs_80[st].v *= fpu.regs_80[other].v;
//flags and such :)
return;
}

static void FPU_FSUB(Bitu st, Bitu other){
FPU_SyncCW();
fenv_t buf;
std::feholdexcept(&buf);
fpu.regs_80[st].v = fpu.regs_80[st].v - fpu.regs_80[other].v;
//flags and such :)
return;
}

static void FPU_FSUBR(Bitu st, Bitu other){
FPU_SyncCW();
fenv_t buf;
std::feholdexcept(&buf);
fpu.regs_80[st].v = fpu.regs_80[other].v - fpu.regs_80[st].v;
//flags and such :)
return;
Expand Down Expand Up @@ -549,7 +556,8 @@ static void FPU_FLDENV(PhysPt addr, bool op16){
tag = static_cast<uint16_t>(mem_readd(addr+8));
}
FPU_SetTag(tag);
FPU_SyncCW();
fenv_t buf;
std::feholdexcept(&buf);
}

static void FPU_FSAVE(PhysPt addr, bool op16){
Expand Down

0 comments on commit f8c2747

Please sign in to comment.