Skip to content

Commit

Permalink
Implement fsin and fcos
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Jan 6, 2020
1 parent 64bc899 commit 9ae0371
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions emu/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,8 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
case 0xd972: TRACE("fsqrt"); FSQRT(); break;
case 0xd974: TRACE("frndint"); FRNDINT(); break;
case 0xd975: TRACE("fscale"); FSCALE(); break;
case 0xd976: TRACE("fsin"); FSIN(); break;
case 0xd977: TRACE("fcos"); FCOS(); break;
case 0xde31: TRACE("fcompp"); FCOM(); FPOP; FPOP; break;
case 0xdf40: TRACE("fnstsw ax"); FSTSW(reg_a); break;
default: TRACE("undefined"); UNDEFINED;
Expand Down
7 changes: 7 additions & 0 deletions emu/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ void fpu_patan(struct cpu_state *cpu) {
fpu_pop(cpu);
}

void fpu_sin(struct cpu_state *cpu) {
ST(0) = f80_from_double(sin(f80_to_double(ST(0))));
}
void fpu_cos(struct cpu_state *cpu) {
ST(0) = f80_from_double(cos(f80_to_double(ST(0))));
}

void fpu_xam(struct cpu_state *cpu) {
float80 f = ST(0);
int outflags = 0;
Expand Down
2 changes: 2 additions & 0 deletions emu/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ void fpu_divm64(struct cpu_state *cpu, double *f);
void fpu_divrm64(struct cpu_state *cpu, double *f);

void fpu_patan(struct cpu_state *cpu);
void fpu_sin(struct cpu_state *cpu);
void fpu_cos(struct cpu_state *cpu);
void fpu_xam(struct cpu_state *cpu);

void fpu_stcw16(struct cpu_state *cpu, uint16_t *i);
Expand Down
4 changes: 3 additions & 1 deletion jit/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ void helper_rdtsc(struct cpu_state *cpu);
#define FSAVE(val,z) h_write(fpu_save, z)
#define FRESTORE(val,z) h_write(fpu_restore, z)
#define FPOP h(fpu_pop)
#define FINCSTP() h(fpu_incstp)
#define FADD(src, dst) hhh(fpu_add, src, dst)
#define FIADD(val,z) h_read(fpu_iadd, z)
#define FADDM(val,z) h_read(fpu_addm, z)
Expand All @@ -419,7 +420,8 @@ void helper_rdtsc(struct cpu_state *cpu);
#define FIDIVR(val,z) h_read(fpu_idivr, z)
#define FDIVRM(val,z) h_read(fpu_divrm, z)
#define FPATAN() h(fpu_patan)
#define FINCSTP() h(fpu_incstp)
#define FSIN() h(fpu_sin)
#define FCOS() h(fpu_cos)

// vector

Expand Down

0 comments on commit 9ae0371

Please sign in to comment.