Home | History | Annotate | Line # | Download | only in fpsp
x_ovfl.sa revision 1.2.44.1
      1  1.2.44.1     fvdl *	$NetBSD: x_ovfl.sa,v 1.2.44.1 2001/10/01 12:40:23 fvdl 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 *	x_ovfl.sa 3.5 7/1/91
     35       1.1  mycroft *
     36       1.1  mycroft *	fpsp_ovfl --- FPSP handler for overflow exception
     37       1.1  mycroft *
     38       1.1  mycroft *	Overflow occurs when a floating-point intermediate result is
     39       1.1  mycroft *	too large to be represented in a floating-point data register,
     40       1.1  mycroft *	or when storing to memory, the contents of a floating-point
     41       1.1  mycroft *	data register are too large to be represented in the
     42       1.1  mycroft *	destination format.
     43       1.1  mycroft *		
     44       1.1  mycroft * Trap disabled results
     45       1.1  mycroft *
     46       1.1  mycroft * If the instruction is move_out, then garbage is stored in the
     47       1.1  mycroft * destination.  If the instruction is not move_out, then the
     48       1.1  mycroft * destination is not affected.  For 68881 compatibility, the
     49       1.1  mycroft * following values should be stored at the destination, based
     50       1.1  mycroft * on the current rounding mode:
     51       1.1  mycroft *
     52       1.1  mycroft *  RN	Infinity with the sign of the intermediate result.
     53       1.1  mycroft *  RZ	Largest magnitude number, with the sign of the
     54       1.1  mycroft *	intermediate result.
     55       1.1  mycroft *  RM   For pos overflow, the largest pos number. For neg overflow,
     56       1.1  mycroft *	-infinity
     57       1.1  mycroft *  RP   For pos overflow, +infinity. For neg overflow, the largest
     58       1.1  mycroft *	neg number
     59       1.1  mycroft *
     60       1.1  mycroft * Trap enabled results
     61       1.1  mycroft * All trap disabled code applies.  In addition the exceptional
     62       1.1  mycroft * operand needs to be made available to the users exception handler
     63       1.1  mycroft * with a bias of $6000 subtracted from the exponent.
     64       1.1  mycroft *
     65       1.1  mycroft 
     66       1.1  mycroft X_OVFL	IDNT    2,1 Motorola 040 Floating Point Software Package
     67       1.1  mycroft 
     68       1.1  mycroft 	section	8
     69       1.1  mycroft 
     70       1.1  mycroft 	include	fpsp.h
     71       1.1  mycroft 
     72       1.1  mycroft 	xref	ovf_r_x2
     73       1.1  mycroft 	xref	ovf_r_x3
     74       1.1  mycroft 	xref	store
     75       1.1  mycroft 	xref	real_ovfl
     76       1.1  mycroft 	xref	real_inex
     77       1.1  mycroft 	xref	fpsp_done
     78       1.1  mycroft 	xref	g_opcls
     79       1.1  mycroft 	xref	b1238_fix
     80       1.1  mycroft 
     81       1.1  mycroft 	xdef	fpsp_ovfl
     82       1.1  mycroft fpsp_ovfl:
     83       1.1  mycroft 	link		a6,#-LOCAL_SIZE
     84       1.1  mycroft 	fsave		-(a7)
     85       1.1  mycroft 	movem.l		d0-d1/a0-a1,USER_DA(a6)
     86       1.1  mycroft 	fmovem.x	fp0-fp3,USER_FP0(a6)
     87       1.1  mycroft 	fmovem.l	fpcr/fpsr/fpiar,USER_FPCR(a6)
     88       1.1  mycroft 
     89       1.1  mycroft *
     90       1.1  mycroft *	The 040 doesn't set the AINEX bit in the FPSR, the following
     91       1.1  mycroft *	line temporarily rectifies this error.
     92       1.1  mycroft *
     93       1.1  mycroft 	bset.b	#ainex_bit,FPSR_AEXCEPT(a6)
     94       1.1  mycroft *
     95       1.1  mycroft 	bsr.l	ovf_adj		;denormalize, round & store interm op
     96       1.1  mycroft *
     97       1.1  mycroft *	if overflow traps not enabled check for inexact exception
     98       1.1  mycroft *
     99       1.1  mycroft 	btst.b	#ovfl_bit,FPCR_ENABLE(a6)
    100       1.1  mycroft 	beq.b	ck_inex	
    101       1.1  mycroft *
    102       1.1  mycroft 	btst.b		#E3,E_BYTE(a6)
    103       1.1  mycroft 	beq.b		no_e3_1
    104       1.1  mycroft 	bfextu		CMDREG3B(a6){6:3},d0	;get dest reg no
    105       1.1  mycroft 	bclr.b		d0,FPR_DIRTY_BITS(a6)	;clr dest dirty bit
    106       1.1  mycroft 	bsr.l		b1238_fix
    107       1.1  mycroft 	move.l		USER_FPSR(a6),FPSR_SHADOW(a6)
    108       1.1  mycroft 	or.l		#sx_mask,E_BYTE(a6)
    109       1.1  mycroft no_e3_1:
    110       1.1  mycroft 	movem.l		USER_DA(a6),d0-d1/a0-a1
    111       1.1  mycroft 	fmovem.x	USER_FP0(a6),fp0-fp3
    112       1.1  mycroft 	fmovem.l	USER_FPCR(a6),fpcr/fpsr/fpiar
    113       1.1  mycroft 	frestore	(a7)+
    114       1.1  mycroft 	unlk		a6
    115       1.1  mycroft 	bra.l		real_ovfl
    116       1.1  mycroft *
    117       1.1  mycroft * It is possible to have either inex2 or inex1 exceptions with the
    118       1.1  mycroft * ovfl.  If the inex enable bit is set in the FPCR, and either
    119  1.2.44.1     fvdl * inex2 or inex1 occurred, we must clean up and branch to the
    120       1.1  mycroft * real inex handler.
    121       1.1  mycroft *
    122       1.1  mycroft ck_inex:
    123       1.1  mycroft *	move.b		FPCR_ENABLE(a6),d0
    124       1.1  mycroft *	and.b		FPSR_EXCEPT(a6),d0
    125       1.1  mycroft *	andi.b		#$3,d0
    126       1.1  mycroft 	btst.b		#inex2_bit,FPCR_ENABLE(a6)
    127       1.1  mycroft 	beq.b		ovfl_exit
    128       1.1  mycroft *
    129       1.1  mycroft * Inexact enabled and reported, and we must take an inexact exception.
    130       1.1  mycroft *
    131       1.1  mycroft take_inex:
    132       1.1  mycroft 	btst.b		#E3,E_BYTE(a6)
    133       1.1  mycroft 	beq.b		no_e3_2
    134       1.1  mycroft 	bfextu		CMDREG3B(a6){6:3},d0	;get dest reg no
    135       1.1  mycroft 	bclr.b		d0,FPR_DIRTY_BITS(a6)	;clr dest dirty bit
    136       1.1  mycroft 	bsr.l		b1238_fix
    137       1.1  mycroft 	move.l		USER_FPSR(a6),FPSR_SHADOW(a6)
    138       1.1  mycroft 	or.l		#sx_mask,E_BYTE(a6)
    139       1.1  mycroft no_e3_2:
    140       1.1  mycroft 	move.b		#INEX_VEC,EXC_VEC+1(a6)
    141       1.1  mycroft 	movem.l		USER_DA(a6),d0-d1/a0-a1
    142       1.1  mycroft 	fmovem.x	USER_FP0(a6),fp0-fp3
    143       1.1  mycroft 	fmovem.l	USER_FPCR(a6),fpcr/fpsr/fpiar
    144       1.1  mycroft 	frestore	(a7)+
    145       1.1  mycroft 	unlk		a6
    146       1.1  mycroft 	bra.l		real_inex
    147       1.1  mycroft 	
    148       1.1  mycroft ovfl_exit:
    149       1.1  mycroft 	bclr.b	#E3,E_BYTE(a6)	;test and clear E3 bit
    150       1.1  mycroft 	beq.b	e1_set
    151       1.1  mycroft *
    152       1.1  mycroft * Clear dirty bit on dest resister in the frame before branching
    153       1.1  mycroft * to b1238_fix.
    154       1.1  mycroft *
    155       1.1  mycroft 	bfextu		CMDREG3B(a6){6:3},d0	;get dest reg no
    156       1.1  mycroft 	bclr.b		d0,FPR_DIRTY_BITS(a6)	;clr dest dirty bit
    157       1.1  mycroft 	bsr.l		b1238_fix		;test for bug1238 case
    158       1.1  mycroft 
    159       1.1  mycroft 	move.l		USER_FPSR(a6),FPSR_SHADOW(a6)
    160       1.1  mycroft 	or.l		#sx_mask,E_BYTE(a6)
    161       1.1  mycroft 	movem.l		USER_DA(a6),d0-d1/a0-a1
    162       1.1  mycroft 	fmovem.x	USER_FP0(a6),fp0-fp3
    163       1.1  mycroft 	fmovem.l	USER_FPCR(a6),fpcr/fpsr/fpiar
    164       1.1  mycroft 	frestore	(a7)+
    165       1.1  mycroft 	unlk		a6
    166       1.1  mycroft 	bra.l		fpsp_done
    167       1.1  mycroft e1_set:
    168       1.1  mycroft 	movem.l		USER_DA(a6),d0-d1/a0-a1
    169       1.1  mycroft 	fmovem.x	USER_FP0(a6),fp0-fp3
    170       1.1  mycroft 	fmovem.l	USER_FPCR(a6),fpcr/fpsr/fpiar
    171       1.1  mycroft 	unlk		a6
    172       1.1  mycroft 	bra.l		fpsp_done
    173       1.1  mycroft 
    174       1.1  mycroft *
    175       1.1  mycroft *	ovf_adj
    176       1.1  mycroft *
    177       1.1  mycroft ovf_adj:
    178       1.1  mycroft *
    179       1.1  mycroft * Have a0 point to the correct operand. 
    180       1.1  mycroft *
    181       1.1  mycroft 	btst.b	#E3,E_BYTE(a6)	;test E3 bit
    182       1.1  mycroft 	beq.b	ovf_e1
    183       1.1  mycroft 
    184       1.1  mycroft 	lea	WBTEMP(a6),a0
    185       1.1  mycroft 	bra.b	ovf_com
    186       1.1  mycroft ovf_e1:
    187       1.1  mycroft 	lea	ETEMP(a6),a0
    188       1.1  mycroft 
    189       1.1  mycroft ovf_com:
    190       1.1  mycroft 	bclr.b	#sign_bit,LOCAL_EX(a0)
    191       1.1  mycroft 	sne	LOCAL_SGN(a0)
    192       1.1  mycroft 
    193       1.1  mycroft 	bsr.l	g_opcls		;returns opclass in d0
    194       1.1  mycroft 	cmpi.w	#3,d0		;check for opclass3
    195       1.1  mycroft 	bne.b	not_opc011
    196       1.1  mycroft 
    197       1.1  mycroft *
    198       1.1  mycroft * FPSR_CC is saved and restored because ovf_r_x3 affects it. The
    199       1.1  mycroft * CCs are defined to be 'not affected' for the opclass3 instruction.
    200       1.1  mycroft *
    201       1.1  mycroft 	move.b	FPSR_CC(a6),L_SCR1(a6)
    202       1.1  mycroft  	bsr.l	ovf_r_x3	;returns a0 pointing to result
    203       1.1  mycroft 	move.b	L_SCR1(a6),FPSR_CC(a6)
    204       1.1  mycroft 	bra.l	store		;stores to memory or register
    205       1.1  mycroft 	
    206       1.1  mycroft not_opc011:
    207       1.1  mycroft 	bsr.l	ovf_r_x2	;returns a0 pointing to result
    208       1.1  mycroft 	bra.l	store		;stores to memory or register
    209       1.1  mycroft 
    210       1.1  mycroft 	end
    211