xref: /netbsd-src/sys/arch/m68k/fpsp/scale.sa (revision 57fb77a14ebcd83f1fae16b59e7b83fd0f166e03)
1*57fb77a1Scgd*	$NetBSD: scale.sa,v 1.3 1994/10/26 07:49:34 cgd Exp $
2*57fb77a1Scgd
322ef5fa9Smycroft*	MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
422ef5fa9Smycroft*	M68000 Hi-Performance Microprocessor Division
522ef5fa9Smycroft*	M68040 Software Package
622ef5fa9Smycroft*
722ef5fa9Smycroft*	M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
822ef5fa9Smycroft*	All rights reserved.
922ef5fa9Smycroft*
1022ef5fa9Smycroft*	THE SOFTWARE is provided on an "AS IS" basis and without warranty.
1122ef5fa9Smycroft*	To the maximum extent permitted by applicable law,
1222ef5fa9Smycroft*	MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
1322ef5fa9Smycroft*	INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
1422ef5fa9Smycroft*	PARTICULAR PURPOSE and any warranty against infringement with
1522ef5fa9Smycroft*	regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
1622ef5fa9Smycroft*	and any accompanying written materials.
1722ef5fa9Smycroft*
1822ef5fa9Smycroft*	To the maximum extent permitted by applicable law,
1922ef5fa9Smycroft*	IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
2022ef5fa9Smycroft*	(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
2122ef5fa9Smycroft*	PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
2222ef5fa9Smycroft*	OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
2322ef5fa9Smycroft*	SOFTWARE.  Motorola assumes no responsibility for the maintenance
2422ef5fa9Smycroft*	and support of the SOFTWARE.
2522ef5fa9Smycroft*
2622ef5fa9Smycroft*	You are hereby granted a copyright license to use, modify, and
2722ef5fa9Smycroft*	distribute the SOFTWARE so long as this entire notice is retained
2822ef5fa9Smycroft*	without alteration in any modified and/or redistributed versions,
2922ef5fa9Smycroft*	and that such modified versions are clearly identified as such.
3022ef5fa9Smycroft*	No licenses are granted by implication, estoppel or otherwise
3122ef5fa9Smycroft*	under any patents or trademarks of Motorola, Inc.
3222ef5fa9Smycroft
3322ef5fa9Smycroft*
3422ef5fa9Smycroft*	scale.sa 3.3 7/30/91
3522ef5fa9Smycroft*
3622ef5fa9Smycroft*	The entry point sSCALE computes the destination operand
3722ef5fa9Smycroft*	scaled by the source operand.  If the absoulute value of
3822ef5fa9Smycroft*	the source operand is (>= 2^14) an overflow or underflow
3922ef5fa9Smycroft*	is returned.
4022ef5fa9Smycroft*
4122ef5fa9Smycroft*	The entry point sscale is called from do_func to emulate
4222ef5fa9Smycroft*	the fscale unimplemented instruction.
4322ef5fa9Smycroft*
4422ef5fa9Smycroft*	Input: Double-extended destination operand in FPTEMP,
4522ef5fa9Smycroft*		double-extended source operand in ETEMP.
4622ef5fa9Smycroft*
4722ef5fa9Smycroft*	Output: The function returns scale(X,Y) to fp0.
4822ef5fa9Smycroft*
4922ef5fa9Smycroft*	Modifies: fp0.
5022ef5fa9Smycroft*
5122ef5fa9Smycroft*	Algorithm:
5222ef5fa9Smycroft*
5322ef5fa9Smycroft
5422ef5fa9SmycroftSCALE    IDNT    2,1 Motorola 040 Floating Point Software Package
5522ef5fa9Smycroft
5622ef5fa9Smycroft	section	8
5722ef5fa9Smycroft
5822ef5fa9Smycroft	include	fpsp.h
5922ef5fa9Smycroft
6022ef5fa9Smycroft	xref	t_ovfl2
6122ef5fa9Smycroft	xref	t_unfl
6222ef5fa9Smycroft	xref	round
6322ef5fa9Smycroft	xref	t_resdnrm
6422ef5fa9Smycroft
6522ef5fa9SmycroftSRC_BNDS dc.w	$3fff,$400c
6622ef5fa9Smycroft
6722ef5fa9Smycroft*
6822ef5fa9Smycroft* This entry point is used by the unimplemented instruction exception
6922ef5fa9Smycroft* handler.
7022ef5fa9Smycroft*
7122ef5fa9Smycroft*
7222ef5fa9Smycroft*
7322ef5fa9Smycroft*	FSCALE
7422ef5fa9Smycroft*
7522ef5fa9Smycroft	xdef	sscale
7622ef5fa9Smycroftsscale:
7722ef5fa9Smycroft	fmove.l		#0,fpcr		;clr user enabled exc
7822ef5fa9Smycroft	clr.l		d1
7922ef5fa9Smycroft	move.w		FPTEMP(a6),d1	;get dest exponent
8022ef5fa9Smycroft	smi		L_SCR1(a6)	;use L_SCR1 to hold sign
8122ef5fa9Smycroft	andi.l		#$7fff,d1	;strip sign
8222ef5fa9Smycroft	move.w		ETEMP(a6),d0	;check src bounds
8322ef5fa9Smycroft	andi.w		#$7fff,d0	;clr sign bit
8422ef5fa9Smycroft	cmp2.w		SRC_BNDS,d0
8522ef5fa9Smycroft	bcc.b		src_in
8622ef5fa9Smycroft	cmpi.w		#$400c,d0	;test for too large
8722ef5fa9Smycroft	bge.w		src_out
8822ef5fa9Smycroft*
8922ef5fa9Smycroft* The source input is below 1, so we check for denormalized numbers
9022ef5fa9Smycroft* and set unfl.
9122ef5fa9Smycroft*
9222ef5fa9Smycroftsrc_small:
9322ef5fa9Smycroft	move.b		DTAG(a6),d0
9422ef5fa9Smycroft	andi.b		#$e0,d0
9522ef5fa9Smycroft	tst.b		d0
9622ef5fa9Smycroft	beq.b		no_denorm
9722ef5fa9Smycroft	st		STORE_FLG(a6)	;dest already contains result
9822ef5fa9Smycroft	or.l		#unfl_mask,USER_FPSR(a6) ;set UNFL
9922ef5fa9Smycroftden_done:
10022ef5fa9Smycroft	lea.l		FPTEMP(a6),a0
10122ef5fa9Smycroft	bra		t_resdnrm
10222ef5fa9Smycroftno_denorm:
10322ef5fa9Smycroft	fmove.l		USER_FPCR(a6),FPCR
10422ef5fa9Smycroft	fmove.x		FPTEMP(a6),fp0	;simply return dest
10522ef5fa9Smycroft	rts
10622ef5fa9Smycroft
10722ef5fa9Smycroft
10822ef5fa9Smycroft*
10922ef5fa9Smycroft* Source is within 2^14 range.  To perform the int operation,
11022ef5fa9Smycroft* move it to d0.
11122ef5fa9Smycroft*
11222ef5fa9Smycroftsrc_in:
11322ef5fa9Smycroft	fmove.x		ETEMP(a6),fp0	;move in src for int
11422ef5fa9Smycroft	fmove.l		#rz_mode,fpcr	;force rz for src conversion
11522ef5fa9Smycroft	fmove.l		fp0,d0		;int src to d0
11622ef5fa9Smycroft	fmove.l		#0,FPSR		;clr status from above
11722ef5fa9Smycroft	tst.w		ETEMP(a6)	;check src sign
11822ef5fa9Smycroft	blt.w		src_neg
11922ef5fa9Smycroft*
12022ef5fa9Smycroft* Source is positive.  Add the src to the dest exponent.
12122ef5fa9Smycroft* The result can be denormalized, if src = 0, or overflow,
12222ef5fa9Smycroft* if the result of the add sets a bit in the upper word.
12322ef5fa9Smycroft*
12422ef5fa9Smycroftsrc_pos:
12522ef5fa9Smycroft	tst.w		d1		;check for denorm
12622ef5fa9Smycroft	beq.w		dst_dnrm
12722ef5fa9Smycroft	add.l		d0,d1		;add src to dest exp
12822ef5fa9Smycroft	beq.b		denorm		;if zero, result is denorm
12922ef5fa9Smycroft	cmpi.l		#$7fff,d1	;test for overflow
13022ef5fa9Smycroft	bge.b		ovfl
13122ef5fa9Smycroft	tst.b		L_SCR1(a6)
13222ef5fa9Smycroft	beq.b		spos_pos
13322ef5fa9Smycroft	or.w		#$8000,d1
13422ef5fa9Smycroftspos_pos:
13522ef5fa9Smycroft	move.w		d1,FPTEMP(a6)	;result in FPTEMP
13622ef5fa9Smycroft	fmove.l		USER_FPCR(a6),FPCR
13722ef5fa9Smycroft	fmove.x		FPTEMP(a6),fp0	;write result to fp0
13822ef5fa9Smycroft	rts
13922ef5fa9Smycroftovfl:
14022ef5fa9Smycroft	tst.b		L_SCR1(a6)
14122ef5fa9Smycroft	beq.b		sovl_pos
14222ef5fa9Smycroft	or.w		#$8000,d1
14322ef5fa9Smycroftsovl_pos:
14422ef5fa9Smycroft	move.w		FPTEMP(a6),ETEMP(a6)	;result in ETEMP
14522ef5fa9Smycroft	move.l		FPTEMP_HI(a6),ETEMP_HI(a6)
14622ef5fa9Smycroft	move.l		FPTEMP_LO(a6),ETEMP_LO(a6)
14722ef5fa9Smycroft	bra		t_ovfl2
14822ef5fa9Smycroft
14922ef5fa9Smycroftdenorm:
15022ef5fa9Smycroft	tst.b		L_SCR1(a6)
15122ef5fa9Smycroft	beq.b		den_pos
15222ef5fa9Smycroft	or.w		#$8000,d1
15322ef5fa9Smycroftden_pos:
15422ef5fa9Smycroft	tst.l		FPTEMP_HI(a6)	;check j bit
15522ef5fa9Smycroft	blt.b		nden_exit	;if set, not denorm
15622ef5fa9Smycroft	move.w		d1,ETEMP(a6)	;input expected in ETEMP
15722ef5fa9Smycroft	move.l		FPTEMP_HI(a6),ETEMP_HI(a6)
15822ef5fa9Smycroft	move.l		FPTEMP_LO(a6),ETEMP_LO(a6)
15922ef5fa9Smycroft	or.l		#unfl_bit,USER_FPSR(a6)	;set unfl
16022ef5fa9Smycroft	lea.l		ETEMP(a6),a0
16122ef5fa9Smycroft	bra		t_resdnrm
16222ef5fa9Smycroftnden_exit:
16322ef5fa9Smycroft	move.w		d1,FPTEMP(a6)	;result in FPTEMP
16422ef5fa9Smycroft	fmove.l		USER_FPCR(a6),FPCR
16522ef5fa9Smycroft	fmove.x		FPTEMP(a6),fp0	;write result to fp0
16622ef5fa9Smycroft	rts
16722ef5fa9Smycroft
16822ef5fa9Smycroft*
16922ef5fa9Smycroft* Source is negative.  Add the src to the dest exponent.
17022ef5fa9Smycroft* (The result exponent will be reduced).  The result can be
17122ef5fa9Smycroft* denormalized.
17222ef5fa9Smycroft*
17322ef5fa9Smycroftsrc_neg:
17422ef5fa9Smycroft	add.l		d0,d1		;add src to dest
17522ef5fa9Smycroft	beq.b		denorm		;if zero, result is denorm
17622ef5fa9Smycroft	blt.b		fix_dnrm	;if negative, result is
17722ef5fa9Smycroft*					;needing denormalization
17822ef5fa9Smycroft	tst.b		L_SCR1(a6)
17922ef5fa9Smycroft	beq.b		sneg_pos
18022ef5fa9Smycroft	or.w		#$8000,d1
18122ef5fa9Smycroftsneg_pos:
18222ef5fa9Smycroft	move.w		d1,FPTEMP(a6)	;result in FPTEMP
18322ef5fa9Smycroft	fmove.l		USER_FPCR(a6),FPCR
18422ef5fa9Smycroft	fmove.x		FPTEMP(a6),fp0	;write result to fp0
18522ef5fa9Smycroft	rts
18622ef5fa9Smycroft
18722ef5fa9Smycroft
18822ef5fa9Smycroft*
18922ef5fa9Smycroft* The result exponent is below denorm value.  Test for catastrophic
19022ef5fa9Smycroft* underflow and force zero if true.  If not, try to shift the
19122ef5fa9Smycroft* mantissa right until a zero exponent exists.
19222ef5fa9Smycroft*
19322ef5fa9Smycroftfix_dnrm:
19422ef5fa9Smycroft	cmpi.w		#$ffc0,d1	;lower bound for normalization
19522ef5fa9Smycroft	blt.w		fix_unfl	;if lower, catastrophic unfl
19622ef5fa9Smycroft	move.w		d1,d0		;use d0 for exp
19722ef5fa9Smycroft	move.l		d2,-(a7)	;free d2 for norm
19822ef5fa9Smycroft	move.l		FPTEMP_HI(a6),d1
19922ef5fa9Smycroft	move.l		FPTEMP_LO(a6),d2
20022ef5fa9Smycroft	clr.l		L_SCR2(a6)
20122ef5fa9Smycroftfix_loop:
20222ef5fa9Smycroft	add.w		#1,d0		;drive d0 to 0
20322ef5fa9Smycroft	lsr.l		#1,d1		;while shifting the
20422ef5fa9Smycroft	roxr.l		#1,d2		;mantissa to the right
20522ef5fa9Smycroft	bcc.b		no_carry
20622ef5fa9Smycroft	st		L_SCR2(a6)	;use L_SCR2 to capture inex
20722ef5fa9Smycroftno_carry:
20822ef5fa9Smycroft	tst.w		d0		;it is finished when
20922ef5fa9Smycroft	blt.b		fix_loop	;d0 is zero or the mantissa
21022ef5fa9Smycroft	tst.b		L_SCR2(a6)
21122ef5fa9Smycroft	beq.b		tst_zero
21222ef5fa9Smycroft	or.l		#unfl_inx_mask,USER_FPSR(a6)
21322ef5fa9Smycroft*					;set unfl, aunfl, ainex
21422ef5fa9Smycroft*
21522ef5fa9Smycroft* Test for zero. If zero, simply use fmove to return +/- zero
21622ef5fa9Smycroft* to the fpu.
21722ef5fa9Smycroft*
21822ef5fa9Smycrofttst_zero:
21922ef5fa9Smycroft	clr.w		FPTEMP_EX(a6)
22022ef5fa9Smycroft	tst.b		L_SCR1(a6)	;test for sign
22122ef5fa9Smycroft	beq.b		tst_con
22222ef5fa9Smycroft	or.w		#$8000,FPTEMP_EX(a6) ;set sign bit
22322ef5fa9Smycrofttst_con:
22422ef5fa9Smycroft	move.l		d1,FPTEMP_HI(a6)
22522ef5fa9Smycroft	move.l		d2,FPTEMP_LO(a6)
22622ef5fa9Smycroft	move.l		(a7)+,d2
22722ef5fa9Smycroft	tst.l		d1
22822ef5fa9Smycroft	bne.b		not_zero
22922ef5fa9Smycroft	tst.l		FPTEMP_LO(a6)
23022ef5fa9Smycroft	bne.b		not_zero
23122ef5fa9Smycroft*
23222ef5fa9Smycroft* Result is zero.  Check for rounding mode to set lsb.  If the
23322ef5fa9Smycroft* mode is rp, and the zero is positive, return smallest denorm.
23422ef5fa9Smycroft* If the mode is rm, and the zero is negative, return smallest
23522ef5fa9Smycroft* negative denorm.
23622ef5fa9Smycroft*
23722ef5fa9Smycroft	btst.b		#5,FPCR_MODE(a6) ;test if rm or rp
23822ef5fa9Smycroft	beq.b		no_dir
23922ef5fa9Smycroft	btst.b		#4,FPCR_MODE(a6) ;check which one
24022ef5fa9Smycroft	beq.b		zer_rm
24122ef5fa9Smycroftzer_rp:
24222ef5fa9Smycroft	tst.b		L_SCR1(a6)	;check sign
24322ef5fa9Smycroft	bne.b		no_dir		;if set, neg op, no inc
24422ef5fa9Smycroft	move.l		#1,FPTEMP_LO(a6) ;set lsb
24522ef5fa9Smycroft	bra.b		sm_dnrm
24622ef5fa9Smycroftzer_rm:
24722ef5fa9Smycroft	tst.b		L_SCR1(a6)	;check sign
24822ef5fa9Smycroft	beq.b		no_dir		;if clr, neg op, no inc
24922ef5fa9Smycroft	move.l		#1,FPTEMP_LO(a6) ;set lsb
25022ef5fa9Smycroft	or.l		#neg_mask,USER_FPSR(a6) ;set N
25122ef5fa9Smycroft	bra.b		sm_dnrm
25222ef5fa9Smycroftno_dir:
25322ef5fa9Smycroft	fmove.l		USER_FPCR(a6),FPCR
25422ef5fa9Smycroft	fmove.x		FPTEMP(a6),fp0	;use fmove to set cc's
25522ef5fa9Smycroft	rts
25622ef5fa9Smycroft
25722ef5fa9Smycroft*
25822ef5fa9Smycroft* The rounding mode changed the zero to a smallest denorm. Call
25922ef5fa9Smycroft* t_resdnrm with exceptional operand in ETEMP.
26022ef5fa9Smycroft*
26122ef5fa9Smycroftsm_dnrm:
26222ef5fa9Smycroft	move.l		FPTEMP_EX(a6),ETEMP_EX(a6)
26322ef5fa9Smycroft	move.l		FPTEMP_HI(a6),ETEMP_HI(a6)
26422ef5fa9Smycroft	move.l		FPTEMP_LO(a6),ETEMP_LO(a6)
26522ef5fa9Smycroft	lea.l		ETEMP(a6),a0
26622ef5fa9Smycroft	bra		t_resdnrm
26722ef5fa9Smycroft
26822ef5fa9Smycroft*
26922ef5fa9Smycroft* Result is still denormalized.
27022ef5fa9Smycroft*
27122ef5fa9Smycroftnot_zero:
27222ef5fa9Smycroft	or.l		#unfl_mask,USER_FPSR(a6) ;set unfl
27322ef5fa9Smycroft	tst.b		L_SCR1(a6)	;check for sign
27422ef5fa9Smycroft	beq.b		fix_exit
27522ef5fa9Smycroft	or.l		#neg_mask,USER_FPSR(a6) ;set N
27622ef5fa9Smycroftfix_exit:
27722ef5fa9Smycroft	bra.b		sm_dnrm
27822ef5fa9Smycroft
27922ef5fa9Smycroft
28022ef5fa9Smycroft*
28122ef5fa9Smycroft* The result has underflowed to zero. Return zero and set
28222ef5fa9Smycroft* unfl, aunfl, and ainex.
28322ef5fa9Smycroft*
28422ef5fa9Smycroftfix_unfl:
28522ef5fa9Smycroft	or.l		#unfl_inx_mask,USER_FPSR(a6)
28622ef5fa9Smycroft	btst.b		#5,FPCR_MODE(a6) ;test if rm or rp
28722ef5fa9Smycroft	beq.b		no_dir2
28822ef5fa9Smycroft	btst.b		#4,FPCR_MODE(a6) ;check which one
28922ef5fa9Smycroft	beq.b		zer_rm2
29022ef5fa9Smycroftzer_rp2:
29122ef5fa9Smycroft	tst.b		L_SCR1(a6)	;check sign
29222ef5fa9Smycroft	bne.b		no_dir2		;if set, neg op, no inc
29322ef5fa9Smycroft	clr.l		FPTEMP_EX(a6)
29422ef5fa9Smycroft	clr.l		FPTEMP_HI(a6)
29522ef5fa9Smycroft	move.l		#1,FPTEMP_LO(a6) ;set lsb
29622ef5fa9Smycroft	bra.b		sm_dnrm		;return smallest denorm
29722ef5fa9Smycroftzer_rm2:
29822ef5fa9Smycroft	tst.b		L_SCR1(a6)	;check sign
29922ef5fa9Smycroft	beq.b		no_dir2		;if clr, neg op, no inc
30022ef5fa9Smycroft	move.w		#$8000,FPTEMP_EX(a6)
30122ef5fa9Smycroft	clr.l		FPTEMP_HI(a6)
30222ef5fa9Smycroft	move.l		#1,FPTEMP_LO(a6) ;set lsb
30322ef5fa9Smycroft	or.l		#neg_mask,USER_FPSR(a6) ;set N
30422ef5fa9Smycroft	bra.w		sm_dnrm		;return smallest denorm
30522ef5fa9Smycroft
30622ef5fa9Smycroftno_dir2:
30722ef5fa9Smycroft	tst.b		L_SCR1(a6)
30822ef5fa9Smycroft	bge.b		pos_zero
30922ef5fa9Smycroftneg_zero:
31022ef5fa9Smycroft	clr.l		FP_SCR1(a6)	;clear the exceptional operand
31122ef5fa9Smycroft	clr.l		FP_SCR1+4(a6)	;for gen_except.
31222ef5fa9Smycroft	clr.l		FP_SCR1+8(a6)
31322ef5fa9Smycroft	fmove.s		#:80000000,fp0
31422ef5fa9Smycroft	rts
31522ef5fa9Smycroftpos_zero:
31622ef5fa9Smycroft	clr.l		FP_SCR1(a6)	;clear the exceptional operand
31722ef5fa9Smycroft	clr.l		FP_SCR1+4(a6)	;for gen_except.
31822ef5fa9Smycroft	clr.l		FP_SCR1+8(a6)
31922ef5fa9Smycroft	fmove.s		#:00000000,fp0
32022ef5fa9Smycroft	rts
32122ef5fa9Smycroft
32222ef5fa9Smycroft*
32322ef5fa9Smycroft* The destination is a denormalized number.  It must be handled
32422ef5fa9Smycroft* by first shifting the bits in the mantissa until it is normalized,
32522ef5fa9Smycroft* then adding the remainder of the source to the exponent.
32622ef5fa9Smycroft*
32722ef5fa9Smycroftdst_dnrm:
32822ef5fa9Smycroft	movem.l		d2/d3,-(a7)
32922ef5fa9Smycroft	move.w		FPTEMP_EX(a6),d1
33022ef5fa9Smycroft	move.l		FPTEMP_HI(a6),d2
33122ef5fa9Smycroft	move.l		FPTEMP_LO(a6),d3
33222ef5fa9Smycroftdst_loop:
33322ef5fa9Smycroft	tst.l		d2		;test for normalized result
33422ef5fa9Smycroft	blt.b		dst_norm	;exit loop if so
33522ef5fa9Smycroft	tst.l		d0		;otherwise, test shift count
33622ef5fa9Smycroft	beq.b		dst_fin		;if zero, shifting is done
337eddb30abSmycroft	subq.l		#1,d0		;dec src
338eddb30abSmycroft	add.l		d3,d3
339eddb30abSmycroft	addx.l		d2,d2
34022ef5fa9Smycroft	bra.b		dst_loop
34122ef5fa9Smycroft*
34222ef5fa9Smycroft* Destination became normalized.  Simply add the remaining
34322ef5fa9Smycroft* portion of the src to the exponent.
34422ef5fa9Smycroft*
34522ef5fa9Smycroftdst_norm:
34622ef5fa9Smycroft	add.w		d0,d1		;dst is normalized; add src
34722ef5fa9Smycroft	tst.b		L_SCR1(a6)
34822ef5fa9Smycroft	beq.b		dnrm_pos
349eddb30abSmycroft	or.w		#$8000,d1
35022ef5fa9Smycroftdnrm_pos:
35122ef5fa9Smycroft	movem.w		d1,FPTEMP_EX(a6)
35222ef5fa9Smycroft	movem.l		d2,FPTEMP_HI(a6)
35322ef5fa9Smycroft	movem.l		d3,FPTEMP_LO(a6)
35422ef5fa9Smycroft	fmove.l		USER_FPCR(a6),FPCR
35522ef5fa9Smycroft	fmove.x		FPTEMP(a6),fp0
35622ef5fa9Smycroft	movem.l		(a7)+,d2/d3
35722ef5fa9Smycroft	rts
35822ef5fa9Smycroft
35922ef5fa9Smycroft*
36022ef5fa9Smycroft* Destination remained denormalized.  Call t_excdnrm with
36122ef5fa9Smycroft* exceptional operand in ETEMP.
36222ef5fa9Smycroft*
36322ef5fa9Smycroftdst_fin:
36422ef5fa9Smycroft	tst.b		L_SCR1(a6)	;check for sign
36522ef5fa9Smycroft	beq.b		dst_exit
36622ef5fa9Smycroft	or.l		#neg_mask,USER_FPSR(a6) ;set N
367eddb30abSmycroft	or.w		#$8000,d1
36822ef5fa9Smycroftdst_exit:
36922ef5fa9Smycroft	movem.w		d1,ETEMP_EX(a6)
37022ef5fa9Smycroft	movem.l		d2,ETEMP_HI(a6)
37122ef5fa9Smycroft	movem.l		d3,ETEMP_LO(a6)
37222ef5fa9Smycroft	or.l		#unfl_mask,USER_FPSR(a6) ;set unfl
37322ef5fa9Smycroft	movem.l		(a7)+,d2/d3
37422ef5fa9Smycroft	lea.l		ETEMP(a6),a0
37522ef5fa9Smycroft	bra		t_resdnrm
37622ef5fa9Smycroft
37722ef5fa9Smycroft*
37822ef5fa9Smycroft* Source is outside of 2^14 range.  Test the sign and branch
37922ef5fa9Smycroft* to the appropriate exception handler.
38022ef5fa9Smycroft*
38122ef5fa9Smycroftsrc_out:
38222ef5fa9Smycroft	tst.b		L_SCR1(a6)
38322ef5fa9Smycroft	beq.b		scro_pos
384eddb30abSmycroft	or.w		#$8000,d1
38522ef5fa9Smycroftscro_pos:
38622ef5fa9Smycroft	move.l		FPTEMP_HI(a6),ETEMP_HI(a6)
38722ef5fa9Smycroft	move.l		FPTEMP_LO(a6),ETEMP_LO(a6)
38822ef5fa9Smycroft	tst.w		ETEMP(a6)
38922ef5fa9Smycroft	blt.b		res_neg
39022ef5fa9Smycroftres_pos:
39122ef5fa9Smycroft	move.w		d1,ETEMP(a6)	;result in ETEMP
39222ef5fa9Smycroft	bra		t_ovfl2
39322ef5fa9Smycroftres_neg:
39422ef5fa9Smycroft	move.w		d1,ETEMP(a6)	;result in ETEMP
39522ef5fa9Smycroft	lea.l		ETEMP(a6),a0
39622ef5fa9Smycroft	bra		t_unfl
39722ef5fa9Smycroft	end
398