Skip to content

Commit

Permalink
Implement frndint
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Oct 30, 2018
1 parent 5c592c4 commit c10fac1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions emu/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
case 0xd950: TRACE("fld1"); FLDC(one); break;
case 0xd956: TRACE("fldz"); FLDC(zero); break;
case 0xd970: TRACE("fprem"); FPREM(); break;
case 0xd974: TRACE("frndint"); FRNDINT(); break;
case 0xdf40: TRACE("fnstsw ax"); FSTSW(reg_a); break;
default: TRACE("undefined"); UNDEFINED;
}}
Expand Down
6 changes: 6 additions & 0 deletions emu/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ void fpu_prem(struct cpu_state *cpu) {
ST(0) = f80_mod(ST(0), ST(1));
}

void fpu_rndint(struct cpu_state *cpu) {
if (f80_isinf(ST(0)) || f80_isnan(ST(0)))
return;
ST(0) = f80_from_int(f80_to_int(ST(0)));
}

void fpu_ucom(struct cpu_state *cpu, int i) {
cpu->c1 = 0;
cpu->c0 = f80_lt(ST(0), ST(i));
Expand Down
1 change: 1 addition & 0 deletions emu/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void fpu_ldm64(struct cpu_state *cpu, double *f);
void fpu_ldm80(struct cpu_state *cpu, float80 *f);

void fpu_prem(struct cpu_state *cpu);
void fpu_rndint(struct cpu_state *cpu);
void fpu_ucom(struct cpu_state *cpu, int i);
void fpu_abs(struct cpu_state *cpu);
void fpu_chs(struct cpu_state *cpu);
Expand Down
2 changes: 2 additions & 0 deletions emu/interp/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
#define FPREM() \
ST(0) = f80_mod(ST(0), ST(1))

#define FRNDINT() UNDEFINED

#define FUCOMI() \
cpu->zf = f80_eq(ST(0), ST_i); \
cpu->cf = f80_lt(ST(0), ST_i); \
Expand Down
1 change: 1 addition & 0 deletions jit/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ static inline bool gen_op(struct gen_state *state, gadget_t *gadgets, enum arg a
#define FABS() h(fpu_abs)
#define FLDC(what) hh(fpu_ldc, fconst_##what)
#define FPREM() h(fpu_prem)
#define FRNDINT() h(fpu_rndint)
#define FSTSW(dst) if (arg_##dst == arg_reg_a) g(fstsw_ax); else UNDEFINED
#define FSTCW(dst) if (arg_##dst == arg_reg_a) UNDEFINED; else h_write(fpu_stcw, 16)
#define FLDCW(dst) if (arg_##dst == arg_reg_a) UNDEFINED; else h_read(fpu_ldcw, 16)
Expand Down

0 comments on commit c10fac1

Please sign in to comment.