Skip to content

Commit

Permalink
Implement fdivr and fill in some FPU opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Nov 16, 2018
1 parent 071e6c8 commit e8d0937
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions emu/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
case 0xdb5: TRACE("fucomi st"); FUCOMI(); break;
case 0xdc0: TRACE("fadd st, st(i)"); FADD(st_0, st_i); break;
case 0xdc1: TRACE("fmul st, st(i)"); FMUL(st_0, st_i); break;
case 0xdc4: TRACE("fsubr st, st(i)"); FSUBR(st_0, st_i); break;
case 0xdc5: TRACE("fsub st, st(i)"); FSUB(st_0, st_i); break;
case 0xdc6: TRACE("fdivr st, st(i)"); FDIVR(st_0, st_i); break;
case 0xdc7: TRACE("fdiv st, st(i)"); FDIV(st_0, st_i); break;
case 0xdd3: TRACE("fstp st"); FST(); FPOP; break;
case 0xdd4: TRACE("fucom st"); FUCOM(); break;
case 0xdd5: TRACE("fucomp st"); FUCOM(); FPOP; break;
Expand All @@ -606,6 +610,7 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
case 0xde1: TRACE("fmulp st, st(i)"); FMUL(st_0, st_i); FPOP; break;
case 0xde4: TRACE("fsubrp st, st(i)"); FSUBR(st_0, st_i); FPOP; break;
case 0xde5: TRACE("fsubp st, st(i)"); FSUB(st_0, st_i); FPOP; break;
case 0xde6: TRACE("fdivrp st, st(i)"); FDIVR(st_0, st_i); FPOP; break;
case 0xde7: TRACE("fdivp st, st(i)"); FDIV(st_0, st_i); FPOP; break;
case 0xdf5: TRACE("fucomip st"); FUCOMI(); FPOP; break;
default: switch (insn << 8 | modrm.opcode << 4 | modrm.rm_opcode) {
Expand Down
3 changes: 3 additions & 0 deletions emu/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ void fpu_mul(struct cpu_state *cpu, int srci, int dsti) {
void fpu_div(struct cpu_state *cpu, int srci, int dsti) {
ST(dsti) = f80_div(ST(dsti), ST(srci));
}
void fpu_divr(struct cpu_state *cpu, int srci, int dsti) {
ST(dsti) = f80_div(ST(srci), ST(dsti));
}

void fpu_iadd16(struct cpu_state *cpu, int16_t *i) {
ST(0) = f80_add(ST(0), f80_from_int(*i));
Expand Down
1 change: 1 addition & 0 deletions emu/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void fpu_sub(struct cpu_state *cpu, int srci, int dsti);
void fpu_subr(struct cpu_state *cpu, int srci, int dsti);
void fpu_mul(struct cpu_state *cpu, int srci, int dsti);
void fpu_div(struct cpu_state *cpu, int srci, int dsti);
void fpu_divr(struct cpu_state *cpu, int srci, int dsti);
void fpu_iadd16(struct cpu_state *cpu, int16_t *i);
void fpu_isub16(struct cpu_state *cpu, int16_t *i);
void fpu_isubr16(struct cpu_state *cpu, int16_t *i);
Expand Down
6 changes: 4 additions & 2 deletions emu/interp/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@
dst = f80_div(dst, src)
#define FIDIV(val,z) \
ST(0) = f80_div(ST(0), f80_from_int((sint(z)) get(val,z)))
#define FIDIVR(val,z) \
ST(0) = f80_div(f80_from_int((sint(z)) get(val,z)), ST(0))
#define FDIVM(val,z) \
ST(0) = f80_div(ST(0), f80_from_float(get(val,z),z))
#define FDIV(src, dst) \
dst = f80_div(src, dst)
#define FIDIVR(val,z) \
ST(0) = f80_div(f80_from_int((sint(z)) get(val,z)), ST(0))
#define FDIVRM(val,z) \
ST(0) = f80_div(f80_from_float(get(val,z),z), ST(0))

Expand Down
3 changes: 2 additions & 1 deletion jit/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,9 @@ static inline bool gen_op(struct gen_state *state, gadget_t *gadgets, enum arg a
#define FMULM(val,z) h_read(fpu_mulm, z)
#define FDIV(src, dst) hhh(fpu_div, src, dst)
#define FIDIV(val,z) h_read(fpu_idiv, z)
#define FIDIVR(val,z) h_read(fpu_idivr, z)
#define FDIVM(val,z) h_read(fpu_divm, z)
#define FDIVR(src, dst) hhh(fpu_divr, src, dst)
#define FIDIVR(val,z) h_read(fpu_idivr, z)
#define FDIVRM(val,z) h_read(fpu_divrm, z)

#define DECODER_RET int
Expand Down

0 comments on commit e8d0937

Please sign in to comment.