summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/bfin/bsdsetjmp.c
blob: 87de78a4ca0561b7558e657910431775175c9e8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * setjmp for the Blackfin project
 *
 * Copyright (C) 2003,  Metrowerks
 * Based on code from Analog Devices.
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License.  See the file COPYING.LIB in the main
 * directory of this archive for more details.
 *
 */
#include <setjmp.h>

int setjmp(jmp_buf env){
   __asm__ __volatile__("[--SP] = p0;\n\t"
       "p0 = r0;\n\t"
       "r0 = [SP++];\n\t"

       "[p0++] = r0;\n\t"	/* GP address registers */
       "[p0++] = p1;\n\t"
       "[p0++] = p2;\n\t"
       "[p0++] = p3;\n\t"
       "[p0++] = p4;\n\t"
       "[p0++] = p5;\n\t"

       "[p0++] = FP;\n\t"       /* frame pointer */
       "[p0++] = SP;\n\t"	/* stack pointer */

       "[p0++] = p0;\n\t"	/* data regs */
       "[p0++] = r1;\n\t"
       "[p0++] = r2;\n\t"
       "[p0++] = r3;\n\t"
       "[p0++] = r4;\n\t"
       "[p0++] = r5;\n\t"
       "[p0++] = r6;\n\t"
       "[p0++] = r7;\n\t"

       "r0 = ASTAT;\n\t"
       "[p0++] = r0;\n\t"

       "r0 = LC0;\n\t"		/* loop counters */
       "[p0++] = r0;\n\t"
       "r0 = LC1;\n\t"
       "[p0++] = r0;\n\t"

       "r0 = A0.w;\n\t"
       "[p0++] = r0;\n\t"
       "r0.l = A0.x;\n\t"
       "[p0++] = r0;\n\t"
       "r0 = A1.w;\n\t"
       "[p0++] = r0;\n\t"
       "r0.l = A1.x;\n\t"
       "[p0++] = r0;\n\t"

	       			/* Dag regs */
       "r0 = i0;\n\t"		/* index registers */
       "[p0++] = r0;\n\t"
       "r0 = i1;\n\t"
       "[p0++] = r0;\n\t"
       "r0 = i2;\n\t"
       "[p0++] = r0;\n\t"
       "r0 = i3;\n\t"
       "[p0++] = r0;\n\t"

       "r0 = m0;\n\t"		/* modifier registers */
       "[p0++] = r0;\n\t"
       "r0 = m1;\n\t"
       "[p0++] = r0;\n\t"
       "r0 = m2;\n\t"
       "[p0++] = r0;\n\t"
       "r0 = m3;\n\t"
       "[p0++] = r0;\n\t"

       "r0 = l0;\n\t"	        /* length registers */
       "[p0++] = r0;\n\t"
       "r0 = l1;\n\t"
       "[p0++] = r0;\n\t"
       "r0 = l2;\n\t"
       "[p0++] = r0;\n\t"
       "r0 = l3;\n\t"
       "[p0++] = r0;\n\t"

       "r0 = b0;\n\t"	        /* base registers */
       "[p0++] = r0;\n\t"
       "r0 = b1;\n\t"
       "[p0++] = r0;\n\t"
       "r0 = b2;\n\t"
       "[p0++] = r0;\n\t"
       "r0 = b3;\n\t"
       "[p0++] = r0;\n\t"

       "r0 = RETS;\n\t"		/* store return address */
       "[p0++] = r0;\n\t"

       "r0 = 0;\n\t"
      :
      :
     );
return 0;
}