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