162306a36Sopenharmony_ci|
262306a36Sopenharmony_ci|	x_unsupp.sa 3.3 7/1/91
362306a36Sopenharmony_ci|
462306a36Sopenharmony_ci|	fpsp_unsupp --- FPSP handler for unsupported data type exception
562306a36Sopenharmony_ci|
662306a36Sopenharmony_ci| Trap vector #55	(See table 8-1 Mc68030 User's manual).
762306a36Sopenharmony_ci| Invoked when the user program encounters a data format (packed) that
862306a36Sopenharmony_ci| hardware does not support or a data type (denormalized numbers or un-
962306a36Sopenharmony_ci| normalized numbers).
1062306a36Sopenharmony_ci| Normalizes denorms and unnorms, unpacks packed numbers then stores
1162306a36Sopenharmony_ci| them back into the machine to let the 040 finish the operation.
1262306a36Sopenharmony_ci|
1362306a36Sopenharmony_ci| Unsupp calls two routines:
1462306a36Sopenharmony_ci|	1. get_op -  gets the operand(s)
1562306a36Sopenharmony_ci|	2. res_func - restore the function back into the 040 or
1662306a36Sopenharmony_ci|			if fmove.p fpm,<ea> then pack source (fpm)
1762306a36Sopenharmony_ci|			and store in users memory <ea>.
1862306a36Sopenharmony_ci|
1962306a36Sopenharmony_ci|  Input: Long fsave stack frame
2062306a36Sopenharmony_ci|
2162306a36Sopenharmony_ci|
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci|		Copyright (C) Motorola, Inc. 1990
2462306a36Sopenharmony_ci|			All Rights Reserved
2562306a36Sopenharmony_ci|
2662306a36Sopenharmony_ci|       For details on the license for this file, please see the
2762306a36Sopenharmony_ci|       file, README, in this same directory.
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ciX_UNSUPP:	|idnt    2,1 | Motorola 040 Floating Point Software Package
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci	|section	8
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#include "fpsp.h"
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci	|xref	get_op
3662306a36Sopenharmony_ci	|xref	res_func
3762306a36Sopenharmony_ci	|xref	gen_except
3862306a36Sopenharmony_ci	|xref	fpsp_fmt_error
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci	.global	fpsp_unsupp
4162306a36Sopenharmony_cifpsp_unsupp:
4262306a36Sopenharmony_ci|
4362306a36Sopenharmony_ci	link		%a6,#-LOCAL_SIZE
4462306a36Sopenharmony_ci	fsave		-(%a7)
4562306a36Sopenharmony_ci	moveml		%d0-%d1/%a0-%a1,USER_DA(%a6)
4662306a36Sopenharmony_ci	fmovemx	%fp0-%fp3,USER_FP0(%a6)
4762306a36Sopenharmony_ci	fmoveml	%fpcr/%fpsr/%fpiar,USER_FPCR(%a6)
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci	moveb		(%a7),VER_TMP(%a6) |save version number
5162306a36Sopenharmony_ci	moveb		(%a7),%d0		|test for valid version num
5262306a36Sopenharmony_ci	andib		#0xf0,%d0		|test for $4x
5362306a36Sopenharmony_ci	cmpib		#VER_4,%d0	|must be $4x or exit
5462306a36Sopenharmony_ci	bnel		fpsp_fmt_error
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci	fmovel		#0,%FPSR		|clear all user status bits
5762306a36Sopenharmony_ci	fmovel		#0,%FPCR		|clear all user control bits
5862306a36Sopenharmony_ci|
5962306a36Sopenharmony_ci|	The following lines are used to ensure that the FPSR
6062306a36Sopenharmony_ci|	exception byte and condition codes are clear before proceeding,
6162306a36Sopenharmony_ci|	except in the case of fmove, which leaves the cc's intact.
6262306a36Sopenharmony_ci|
6362306a36Sopenharmony_ciunsupp_con:
6462306a36Sopenharmony_ci	movel		USER_FPSR(%a6),%d1
6562306a36Sopenharmony_ci	btst		#5,CMDREG1B(%a6)	|looking for fmove out
6662306a36Sopenharmony_ci	bne		fmove_con
6762306a36Sopenharmony_ci	andl		#0xFF00FF,%d1	|clear all but aexcs and qbyte
6862306a36Sopenharmony_ci	bras		end_fix
6962306a36Sopenharmony_cifmove_con:
7062306a36Sopenharmony_ci	andl		#0x0FFF40FF,%d1	|clear all but cc's, snan bit, aexcs, and qbyte
7162306a36Sopenharmony_ciend_fix:
7262306a36Sopenharmony_ci	movel		%d1,USER_FPSR(%a6)
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci	st		UFLG_TMP(%a6)	|set flag for unsupp data
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci	bsrl		get_op		|everything okay, go get operand(s)
7762306a36Sopenharmony_ci	bsrl		res_func	|fix up stack frame so can restore it
7862306a36Sopenharmony_ci	clrl		-(%a7)
7962306a36Sopenharmony_ci	moveb		VER_TMP(%a6),(%a7) |move idle fmt word to top of stack
8062306a36Sopenharmony_ci	bral		gen_except
8162306a36Sopenharmony_ci|
8262306a36Sopenharmony_ci	|end
83