1 | ;/* |
---|
2 | ; * C library -- _setjmp, _longjmp |
---|
3 | ; * |
---|
4 | ; * _longjmp(a,v) |
---|
5 | ; * will generate a "return(v?v:1)" from |
---|
6 | ; * the last call to |
---|
7 | ; * _setjmp(a) |
---|
8 | ; * by unwinding the call stack. |
---|
9 | ; * The previous signal state is NOT restored. |
---|
10 | ; * |
---|
11 | ; * |
---|
12 | ; * Copyright (c) 2003 Altera Corporation |
---|
13 | ; * All rights reserved. |
---|
14 | ; * |
---|
15 | ; * Redistribution and use in source and binary forms, with or without |
---|
16 | ; * modification, are permitted provided that the following conditions |
---|
17 | ; * are met: |
---|
18 | ; * |
---|
19 | ; * o Redistributions of source code must retain the above copyright |
---|
20 | ; * notice, this list of conditions and the following disclaimer. |
---|
21 | ; * o Redistributions in binary form must reproduce the above copyright |
---|
22 | ; * notice, this list of conditions and the following disclaimer in the |
---|
23 | ; * documentation and/or other materials provided with the distribution. |
---|
24 | ; * o Neither the name of Altera Corporation nor the names of its |
---|
25 | ; * contributors may be used to endorse or promote products derived from |
---|
26 | ; * this software without specific prior written permission. |
---|
27 | ; * |
---|
28 | ; * THIS SOFTWARE IS PROVIDED BY ALTERA CORPORATION, THE COPYRIGHT HOLDER, |
---|
29 | ; * AND ITS CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
---|
30 | ; * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
---|
31 | ; * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
---|
32 | ; * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
---|
33 | ; * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
---|
34 | ; * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
---|
35 | ; * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
---|
36 | ; * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
---|
37 | ; * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
---|
38 | ; * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
39 | ; */ |
---|
40 | |
---|
41 | .section .text |
---|
42 | .align 3 |
---|
43 | .globl setjmp |
---|
44 | .type setjmp,@function |
---|
45 | .globl longjmp |
---|
46 | .type longjmp,@function |
---|
47 | |
---|
48 | |
---|
49 | setjmp: |
---|
50 | stw r16, 0(r4) |
---|
51 | stw r17, 4(r4) |
---|
52 | stw r18, 8(r4) |
---|
53 | stw r19, 12(r4) |
---|
54 | stw r20, 16(r4) |
---|
55 | stw r21, 20(r4) |
---|
56 | stw r22, 24(r4) |
---|
57 | stw r23, 28(r4) |
---|
58 | stw gp, 32(r4) |
---|
59 | stw sp, 36(r4) |
---|
60 | stw fp, 40(r4) |
---|
61 | stw ra, 44(r4) |
---|
62 | mov r2, zero |
---|
63 | ret |
---|
64 | |
---|
65 | longjmp: |
---|
66 | ldw r16, 0(r4) |
---|
67 | ldw r17, 4(r4) |
---|
68 | ldw r18, 8(r4) |
---|
69 | ldw r19, 12(r4) |
---|
70 | ldw r20, 16(r4) |
---|
71 | ldw r21, 20(r4) |
---|
72 | ldw r22, 24(r4) |
---|
73 | ldw r23, 28(r4) |
---|
74 | ldw gp, 32(r4) |
---|
75 | ldw sp, 36(r4) |
---|
76 | ldw fp, 40(r4) |
---|
77 | ldw ra, 44(r4) |
---|
78 | mov r2, r5 |
---|
79 | bne r2, zero, 1f |
---|
80 | movi r2, 1 |
---|
81 | 1: |
---|
82 | ret |
---|