From c4837720ff407fc47ea2e515ef5bc9ba76daea78 Mon Sep 17 00:00:00 2001 From: Theodore Dubois Date: Mon, 8 Oct 2018 15:25:45 -0700 Subject: [PATCH] Implement fabs/fchs --- emu/fpu.c | 8 ++++++++ emu/fpu.h | 2 ++ jit/gen.c | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/emu/fpu.c b/emu/fpu.c index dd4b86d4..4b18f8f7 100644 --- a/emu/fpu.c +++ b/emu/fpu.c @@ -93,6 +93,14 @@ void fpu_ucom(struct cpu_state *cpu, int i) { cpu->c0 = cpu->c2 = cpu->c3 = 1; } +void fpu_abs(struct cpu_state *cpu) { + ST(0) = f80_abs(ST(0)); +} + +void fpu_chs(struct cpu_state *cpu) { + ST(0) = f80_neg(ST(0)); +} + void fpu_add(struct cpu_state *cpu, int srci, int dsti) { ST(dsti) = f80_add(ST(srci), ST(dsti)); } diff --git a/emu/fpu.h b/emu/fpu.h index 138d8645..0aa01b12 100644 --- a/emu/fpu.h +++ b/emu/fpu.h @@ -30,6 +30,8 @@ void fpu_ldm80(struct cpu_state *cpu, float80 *f); void fpu_prem(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); void fpu_add(struct cpu_state *cpu, int srci, int dsti); void fpu_sub(struct cpu_state *cpu, int srci, int dsti); diff --git a/jit/gen.c b/jit/gen.c index 53ca014d..5a339d6e 100644 --- a/jit/gen.c +++ b/jit/gen.c @@ -339,8 +339,8 @@ static inline bool gen_op(struct gen_state *state, gadget_t *gadgets, enum arg a #define FUCOM() hh(fpu_ucom, st_i) #define FUCOMI() UNDEFINED #define FST() hh(fpu_st, st_i) -#define FCHS() UNDEFINED -#define FABS() UNDEFINED +#define FCHS() h(fpu_chs) +#define FABS() h(fpu_abs) #define FLDC(what) hh(fpu_ldc, fconst_##what) #define FPREM() h(fpu_prem) #define FSTSW(dst) if (arg_##dst == arg_reg_a) g(fstsw_ax); else UNDEFINED