xref: /netbsd/sys/arch/m68k/fpsp/MONADIC.GCC (revision bf9ec67e)
1*	$NetBSD: MONADIC.GCC,v 1.2 1994/10/26 07:48:40 cgd Exp $
2
3*	MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
4*	M68000 Hi-Performance Microprocessor Division
5*	M68040 Software Package
6*
7*	M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
8*	All rights reserved.
9*
10*	THE SOFTWARE is provided on an "AS IS" basis and without warranty.
11*	To the maximum extent permitted by applicable law,
12*	MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
13*	INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
14*	PARTICULAR PURPOSE and any warranty against infringement with
15*	regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
16*	and any accompanying written materials.
17*
18*	To the maximum extent permitted by applicable law,
19*	IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
20*	(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
21*	PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
22*	OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
23*	SOFTWARE.  Motorola assumes no responsibility for the maintenance
24*	and support of the SOFTWARE.
25*
26*	You are hereby granted a copyright license to use, modify, and
27*	distribute the SOFTWARE so long as this entire notice is retained
28*	without alteration in any modified and/or redistributed versions,
29*	and that such modified versions are clearly identified as such.
30*	No licenses are granted by implication, estoppel or otherwise
31*	under any patents or trademarks of Motorola, Inc.
32
33*
34*	MONADIC.GCC --- MONADIC template for GCC compiler
35*
36*	This is based on the generic template.  The only difference is that
37*	GCC does not need the d0-d1/a0-a1 registers saved.
38*
39*	Customizations:
40*		2. Likewise, don't save FP0/FP1 if they are scratch
41*		   registers.
42*		3. Delete handling of the fpsr if you only care about
43*		   the result.
44*		5. Move the result to d0/d1 if the compiler is that old.
45*
46
47	xref	tag
48	xref	_OPr_
49	xref	_OPz_
50	xref	_OPi_
51	xref	_OPn_
52	xref	_OPm_
53
54	xdef	_OPs_
55_OPs_:
56	link	a6,#-LOCAL_SIZE
57	fmovem.x fp0-fp3,USER_FP0(a6)
58	fmove.l	fpsr,USER_FPSR(a6)
59	fmove.l	fpcr,USER_FPCR(a6)
60	fmove.l	fpcr,d1		; user's rounding mode/precision
61	fmove.l	#0,fpcr		; force rounding mode/prec to extended,rn
62*
63*	copy, convert and tag input argument
64*
65	fmove.s	8(a6),fp0
66	fmove.x	fp0,ETEMP(a6)
67	lea	ETEMP(a6),a0
68	bsr	tag
69	move.b	d0,STAG(a6)
70	tst.b	d0
71	bne.b	_TMP_2
72	bsr	_OPr_		; normalized (regular) number
73	bra.b	_TMP_6
74_TMP_2:
75	cmp.b	#$20,d0		; zero?
76	bne.b	_TMP_3
77	bsr	_OPz_
78	bra.b	_TMP_6
79_TMP_3:
80	cmp.b	#$40,d0		; infinity?
81	bne.b	_TMP_4
82	bsr	_OPi_
83	bra.b	_TMP_6
84_TMP_4:
85	cmp.b	#$60,d0		; NaN?
86	bne.b	_TMP_5
87	bsr	_OPn_
88	bra.b	_TMP_6
89_TMP_5:
90	bsr	_OPm_		; assuming a denorm...
91
92_TMP_6:
93	fmove.l	fpsr,d0		; update status register
94	or.b	FPSR_AEXCEPT(a6),d0	;add previously accrued exceptions
95	fmove.l	d0,fpsr
96*
97*	Result is now in FP0
98*
99	fmovem.x USER_FP1(a6),fp1-fp3	; note: FP0 not restored
100	fmove.l USER_FPCR(a6),fpcr	; fpcr restored
101	unlk	a6
102	rts
103
104	xdef	_OPd_
105_OPd_:
106	link	a6,#-LOCAL_SIZE
107	fmovem.x fp0-fp3,USER_FP0(a6)
108	fmove.l	fpsr,USER_FPSR(a6)
109	fmove.l	fpcr,USER_FPCR(a6)
110	fmove.l	fpcr,d1		; user's rounding mode/precision
111	fmove.l	#0,fpcr		; force rounding mode/prec to extended,rn
112*
113*	copy, convert and tag input argument
114*
115	fmove.d	8(a6),fp0
116	fmove.x	fp0,ETEMP(a6)
117	lea	ETEMP(a6),a0
118	bsr	tag
119	move.b	d0,STAG(a6)
120	tst.b	d0
121	bne.b	_TMP_7
122	bsr	_OPr_		; normalized (regular) number
123	bra.b	_TMP_B
124_TMP_7:
125	cmp.b	#$20,d0		; zero?
126	bne.b	_TMP_8
127	bsr	_OPz_
128	bra.b	_TMP_B
129_TMP_8:
130	cmp.b	#$40,d0		; infinity?
131	bne.b	_TMP_9
132	bsr	_OPi_
133	bra.b	_TMP_B
134_TMP_9:
135	cmp.b	#$60,d0		; NaN?
136	bne.b	_TMP_A
137	bsr	_OPn_
138	bra.b	_TMP_B
139_TMP_A:
140	bsr	_OPm_		; assuming a denorm...
141
142_TMP_B:
143	fmove.l	fpsr,d0		; update status register
144	or.b	FPSR_AEXCEPT(a6),d0	;add previously accrued exceptions
145	fmove.l	d0,fpsr
146*
147*	Result is now in FP0
148*
149	fmovem.x USER_FP1(a6),fp1-fp3	; note: FP0 not restored
150	fmove.l USER_FPCR(a6),fpcr	; fpcr restored
151	unlk	a6
152	rts
153
154	xdef	_OPx_
155_OPx_:
156	link	a6,#-LOCAL_SIZE
157	fmovem.x fp0-fp3,USER_FP0(a6)
158	fmove.l	fpsr,USER_FPSR(a6)
159	fmove.l	fpcr,USER_FPCR(a6)
160	fmove.l	fpcr,d1		; user's rounding mode/precision
161	fmove.l	#0,fpcr		; force rounding mode/prec to extended,rn
162*
163*	copy, convert and tag input argument
164*
165	fmove.x	8(a6),fp0
166	fmove.x	fp0,ETEMP(a6)
167	lea	ETEMP(a6),a0
168	bsr	tag
169	move.b	d0,STAG(a6)
170	tst.b	d0
171	bne.b	_TMP_C
172	bsr	_OPr_		; normalized (regular) number
173	bra.b	_TMP_G
174_TMP_C:
175	cmp.b	#$20,d0		; zero?
176	bne.b	_TMP_D
177	bsr	_OPz_
178	bra.b	_TMP_G
179_TMP_D:
180	cmp.b	#$40,d0		; infinity?
181	bne.b	_TMP_E
182	bsr	_OPi_
183	bra.b	_TMP_G
184_TMP_E:
185	cmp.b	#$60,d0		; NaN?
186	bne.b	_TMP_F
187	bsr	_OPn_
188	bra.b	_TMP_G
189_TMP_F:
190	bsr	_OPm_		; assuming a denorm...
191
192_TMP_G:
193	fmove.l	fpsr,d0		; update status register
194	or.b	FPSR_AEXCEPT(a6),d0	;add previously accrued exceptions
195	fmove.l	d0,fpsr
196*
197*	Result is now in FP0
198*
199	fmovem.x USER_FP1(a6),fp1-fp3	; note: FP0 not restored
200	fmove.l USER_FPCR(a6),fpcr	; fpcr restored
201	unlk	a6
202	rts
203
204