18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * fp_scan.S
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright Roman Zippel, 1997.  All rights reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
78c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
88c2ecf20Sopenharmony_ci * are met:
98c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
108c2ecf20Sopenharmony_ci *    notice, and the entire permission notice in its entirety,
118c2ecf20Sopenharmony_ci *    including the disclaimer of warranties.
128c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
138c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
148c2ecf20Sopenharmony_ci *    documentation and/or other materials provided with the distribution.
158c2ecf20Sopenharmony_ci * 3. The name of the author may not be used to endorse or promote
168c2ecf20Sopenharmony_ci *    products derived from this software without specific prior
178c2ecf20Sopenharmony_ci *    written permission.
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * ALTERNATIVELY, this product may be distributed under the terms of
208c2ecf20Sopenharmony_ci * the GNU General Public License, in which case the provisions of the GPL are
218c2ecf20Sopenharmony_ci * required INSTEAD OF the above restrictions.  (This clause is
228c2ecf20Sopenharmony_ci * necessary due to a potential bad interaction between the GPL and
238c2ecf20Sopenharmony_ci * the restrictions contained in a BSD-style copyright.)
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
268c2ecf20Sopenharmony_ci * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
278c2ecf20Sopenharmony_ci * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
288c2ecf20Sopenharmony_ci * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
298c2ecf20Sopenharmony_ci * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
308c2ecf20Sopenharmony_ci * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
318c2ecf20Sopenharmony_ci * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
328c2ecf20Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
338c2ecf20Sopenharmony_ci * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
348c2ecf20Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
358c2ecf20Sopenharmony_ci * OF THE POSSIBILITY OF SUCH DAMAGE.
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#include "fp_emu.h"
398c2ecf20Sopenharmony_ci#include "fp_decode.h"
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	.globl	fp_scan, fp_datasize
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	.data
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci| %d2 - first two instr words
468c2ecf20Sopenharmony_ci| %d1 - operand size
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/* operand formats are:
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci	Long = 0,		i.e. fmove.l
518c2ecf20Sopenharmony_ci	Single,			i.e. fmove.s
528c2ecf20Sopenharmony_ci	Extended,		i.e. fmove.x
538c2ecf20Sopenharmony_ci	Packed-BCD,		i.e. fmove.p
548c2ecf20Sopenharmony_ci	Word,			i.e. fmove.w
558c2ecf20Sopenharmony_ci	Double,			i.e. fmove.d
568c2ecf20Sopenharmony_ci*/
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	.text
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci| On entry:
618c2ecf20Sopenharmony_ci| FPDATA - base of emulated FPU registers
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_cifp_scan:
648c2ecf20Sopenharmony_ci| normal fpu instruction? (this excludes fsave/frestore)
658c2ecf20Sopenharmony_ci	fp_get_pc %a0
668c2ecf20Sopenharmony_ci	printf	PDECODE,"%08x: ",1,%a0
678c2ecf20Sopenharmony_ci	getuser.b (%a0),%d0,fp_err_ua1,%a0
688c2ecf20Sopenharmony_ci#if 1
698c2ecf20Sopenharmony_ci	cmp.b	#0xf2,%d0		| cpid = 1
708c2ecf20Sopenharmony_ci#else
718c2ecf20Sopenharmony_ci	cmp.b	#0xfc,%d0		| cpid = 6
728c2ecf20Sopenharmony_ci#endif
738c2ecf20Sopenharmony_ci	jne	fp_nonstd
748c2ecf20Sopenharmony_ci| first two instruction words are kept in %d2
758c2ecf20Sopenharmony_ci	getuser.l (%a0)+,%d2,fp_err_ua1,%a0
768c2ecf20Sopenharmony_ci	fp_put_pc %a0
778c2ecf20Sopenharmony_cifp_decode_cond:				| separate conditional instr
788c2ecf20Sopenharmony_ci	fp_decode_cond_instr_type
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	.long	fp_decode_move, fp_fscc
818c2ecf20Sopenharmony_ci	.long	fp_fbccw, fp_fbccl
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cifp_decode_move:				| separate move instr
848c2ecf20Sopenharmony_ci	fp_decode_move_instr_type
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	.long	fp_fgen_fp, fp_ill
878c2ecf20Sopenharmony_ci	.long	fp_fgen_ea, fp_fmove_fp2mem
888c2ecf20Sopenharmony_ci	.long	fp_fmovem_cr, fp_fmovem_cr
898c2ecf20Sopenharmony_ci	.long	fp_fmovem_fp, fp_fmovem_fp
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci| now all arithmetic instr and a few move instr are left
928c2ecf20Sopenharmony_cifp_fgen_fp:				| source is a fpu register
938c2ecf20Sopenharmony_ci	clr.b	(FPD_FPSR+2,FPDATA)	| clear the exception byte
948c2ecf20Sopenharmony_ci	fp_decode_sourcespec
958c2ecf20Sopenharmony_ci	printf	PDECODE,"f<op>.x fp%d",1,%d0
968c2ecf20Sopenharmony_ci	fp_get_fp_reg
978c2ecf20Sopenharmony_ci	lea	(FPD_TEMPFP1,FPDATA),%a1 | copy src into a temp location
988c2ecf20Sopenharmony_ci	move.l	(%a0)+,(%a1)+
998c2ecf20Sopenharmony_ci	move.l	(%a0)+,(%a1)+
1008c2ecf20Sopenharmony_ci	move.l	(%a0),(%a1)
1018c2ecf20Sopenharmony_ci	lea	(-8,%a1),%a0
1028c2ecf20Sopenharmony_ci	jra	fp_getdest
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cifp_fgen_ea:				| source is <ea>
1058c2ecf20Sopenharmony_ci	clr.b	(FPD_FPSR+2,FPDATA)	| clear the exception byte
1068c2ecf20Sopenharmony_ci	| sort out fmovecr, keep data size in %d1
1078c2ecf20Sopenharmony_ci	fp_decode_sourcespec
1088c2ecf20Sopenharmony_ci	cmp.w	#7,%d0
1098c2ecf20Sopenharmony_ci	jeq	fp_fmovecr
1108c2ecf20Sopenharmony_ci	move.w	%d0,%d1			| store data size twice in %d1
1118c2ecf20Sopenharmony_ci	swap	%d1			| one can be trashed below
1128c2ecf20Sopenharmony_ci	move.w	%d0,%d1
1138c2ecf20Sopenharmony_ci#ifdef FPU_EMU_DEBUG
1148c2ecf20Sopenharmony_ci	lea	0f,%a0
1158c2ecf20Sopenharmony_ci	clr.l	%d0
1168c2ecf20Sopenharmony_ci	move.b	(%a0,%d1.w),%d0
1178c2ecf20Sopenharmony_ci	printf	PDECODE,"f<op>.%c ",1,%d0
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	.data
1208c2ecf20Sopenharmony_ci0:	.byte	'l','s','x','p','w','d','b',0
1218c2ecf20Sopenharmony_ci	.previous
1228c2ecf20Sopenharmony_ci#endif
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci/*
1258c2ecf20Sopenharmony_ci	fp_getsource, fp_getdest
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	basically, we end up with a pointer to the source operand in
1288c2ecf20Sopenharmony_ci	%a1, and a pointer to the destination operand in %a0.  both
1298c2ecf20Sopenharmony_ci	are, of course, 96-bit extended floating point numbers.
1308c2ecf20Sopenharmony_ci*/
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_cifp_getsource:
1338c2ecf20Sopenharmony_ci	| decode addressing mode for source
1348c2ecf20Sopenharmony_ci	fp_decode_addr_mode
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	.long	fp_data, fp_ill
1378c2ecf20Sopenharmony_ci	.long	fp_indirect, fp_postinc
1388c2ecf20Sopenharmony_ci	.long	fp_predecr, fp_disp16
1398c2ecf20Sopenharmony_ci	.long	fp_extmode0, fp_extmode1
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	| addressing mode: data register direct
1428c2ecf20Sopenharmony_cifp_data:
1438c2ecf20Sopenharmony_ci	fp_mode_data_direct
1448c2ecf20Sopenharmony_ci	jsr	fp_get_data_reg
1458c2ecf20Sopenharmony_ci	lea	(FPD_TEMPFP1,FPDATA),%a0
1468c2ecf20Sopenharmony_ci	jmp	([0f:w,%pc,%d1.w*4])
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	.align	4
1498c2ecf20Sopenharmony_ci0:
1508c2ecf20Sopenharmony_ci	.long	fp_data_long, fp_data_single
1518c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill
1528c2ecf20Sopenharmony_ci	.long	fp_data_word, fp_ill
1538c2ecf20Sopenharmony_ci	.long	fp_data_byte, fp_ill
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci	| data types that fit in an integer data register
1568c2ecf20Sopenharmony_cifp_data_byte:
1578c2ecf20Sopenharmony_ci	extb.l	%d0
1588c2ecf20Sopenharmony_ci	jra	fp_data_long
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_cifp_data_word:
1618c2ecf20Sopenharmony_ci	ext.l	%d0
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cifp_data_long:
1648c2ecf20Sopenharmony_ci	jsr	fp_conv_long2ext
1658c2ecf20Sopenharmony_ci	jra	fp_getdest
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_cifp_data_single:
1688c2ecf20Sopenharmony_ci	jsr	fp_conv_single2ext
1698c2ecf20Sopenharmony_ci	jra	fp_getdest
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	| addressing mode: address register indirect
1728c2ecf20Sopenharmony_cifp_indirect:
1738c2ecf20Sopenharmony_ci	fp_mode_addr_indirect
1748c2ecf20Sopenharmony_ci	jra	fp_fetchsource
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	| addressing mode: address register indirect with postincrement
1778c2ecf20Sopenharmony_cifp_postinc:
1788c2ecf20Sopenharmony_ci	fp_mode_addr_indirect_postinc
1798c2ecf20Sopenharmony_ci	jra	fp_fetchsource
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci	| addressing mode: address register indirect with predecrement
1828c2ecf20Sopenharmony_cifp_predecr:
1838c2ecf20Sopenharmony_ci	fp_mode_addr_indirect_predec
1848c2ecf20Sopenharmony_ci	jra	fp_fetchsource
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci	| addressing mode: address register/programm counter indirect
1878c2ecf20Sopenharmony_ci	|		   with 16bit displacement
1888c2ecf20Sopenharmony_cifp_disp16:
1898c2ecf20Sopenharmony_ci	fp_mode_addr_indirect_disp16
1908c2ecf20Sopenharmony_ci	jra	fp_fetchsource
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci	| all other indirect addressing modes will finally end up here
1938c2ecf20Sopenharmony_cifp_extmode0:
1948c2ecf20Sopenharmony_ci	fp_mode_addr_indirect_extmode0
1958c2ecf20Sopenharmony_ci	jra	fp_fetchsource
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci| all pc relative addressing modes and immediate/absolute modes end up here
1988c2ecf20Sopenharmony_ci| the first ones are sent to fp_extmode0 or fp_disp16
1998c2ecf20Sopenharmony_ci| and only the latter are handled here
2008c2ecf20Sopenharmony_cifp_extmode1:
2018c2ecf20Sopenharmony_ci	fp_decode_addr_reg
2028c2ecf20Sopenharmony_ci	jmp	([0f:w,%pc,%d0*4])
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	.align	4
2058c2ecf20Sopenharmony_ci0:
2068c2ecf20Sopenharmony_ci	.long	fp_abs_short, fp_abs_long
2078c2ecf20Sopenharmony_ci	.long	fp_disp16, fp_extmode0
2088c2ecf20Sopenharmony_ci	.long	fp_immediate, fp_ill
2098c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci	| addressing mode: absolute short
2128c2ecf20Sopenharmony_cifp_abs_short:
2138c2ecf20Sopenharmony_ci	fp_mode_abs_short
2148c2ecf20Sopenharmony_ci	jra	fp_fetchsource
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci	| addressing mode: absolute long
2178c2ecf20Sopenharmony_cifp_abs_long:
2188c2ecf20Sopenharmony_ci	fp_mode_abs_long
2198c2ecf20Sopenharmony_ci	jra	fp_fetchsource
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci	| addressing mode: immediate data
2228c2ecf20Sopenharmony_cifp_immediate:
2238c2ecf20Sopenharmony_ci	printf	PDECODE,"#"
2248c2ecf20Sopenharmony_ci	fp_get_pc %a0
2258c2ecf20Sopenharmony_ci	move.w	(fp_datasize,%d1.w*2),%d0
2268c2ecf20Sopenharmony_ci	addq.w	#1,%d0
2278c2ecf20Sopenharmony_ci	and.w	#-2,%d0
2288c2ecf20Sopenharmony_ci#ifdef FPU_EMU_DEBUG
2298c2ecf20Sopenharmony_ci	movem.l	%d0/%d1,-(%sp)
2308c2ecf20Sopenharmony_ci	movel	%a0,%a1
2318c2ecf20Sopenharmony_ci	clr.l	%d1
2328c2ecf20Sopenharmony_ci	jra	2f
2338c2ecf20Sopenharmony_ci1:	getuser.b (%a1)+,%d1,fp_err_ua1,%a1
2348c2ecf20Sopenharmony_ci	printf	PDECODE,"%02x",1,%d1
2358c2ecf20Sopenharmony_ci2:	dbra	%d0,1b
2368c2ecf20Sopenharmony_ci	movem.l	(%sp)+,%d0/%d1
2378c2ecf20Sopenharmony_ci#endif
2388c2ecf20Sopenharmony_ci	lea	(%a0,%d0.w),%a1
2398c2ecf20Sopenharmony_ci	fp_put_pc %a1
2408c2ecf20Sopenharmony_ci|	jra	fp_fetchsource
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_cifp_fetchsource:
2438c2ecf20Sopenharmony_ci	move.l	%a0,%a1
2448c2ecf20Sopenharmony_ci	swap	%d1
2458c2ecf20Sopenharmony_ci	lea	(FPD_TEMPFP1,FPDATA),%a0
2468c2ecf20Sopenharmony_ci	jmp	([0f:w,%pc,%d1.w*4])
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci	.align	4
2498c2ecf20Sopenharmony_ci0:	.long	fp_long, fp_single
2508c2ecf20Sopenharmony_ci	.long	fp_ext, fp_pack
2518c2ecf20Sopenharmony_ci	.long	fp_word, fp_double
2528c2ecf20Sopenharmony_ci	.long	fp_byte, fp_ill
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_cifp_long:
2558c2ecf20Sopenharmony_ci	getuser.l (%a1),%d0,fp_err_ua1,%a1
2568c2ecf20Sopenharmony_ci	jsr	fp_conv_long2ext
2578c2ecf20Sopenharmony_ci	jra	fp_getdest
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_cifp_single:
2608c2ecf20Sopenharmony_ci	getuser.l (%a1),%d0,fp_err_ua1,%a1
2618c2ecf20Sopenharmony_ci	jsr	fp_conv_single2ext
2628c2ecf20Sopenharmony_ci	jra	fp_getdest
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_cifp_ext:
2658c2ecf20Sopenharmony_ci	getuser.l (%a1)+,%d0,fp_err_ua1,%a1
2668c2ecf20Sopenharmony_ci	lsr.l	#8,%d0
2678c2ecf20Sopenharmony_ci	lsr.l	#7,%d0
2688c2ecf20Sopenharmony_ci	lsr.w	#1,%d0
2698c2ecf20Sopenharmony_ci	move.l	%d0,(%a0)+
2708c2ecf20Sopenharmony_ci	getuser.l (%a1)+,%d0,fp_err_ua1,%a1
2718c2ecf20Sopenharmony_ci	move.l	%d0,(%a0)+
2728c2ecf20Sopenharmony_ci	getuser.l (%a1),%d0,fp_err_ua1,%a1
2738c2ecf20Sopenharmony_ci	move.l	%d0,(%a0)
2748c2ecf20Sopenharmony_ci	subq.l	#8,%a0
2758c2ecf20Sopenharmony_ci	jra	fp_getdest
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_cifp_pack:
2788c2ecf20Sopenharmony_ci	/* not supported yet */
2798c2ecf20Sopenharmony_ci	jra	fp_ill
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_cifp_word:
2828c2ecf20Sopenharmony_ci	getuser.w (%a1),%d0,fp_err_ua1,%a1
2838c2ecf20Sopenharmony_ci	ext.l	%d0
2848c2ecf20Sopenharmony_ci	jsr	fp_conv_long2ext
2858c2ecf20Sopenharmony_ci	jra	fp_getdest
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_cifp_double:
2888c2ecf20Sopenharmony_ci	jsr	fp_conv_double2ext
2898c2ecf20Sopenharmony_ci	jra	fp_getdest
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_cifp_byte:
2928c2ecf20Sopenharmony_ci	getuser.b (%a1),%d0,fp_err_ua1,%a1
2938c2ecf20Sopenharmony_ci	extb.l	%d0
2948c2ecf20Sopenharmony_ci	jsr	fp_conv_long2ext
2958c2ecf20Sopenharmony_ci|	jra	fp_getdest
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_cifp_getdest:
2988c2ecf20Sopenharmony_ci	move.l	%a0,%a1
2998c2ecf20Sopenharmony_ci	bfextu	%d2{#22,#3},%d0
3008c2ecf20Sopenharmony_ci	printf	PDECODE,",fp%d\n",1,%d0
3018c2ecf20Sopenharmony_ci	fp_get_fp_reg
3028c2ecf20Sopenharmony_ci	movem.l	%a0/%a1,-(%sp)
3038c2ecf20Sopenharmony_ci	pea	fp_finalrounding
3048c2ecf20Sopenharmony_ci	bfextu	%d2{#25,#7},%d0
3058c2ecf20Sopenharmony_ci	jmp	([0f:w,%pc,%d0*4])
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci	.align	4
3088c2ecf20Sopenharmony_ci0:
3098c2ecf20Sopenharmony_ci	.long	fp_fmove_mem2fp, fp_fint, fp_fsinh, fp_fintrz
3108c2ecf20Sopenharmony_ci	.long	fp_fsqrt, fp_ill, fp_flognp1, fp_ill
3118c2ecf20Sopenharmony_ci	.long	fp_fetoxm1, fp_ftanh, fp_fatan, fp_ill
3128c2ecf20Sopenharmony_ci	.long	fp_fasin, fp_fatanh, fp_fsin, fp_ftan
3138c2ecf20Sopenharmony_ci	.long	fp_fetox, fp_ftwotox, fp_ftentox, fp_ill
3148c2ecf20Sopenharmony_ci	.long	fp_flogn, fp_flog10, fp_flog2, fp_ill
3158c2ecf20Sopenharmony_ci	.long	fp_fabs, fp_fcosh, fp_fneg, fp_ill
3168c2ecf20Sopenharmony_ci	.long	fp_facos, fp_fcos, fp_fgetexp, fp_fgetman
3178c2ecf20Sopenharmony_ci	.long	fp_fdiv, fp_fmod, fp_fadd, fp_fmul
3188c2ecf20Sopenharmony_ci	.long	fpa_fsgldiv, fp_frem, fp_fscale, fpa_fsglmul
3198c2ecf20Sopenharmony_ci	.long	fp_fsub, fp_ill, fp_ill, fp_ill
3208c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3218c2ecf20Sopenharmony_ci	.long	fp_fsincos0, fp_fsincos1, fp_fsincos2, fp_fsincos3
3228c2ecf20Sopenharmony_ci	.long	fp_fsincos4, fp_fsincos5, fp_fsincos6, fp_fsincos7
3238c2ecf20Sopenharmony_ci	.long	fp_fcmp, fp_ill, fp_ftst, fp_ill
3248c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3258c2ecf20Sopenharmony_ci	.long	fp_fsmove, fp_fssqrt, fp_ill, fp_ill
3268c2ecf20Sopenharmony_ci	.long	fp_fdmove, fp_fdsqrt, fp_ill, fp_ill
3278c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3288c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3298c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3308c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3318c2ecf20Sopenharmony_ci	.long	fp_fsabs, fp_ill, fp_fsneg, fp_ill
3328c2ecf20Sopenharmony_ci	.long	fp_fdabs, fp_ill, fp_fdneg, fp_ill
3338c2ecf20Sopenharmony_ci	.long	fp_fsdiv, fp_ill, fp_fsadd, fp_fsmul
3348c2ecf20Sopenharmony_ci	.long	fp_fddiv, fp_ill, fp_fdadd, fp_fdmul
3358c2ecf20Sopenharmony_ci	.long	fp_fssub, fp_ill, fp_ill, fp_ill
3368c2ecf20Sopenharmony_ci	.long	fp_fdsub, fp_ill, fp_ill, fp_ill
3378c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3388c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3398c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3408c2ecf20Sopenharmony_ci	.long	fp_ill, fp_ill, fp_ill, fp_ill
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci	| Instructions follow
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci	| Move an (emulated) ROM constant
3458c2ecf20Sopenharmony_cifp_fmovecr:
3468c2ecf20Sopenharmony_ci	bfextu	%d2{#27,#5},%d0
3478c2ecf20Sopenharmony_ci	printf	PINSTR,"fp_fmovecr #%d",1,%d0
3488c2ecf20Sopenharmony_ci	move.l	%d0,%d1
3498c2ecf20Sopenharmony_ci	add.l	%d0,%d0
3508c2ecf20Sopenharmony_ci	add.l	%d1,%d0
3518c2ecf20Sopenharmony_ci	lea	(fp_constants,%d0*4),%a0
3528c2ecf20Sopenharmony_ci	move.l	#0x801cc0ff,%d0
3538c2ecf20Sopenharmony_ci	addq.l	#1,%d1
3548c2ecf20Sopenharmony_ci	lsl.l	%d1,%d0
3558c2ecf20Sopenharmony_ci	jcc	1f
3568c2ecf20Sopenharmony_ci	fp_set_sr FPSR_EXC_INEX2			| INEX2 exception
3578c2ecf20Sopenharmony_ci1:	moveq	#-128,%d0				| continue with fmove
3588c2ecf20Sopenharmony_ci	and.l	%d0,%d2
3598c2ecf20Sopenharmony_ci	jra	fp_getdest
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci	.data
3628c2ecf20Sopenharmony_ci	.align	4
3638c2ecf20Sopenharmony_cifp_constants:
3648c2ecf20Sopenharmony_ci	.long	0x00004000,0xc90fdaa2,0x2168c235	| pi
3658c2ecf20Sopenharmony_ci	.extend	0,0,0,0,0,0,0,0,0,0
3668c2ecf20Sopenharmony_ci	.long	0x00003ffd,0x9a209a84,0xfbcff798	| log10(2)
3678c2ecf20Sopenharmony_ci	.long	0x00004000,0xadf85458,0xa2bb4a9a	| e
3688c2ecf20Sopenharmony_ci	.long	0x00003fff,0xb8aa3b29,0x5c17f0bc	| log2(e)
3698c2ecf20Sopenharmony_ci	.long	0x00003ffd,0xde5bd8a9,0x37287195	| log10(e)
3708c2ecf20Sopenharmony_ci	.long	0x00000000,0x00000000,0x00000000	| 0.0
3718c2ecf20Sopenharmony_ci	.long	0x00003ffe,0xb17217f7,0xd1cf79ac	| 1n(2)
3728c2ecf20Sopenharmony_ci	.long	0x00004000,0x935d8ddd,0xaaa8ac17	| 1n(10)
3738c2ecf20Sopenharmony_ci	| read this as "1.0 * 2^0" - note the high bit in the mantissa
3748c2ecf20Sopenharmony_ci	.long	0x00003fff,0x80000000,0x00000000	| 10^0
3758c2ecf20Sopenharmony_ci	.long	0x00004002,0xa0000000,0x00000000	| 10^1
3768c2ecf20Sopenharmony_ci	.long	0x00004005,0xc8000000,0x00000000	| 10^2
3778c2ecf20Sopenharmony_ci	.long	0x0000400c,0x9c400000,0x00000000	| 10^4
3788c2ecf20Sopenharmony_ci	.long	0x00004019,0xbebc2000,0x00000000	| 10^8
3798c2ecf20Sopenharmony_ci	.long	0x00004034,0x8e1bc9bf,0x04000000	| 10^16
3808c2ecf20Sopenharmony_ci	.long	0x00004069,0x9dc5ada8,0x2b70b59e	| 10^32
3818c2ecf20Sopenharmony_ci	.long	0x000040d3,0xc2781f49,0xffcfa6d5	| 10^64
3828c2ecf20Sopenharmony_ci	.long	0x000041a8,0x93ba47c9,0x80e98ce0	| 10^128
3838c2ecf20Sopenharmony_ci	.long	0x00004351,0xaa7eebfb,0x9df9de8e	| 10^256
3848c2ecf20Sopenharmony_ci	.long	0x000046a3,0xe319a0ae,0xa60e91c7	| 10^512
3858c2ecf20Sopenharmony_ci	.long	0x00004d48,0xc9767586,0x81750c17	| 10^1024
3868c2ecf20Sopenharmony_ci	.long	0x00005a92,0x9e8b3b5d,0xc53d5de5	| 10^2048
3878c2ecf20Sopenharmony_ci	.long	0x00007525,0xc4605202,0x8a20979b	| 10^4096
3888c2ecf20Sopenharmony_ci	.previous
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_cifp_fmove_mem2fp:
3918c2ecf20Sopenharmony_ci	printf	PINSTR,"fmove %p,%p\n",2,%a0,%a1
3928c2ecf20Sopenharmony_ci	move.l	(%a1)+,(%a0)+
3938c2ecf20Sopenharmony_ci	move.l	(%a1)+,(%a0)+
3948c2ecf20Sopenharmony_ci	move.l	(%a1),(%a0)
3958c2ecf20Sopenharmony_ci	subq.l	#8,%a0
3968c2ecf20Sopenharmony_ci	rts
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_cifpa_fsglmul:
3998c2ecf20Sopenharmony_ci	move.l	#fp_finalrounding_single_fast,(%sp)
4008c2ecf20Sopenharmony_ci	jra	fp_fsglmul
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_cifpa_fsgldiv:
4038c2ecf20Sopenharmony_ci	move.l	#fp_finalrounding_single_fast,(%sp)
4048c2ecf20Sopenharmony_ci	jra	fp_fsgldiv
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci.macro	fp_dosingleprec instr
4078c2ecf20Sopenharmony_ci	printf	PINSTR,"single "
4088c2ecf20Sopenharmony_ci	move.l	#fp_finalrounding_single,(%sp)
4098c2ecf20Sopenharmony_ci	jra	\instr
4108c2ecf20Sopenharmony_ci.endm
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci.macro	fp_dodoubleprec instr
4138c2ecf20Sopenharmony_ci	printf	PINSTR,"double "
4148c2ecf20Sopenharmony_ci	move.l	#fp_finalrounding_double,(%sp)
4158c2ecf20Sopenharmony_ci	jra	\instr
4168c2ecf20Sopenharmony_ci.endm
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_cifp_fsmove:
4198c2ecf20Sopenharmony_ci	fp_dosingleprec fp_fmove_mem2fp
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_cifp_fssqrt:
4228c2ecf20Sopenharmony_ci	fp_dosingleprec fp_fsqrt
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_cifp_fdmove:
4258c2ecf20Sopenharmony_ci	fp_dodoubleprec fp_fmove_mem2fp
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_cifp_fdsqrt:
4288c2ecf20Sopenharmony_ci	fp_dodoubleprec fp_fsqrt
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_cifp_fsabs:
4318c2ecf20Sopenharmony_ci	fp_dosingleprec fp_fabs
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_cifp_fsneg:
4348c2ecf20Sopenharmony_ci	fp_dosingleprec fp_fneg
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_cifp_fdabs:
4378c2ecf20Sopenharmony_ci	fp_dodoubleprec fp_fabs
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_cifp_fdneg:
4408c2ecf20Sopenharmony_ci	fp_dodoubleprec fp_fneg
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_cifp_fsdiv:
4438c2ecf20Sopenharmony_ci	fp_dosingleprec fp_fdiv
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_cifp_fsadd:
4468c2ecf20Sopenharmony_ci	fp_dosingleprec fp_fadd
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_cifp_fsmul:
4498c2ecf20Sopenharmony_ci	fp_dosingleprec fp_fmul
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_cifp_fddiv:
4528c2ecf20Sopenharmony_ci	fp_dodoubleprec fp_fdiv
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_cifp_fdadd:
4558c2ecf20Sopenharmony_ci	fp_dodoubleprec fp_fadd
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_cifp_fdmul:
4588c2ecf20Sopenharmony_ci	fp_dodoubleprec fp_fmul
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_cifp_fssub:
4618c2ecf20Sopenharmony_ci	fp_dosingleprec fp_fsub
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_cifp_fdsub:
4648c2ecf20Sopenharmony_ci	fp_dodoubleprec fp_fsub
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_cifp_nonstd:
4678c2ecf20Sopenharmony_ci	fp_get_pc %a0
4688c2ecf20Sopenharmony_ci	getuser.l (%a0),%d0,fp_err_ua1,%a0
4698c2ecf20Sopenharmony_ci	printf	,"nonstd ((%08x)=%08x)\n",2,%a0,%d0
4708c2ecf20Sopenharmony_ci	moveq	#-1,%d0
4718c2ecf20Sopenharmony_ci	rts
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci	.data
4748c2ecf20Sopenharmony_ci	.align	4
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci	| data sizes corresponding to the operand formats
4778c2ecf20Sopenharmony_cifp_datasize:
4788c2ecf20Sopenharmony_ci	.word	4, 4, 12, 12, 2, 8, 1, 0
479