1/*
2(C) Copyright IBM Corp. 2005, 2006
3
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9    * Redistributions of source code must retain the above copyright notice,
10this list of conditions and the following disclaimer.
11    * Redistributions in binary form must reproduce the above copyright
12notice, this list of conditions and the following disclaimer in the
13documentation and/or other materials provided with the distribution.
14    * Neither the name of IBM nor the names of its contributors may be
15used to endorse or promote products derived from this software without
16specific prior written permission.
17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE.
29
30Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
31*/
32
33/*
34	int setjmp( jmp_buf env );
35*/
36#include <picolibc.h>
37
38	.text
39	.align	2
40	.global	setjmp
41	.type	setjmp, @function
42setjmp:
43	stqd	$80, 2*16($3)
44	stqd	$81, 3*16($3)
45	stqd	$82, 4*16($3)
46	stqd	$83, 5*16($3)
47	stqd	$84, 6*16($3)
48	stqd	$85, 7*16($3)
49	stqd	$86, 8*16($3)
50	stqd	$87, 9*16($3)
51	stqd	$88, 10*16($3)
52	stqd	$89, 11*16($3)
53	stqd	$90, 12*16($3)
54	stqd	$91, 13*16($3)
55	stqd	$92, 14*16($3)
56	stqd	$93, 15*16($3)
57	stqd	$94, 16*16($3)
58	stqd	$95, 17*16($3)
59	stqd	$96, 18*16($3)
60	stqd	$97, 19*16($3)
61	stqd	$98, 20*16($3)
62	stqd	$99, 21*16($3)
63	stqd	$100, 22*16($3)
64	stqd	$101, 23*16($3)
65	stqd	$102, 24*16($3)
66	stqd	$103, 25*16($3)
67	stqd	$104, 26*16($3)
68	stqd	$105, 27*16($3)
69	stqd	$106, 28*16($3)
70	stqd	$107, 29*16($3)
71	stqd	$108, 30*16($3)
72	stqd	$109, 31*16($3)
73	stqd	$110, 32*16($3)
74	stqd	$111, 33*16($3)
75	stqd	$112, 34*16($3)
76	stqd	$113, 35*16($3)
77	stqd	$114, 36*16($3)
78	stqd	$115, 37*16($3)
79	stqd	$116, 38*16($3)
80	stqd	$117, 39*16($3)
81	stqd	$118, 40*16($3)
82	stqd	$119, 41*16($3)
83
84	hbr	setjmp_ret, $0
85	lnop			# pipe1 bubble added for instruction fetch
86
87	stqd	$120, 42*16($3)
88	stqd	$121, 43*16($3)
89	stqd	$122, 44*16($3)
90	stqd	$123, 45*16($3)
91	stqd	$124, 46*16($3)
92	stqd	$125, 47*16($3)
93	stqd	$126, 48*16($3)
94	stqd	$127, 49*16($3)
95
96	stqd	$0, 0*16($3)
97	stqd	$1, 1*16($3)
98
99	il	$3, 0
100
101setjmp_ret:
102	bi	$0
103	.size	setjmp, .-setjmp
104
105/*
106	int longjmp( jmp_buf env, int val );
107*/
108	.text
109	.align	2
110	.global	longjmp
111	.type	longjmp, @function
112longjmp:
113	lr	$127, $1
114
115	lqd	$0, 0*16($3)
116	lqd	$1, 1*16($3)
117
118	sf	$126, $127, $1
119	rotqbyi	$126, $126, 12
120	fsmbi	$127, 0x0F00
121	and	$126, $126, $127
122	a	$1, $1, $126
123
124	# restore all the non-volatile registers
125
126	lqd	$80, 2*16($3)
127	lqd	$81, 3*16($3)
128	lqd	$82, 4*16($3)
129	lqd	$83, 5*16($3)
130	lqd	$84, 6*16($3)
131	lqd	$85, 7*16($3)
132	lqd	$86, 8*16($3)
133	lqd	$87, 9*16($3)
134	lqd	$88, 10*16($3)
135	lqd	$89, 11*16($3)
136	lqd	$90, 12*16($3)
137	lqd	$91, 13*16($3)
138	lqd	$92, 14*16($3)
139	lqd	$93, 15*16($3)
140	lqd	$94, 16*16($3)
141	lqd	$95, 17*16($3)
142	lqd	$96, 18*16($3)
143	lqd	$97, 19*16($3)
144	lqd	$98, 20*16($3)
145	lqd	$99, 21*16($3)
146	lqd	$100, 22*16($3)
147	lqd	$101, 23*16($3)
148	lqd	$102, 24*16($3)
149	lqd	$103, 25*16($3)
150	lqd	$104, 26*16($3)
151	lqd	$105, 27*16($3)
152	lqd	$106, 28*16($3)
153	lqd	$107, 29*16($3)
154	lqd	$108, 30*16($3)
155	lqd	$109, 31*16($3)
156
157	hbr	longjmp_ret, $0
158
159	lqd	$110, 32*16($3)
160	lqd	$111, 33*16($3)
161	lqd	$112, 34*16($3)
162	lqd	$113, 35*16($3)
163	lqd	$114, 36*16($3)
164	lqd	$115, 37*16($3)
165	lqd	$116, 38*16($3)
166	lqd	$117, 39*16($3)
167	lqd	$118, 40*16($3)
168	lqd	$119, 41*16($3)
169	lqd	$120, 42*16($3)
170	lqd	$121, 43*16($3)
171	lqd	$122, 44*16($3)
172	lqd	$123, 45*16($3)
173	lqd	$124, 46*16($3)
174	lqd	$125, 47*16($3)
175
176	ceqi	$5, $4, 0
177	lqd	$126, 48*16($3)
178	lqd	$127, 49*16($3)
179
180	sf	$3, $5, $4
181
182longjmp_ret:
183	bi	$0
184	.size	longjmp, .-longjmp
185
186