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

Annotation of sys/arch/m68k/fpsp/MONADIC.GEN, Revision 1.1

1.1     ! nbrk        1: *      $OpenBSD: MONADIC.GEN,v 1.2 1996/05/29 21:05:22 niklas Exp $
        !             2: *      $NetBSD: MONADIC.GEN,v 1.3 1994/10/26 07:48:42 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: *      MONADIC.GEN 1.5 5/18/92
        !            36: *
        !            37: *      MONADIC.GEN 1.4 1/16/92
        !            38: *
        !            39: *      MONADIC.GEN 1.3 4/30/91
        !            40: *
        !            41: *      MONADIC.GEN --- generic MONADIC template
        !            42: *
        !            43: *      This version saves all registers that will be used by the emulation
        !            44: *      routines and restores all but FP0 on exit.  The FPSR is
        !            45: *      updated to reflect the result of the operation.  Return value
        !            46: *      is placed in FP0 for single, double and extended results.
        !            47: *
        !            48: *      The package subroutines expect the incoming FPCR to be zeroed
        !            49: *      since they need extended precision to work properly.  The
        !            50: *      'final' FPCR is expected in d1 so that the calculated result
        !            51: *      can be properly sized and rounded.  Also, if the incoming FPCR
        !            52: *      has enabled any exceptions, the exception will be taken on the
        !            53: *      final fmovem in this template.
        !            54: *
        !            55: *      Customizations:
        !            56: *              1. Remove the movem.l at the entry and exit of
        !            57: *                 each routine if your compiler treats those
        !            58: *                 registers as scratch.
        !            59: *              2. Likewise, don't save FP0/FP1 if they are scratch
        !            60: *                 registers.
        !            61: *              3. Delete handling of the fpsr if you only care about
        !            62: *                 the result.
        !            63: *              4. Some (most?) C compilers convert all float arguments
        !            64: *                 to double, and provide no support at all for extended
        !            65: *                 precision so remove the _OPs_ and _OPx_ entry points.
        !            66: *              5. Move the result to d0/d1 if the compiler is that old.
        !            67: *
        !            68:
        !            69:        xref    tag
        !            70:        xref    _OPr_
        !            71:        xref    _OPz_
        !            72:        xref    _OPi_
        !            73:        xref    _OPn_
        !            74:        xref    _OPm_
        !            75:
        !            76:        xdef    _OPs_
        !            77: _OPs_:
        !            78:        link    a6,#-LOCAL_SIZE
        !            79:        movem.l d0-d1/a0-a1,USER_DA(a6)
        !            80:        fmovem.x fp0-fp3,USER_FP0(a6)
        !            81:        fmove.l fpsr,USER_FPSR(a6)
        !            82:        fmove.l fpcr,USER_FPCR(a6)
        !            83:        fmove.l fpcr,d1         ; user's rounding mode/precision
        !            84:        fmove.l #0,fpcr         ; force rounding mode/prec to extended,rn
        !            85: *
        !            86: *      copy, convert and tag input argument
        !            87: *
        !            88:        fmove.s 8(a6),fp0
        !            89:        fmove.x fp0,ETEMP(a6)
        !            90:        lea     ETEMP(a6),a0
        !            91:        bsr     tag
        !            92:        move.b  d0,STAG(a6)
        !            93:        tst.b   d0
        !            94:        bne.b   _TMP_2
        !            95:        bsr     _OPr_           ; normalized (regular) number
        !            96:        bra.b   _TMP_6
        !            97: _TMP_2:
        !            98:        cmp.b   #$20,d0         ; zero?
        !            99:        bne.b   _TMP_3
        !           100:        bsr     _OPz_
        !           101:        bra.b   _TMP_6
        !           102: _TMP_3:
        !           103:        cmp.b   #$40,d0         ; infinity?
        !           104:        bne.b   _TMP_4
        !           105:        bsr     _OPi_
        !           106:        bra.b   _TMP_6
        !           107: _TMP_4:
        !           108:        cmp.b   #$60,d0         ; NaN?
        !           109:        bne.b   _TMP_5
        !           110:        bsr     _OPn_
        !           111:        bra.b   _TMP_6
        !           112: _TMP_5:
        !           113:        bsr     _OPm_           ; assuming a denorm...
        !           114:
        !           115: _TMP_6:
        !           116:        fmove.l fpsr,d0         ; update status register
        !           117:        or.b    FPSR_AEXCEPT(a6),d0     ;add previously accrued exceptions
        !           118:        fmove.l d0,fpsr
        !           119: *
        !           120: *      Result is now in FP0
        !           121: *
        !           122:        movem.l USER_DA(a6),d0-d1/a0-a1
        !           123:        fmovem.x USER_FP1(a6),fp1-fp3   ; note: FP0 not restored
        !           124:        fmove.l USER_FPCR(a6),fpcr      ; fpcr restored
        !           125:        unlk    a6
        !           126:        rts
        !           127:
        !           128:        xdef    _OPd_
        !           129: _OPd_:
        !           130:        link    a6,#-LOCAL_SIZE
        !           131:        movem.l d0-d1/a0-a1,USER_DA(a6)
        !           132:        fmovem.x fp0-fp3,USER_FP0(a6)
        !           133:        fmove.l fpsr,USER_FPSR(a6)
        !           134:        fmove.l fpcr,USER_FPCR(a6)
        !           135:        fmove.l fpcr,d1         ; user's rounding mode/precision
        !           136:        fmove.l #0,fpcr         ; force rounding mode/prec to extended,rn
        !           137: *
        !           138: *      copy, convert and tag input argument
        !           139: *
        !           140:        fmove.d 8(a6),fp0
        !           141:        fmove.x fp0,ETEMP(a6)
        !           142:        lea     ETEMP(a6),a0
        !           143:        bsr     tag
        !           144:        move.b  d0,STAG(a6)
        !           145:        tst.b   d0
        !           146:        bne.b   _TMP_7
        !           147:        bsr     _OPr_           ; normalized (regular) number
        !           148:        bra.b   _TMP_B
        !           149: _TMP_7:
        !           150:        cmp.b   #$20,d0         ; zero?
        !           151:        bne.b   _TMP_8
        !           152:        bsr     _OPz_
        !           153:        bra.b   _TMP_B
        !           154: _TMP_8:
        !           155:        cmp.b   #$40,d0         ; infinity?
        !           156:        bne.b   _TMP_9
        !           157:        bsr     _OPi_
        !           158:        bra.b   _TMP_B
        !           159: _TMP_9:
        !           160:        cmp.b   #$60,d0         ; NaN?
        !           161:        bne.b   _TMP_A
        !           162:        bsr     _OPn_
        !           163:        bra.b   _TMP_B
        !           164: _TMP_A:
        !           165:        bsr     _OPm_           ; assuming a denorm...
        !           166:
        !           167: _TMP_B:
        !           168:        fmove.l fpsr,d0         ; update status register
        !           169:        or.b    FPSR_AEXCEPT(a6),d0     ;add previously accrued exceptions
        !           170:        fmove.l d0,fpsr
        !           171: *
        !           172: *      Result is now in FP0
        !           173: *
        !           174:        movem.l USER_DA(a6),d0-d1/a0-a1
        !           175:        fmovem.x USER_FP1(a6),fp1-fp3   ; note: FP0 not restored
        !           176:        fmove.l USER_FPCR(a6),fpcr      ; fpcr restored
        !           177:        unlk    a6
        !           178:        rts
        !           179:
        !           180:        xdef    _OPx_
        !           181: _OPx_:
        !           182:        link    a6,#-LOCAL_SIZE
        !           183:        movem.l d0-d1/a0-a1,USER_DA(a6)
        !           184:        fmovem.x fp0-fp3,USER_FP0(a6)
        !           185:        fmove.l fpsr,USER_FPSR(a6)
        !           186:        fmove.l fpcr,USER_FPCR(a6)
        !           187:        fmove.l fpcr,d1         ; user's rounding mode/precision
        !           188:        fmove.l #0,fpcr         ; force rounding mode/prec to extended,rn
        !           189: *
        !           190: *      copy, convert and tag input argument
        !           191: *
        !           192:        fmove.x 8(a6),fp0
        !           193:        fmove.x fp0,ETEMP(a6)
        !           194:        lea     ETEMP(a6),a0
        !           195:        bsr     tag
        !           196:        move.b  d0,STAG(a6)
        !           197:        tst.b   d0
        !           198:        bne.b   _TMP_C
        !           199:        bsr     _OPr_           ; normalized (regular) number
        !           200:        bra.b   _TMP_G
        !           201: _TMP_C:
        !           202:        cmp.b   #$20,d0         ; zero?
        !           203:        bne.b   _TMP_D
        !           204:        bsr     _OPz_
        !           205:        bra.b   _TMP_G
        !           206: _TMP_D:
        !           207:        cmp.b   #$40,d0         ; infinity?
        !           208:        bne.b   _TMP_E
        !           209:        bsr     _OPi_
        !           210:        bra.b   _TMP_G
        !           211: _TMP_E:
        !           212:        cmp.b   #$60,d0         ; NaN?
        !           213:        bne.b   _TMP_F
        !           214:        bsr     _OPn_
        !           215:        bra.b   _TMP_G
        !           216: _TMP_F:
        !           217:        bsr     _OPm_           ; assuming a denorm...
        !           218:
        !           219: _TMP_G:
        !           220:        fmove.l fpsr,d0         ; update status register
        !           221:        or.b    FPSR_AEXCEPT(a6),d0     ;add previously accrued exceptions
        !           222:        fmove.l d0,fpsr
        !           223: *
        !           224: *      Result is now in FP0
        !           225: *
        !           226:        movem.l USER_DA(a6),d0-d1/a0-a1
        !           227:        fmovem.x USER_FP1(a6),fp1-fp3   ; note: FP0 not restored
        !           228:        fmove.l USER_FPCR(a6),fpcr      ; fpcr restored
        !           229:        unlk    a6
        !           230:        rts
        !           231:

CVSweb