Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) |	scale.sa 3.3 7/30/91
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) |	The entry point sSCALE computes the destination operand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) |	scaled by the source operand.  If the absolute value of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) |	the source operand is (>= 2^14) an overflow or underflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) |	is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) |	The entry point sscale is called from do_func to emulate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) |	the fscale unimplemented instruction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) |	Input: Double-extended destination operand in FPTEMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) |		double-extended source operand in ETEMP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) |	Output: The function returns scale(X,Y) to fp0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) |	Modifies: fp0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) |	Algorithm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) |		Copyright (C) Motorola, Inc. 1990
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) |			All Rights Reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) |       For details on the license for this file, please see the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) |       file, README, in this same directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) |SCALE    idnt    2,1 | Motorola 040 Floating Point Software Package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	|section	8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include "fpsp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	|xref	t_ovfl2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	|xref	t_unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	|xref	round
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	|xref	t_resdnrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) SRC_BNDS: .short	0x3fff,0x400c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) | This entry point is used by the unimplemented instruction exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) | handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) |	FSCALE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	.global	sscale
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) sscale:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	fmovel		#0,%fpcr		|clr user enabled exc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	clrl		%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	movew		FPTEMP(%a6),%d1	|get dest exponent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	smi		L_SCR1(%a6)	|use L_SCR1 to hold sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	andil		#0x7fff,%d1	|strip sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	movew		ETEMP(%a6),%d0	|check src bounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	andiw		#0x7fff,%d0	|clr sign bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	cmp2w		SRC_BNDS,%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	bccs		src_in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	cmpiw		#0x400c,%d0	|test for too large
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	bge		src_out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) | The source input is below 1, so we check for denormalized numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) | and set unfl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) src_small:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	moveb		DTAG(%a6),%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	andib		#0xe0,%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	tstb		%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	beqs		no_denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	st		STORE_FLG(%a6)	|dest already contains result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	orl		#unfl_mask,USER_FPSR(%a6) |set UNFL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) den_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	leal		FPTEMP(%a6),%a0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	bra		t_resdnrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) no_denorm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	fmovel		USER_FPCR(%a6),%FPCR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	fmovex		FPTEMP(%a6),%fp0	|simply return dest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) | Source is within 2^14 range.  To perform the int operation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) | move it to d0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) src_in:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	fmovex		ETEMP(%a6),%fp0	|move in src for int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	fmovel		#rz_mode,%fpcr	|force rz for src conversion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	fmovel		%fp0,%d0		|int src to d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	fmovel		#0,%FPSR		|clr status from above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	tstw		ETEMP(%a6)	|check src sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	blt		src_neg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) | Source is positive.  Add the src to the dest exponent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) | The result can be denormalized, if src = 0, or overflow,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) | if the result of the add sets a bit in the upper word.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) src_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	tstw		%d1		|check for denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	beq		dst_dnrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	addl		%d0,%d1		|add src to dest exp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	beqs		denorm		|if zero, result is denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	cmpil		#0x7fff,%d1	|test for overflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	bges		ovfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	tstb		L_SCR1(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	beqs		spos_pos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	orw		#0x8000,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) spos_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	movew		%d1,FPTEMP(%a6)	|result in FPTEMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	fmovel		USER_FPCR(%a6),%FPCR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	fmovex		FPTEMP(%a6),%fp0	|write result to fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) ovfl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	tstb		L_SCR1(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	beqs		sovl_pos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	orw		#0x8000,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) sovl_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	movew		FPTEMP(%a6),ETEMP(%a6)	|result in ETEMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	movel		FPTEMP_HI(%a6),ETEMP_HI(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	movel		FPTEMP_LO(%a6),ETEMP_LO(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	bra		t_ovfl2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) denorm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	tstb		L_SCR1(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	beqs		den_pos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	orw		#0x8000,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) den_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	tstl		FPTEMP_HI(%a6)	|check j bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	blts		nden_exit	|if set, not denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	movew		%d1,ETEMP(%a6)	|input expected in ETEMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	movel		FPTEMP_HI(%a6),ETEMP_HI(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	movel		FPTEMP_LO(%a6),ETEMP_LO(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	orl		#unfl_bit,USER_FPSR(%a6)	|set unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	leal		ETEMP(%a6),%a0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	bra		t_resdnrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) nden_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	movew		%d1,FPTEMP(%a6)	|result in FPTEMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	fmovel		USER_FPCR(%a6),%FPCR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	fmovex		FPTEMP(%a6),%fp0	|write result to fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) | Source is negative.  Add the src to the dest exponent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) | (The result exponent will be reduced).  The result can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) | denormalized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) src_neg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	addl		%d0,%d1		|add src to dest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	beqs		denorm		|if zero, result is denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	blts		fix_dnrm	|if negative, result is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) |					;needing denormalization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	tstb		L_SCR1(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	beqs		sneg_pos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	orw		#0x8000,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) sneg_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	movew		%d1,FPTEMP(%a6)	|result in FPTEMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	fmovel		USER_FPCR(%a6),%FPCR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	fmovex		FPTEMP(%a6),%fp0	|write result to fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) | The result exponent is below denorm value.  Test for catastrophic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) | underflow and force zero if true.  If not, try to shift the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) | mantissa right until a zero exponent exists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) fix_dnrm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	cmpiw		#0xffc0,%d1	|lower bound for normalization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	blt		fix_unfl	|if lower, catastrophic unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	movew		%d1,%d0		|use d0 for exp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	movel		%d2,-(%a7)	|free d2 for norm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	movel		FPTEMP_HI(%a6),%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	movel		FPTEMP_LO(%a6),%d2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	clrl		L_SCR2(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) fix_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	addw		#1,%d0		|drive d0 to 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	lsrl		#1,%d1		|while shifting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	roxrl		#1,%d2		|mantissa to the right
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	bccs		no_carry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	st		L_SCR2(%a6)	|use L_SCR2 to capture inex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) no_carry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	tstw		%d0		|it is finished when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	blts		fix_loop	|d0 is zero or the mantissa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	tstb		L_SCR2(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	beqs		tst_zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	orl		#unfl_inx_mask,USER_FPSR(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) |					;set unfl, aunfl, ainex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) | Test for zero. If zero, simply use fmove to return +/- zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) | to the fpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) tst_zero:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	clrw		FPTEMP_EX(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	tstb		L_SCR1(%a6)	|test for sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	beqs		tst_con
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	orw		#0x8000,FPTEMP_EX(%a6) |set sign bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) tst_con:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	movel		%d1,FPTEMP_HI(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	movel		%d2,FPTEMP_LO(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	movel		(%a7)+,%d2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	tstl		%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	bnes		not_zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	tstl		FPTEMP_LO(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	bnes		not_zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) | Result is zero.  Check for rounding mode to set lsb.  If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) | mode is rp, and the zero is positive, return smallest denorm.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) | If the mode is rm, and the zero is negative, return smallest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) | negative denorm.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	btstb		#5,FPCR_MODE(%a6) |test if rm or rp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	beqs		no_dir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	btstb		#4,FPCR_MODE(%a6) |check which one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	beqs		zer_rm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) zer_rp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	tstb		L_SCR1(%a6)	|check sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	bnes		no_dir		|if set, neg op, no inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	movel		#1,FPTEMP_LO(%a6) |set lsb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	bras		sm_dnrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) zer_rm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	tstb		L_SCR1(%a6)	|check sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	beqs		no_dir		|if clr, neg op, no inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	movel		#1,FPTEMP_LO(%a6) |set lsb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	orl		#neg_mask,USER_FPSR(%a6) |set N
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	bras		sm_dnrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) no_dir:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	fmovel		USER_FPCR(%a6),%FPCR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	fmovex		FPTEMP(%a6),%fp0	|use fmove to set cc's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) | The rounding mode changed the zero to a smallest denorm. Call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) | t_resdnrm with exceptional operand in ETEMP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) sm_dnrm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	movel		FPTEMP_EX(%a6),ETEMP_EX(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	movel		FPTEMP_HI(%a6),ETEMP_HI(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	movel		FPTEMP_LO(%a6),ETEMP_LO(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	leal		ETEMP(%a6),%a0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	bra		t_resdnrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) | Result is still denormalized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) not_zero:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	orl		#unfl_mask,USER_FPSR(%a6) |set unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	tstb		L_SCR1(%a6)	|check for sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	beqs		fix_exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	orl		#neg_mask,USER_FPSR(%a6) |set N
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) fix_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	bras		sm_dnrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) | The result has underflowed to zero. Return zero and set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) | unfl, aunfl, and ainex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) fix_unfl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	orl		#unfl_inx_mask,USER_FPSR(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	btstb		#5,FPCR_MODE(%a6) |test if rm or rp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	beqs		no_dir2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	btstb		#4,FPCR_MODE(%a6) |check which one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	beqs		zer_rm2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) zer_rp2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	tstb		L_SCR1(%a6)	|check sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	bnes		no_dir2		|if set, neg op, no inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	clrl		FPTEMP_EX(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	clrl		FPTEMP_HI(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	movel		#1,FPTEMP_LO(%a6) |set lsb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	bras		sm_dnrm		|return smallest denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) zer_rm2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	tstb		L_SCR1(%a6)	|check sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	beqs		no_dir2		|if clr, neg op, no inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	movew		#0x8000,FPTEMP_EX(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	clrl		FPTEMP_HI(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	movel		#1,FPTEMP_LO(%a6) |set lsb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	orl		#neg_mask,USER_FPSR(%a6) |set N
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	bra		sm_dnrm		|return smallest denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) no_dir2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	tstb		L_SCR1(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	bges		pos_zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) neg_zero:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	clrl		FP_SCR1(%a6)	|clear the exceptional operand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	clrl		FP_SCR1+4(%a6)	|for gen_except.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	clrl		FP_SCR1+8(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	fmoves		#0x80000000,%fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) pos_zero:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	clrl		FP_SCR1(%a6)	|clear the exceptional operand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	clrl		FP_SCR1+4(%a6)	|for gen_except.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	clrl		FP_SCR1+8(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	fmoves		#0x00000000,%fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) | The destination is a denormalized number.  It must be handled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) | by first shifting the bits in the mantissa until it is normalized,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) | then adding the remainder of the source to the exponent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) dst_dnrm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	moveml		%d2/%d3,-(%a7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	movew		FPTEMP_EX(%a6),%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	movel		FPTEMP_HI(%a6),%d2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	movel		FPTEMP_LO(%a6),%d3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) dst_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	tstl		%d2		|test for normalized result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	blts		dst_norm	|exit loop if so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	tstl		%d0		|otherwise, test shift count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	beqs		dst_fin		|if zero, shifting is done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	subil		#1,%d0		|dec src
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	lsll		#1,%d3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	roxll		#1,%d2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	bras		dst_loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) | Destination became normalized.  Simply add the remaining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) | portion of the src to the exponent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) dst_norm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	addw		%d0,%d1		|dst is normalized; add src
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	tstb		L_SCR1(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	beqs		dnrm_pos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	orl		#0x8000,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) dnrm_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	movemw		%d1,FPTEMP_EX(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	moveml		%d2,FPTEMP_HI(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	moveml		%d3,FPTEMP_LO(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	fmovel		USER_FPCR(%a6),%FPCR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	fmovex		FPTEMP(%a6),%fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	moveml		(%a7)+,%d2/%d3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) | Destination remained denormalized.  Call t_excdnrm with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) | exceptional operand in ETEMP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) dst_fin:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	tstb		L_SCR1(%a6)	|check for sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	beqs		dst_exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	orl		#neg_mask,USER_FPSR(%a6) |set N
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	orl		#0x8000,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) dst_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	movemw		%d1,ETEMP_EX(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	moveml		%d2,ETEMP_HI(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	moveml		%d3,ETEMP_LO(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	orl		#unfl_mask,USER_FPSR(%a6) |set unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	moveml		(%a7)+,%d2/%d3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	leal		ETEMP(%a6),%a0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	bra		t_resdnrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) | Source is outside of 2^14 range.  Test the sign and branch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) | to the appropriate exception handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) src_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	tstb		L_SCR1(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	beqs		scro_pos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	orl		#0x8000,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) scro_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	movel		FPTEMP_HI(%a6),ETEMP_HI(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	movel		FPTEMP_LO(%a6),ETEMP_LO(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	tstw		ETEMP(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	blts		res_neg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) res_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	movew		%d1,ETEMP(%a6)	|result in ETEMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	bra		t_ovfl2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) res_neg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	movew		%d1,ETEMP(%a6)	|result in ETEMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	leal		ETEMP(%a6),%a0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	bra		t_unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	|end