1/* Copyright (c) 2020  C-SKY Microsystems All rights reserved.
2
3   This copyrighted material is made available to anyone wishing to use,
4   modify, copy, or redistribute it subject to the terms and conditions
5   of the FreeBSD License.   This program is distributed in the hope that
6   it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
7   including the implied warranties of MERCHANTABILITY or FITNESS FOR
8   A PARTICULAR PURPOSE.  A copy of this license is available at
9   http://www.opensource.org/licenses.
10*/
11
12	.section	.text
13	.align	3
14	.globl	setjmp
15	.type	setjmp,@function
16	.globl	longjmp
17	.type	longjmp,@function
18
19setjmp:
20
21#if defined(__CK801__)
22	stw	r4, (r0, 0)
23	stw    	r5, (r0, 4)
24	stw    	r6, (r0, 8)
25	stw    	r7, (r0, 12)
26	stw    	r8, (r0, 16)
27	stw    	r15, (r0, 20)
28	stw    	sp, (r0, 24)
29#elif defined(__CK802__)
30	stm	r4-r11, (r0)
31	stw    	r15, (r0, 32)
32	stw    	sp, (r0, 36)
33#else
34	stm    	r4-r11, (r0)
35	stw    	r15, (r0, 32)
36	stw    	r16, (r0, 36)
37	stw    	r17, (r0, 40)
38	stw    	r26, (r0, 44)
39	stw    	r27, (r0, 48)
40	stw    	r28, (r0, 52)
41	stw    	r29, (r0, 56)
42	stw    	r30, (r0, 60)
43	stw    	r31, (r0, 64)
44	stw    	sp, (r0, 68)
45#endif
46	movi   	r0, 0
47	rts
48
49longjmp:
50#if defined(__CK801__)
51	ldw	r4, (r0, 0)
52	ldw    	r5, (r0, 4)
53	ldw    	r6, (r0, 8)
54	ldw    	r7, (r0, 12)
55	ldw    	r8, (r0, 16)
56	ldw    	r15, (r0, 20)
57	ldw    	sp, (r0, 24)
58#elif defined(__CK802__)
59	ldm	r4-r11, (r0)
60	ldw    	r15, (r0, 32)
61	ldw    	sp, (r0, 36)
62#else
63	ldm   	r4-r11, (r0)
64	ldw    	r15, (r0, 32)
65	ldw    	r16, (r0, 36)
66	ldw    	r17, (r0, 40)
67	ldw    	r26, (r0, 44)
68	ldw    	r27, (r0, 48)
69	ldw    	r28, (r0, 52)
70	ldw    	r29, (r0, 56)
71	ldw    	r30, (r0, 60)
72	ldw    	r31, (r0, 64)
73	ldw    	sp, (r0, 68)
74#endif
75	mov    	r0, r1
76	cmpnei 	r1, 0
77	bt     	1f
78	movi   	r0, 1
791:	rts
80