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