Skip to content

Commit

Permalink
Implement f2xm1
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Nov 16, 2018
1 parent 4351f0c commit aaa5015
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions emu/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
case 0xd954: TRACE("fldlg2"); FLDC(log2); break;
case 0xd955: TRACE("fldln2"); FLDC(ln2); break;
case 0xd956: TRACE("fldz"); FLDC(zero); break;
case 0xd960: TRACE("f2xm1"); F2XM1(); break;
case 0xd961: TRACE("fyl2x"); FYL2X(); break;
case 0xd970: TRACE("fprem"); FPREM(); break;
case 0xd974: TRACE("frndint"); FRNDINT(); break;
Expand Down
6 changes: 6 additions & 0 deletions emu/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "emu/cpu.h"
#include "emu/float80.h"
#include "emu/fpu.h"
#include <math.h>

#define ST(i) cpu->fp[cpu->top + i]

Expand Down Expand Up @@ -94,6 +95,11 @@ void fpu_yl2x(struct cpu_state *cpu) {
fpu_pop(cpu);
}

void fpu_2xm1(struct cpu_state *cpu) {
// an example of the ancient chinese art of chi ting
ST(0) = f80_from_double(pow(2, f80_to_double(ST(0))) - 1);
}

static void fpu_comparei(struct cpu_state *cpu, float80 x) {
cpu->zf_res = cpu->pf_res = 0;
cpu->zf = cpu->pf = cpu->cf = 0;
Expand Down
6 changes: 4 additions & 2 deletions emu/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ 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_abs(struct cpu_state *cpu);
void fpu_chs(struct cpu_state *cpu);
void fpu_yl2x(struct cpu_state *cpu);
void fpu_2xm1(struct cpu_state *cpu);

void fpu_com(struct cpu_state *cpu, int i);
void fpu_comm64(struct cpu_state *cpu, double *f);
void fpu_comi(struct cpu_state *cpu, int i);
#define fpu_ucom fpu_com
#define fpu_ucomi fpu_comi
void fpu_abs(struct cpu_state *cpu);
void fpu_chs(struct cpu_state *cpu);

void fpu_add(struct cpu_state *cpu, int srci, int dsti);
void fpu_sub(struct cpu_state *cpu, int srci, int dsti);
Expand Down
1 change: 1 addition & 0 deletions emu/interp/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@

#define FRNDINT() UNDEFINED
#define FYL2X() UNDEFINED
#define F2XM1() UNDEFINED

#define FUCOMI() \
cpu->zf = f80_eq(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 @@ -378,6 +378,7 @@ static inline bool gen_op(struct gen_state *state, gadget_t *gadgets, enum arg a
#define FPREM() h(fpu_prem)
#define FRNDINT() h(fpu_rndint)
#define FYL2X() h(fpu_yl2x)
#define F2XM1() h(fpu_2xm1)
#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 aaa5015

Please sign in to comment.