[BACK]Return to slog2.sa CVS log [TXT][DIR] Up to [local] / sys / arch / m68k / fpsp

Annotation of sys/arch/m68k/fpsp/slog2.sa, Revision 1.1

1.1     ! nbrk        1: *      $OpenBSD: slog2.sa,v 1.2 1996/05/29 21:05:39 niklas Exp $
        !             2: *      $NetBSD: slog2.sa,v 1.2 1994/10/26 07:49:52 cgd Exp $
        !             3:
        !             4: *      MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
        !             5: *      M68000 Hi-Performance Microprocessor Division
        !             6: *      M68040 Software Package
        !             7: *
        !             8: *      M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
        !             9: *      All rights reserved.
        !            10: *
        !            11: *      THE SOFTWARE is provided on an "AS IS" basis and without warranty.
        !            12: *      To the maximum extent permitted by applicable law,
        !            13: *      MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
        !            14: *      INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
        !            15: *      PARTICULAR PURPOSE and any warranty against infringement with
        !            16: *      regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
        !            17: *      and any accompanying written materials.
        !            18: *
        !            19: *      To the maximum extent permitted by applicable law,
        !            20: *      IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
        !            21: *      (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
        !            22: *      PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
        !            23: *      OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
        !            24: *      SOFTWARE.  Motorola assumes no responsibility for the maintenance
        !            25: *      and support of the SOFTWARE.
        !            26: *
        !            27: *      You are hereby granted a copyright license to use, modify, and
        !            28: *      distribute the SOFTWARE so long as this entire notice is retained
        !            29: *      without alteration in any modified and/or redistributed versions,
        !            30: *      and that such modified versions are clearly identified as such.
        !            31: *      No licenses are granted by implication, estoppel or otherwise
        !            32: *      under any patents or trademarks of Motorola, Inc.
        !            33:
        !            34: *
        !            35: *      slog2.sa 3.1 12/10/90
        !            36: *
        !            37: *       The entry point slog10 computes the base-10
        !            38: *      logarithm of an input argument X.
        !            39: *      slog10d does the same except the input value is a
        !            40: *      denormalized number.
        !            41: *      sLog2 and sLog2d are the base-2 analogues.
        !            42: *
        !            43: *       INPUT: Double-extended value in memory location pointed to
        !            44: *              by address register a0.
        !            45: *
        !            46: *       OUTPUT: log_10(X) or log_2(X) returned in floating-point
        !            47: *              register fp0.
        !            48: *
        !            49: *       ACCURACY and MONOTONICITY: The returned result is within 1.7
        !            50: *              ulps in 64 significant bit, i.e. within 0.5003 ulp
        !            51: *              to 53 bits if the result is subsequently rounded
        !            52: *              to double precision. The result is provably monotonic
        !            53: *              in double precision.
        !            54: *
        !            55: *       SPEED: Two timings are measured, both in the copy-back mode.
        !            56: *              The first one is measured when the function is invoked
        !            57: *              the first time (so the instructions and data are not
        !            58: *              in cache), and the second one is measured when the
        !            59: *              function is reinvoked at the same input argument.
        !            60: *
        !            61: *       ALGORITHM and IMPLEMENTATION NOTES:
        !            62: *
        !            63: *       slog10d:
        !            64: *
        !            65: *       Step 0.   If X < 0, create a NaN and raise the invalid operation
        !            66: *                 flag. Otherwise, save FPCR in D1; set FpCR to default.
        !            67: *       Notes:    Default means round-to-nearest mode, no floating-point
        !            68: *                 traps, and precision control = double extended.
        !            69: *
        !            70: *       Step 1.   Call slognd to obtain Y = log(X), the natural log of X.
        !            71: *       Notes:    Even if X is denormalized, log(X) is always normalized.
        !            72: *
        !            73: *       Step 2.   Compute log_10(X) = log(X) * (1/log(10)).
        !            74: *            2.1  Restore the user FPCR
        !            75: *            2.2  Return ans := Y * INV_L10.
        !            76: *
        !            77: *
        !            78: *       slog10:
        !            79: *
        !            80: *       Step 0.   If X < 0, create a NaN and raise the invalid operation
        !            81: *                 flag. Otherwise, save FPCR in D1; set FpCR to default.
        !            82: *       Notes:    Default means round-to-nearest mode, no floating-point
        !            83: *                 traps, and precision control = double extended.
        !            84: *
        !            85: *       Step 1.   Call sLogN to obtain Y = log(X), the natural log of X.
        !            86: *
        !            87: *       Step 2.   Compute log_10(X) = log(X) * (1/log(10)).
        !            88: *            2.1  Restore the user FPCR
        !            89: *            2.2  Return ans := Y * INV_L10.
        !            90: *
        !            91: *
        !            92: *       sLog2d:
        !            93: *
        !            94: *       Step 0.   If X < 0, create a NaN and raise the invalid operation
        !            95: *                 flag. Otherwise, save FPCR in D1; set FpCR to default.
        !            96: *       Notes:    Default means round-to-nearest mode, no floating-point
        !            97: *                 traps, and precision control = double extended.
        !            98: *
        !            99: *       Step 1.   Call slognd to obtain Y = log(X), the natural log of X.
        !           100: *       Notes:    Even if X is denormalized, log(X) is always normalized.
        !           101: *
        !           102: *       Step 2.   Compute log_10(X) = log(X) * (1/log(2)).
        !           103: *            2.1  Restore the user FPCR
        !           104: *            2.2  Return ans := Y * INV_L2.
        !           105: *
        !           106: *
        !           107: *       sLog2:
        !           108: *
        !           109: *       Step 0.   If X < 0, create a NaN and raise the invalid operation
        !           110: *                 flag. Otherwise, save FPCR in D1; set FpCR to default.
        !           111: *       Notes:    Default means round-to-nearest mode, no floating-point
        !           112: *                 traps, and precision control = double extended.
        !           113: *
        !           114: *       Step 1.   If X is not an integer power of two, i.e., X != 2^k,
        !           115: *                 go to Step 3.
        !           116: *
        !           117: *       Step 2.   Return k.
        !           118: *            2.1  Get integer k, X = 2^k.
        !           119: *            2.2  Restore the user FPCR.
        !           120: *            2.3  Return ans := convert-to-double-extended(k).
        !           121: *
        !           122: *       Step 3.   Call sLogN to obtain Y = log(X), the natural log of X.
        !           123: *
        !           124: *       Step 4.   Compute log_2(X) = log(X) * (1/log(2)).
        !           125: *            4.1  Restore the user FPCR
        !           126: *            4.2  Return ans := Y * INV_L2.
        !           127: *
        !           128:
        !           129: SLOG2    IDNT    2,1 Motorola 040 Floating Point Software Package
        !           130:
        !           131:        section 8
        !           132:
        !           133:        xref    t_frcinx
        !           134:        xref    t_operr
        !           135:        xref    slogn
        !           136:        xref    slognd
        !           137:
        !           138: INV_L10  DC.L $3FFD0000,$DE5BD8A9,$37287195,$00000000
        !           139:
        !           140: INV_L2   DC.L $3FFF0000,$B8AA3B29,$5C17F0BC,$00000000
        !           141:
        !           142:        xdef    slog10d
        !           143: slog10d:
        !           144: *--entry point for Log10(X), X is denormalized
        !           145:        move.l          (a0),d0
        !           146:        blt.w           invalid
        !           147:        move.l          d1,-(sp)
        !           148:        clr.l           d1
        !           149:        bsr             slognd                  ...log(X), X denorm.
        !           150:        fmove.l         (sp)+,fpcr
        !           151:        fmul.x          INV_L10,fp0
        !           152:        bra             t_frcinx
        !           153:
        !           154:        xdef    slog10
        !           155: slog10:
        !           156: *--entry point for Log10(X), X is normalized
        !           157:
        !           158:        move.l          (a0),d0
        !           159:        blt.w           invalid
        !           160:        move.l          d1,-(sp)
        !           161:        clr.l           d1
        !           162:        bsr             slogn                   ...log(X), X normal.
        !           163:        fmove.l         (sp)+,fpcr
        !           164:        fmul.x          INV_L10,fp0
        !           165:        bra             t_frcinx
        !           166:
        !           167:
        !           168:        xdef    slog2d
        !           169: slog2d:
        !           170: *--entry point for Log2(X), X is denormalized
        !           171:
        !           172:        move.l          (a0),d0
        !           173:        blt.w           invalid
        !           174:        move.l          d1,-(sp)
        !           175:        clr.l           d1
        !           176:        bsr             slognd                  ...log(X), X denorm.
        !           177:        fmove.l         (sp)+,fpcr
        !           178:        fmul.x          INV_L2,fp0
        !           179:        bra             t_frcinx
        !           180:
        !           181:        xdef    slog2
        !           182: slog2:
        !           183: *--entry point for Log2(X), X is normalized
        !           184:        move.l          (a0),d0
        !           185:        blt.w           invalid
        !           186:
        !           187:        move.l          8(a0),d0
        !           188:        bne.b           continue                ...X is not 2^k
        !           189:
        !           190:        move.l          4(a0),d0
        !           191:        and.l           #$7FFFFFFF,d0
        !           192:        tst.l           d0
        !           193:        bne.b           continue
        !           194:
        !           195: *--X = 2^k.
        !           196:        move.w          (a0),d0
        !           197:        and.l           #$00007FFF,d0
        !           198:        sub.l           #$3FFF,d0
        !           199:        fmove.l         d1,fpcr
        !           200:        fmove.l         d0,fp0
        !           201:        bra             t_frcinx
        !           202:
        !           203: continue:
        !           204:        move.l          d1,-(sp)
        !           205:        clr.l           d1
        !           206:        bsr             slogn                   ...log(X), X normal.
        !           207:        fmove.l         (sp)+,fpcr
        !           208:        fmul.x          INV_L2,fp0
        !           209:        bra             t_frcinx
        !           210:
        !           211: invalid:
        !           212:        bra             t_operr
        !           213:
        !           214:        end

CVSweb