Home | History | Annotate | Line # | Download | only in fpsp
x_ovfl.sa revision 1.1.1.1
      1  1.1  mycroft *	MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
      2  1.1  mycroft *	M68000 Hi-Performance Microprocessor Division
      3  1.1  mycroft *	M68040 Software Package 
      4  1.1  mycroft *
      5  1.1  mycroft *	M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
      6  1.1  mycroft *	All rights reserved.
      7  1.1  mycroft *
      8  1.1  mycroft *	THE SOFTWARE is provided on an "AS IS" basis and without warranty.
      9  1.1  mycroft *	To the maximum extent permitted by applicable law,
     10  1.1  mycroft *	MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
     11  1.1  mycroft *	INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
     12  1.1  mycroft *	PARTICULAR PURPOSE and any warranty against infringement with
     13  1.1  mycroft *	regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
     14  1.1  mycroft *	and any accompanying written materials. 
     15  1.1  mycroft *
     16  1.1  mycroft *	To the maximum extent permitted by applicable law,
     17  1.1  mycroft *	IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
     18  1.1  mycroft *	(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
     19  1.1  mycroft *	PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
     20  1.1  mycroft *	OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
     21  1.1  mycroft *	SOFTWARE.  Motorola assumes no responsibility for the maintenance
     22  1.1  mycroft *	and support of the SOFTWARE.  
     23  1.1  mycroft *
     24  1.1  mycroft *	You are hereby granted a copyright license to use, modify, and
     25  1.1  mycroft *	distribute the SOFTWARE so long as this entire notice is retained
     26  1.1  mycroft *	without alteration in any modified and/or redistributed versions,
     27  1.1  mycroft *	and that such modified versions are clearly identified as such.
     28  1.1  mycroft *	No licenses are granted by implication, estoppel or otherwise
     29  1.1  mycroft *	under any patents or trademarks of Motorola, Inc.
     30  1.1  mycroft 
     31  1.1  mycroft *
     32  1.1  mycroft *	x_ovfl.sa 3.5 7/1/91
     33  1.1  mycroft *
     34  1.1  mycroft *	fpsp_ovfl --- FPSP handler for overflow exception
     35  1.1  mycroft *
     36  1.1  mycroft *	Overflow occurs when a floating-point intermediate result is
     37  1.1  mycroft *	too large to be represented in a floating-point data register,
     38  1.1  mycroft *	or when storing to memory, the contents of a floating-point
     39  1.1  mycroft *	data register are too large to be represented in the
     40  1.1  mycroft *	destination format.
     41  1.1  mycroft *		
     42  1.1  mycroft * Trap disabled results
     43  1.1  mycroft *
     44  1.1  mycroft * If the instruction is move_out, then garbage is stored in the
     45  1.1  mycroft * destination.  If the instruction is not move_out, then the
     46  1.1  mycroft * destination is not affected.  For 68881 compatibility, the
     47  1.1  mycroft * following values should be stored at the destination, based
     48  1.1  mycroft * on the current rounding mode:
     49  1.1  mycroft *
     50  1.1  mycroft *  RN	Infinity with the sign of the intermediate result.
     51  1.1  mycroft *  RZ	Largest magnitude number, with the sign of the
     52  1.1  mycroft *	intermediate result.
     53  1.1  mycroft *  RM   For pos overflow, the largest pos number. For neg overflow,
     54  1.1  mycroft *	-infinity
     55  1.1  mycroft *  RP   For pos overflow, +infinity. For neg overflow, the largest
     56  1.1  mycroft *	neg number
     57  1.1  mycroft *
     58  1.1  mycroft * Trap enabled results
     59  1.1  mycroft * All trap disabled code applies.  In addition the exceptional
     60  1.1  mycroft * operand needs to be made available to the users exception handler
     61  1.1  mycroft * with a bias of $6000 subtracted from the exponent.
     62  1.1  mycroft *
     63  1.1  mycroft 
     64  1.1  mycroft X_OVFL	IDNT    2,1 Motorola 040 Floating Point Software Package
     65  1.1  mycroft 
     66  1.1  mycroft 	section	8
     67  1.1  mycroft 
     68  1.1  mycroft 	include	fpsp.h
     69  1.1  mycroft 
     70  1.1  mycroft 	xref	ovf_r_x2
     71  1.1  mycroft 	xref	ovf_r_x3
     72  1.1  mycroft 	xref	store
     73  1.1  mycroft 	xref	real_ovfl
     74  1.1  mycroft 	xref	real_inex
     75  1.1  mycroft 	xref	fpsp_done
     76  1.1  mycroft 	xref	g_opcls
     77  1.1  mycroft 	xref	b1238_fix
     78  1.1  mycroft 
     79  1.1  mycroft 	xdef	fpsp_ovfl
     80  1.1  mycroft fpsp_ovfl:
     81  1.1  mycroft 	link		a6,#-LOCAL_SIZE
     82  1.1  mycroft 	fsave		-(a7)
     83  1.1  mycroft 	movem.l		d0-d1/a0-a1,USER_DA(a6)
     84  1.1  mycroft 	fmovem.x	fp0-fp3,USER_FP0(a6)
     85  1.1  mycroft 	fmovem.l	fpcr/fpsr/fpiar,USER_FPCR(a6)
     86  1.1  mycroft 
     87  1.1  mycroft *
     88  1.1  mycroft *	The 040 doesn't set the AINEX bit in the FPSR, the following
     89  1.1  mycroft *	line temporarily rectifies this error.
     90  1.1  mycroft *
     91  1.1  mycroft 	bset.b	#ainex_bit,FPSR_AEXCEPT(a6)
     92  1.1  mycroft *
     93  1.1  mycroft 	bsr.l	ovf_adj		;denormalize, round & store interm op
     94  1.1  mycroft *
     95  1.1  mycroft *	if overflow traps not enabled check for inexact exception
     96  1.1  mycroft *
     97  1.1  mycroft 	btst.b	#ovfl_bit,FPCR_ENABLE(a6)
     98  1.1  mycroft 	beq.b	ck_inex	
     99  1.1  mycroft *
    100  1.1  mycroft 	btst.b		#E3,E_BYTE(a6)
    101  1.1  mycroft 	beq.b		no_e3_1
    102  1.1  mycroft 	bfextu		CMDREG3B(a6){6:3},d0	;get dest reg no
    103  1.1  mycroft 	bclr.b		d0,FPR_DIRTY_BITS(a6)	;clr dest dirty bit
    104  1.1  mycroft 	bsr.l		b1238_fix
    105  1.1  mycroft 	move.l		USER_FPSR(a6),FPSR_SHADOW(a6)
    106  1.1  mycroft 	or.l		#sx_mask,E_BYTE(a6)
    107  1.1  mycroft no_e3_1:
    108  1.1  mycroft 	movem.l		USER_DA(a6),d0-d1/a0-a1
    109  1.1  mycroft 	fmovem.x	USER_FP0(a6),fp0-fp3
    110  1.1  mycroft 	fmovem.l	USER_FPCR(a6),fpcr/fpsr/fpiar
    111  1.1  mycroft 	frestore	(a7)+
    112  1.1  mycroft 	unlk		a6
    113  1.1  mycroft 	bra.l		real_ovfl
    114  1.1  mycroft *
    115  1.1  mycroft * It is possible to have either inex2 or inex1 exceptions with the
    116  1.1  mycroft * ovfl.  If the inex enable bit is set in the FPCR, and either
    117  1.1  mycroft * inex2 or inex1 occured, we must clean up and branch to the
    118  1.1  mycroft * real inex handler.
    119  1.1  mycroft *
    120  1.1  mycroft ck_inex:
    121  1.1  mycroft *	move.b		FPCR_ENABLE(a6),d0
    122  1.1  mycroft *	and.b		FPSR_EXCEPT(a6),d0
    123  1.1  mycroft *	andi.b		#$3,d0
    124  1.1  mycroft 	btst.b		#inex2_bit,FPCR_ENABLE(a6)
    125  1.1  mycroft 	beq.b		ovfl_exit
    126  1.1  mycroft *
    127  1.1  mycroft * Inexact enabled and reported, and we must take an inexact exception.
    128  1.1  mycroft *
    129  1.1  mycroft take_inex:
    130  1.1  mycroft 	btst.b		#E3,E_BYTE(a6)
    131  1.1  mycroft 	beq.b		no_e3_2
    132  1.1  mycroft 	bfextu		CMDREG3B(a6){6:3},d0	;get dest reg no
    133  1.1  mycroft 	bclr.b		d0,FPR_DIRTY_BITS(a6)	;clr dest dirty bit
    134  1.1  mycroft 	bsr.l		b1238_fix
    135  1.1  mycroft 	move.l		USER_FPSR(a6),FPSR_SHADOW(a6)
    136  1.1  mycroft 	or.l		#sx_mask,E_BYTE(a6)
    137  1.1  mycroft no_e3_2:
    138  1.1  mycroft 	move.b		#INEX_VEC,EXC_VEC+1(a6)
    139  1.1  mycroft 	movem.l		USER_DA(a6),d0-d1/a0-a1
    140  1.1  mycroft 	fmovem.x	USER_FP0(a6),fp0-fp3
    141  1.1  mycroft 	fmovem.l	USER_FPCR(a6),fpcr/fpsr/fpiar
    142  1.1  mycroft 	frestore	(a7)+
    143  1.1  mycroft 	unlk		a6
    144  1.1  mycroft 	bra.l		real_inex
    145  1.1  mycroft 	
    146  1.1  mycroft ovfl_exit:
    147  1.1  mycroft 	bclr.b	#E3,E_BYTE(a6)	;test and clear E3 bit
    148  1.1  mycroft 	beq.b	e1_set
    149  1.1  mycroft *
    150  1.1  mycroft * Clear dirty bit on dest resister in the frame before branching
    151  1.1  mycroft * to b1238_fix.
    152  1.1  mycroft *
    153  1.1  mycroft 	bfextu		CMDREG3B(a6){6:3},d0	;get dest reg no
    154  1.1  mycroft 	bclr.b		d0,FPR_DIRTY_BITS(a6)	;clr dest dirty bit
    155  1.1  mycroft 	bsr.l		b1238_fix		;test for bug1238 case
    156  1.1  mycroft 
    157  1.1  mycroft 	move.l		USER_FPSR(a6),FPSR_SHADOW(a6)
    158  1.1  mycroft 	or.l		#sx_mask,E_BYTE(a6)
    159  1.1  mycroft 	movem.l		USER_DA(a6),d0-d1/a0-a1
    160  1.1  mycroft 	fmovem.x	USER_FP0(a6),fp0-fp3
    161  1.1  mycroft 	fmovem.l	USER_FPCR(a6),fpcr/fpsr/fpiar
    162  1.1  mycroft 	frestore	(a7)+
    163  1.1  mycroft 	unlk		a6
    164  1.1  mycroft 	bra.l		fpsp_done
    165  1.1  mycroft e1_set:
    166  1.1  mycroft 	movem.l		USER_DA(a6),d0-d1/a0-a1
    167  1.1  mycroft 	fmovem.x	USER_FP0(a6),fp0-fp3
    168  1.1  mycroft 	fmovem.l	USER_FPCR(a6),fpcr/fpsr/fpiar
    169  1.1  mycroft 	unlk		a6
    170  1.1  mycroft 	bra.l		fpsp_done
    171  1.1  mycroft 
    172  1.1  mycroft *
    173  1.1  mycroft *	ovf_adj
    174  1.1  mycroft *
    175  1.1  mycroft ovf_adj:
    176  1.1  mycroft *
    177  1.1  mycroft * Have a0 point to the correct operand. 
    178  1.1  mycroft *
    179  1.1  mycroft 	btst.b	#E3,E_BYTE(a6)	;test E3 bit
    180  1.1  mycroft 	beq.b	ovf_e1
    181  1.1  mycroft 
    182  1.1  mycroft 	lea	WBTEMP(a6),a0
    183  1.1  mycroft 	bra.b	ovf_com
    184  1.1  mycroft ovf_e1:
    185  1.1  mycroft 	lea	ETEMP(a6),a0
    186  1.1  mycroft 
    187  1.1  mycroft ovf_com:
    188  1.1  mycroft 	bclr.b	#sign_bit,LOCAL_EX(a0)
    189  1.1  mycroft 	sne	LOCAL_SGN(a0)
    190  1.1  mycroft 
    191  1.1  mycroft 	bsr.l	g_opcls		;returns opclass in d0
    192  1.1  mycroft 	cmpi.w	#3,d0		;check for opclass3
    193  1.1  mycroft 	bne.b	not_opc011
    194  1.1  mycroft 
    195  1.1  mycroft *
    196  1.1  mycroft * FPSR_CC is saved and restored because ovf_r_x3 affects it. The
    197  1.1  mycroft * CCs are defined to be 'not affected' for the opclass3 instruction.
    198  1.1  mycroft *
    199  1.1  mycroft 	move.b	FPSR_CC(a6),L_SCR1(a6)
    200  1.1  mycroft  	bsr.l	ovf_r_x3	;returns a0 pointing to result
    201  1.1  mycroft 	move.b	L_SCR1(a6),FPSR_CC(a6)
    202  1.1  mycroft 	bra.l	store		;stores to memory or register
    203  1.1  mycroft 	
    204  1.1  mycroft not_opc011:
    205  1.1  mycroft 	bsr.l	ovf_r_x2	;returns a0 pointing to result
    206  1.1  mycroft 	bra.l	store		;stores to memory or register
    207  1.1  mycroft 
    208  1.1  mycroft 	end
    209