^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*---------------------------------------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) | poly_l2.c |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) | Compute the base 2 log of a FPU_REG, using a polynomial approximation. |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) | Copyright (C) 1992,1993,1994,1997 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) | E-mail billm@suburbia.net |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) +---------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "exception.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "reg_constant.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "fpu_emu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "fpu_system.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "control_w.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "poly.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static void log2_kernel(FPU_REG const *arg, u_char argsign,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Xsig * accum_result, long int *expon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /*--- poly_l2() -------------------------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) | Base 2 logarithm by a polynomial approximation. |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) +---------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) void poly_l2(FPU_REG *st0_ptr, FPU_REG *st1_ptr, u_char st1_sign)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) long int exponent, expon, expon_expon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) Xsig accumulator, expon_accum, yaccum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u_char sign, argsign;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) FPU_REG x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) exponent = exponent16(st0_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* From st0_ptr, make a number > sqrt(2)/2 and < sqrt(2) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) if (st0_ptr->sigh > (unsigned)0xb504f334) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* Treat as sqrt(2)/2 < st0_ptr < 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) significand(&x) = -significand(st0_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) setexponent16(&x, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) exponent++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) argsign = SIGN_NEG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* Treat as 1 <= st0_ptr < sqrt(2) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) x.sigh = st0_ptr->sigh - 0x80000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) x.sigl = st0_ptr->sigl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) setexponent16(&x, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) argsign = SIGN_POS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) tag = FPU_normalize_nuo(&x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (tag == TAG_Zero) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) expon = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) accumulator.msw = accumulator.midw = accumulator.lsw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) log2_kernel(&x, argsign, &accumulator, &expon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if (exponent < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) sign = SIGN_NEG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) exponent = -exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) sign = SIGN_POS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) expon_accum.msw = exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) expon_accum.midw = expon_accum.lsw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (exponent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) expon_expon = 31 + norm_Xsig(&expon_accum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) shr_Xsig(&accumulator, expon_expon - expon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (sign ^ argsign)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) negate_Xsig(&accumulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) add_Xsig_Xsig(&accumulator, &expon_accum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) expon_expon = expon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) sign = argsign;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) yaccum.lsw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) XSIG_LL(yaccum) = significand(st1_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) mul_Xsig_Xsig(&accumulator, &yaccum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) expon_expon += round_Xsig(&accumulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) if (accumulator.msw == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) FPU_copy_to_reg1(&CONST_Z, TAG_Zero);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) significand(st1_ptr) = XSIG_LL(accumulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) setexponent16(st1_ptr, expon_expon + exponent16(st1_ptr) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) tag = FPU_round(st1_ptr, 1, 0, FULL_PRECISION, sign ^ st1_sign);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) FPU_settagi(1, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) set_precision_flag_up(); /* 80486 appears to always do this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*--- poly_l2p1() -----------------------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) | Base 2 logarithm by a polynomial approximation. |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) | log2(x+1) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) +---------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int poly_l2p1(u_char sign0, u_char sign1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) FPU_REG * st0_ptr, FPU_REG * st1_ptr, FPU_REG * dest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) u_char tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) long int exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) Xsig accumulator, yaccum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (exponent16(st0_ptr) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) log2_kernel(st0_ptr, sign0, &accumulator, &exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) yaccum.lsw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) XSIG_LL(yaccum) = significand(st1_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) mul_Xsig_Xsig(&accumulator, &yaccum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) exponent += round_Xsig(&accumulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) exponent += exponent16(st1_ptr) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) if (exponent < EXP_WAY_UNDER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) exponent = EXP_WAY_UNDER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) significand(dest) = XSIG_LL(accumulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) setexponent16(dest, exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) tag = FPU_round(dest, 1, 0, FULL_PRECISION, sign0 ^ sign1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) FPU_settagi(1, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) if (tag == TAG_Valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) set_precision_flag_up(); /* 80486 appears to always do this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* The magnitude of st0_ptr is far too large. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) if (sign0 != SIGN_POS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /* Trying to get the log of a negative number. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #ifdef PECULIAR_486 /* Stupid 80486 doesn't worry about log(negative). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) changesign(st1_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (arith_invalid(1) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #endif /* PECULIAR_486 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /* 80486 appears to do this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (sign0 == SIGN_NEG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) set_precision_flag_down();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) set_precision_flag_up();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (exponent(dest) <= EXP_UNDER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) EXCEPTION(EX_Underflow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #undef HIPOWER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #define HIPOWER 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static const unsigned long long logterms[HIPOWER] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 0x2a8eca5705fc2ef0LL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 0xf6384ee1d01febceLL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 0x093bb62877cdf642LL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 0x006985d8a9ec439bLL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 0x0005212c4f55a9c8LL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 0x00004326a16927f0LL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 0x0000038d1d80a0e7LL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 0x0000003141cc80c6LL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 0x00000002b1668c9fLL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 0x000000002c7a46aaLL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static const unsigned long leadterm = 0xb8000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /*--- log2_kernel() ---------------------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) | Base 2 logarithm by a polynomial approximation. |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) | log2(x+1) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) +---------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static void log2_kernel(FPU_REG const *arg, u_char argsign, Xsig *accum_result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) long int *expon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) long int exponent, adj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) unsigned long long Xsq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) Xsig accumulator, Numer, Denom, argSignif, arg_signif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) exponent = exponent16(arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) Numer.lsw = Denom.lsw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) XSIG_LL(Numer) = XSIG_LL(Denom) = significand(arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (argsign == SIGN_POS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) shr_Xsig(&Denom, 2 - (1 + exponent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) Denom.msw |= 0x80000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) div_Xsig(&Numer, &Denom, &argSignif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) shr_Xsig(&Denom, 1 - (1 + exponent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) negate_Xsig(&Denom);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (Denom.msw & 0x80000000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) div_Xsig(&Numer, &Denom, &argSignif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) exponent++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) /* Denom must be 1.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) argSignif.lsw = Numer.lsw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) argSignif.midw = Numer.midw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) argSignif.msw = Numer.msw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #ifndef PECULIAR_486
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /* Should check here that |local_arg| is within the valid range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if (exponent >= -2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if ((exponent > -2) || (argSignif.msw > (unsigned)0xafb0ccc0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /* The argument is too large */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #endif /* PECULIAR_486 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) arg_signif.lsw = argSignif.lsw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) XSIG_LL(arg_signif) = XSIG_LL(argSignif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) adj = norm_Xsig(&argSignif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) accumulator.lsw = argSignif.lsw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) XSIG_LL(accumulator) = XSIG_LL(argSignif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) mul_Xsig_Xsig(&accumulator, &accumulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) shr_Xsig(&accumulator, 2 * (-1 - (1 + exponent + adj)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) Xsq = XSIG_LL(accumulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) if (accumulator.lsw & 0x80000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) Xsq++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) accumulator.msw = accumulator.midw = accumulator.lsw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /* Do the basic fixed point polynomial evaluation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) polynomial_Xsig(&accumulator, &Xsq, logterms, HIPOWER - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) mul_Xsig_Xsig(&accumulator, &argSignif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) shr_Xsig(&accumulator, 6 - adj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) mul32_Xsig(&arg_signif, leadterm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) add_two_Xsig(&accumulator, &arg_signif, &exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) *expon = exponent + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) accum_result->lsw = accumulator.lsw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) accum_result->midw = accumulator.midw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) accum_result->msw = accumulator.msw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }