1* $NetBSD: DYADIC.GCC,v 1.2 1994/10/26 07:48:27 cgd Exp $ 2 3* MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP 4* M68000 Hi-Performance Microprocessor Division 5* M68040 Software Package 6* 7* M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc. 8* All rights reserved. 9* 10* THE SOFTWARE is provided on an "AS IS" basis and without warranty. 11* To the maximum extent permitted by applicable law, 12* MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, 13* INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A 14* PARTICULAR PURPOSE and any warranty against infringement with 15* regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) 16* and any accompanying written materials. 17* 18* To the maximum extent permitted by applicable law, 19* IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER 20* (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS 21* PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR 22* OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE 23* SOFTWARE. Motorola assumes no responsibility for the maintenance 24* and support of the SOFTWARE. 25* 26* You are hereby granted a copyright license to use, modify, and 27* distribute the SOFTWARE so long as this entire notice is retained 28* without alteration in any modified and/or redistributed versions, 29* and that such modified versions are clearly identified as such. 30* No licenses are granted by implication, estoppel or otherwise 31* under any patents or trademarks of Motorola, Inc. 32 33* 34* DYADIC.GCC --- DYADIC template for GCC compiler 35* 36* This is based on the generic template. The only difference is that 37* GCC does not need the d0-d1/a0-a1 registers saved. 38* 39* Customizations: 40* 2. Likewise, don't save FP0/FP1 if they are scratch 41* registers. 42* 3. Delete updating of the fpsr if you only care about 43* the result. 44* 5. Move the result to d0/d1 if the compiler is that old. 45* 46 47 xref _OPa_ 48 xref tag 49 50 xdef _OPs_ 51_OPs_: 52 link a6,#-LOCAL_SIZE 53 fmovem.x fp0-fp3,USER_FP0(a6) 54 fmove.l fpsr,USER_FPSR(a6) 55 fmove.l fpcr,USER_FPCR(a6) ; user's rounding mode/precision 56 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn 57* 58* copy, convert and tag input arguments 59* 60 fmove.s 8(a6),fp0 61 fmove.x fp0,FPTEMP(a6) 62 lea FPTEMP(a6),a0 63 bsr tag 64 move.b d0,DTAG(a6) 65 66 fmove.s 12(a6),fp0 67 fmove.x fp0,ETEMP(a6) 68 lea ETEMP(a6),a0 69 bsr tag 70 move.b d0,STAG(a6) 71 72 bsr _OPa_ 73 74 fmove.l fpsr,d0 ; update status register 75 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions 76 swap.w d0 77 or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte 78 swap.w d0 79 fmove.l d0,fpsr 80* 81* Result is now in FP0 82* 83 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored 84 unlk a6 85 rts 86 87 xdef _OPd_ 88_OPd_: 89 link a6,#-LOCAL_SIZE 90 fmovem.x fp0-fp3,USER_FP0(a6) 91 fmove.l fpsr,USER_FPSR(a6) 92 fmove.l fpcr,USER_FPCR(a6) ; user's rounding mode/precision 93 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn 94* 95* copy, convert and tag input arguments 96* 97 fmove.d 8(a6),fp0 98 fmove.x fp0,FPTEMP(a6) 99 lea FPTEMP(a6),a0 100 bsr tag 101 move.b d0,DTAG(a6) 102 103 fmove.d 16(a6),fp0 104 fmove.x fp0,ETEMP(a6) 105 lea ETEMP(a6),a0 106 bsr tag 107 move.b d0,STAG(a6) 108 109 bsr _OPa_ 110 111 fmove.l fpsr,d0 ; update status register 112 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions 113 swap.w d0 114 or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte 115 swap.w d0 116 fmove.l d0,fpsr 117* 118* Result is now in FP0 119* 120 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored 121 unlk a6 122 rts 123 124 xdef _OPx_ 125_OPx_: 126 link a6,#-LOCAL_SIZE 127 fmovem.x fp0-fp3,USER_FP0(a6) 128 fmove.l fpsr,USER_FPSR(a6) 129 fmove.l fpcr,USER_FPCR(a6) ; user's rounding mode/precision 130 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn 131* 132* copy, convert and tag input arguments 133* 134 fmove.x 8(a6),fp0 135 fmove.x fp0,FPTEMP(a6) 136 lea FPTEMP(a6),a0 137 bsr tag 138 move.b d0,DTAG(a6) 139 140 fmove.x 20(a6),fp0 141 fmove.x fp0,ETEMP(a6) 142 lea ETEMP(a6),a0 143 bsr tag 144 move.b d0,STAG(a6) 145 146 bsr _OPa_ 147 148 fmove.l fpsr,d0 ; update status register 149 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions 150 swap.w d0 151 or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte 152 swap.w d0 153 fmove.l d0,fpsr 154* 155* Result is now in FP0 156* 157 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored 158 unlk a6 159 rts 160 161