Annotation of sys/arch/m68k/fpsp/DYADIC.GEN, Revision 1.1
1.1 ! nbrk 1: * $OpenBSD: DYADIC.GEN,v 1.2 1996/05/29 21:05:19 niklas Exp $
! 2: * $NetBSD: DYADIC.GEN,v 1.2 1994/10/26 07:48:29 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: * DYADIC.GEN 1.2 4/30/91
! 36: *
! 37: * DYADIC.GEN --- generic DYADIC template
! 38: *
! 39: * This version saves all registers that will be used by the emulation
! 40: * routines and restores all but FP0 on exit. The FPSR is
! 41: * updated to reflect the result of the operation. Return value
! 42: * is placed in FP0 for single, double and extended results.
! 43: *
! 44: * The package subroutines expect the incoming FPCR to be zeroed
! 45: * since they need extended precision to work properly. The
! 46: * 'final' FPCR is expected in USER_FPCR(a6) so that the calculated result
! 47: * can be properly sized and rounded. Also, if the incoming FPCR
! 48: * has enabled any exceptions, the exception will be taken on the
! 49: * final fmovem in this template.
! 50: *
! 51: * Customizations:
! 52: * 1. Remove the movem.l at the entry and exit of
! 53: * each routine if your compiler treats those
! 54: * registers as scratch.
! 55: * 2. Likewise, don't save FP0/FP1 if they are scratch
! 56: * registers.
! 57: * 3. Delete updating of the fpsr if you only care about
! 58: * the result.
! 59: * 4. Remove the _OPs_ and _OPx_ entry points if your compiler
! 60: * treats everything as doubles.
! 61: * 5. Move the result to d0/d1 if the compiler is that old.
! 62: *
! 63:
! 64: xref _OPa_
! 65: xref tag
! 66:
! 67: xdef _OPs_
! 68: _OPs_:
! 69: link a6,#-LOCAL_SIZE
! 70: movem.l d0-d1/a0-a1,USER_DA(a6)
! 71: fmovem.x fp0-fp3,USER_FP0(a6)
! 72: fmovem.l fpsr/fpcr,USER_FPSR(a6) ; user's rounding mode/precision
! 73: fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
! 74: *
! 75: * copy, convert and tag input arguments
! 76: *
! 77: fmove.s 8(a6),fp0
! 78: fmove.x fp0,FPTEMP(a6)
! 79: lea FPTEMP(a6),a0
! 80: bsr tag
! 81: move.b d0,DTAG(a6)
! 82:
! 83: fmove.s 12(a6),fp0
! 84: fmove.x fp0,ETEMP(a6)
! 85: lea ETEMP(a6),a0
! 86: bsr tag
! 87: move.b d0,STAG(a6)
! 88:
! 89: bsr _OPa_
! 90:
! 91: fmove.l fpsr,d0 ; update status register
! 92: or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
! 93: swap.w d0
! 94: or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte
! 95: swap.w d0
! 96: fmove.l d0,fpsr
! 97: *
! 98: * Result is now in FP0
! 99: *
! 100: movem.l USER_DA(a6),d0-d1/a0-a1
! 101: fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
! 102: unlk a6
! 103: rts
! 104:
! 105: xdef _OPd_
! 106: _OPd_:
! 107: link a6,#-LOCAL_SIZE
! 108: movem.l d0-d1/a0-a1,USER_DA(a6)
! 109: fmovem.x fp0-fp3,USER_FP0(a6)
! 110: fmovem.l fpsr/fpcr,USER_FPSR(a6) ; user's rounding mode/precision
! 111: fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
! 112: *
! 113: * copy, convert and tag input arguments
! 114: *
! 115: fmove.d 8(a6),fp0
! 116: fmove.x fp0,FPTEMP(a6)
! 117: lea FPTEMP(a6),a0
! 118: bsr tag
! 119: move.b d0,DTAG(a6)
! 120:
! 121: fmove.d 16(a6),fp0
! 122: fmove.x fp0,ETEMP(a6)
! 123: lea ETEMP(a6),a0
! 124: bsr tag
! 125: move.b d0,STAG(a6)
! 126:
! 127: bsr _OPa_
! 128:
! 129: fmove.l fpsr,d0 ; update status register
! 130: or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
! 131: swap.w d0
! 132: or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte
! 133: swap.w d0
! 134: fmove.l d0,fpsr
! 135: *
! 136: * Result is now in FP0
! 137: *
! 138: movem.l USER_DA(a6),d0-d1/a0-a1
! 139: fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
! 140: unlk a6
! 141: rts
! 142:
! 143: xdef _OPx_
! 144: _OPx_:
! 145: link a6,#-LOCAL_SIZE
! 146: movem.l d0-d1/a0-a1,USER_DA(a6)
! 147: fmovem.x fp0-fp3,USER_FP0(a6)
! 148: fmovem.l fpsr/fpcr,USER_FPSR(a6) ; user's rounding mode/precision
! 149: fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
! 150: *
! 151: * copy, convert and tag input arguments
! 152: *
! 153: fmove.x 8(a6),fp0
! 154: fmove.x fp0,FPTEMP(a6)
! 155: lea FPTEMP(a6),a0
! 156: bsr tag
! 157: move.b d0,DTAG(a6)
! 158:
! 159: fmove.x 20(a6),fp0
! 160: fmove.x fp0,ETEMP(a6)
! 161: lea ETEMP(a6),a0
! 162: bsr tag
! 163: move.b d0,STAG(a6)
! 164:
! 165: bsr _OPa_
! 166:
! 167: fmove.l fpsr,d0 ; update status register
! 168: or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
! 169: swap.w d0
! 170: or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte
! 171: swap.w d0
! 172: fmove.l d0,fpsr
! 173: *
! 174: * Result is now in FP0
! 175: *
! 176: movem.l USER_DA(a6),d0-d1/a0-a1
! 177: fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
! 178: unlk a6
! 179: rts
! 180:
CVSweb