1/*
2Copyright (c) 1990 The Regents of the University of California.
3All rights reserved.
4
5Redistribution and use in source and binary forms are permitted
6provided that the above copyright notice and this paragraph are
7duplicated in all such forms and that any documentation,
8and/or other materials related to such
9distribution and use acknowledge that the software was developed
10by the University of California, Berkeley.  The name of the
11University may not be used to endorse or promote products derived
12from this software without specific prior written permission.
13THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 */
17/* We want to pretend we're in SHmedia mode, even when assembling for
18   SHcompact.  */
19#if __SH5__ == 32 && ! __SHMEDIA__
20# undef __SHMEDIA__
21# define __SHMEDIA__ 1
22#endif
23
24#if __SHMEDIA__
25	.mode	SHmedia
26#endif
27
28#include "asm.h"
29
30ENTRY(setjmp)
31#if __SH5__
32	ptabs	r18, tr0
33	gettr	tr5, r5
34	gettr	tr6, r6
35	gettr	tr7, r7
36	st.q	r2,  0*8, r18
37	st.q	r2,  1*8, r10
38	st.q	r2,  2*8, r11
39	st.q	r2,  3*8, r12
40	st.q	r2,  4*8, r13
41	st.q	r2,  5*8, r14
42	st.q	r2,  6*8, r15
43	st.q	r2,  7*8, r28
44	st.q	r2,  8*8, r29
45	st.q	r2,  9*8, r30
46	st.q	r2, 10*8, r31
47	st.q	r2, 11*8, r32
48	st.q	r2, 12*8, r33
49	st.q	r2, 13*8, r34
50	st.q	r2, 14*8, r35
51	st.q	r2, 15*8, r44
52	st.q	r2, 16*8, r45
53	st.q	r2, 17*8, r46
54	st.q	r2, 18*8, r47
55	st.q	r2, 19*8, r48
56	st.q	r2, 20*8, r49
57	st.q	r2, 21*8, r50
58	st.q	r2, 22*8, r51
59	st.q	r2, 23*8, r52
60	st.q	r2, 24*8, r53
61	st.q	r2, 25*8, r54
62	st.q	r2, 26*8, r55
63	st.q	r2, 27*8, r56
64	st.q	r2, 28*8, r57
65	st.q	r2, 29*8, r58
66	st.q	r2, 30*8, r59
67	st.q	r2, 31*8, r5
68	st.q	r2, 32*8, r6
69	st.q	r2, 33*8, r7
70#if ! __SH4_NOFPU__
71	fst.d	r2, 34*8, dr12
72	fst.d	r2, 35*8, dr14
73	fst.d	r2, 36*8, dr36
74	fst.d	r2, 37*8, dr38
75	fst.d	r2, 38*8, dr40
76	fst.d	r2, 39*8, dr42
77	fst.d	r2, 40*8, dr44
78	fst.d	r2, 41*8, dr46
79	fst.d	r2, 42*8, dr48
80	fst.d	r2, 43*8, dr50
81	fst.d	r2, 44*8, dr52
82	fst.d	r2, 45*8, dr54
83	fst.d	r2, 46*8, dr56
84	fst.d	r2, 47*8, dr58
85	fst.d	r2, 48*8, dr60
86	fst.d	r2, 49*8, dr62
87#endif
88	movi	0, r2
89	blink	tr0, r63
90#else
91#if defined (__SH2E__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
92	add	#(13*4),r4
93#else
94	add	#(9*4),r4
95#endif
96
97	sts.l	pr,@-r4
98
99#if defined (__SH2E__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
100	fmov.s	fr15,@-r4	! call saved floating point registers
101	fmov.s	fr14,@-r4
102	fmov.s	fr13,@-r4
103	fmov.s	fr12,@-r4
104#endif
105
106	mov.l	r15,@-r4	! call saved integer registers
107	mov.l	r14,@-r4
108	mov.l	r13,@-r4
109	mov.l	r12,@-r4
110
111	mov.l	r11,@-r4
112	mov.l	r10,@-r4
113	mov.l	r9,@-r4
114	mov.l	r8,@-r4
115
116	rts
117	mov    #0,r0
118#endif /* __SH5__ */
119
120ENTRY(longjmp)
121#if __SH5__
122	ld.q	r2,  0*8, r18
123	ptabs	r18, tr0
124	ld.q	r2,  1*8, r10
125	ld.q	r2,  2*8, r11
126	ld.q	r2,  3*8, r12
127	ld.q	r2,  4*8, r13
128	ld.q	r2,  5*8, r14
129	ld.q	r2,  6*8, r15
130	ld.q	r2,  7*8, r28
131	ld.q	r2,  8*8, r29
132	ld.q	r2,  9*8, r30
133	ld.q	r2, 10*8, r31
134	ld.q	r2, 11*8, r32
135	ld.q	r2, 12*8, r33
136	ld.q	r2, 13*8, r34
137	ld.q	r2, 14*8, r35
138	ld.q	r2, 15*8, r44
139	ld.q	r2, 16*8, r45
140	ld.q	r2, 17*8, r46
141	ld.q	r2, 18*8, r47
142	ld.q	r2, 19*8, r48
143	ld.q	r2, 20*8, r49
144	ld.q	r2, 21*8, r50
145	ld.q	r2, 22*8, r51
146	ld.q	r2, 23*8, r52
147	ld.q	r2, 24*8, r53
148	ld.q	r2, 25*8, r54
149	ld.q	r2, 26*8, r55
150	ld.q	r2, 27*8, r56
151	ld.q	r2, 28*8, r57
152	ld.q	r2, 29*8, r58
153	ld.q	r2, 30*8, r59
154	ld.q	r2, 31*8, r5
155	ld.q	r2, 32*8, r6
156	ld.q	r2, 33*8, r7
157	ptabs	r5, tr5
158	ptabs	r6, tr6
159	ptabs	r7, tr7
160#if ! __SH4_NOFPU__
161	fld.d	r2, 34*8, dr12
162	fld.d	r2, 35*8, dr14
163	fld.d	r2, 36*8, dr36
164	fld.d	r2, 37*8, dr38
165	fld.d	r2, 38*8, dr40
166	fld.d	r2, 39*8, dr42
167	fld.d	r2, 40*8, dr44
168	fld.d	r2, 41*8, dr46
169	fld.d	r2, 42*8, dr48
170	fld.d	r2, 43*8, dr50
171	fld.d	r2, 44*8, dr52
172	fld.d	r2, 45*8, dr54
173	fld.d	r2, 46*8, dr56
174	fld.d	r2, 47*8, dr58
175	fld.d	r2, 48*8, dr60
176	fld.d	r2, 49*8, dr62
177#endif
178	movi	1, r2
179	cmvne	r3, r3, r2
180	blink	tr0, r63
181#else
182	mov.l	@r4+,r8
183	mov.l	@r4+,r9
184	mov.l	@r4+,r10
185	mov.l	@r4+,r11
186
187	mov.l	@r4+,r12
188	mov.l	@r4+,r13
189	mov.l	@r4+,r14
190	mov.l	@r4+,r15
191
192#if defined (__SH2E__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
193	fmov.s	@r4+,fr12	! call saved floating point registers
194	fmov.s	@r4+,fr13
195	fmov.s	@r4+,fr14
196	fmov.s	@r4+,fr15
197#endif
198
199	lds.l	@r4+,pr
200
201	mov	r5,r0
202	tst	r0,r0
203	bf	retr4
204	movt	r0
205retr4:	rts
206	nop
207#endif /* __SH5__ */
208