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; setjmp/longjmp for D30V.
18
19	.text
20	.globl	setjmp
21	.type	setjmp,@function
22	.stabs	"setjmp.S",100,0,0,setjmp
23	.stabs	"int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,0,0
24	.stabs	"setjmp:F(0,1)",36,0,1,setjmp
25
26setjmp:
27; Address of jmpbuf is passed in R2.  Save the appropriate registers.
28	st2w	r26, @(r2+,r0)
29	st2w	r28, @(r2+,r0)
30	st2w	r30, @(r2+,r0)
31	st2w	r32, @(r2+,r0)
32	st2w	r34, @(r2+,r0)
33	st2w	r36, @(r2+,r0)
34	st2w	r38, @(r2+,r0)
35	st2w	r40, @(r2+,r0)
36	st2w	r42, @(r2+,r0)
37	st2w	r44, @(r2+,r0)
38	st2w	r46, @(r2+,r0)
39	st2w	r48, @(r2+,r0)
40	st2w	r50, @(r2+,r0)
41	st2w	r52, @(r2+,r0)
42	st2w	r54, @(r2+,r0)
43	st2w	r56, @(r2+,r0)
44	st2w	r58, @(r2+,r0)
45	st2w	r60, @(r2+,r0)
46	st2w	r62, @(r2+,r0)
47
48	mvfacc	r4, a1, 16
49	mvfacc	r5, a1, 0
50	st2w	r4, @(r2+,r0)
51
52	mvfsys	r4, psw
53	mvfsys	r5, rpt_c
54	st2w	r4, @(r2+,r0)
55
56	mvfsys	r4, rpt_s
57	mvfsys	r5, rpt_e
58	st2w	r4, @(r2+,r0)
59
60	mvfsys	r4, mod_s
61	mvfsys	r5, mod_e
62	st2w	r4, @(r2+,r0)
63
64; Return 0 to caller
65	add	r2, r0, r0
66	jmp	link
67.Lsetjmp:
68	.size	setjmp,.Lsetjmp-setjmp
69	.stabs	"",36,0,0,.Lsetjmp-setjmp
70
71	.globl	longjmp
72	.type	longjmp,@function
73	.stabs	"longjmp:F(0,1)",36,0,1,longjmp
74longjmp:
75; Address of jmpbuf is in R2.  Restore the registers.
76	ld2w	r26, @(r2+,r0)
77	ld2w	r28, @(r2+,r0)
78	ld2w	r30, @(r2+,r0)
79	ld2w	r32, @(r2+,r0)
80	ld2w	r34, @(r2+,r0)
81	ld2w	r36, @(r2+,r0)
82	ld2w	r38, @(r2+,r0)
83	ld2w	r40, @(r2+,r0)
84	ld2w	r42, @(r2+,r0)
85	ld2w	r44, @(r2+,r0)
86	ld2w	r46, @(r2+,r0)
87	ld2w	r48, @(r2+,r0)
88	ld2w	r50, @(r2+,r0)
89	ld2w	r52, @(r2+,r0)
90	ld2w	r54, @(r2+,r0)
91	ld2w	r56, @(r2+,r0)
92	ld2w	r58, @(r2+,r0)
93	ld2w	r60, @(r2+,r0)
94	ld2w	r62, @(r2+,r0)
95
96	ld2w	r4, @(r2+,r0)
97	mvtacc	a1, r4, r5
98
99	mvfsys	r6, psw
100	ld2w	r4, @(r2+,r0)		/* psw, rpt_c */
101	and	r6, r6, 0xfcff		/* set rp, md bits from setjmp, leave */
102	and	r4, r4, 0x0300		/* all other psw bits the same */
103	or	r4, r4, r6
104	mvtsys	psw, r4
105	mvtsys	rpt_c, r5
106
107	ld2w	r4, @(r2+,r0)
108	mvtsys	rpt_s, r4
109	mvtsys	rpt_e, r5
110
111	ld2w	r4, @(r2+,r0)
112	mvtsys	mod_s, r4
113	mvtsys	mod_e, r5
114
115; Value to return to caller is in R3.  If caller attemped to return 0,
116; return 1 instead.
117
118	cmpeq	f0, r3, 0	|| 	add	r2, r3, r0
119	jmp	link		||	add/tx	r2, r2, 1
120.Llongjmp:
121	.size	longjmp,.Llongjmp-longjmp
122	.stabs	"",36,0,0,.Llongjmp-longjmp
123