xref: /DragonStub/lib/loongarch64/setjmp.S (revision 5849eacdce81bda09fd61e71f440f15e62c25deb)
1/*
2 * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
3 * Copyright (c) 2021 Loongson Technology Corporation Limited.All rights
4 * reserved.
5 * Author: zhoumingtao <zhoumingtao@loongson.cn>
6 *
7 * This program and the accompanying materials are licensed and made
8 * available
9 * under the terms and conditions of the BSD License which accompanies
10 * this
11 * distribution.  The full text of the license may be found at
12 * http://opensource.org/licenses/bsd-license.php.
13 *
14 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
15 * BASIS,
16 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
17 * IMPLIED.
18 */
19
20	.text
21	.p2align 3
22
23/*
24   int setjmp(jmp_buf env);
25*/
26	.globl	setjmp
27	.type	setjmp, @function
28setjmp:
29	st.d $ra, $a0, 0x0
30	st.d $sp, $a0, 0x8
31	st.d $fp, $a0, 0x10
32	st.d $s0, $a0, 0x18
33	st.d $s1, $a0, 0x20
34	st.d $s2, $a0, 0x28
35	st.d $s3, $a0, 0x30
36	st.d $s4, $a0, 0x38
37	st.d $s5, $a0, 0x40
38	st.d $s6, $a0, 0x48
39	st.d $s7, $a0, 0x50
40	st.d $s8, $a0, 0x58
41
42	move $a0, $zero
43	jr   $ra
44
45/*
46   void longjmp(jmp_buf env, int val);
47*/
48	.globl	longjmp
49	.type	longjmp, @function
50longjmp:
51	ld.d $ra, $a0, 0x0
52	ld.d $sp, $a0, 0x8
53	ld.d $fp, $a0, 0x10
54	ld.d $s0, $a0, 0x18
55	ld.d $s1, $a0, 0x20
56	ld.d $s2, $a0, 0x28
57	ld.d $s3, $a0, 0x30
58	ld.d $s4, $a0, 0x38
59	ld.d $s5, $a0, 0x40
60	ld.d $s6, $a0, 0x48
61	ld.d $s7, $a0, 0x50
62	ld.d $s8, $a0, 0x58
63
64	addi.d $a0, $zero, 1	# a0 = 1
65	beqz $a1, .L0		# if (a1 == 0); goto L0
66	move $a0, $a1		# a0 = a1
67.L0:
68	jr   $ra
69