Skip to content

Commit

Permalink
Implement fxtract
Browse files Browse the repository at this point in the history
Go's math/big has an initializer that creates a singleton 3, and doing
so involves fxtract

For ish-app#57
  • Loading branch information
tbodt committed May 4, 2020
1 parent 7b90fb1 commit d73ca72
Show file tree
Hide file tree
Showing 6 changed files with 20 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 @@ -725,6 +725,7 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
case 0xd960: TRACE("f2xm1"); F2XM1(); break;
case 0xd961: TRACE("fyl2x"); FYL2X(); break;
case 0xd963: TRACE("fpatan"); FPATAN(); break;
case 0xd964: TRACE("fxtract"); FXTRACT(); break;
case 0xd967: TRACE("fincstp"); FINCSTP(); break;
case 0xd970: TRACE("fprem"); FPREM(); break;
case 0xd972: TRACE("fsqrt"); FSQRT(); break;
Expand Down
6 changes: 6 additions & 0 deletions emu/float80.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,9 @@ float80 f80_scale(float80 x, int scale) {
return F80_NAN;
return u128_normalize_round((uint128_t) x.signif << 64, unbias(x.exp) + scale, x.sign);
}

void f80_xtract(float80 f, int *exp, float80 *signif) {
*exp = unbias(f.exp);
*signif = f;
signif->exp = bias(0);
}
3 changes: 3 additions & 0 deletions emu/float80.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ float80 f80_sqrt(float80 x);

float80 f80_scale(float80 x, int scale);

// Used to implement fxtract
void f80_xtract(float80 f, int *exp, float80 *signif);

enum f80_rounding_mode {
round_to_nearest = 0,
round_down = 1,
Expand Down
8 changes: 8 additions & 0 deletions emu/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ void fpu_cos(struct cpu_state *cpu) {
ST(0) = f80_from_double(cos(f80_to_double(ST(0))));
}

void fpu_xtract(struct cpu_state *cpu) {
int exp;
float80 signif;
f80_xtract(ST(0), &exp, &signif);
ST(0) = f80_from_int(exp);
fpush(signif);
}

void fpu_xam(struct cpu_state *cpu) {
float80 f = ST(0);
int outflags = 0;
Expand Down
1 change: 1 addition & 0 deletions emu/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ 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_xtract(struct cpu_state *cpu);

void fpu_stcw16(struct cpu_state *cpu, uint16_t *i);
void fpu_ldcw16(struct cpu_state *cpu, uint16_t *i);
Expand Down
1 change: 1 addition & 0 deletions jit/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ void helper_rdtsc(struct cpu_state *cpu);
#define FPATAN() h(fpu_patan)
#define FSIN() h(fpu_sin)
#define FCOS() h(fpu_cos)
#define FXTRACT() h(fpu_xtract)

// vector

Expand Down

0 comments on commit d73ca72

Please sign in to comment.