Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions asbestos/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ void helper_rdtsc(struct cpu_state *cpu);
#define FLDENV(val,z) h_write(fpu_ldenv, z)
#define FSAVE(val,z) h_write(fpu_save, z)
#define FRESTORE(val,z) h_write(fpu_restore, z)
#define FINIT() h(fpu_init)
#define FCLEX() h(fpu_clex)
#define FPOP h(fpu_pop)
#define FINCSTP() h(fpu_incstp)
Expand Down
1 change: 1 addition & 0 deletions emu/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
case 0xd976: TRACE("fsin"); FSIN(); break;
case 0xd977: TRACE("fcos"); FCOS(); break;
case 0xdb42: TRACE("fnclex"); FCLEX(); break;
case 0xdb43: TRACE("fninit"); FINIT(); break;
case 0xde31: TRACE("fcompp"); FCOM(); FPOP; FPOP; break;
case 0xdf40: TRACE("fnstsw ax"); FSTSW(reg_a); break;
default: TRACE("undefined"); UNDEFINED;
Expand Down
12 changes: 12 additions & 0 deletions emu/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,18 @@ void fpu_restore32(struct cpu_state *cpu, struct fpu_state32 *state) {
memcpy(&ST(i), state->regs[i], 10);
}

// FNINIT: control word back to 0x037f (all exceptions masked, round to
// nearest, extended precision) and the status word cleared. Clearing fsw also
// resets TOP, since TOP is a field of it, which is what empties the register
// stack; there is no tag word to write because we do not model one. The
// control word changing means the live rounding mode has to follow it, the
// same way fldcw does.
void fpu_init(struct cpu_state *cpu) {
cpu->fcw = 0x037f;
cpu->fsw = 0;
f80_rounding_mode = cpu->rc;
}

void fpu_clex(struct cpu_state *cpu) {
cpu->pe = cpu->ue = cpu->oe = cpu->ze = cpu->de = cpu->ie = cpu->es = cpu->sf = cpu->b = 0;
}
1 change: 1 addition & 0 deletions emu/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void fpu_stenv32(struct cpu_state *cpu, struct fpu_env32 *env);
void fpu_ldenv32(struct cpu_state *cpu, struct fpu_env32 *env);
void fpu_save32(struct cpu_state *cpu, struct fpu_state32 *state);
void fpu_restore32(struct cpu_state *cpu, struct fpu_state32 *state);
void fpu_init(struct cpu_state *cpu);
void fpu_clex(struct cpu_state *cpu);

#endif
Loading