1/* Copyright (c) 2002 Dave Brolley  <brolley@redhat.com> */
2# setjmp/longjmp for Frv.  The jmpbuf looks like this:
3#
4# Register	jmpbuf offset
5# R16-R31	0x0-0x03c
6# R48-R63	0x40-0x7c
7# FR16-FR31     0x80-0xbc
8# FR48-FR63     0xc0-0xfc
9# LR            0x100
10# SP            0x104
11# FP            0x108
12#
13# R8 contains the pointer to jmpbuf
14
15#include <frv-asm.h>
16
17	.text
18	.global	EXT(setjmp)
19	.type	EXT(setjmp),@function
20EXT(setjmp):
21	stdi	gr16, @(gr8,0)
22	stdi	gr18, @(gr8,8)
23	stdi 	gr20, @(gr8,16)
24	stdi	gr22, @(gr8,24)
25	stdi	gr24, @(gr8,32)
26	stdi	gr26, @(gr8,40)
27	stdi	gr28, @(gr8,48)
28	stdi	gr30, @(gr8,56)
29#if __FRV_GPR__ != 32
30	stdi	gr48, @(gr8,64)
31	stdi	gr50, @(gr8,72)
32	stdi	gr52, @(gr8,80)
33	stdi	gr54, @(gr8,88)
34	stdi	gr56, @(gr8,96)
35	stdi	gr58, @(gr8,104)
36	stdi	gr60, @(gr8,112)
37	stdi	gr62, @(gr8,120)
38#endif
39
40#if __FRV_FPR__ != 0
41	stdfi	fr16, @(gr8,128)
42	stdfi	fr18, @(gr8,136)
43	stdfi 	fr20, @(gr8,144)
44	stdfi	fr22, @(gr8,152)
45	stdfi	fr24, @(gr8,160)
46	stdfi	fr26, @(gr8,168)
47	stdfi	fr28, @(gr8,176)
48	stdfi	fr30, @(gr8,184)
49#if __FRV_FPR__ != 32
50	stdfi	fr48, @(gr8,192)
51	stdfi	fr50, @(gr8,200)
52	stdfi	fr52, @(gr8,208)
53	stdfi	fr54, @(gr8,216)
54	stdfi	fr56, @(gr8,224)
55	stdfi	fr58, @(gr8,232)
56	stdfi	fr60, @(gr8,240)
57	stdfi	fr62, @(gr8,248)
58#endif
59#endif
60
61        movsg	lr, gr4
62	sti     gr4, @(gr8,256)
63	sti     sp, @(gr8,260)
64	sti     fp, @(gr8,264)
65
66	mov     gr0,gr8
67	ret
68.Lend1:
69	.size	EXT(setjmp),.Lend1-EXT(setjmp)
70
71	.global	EXT(longjmp)
72	.type	EXT(longjmp),@function
73EXT(longjmp):
74	lddi	@(gr8,0), gr16
75	lddi	@(gr8,8), gr18
76	lddi 	@(gr8,16), gr20
77	lddi	@(gr8,24), gr22
78	lddi	@(gr8,32), gr24
79	lddi	@(gr8,40), gr26
80	lddi	@(gr8,48), gr28
81	lddi	@(gr8,56), gr30
82#if __FRV_GPR__ != 32
83	lddi	@(gr8,64), gr48
84	lddi	@(gr8,72), gr50
85	lddi	@(gr8,80), gr52
86	lddi	@(gr8,88), gr54
87	lddi	@(gr8,96), gr56
88	lddi	@(gr8,104), gr58
89	lddi	@(gr8,112), gr60
90	lddi	@(gr8,120), gr62
91#endif
92
93#if __FRV_FPR__ != 0
94	lddfi	@(gr8,128), fr16
95	lddfi	@(gr8,136), fr18
96	lddfi 	@(gr8,144), fr20
97	lddfi	@(gr8,152), fr22
98	lddfi	@(gr8,160), fr24
99	lddfi	@(gr8,168), fr26
100	lddfi	@(gr8,176), fr28
101	lddfi	@(gr8,184), fr30
102#if __FRV_FPR__ != 32
103	lddfi	@(gr8,192), fr48
104	lddfi	@(gr8,200), fr50
105	lddfi	@(gr8,208), fr52
106	lddfi	@(gr8,216), fr54
107	lddfi	@(gr8,224), fr56
108	lddfi	@(gr8,232), fr58
109	lddfi	@(gr8,240), fr60
110	lddfi	@(gr8,248), fr62
111#endif
112#endif
113
114        ldi     @(gr8,256), gr4
115	movgs   gr4,lr
116
117        ldi     @(gr8,260), sp
118        ldi     @(gr8,264), fp
119
120# Value to return is in r9.  If zero, return 1
121	cmp	gr9, gr0, icc0
122	setlos	#1, gr8
123	ckne	icc0, cc4
124	cmov	gr9, gr8, cc4, 1
125	ret
126.Lend2:
127	.size	EXT(longjmp),.Lend2-EXT(longjmp)
128