From 7fa1e15257713370f74ce0d54718cfd88114e180 Mon Sep 17 00:00:00 2001 From: Peter Rutenbar Date: Sun, 9 Nov 2014 13:56:16 -0500 Subject: [PATCH] Implemented flog2, flog10, and flogn, fixed fneg xeyes works now --- core/newfpu.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/core/newfpu.c b/core/newfpu.c index 4947c56..34927ae 100644 --- a/core/newfpu.c +++ b/core/newfpu.c @@ -1479,21 +1479,87 @@ static void inst_fmath_flog10 () { fpu_get_state_ptr(); - assert(!"fmath: flog10 not implemented"); + const _Bool source_zero = _float128_is_zero(fpu->source); + const _Bool source_inf = _float128_is_infinity(fpu->source); + const _Bool source_sign = _float128_is_neg(fpu->source); + + /* If source is zero, set dz, result is -inf */ + if (source_zero) { + fpu->result = _assemble_float128(1, 0x7fff, 0, 0); + es_dz = 1; + return; + } + /* If source is negative, set operr, result is nan */ + else if (source_sign) { + fpu->result = _nan128; + es_operr = 1; + return; + } + /* If source is +inf, result is +inf. */ + else if (source_inf) { + fpu->result = fpu->source; + return; + } + + fpu->result = _hack_log10(fpu->source); } static void inst_fmath_flog2 () { fpu_get_state_ptr(); - assert(!"fmath: flog2 not implemented"); + const _Bool source_zero = _float128_is_zero(fpu->source); + const _Bool source_inf = _float128_is_infinity(fpu->source); + const _Bool source_sign = _float128_is_neg(fpu->source); + + /* If source is zero, set dz, result is -inf */ + if (source_zero) { + fpu->result = _assemble_float128(1, 0x7fff, 0, 0); + es_dz = 1; + return; + } + /* If source is negative, set operr, result is nan */ + else if (source_sign) { + fpu->result = _nan128; + es_operr = 1; + return; + } + /* If source is +inf, result is +inf. */ + else if (source_inf) { + fpu->result = fpu->source; + return; + } + + fpu->result = _hack_log2(fpu->source); } static void inst_fmath_flogn () { fpu_get_state_ptr(); - assert(!"fmath: flogn not implemented"); + const _Bool source_zero = _float128_is_zero(fpu->source); + const _Bool source_inf = _float128_is_infinity(fpu->source); + const _Bool source_sign = _float128_is_neg(fpu->source); + + /* If source is zero, set dz, result is -inf */ + if (source_zero) { + fpu->result = _assemble_float128(1, 0x7fff, 0, 0); + es_dz = 1; + return; + } + /* If source is negative, set operr, result is nan */ + else if (source_sign) { + fpu->result = _nan128; + es_operr = 1; + return; + } + /* If source is +inf, result is +inf. */ + else if (source_inf) { + fpu->result = fpu->source; + return; + } + + fpu->result = _hack_logn(fpu->source); } static void inst_fmath_flognp1 () @@ -1541,7 +1607,7 @@ static void inst_fmath_fneg () fpu_get_state_ptr(); /* Flip the sign bit */ - fpu->result = fpu->dest; + fpu->result = fpu->source; fpu->result.high ^= (1ULL << 63); /*