Commit | Line | Data |
---|---|---|
99714846 KB |
1 | /*- |
2 | * Copyright (c) 1991 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This code is derived from software contributed to Berkeley by | |
6 | * Ralph Campbell. | |
7 | * | |
8 | * %sccs.include.redist.c% | |
9 | */ | |
10 | ||
f1e99c02 KB |
11 | #include "DEFS.h" |
12 | ||
99714846 | 13 | #if defined(LIBC_SCCS) && !defined(lint) |
f1e99c02 | 14 | ASMSTR("@(#)_setjmp.s 5.2 (Berkeley) %G%") |
99714846 KB |
15 | #endif /* LIBC_SCCS and not lint */ |
16 | ||
99714846 KB |
17 | /* |
18 | * C library -- _setjmp, _longjmp | |
19 | * | |
20 | * _longjmp(a,v) | |
21 | * will generate a "return(v)" from | |
22 | * the last call to | |
23 | * _setjmp(a) | |
24 | * by restoring registers from the stack, | |
25 | * The previous signal state is NOT restored. | |
26 | */ | |
27 | ||
28 | LEAF(_setjmp) | |
29 | li v0, 0xACEDBADE # sigcontext magic number | |
30 | sw ra, (2 * 4)(a0) # sc_pc = return address | |
31 | sw v0, (3 * 4)(a0) # saved in sc_regs[0] | |
32 | sw s0, ((S0 + 3) * 4)(a0) | |
33 | sw s1, ((S1 + 3) * 4)(a0) | |
34 | sw s2, ((S2 + 3) * 4)(a0) | |
35 | sw s3, ((S3 + 3) * 4)(a0) | |
36 | sw s4, ((S4 + 3) * 4)(a0) | |
37 | sw s5, ((S5 + 3) * 4)(a0) | |
38 | sw s6, ((S6 + 3) * 4)(a0) | |
39 | sw s7, ((S7 + 3) * 4)(a0) | |
40 | sw sp, ((SP + 3) * 4)(a0) | |
41 | sw s8, ((S8 + 3) * 4)(a0) | |
42 | cfc1 v0, $31 # too bad can't check if FP used | |
43 | swc1 $f20, ((20 + 38) * 4)(a0) | |
44 | swc1 $f21, ((21 + 38) * 4)(a0) | |
45 | swc1 $f22, ((22 + 38) * 4)(a0) | |
46 | swc1 $f23, ((23 + 38) * 4)(a0) | |
47 | swc1 $f24, ((24 + 38) * 4)(a0) | |
48 | swc1 $f25, ((25 + 38) * 4)(a0) | |
49 | swc1 $f26, ((26 + 38) * 4)(a0) | |
50 | swc1 $f27, ((27 + 38) * 4)(a0) | |
51 | swc1 $f28, ((28 + 38) * 4)(a0) | |
52 | swc1 $f29, ((29 + 38) * 4)(a0) | |
53 | swc1 $f30, ((30 + 38) * 4)(a0) | |
54 | swc1 $f31, ((31 + 38) * 4)(a0) | |
55 | sw v0, ((32 + 38) * 4)(a0) | |
56 | move v0, zero | |
57 | j ra | |
58 | END(_setjmp) | |
59 | ||
60 | LEAF(_longjmp) | |
61 | lw v0, (3 * 4)(a0) # get magic number | |
62 | bne v0, 0xACEDBADE, botch # jump if error | |
63 | lw ra, (2 * 4)(a0) | |
64 | lw s0, ((S0 + 3) * 4)(a0) | |
65 | lw s1, ((S1 + 3) * 4)(a0) | |
66 | lw s2, ((S2 + 3) * 4)(a0) | |
67 | lw s3, ((S3 + 3) * 4)(a0) | |
68 | lw s4, ((S4 + 3) * 4)(a0) | |
69 | lw s5, ((S5 + 3) * 4)(a0) | |
70 | lw s6, ((S6 + 3) * 4)(a0) | |
71 | lw s7, ((S7 + 3) * 4)(a0) | |
72 | lw sp, ((SP + 3) * 4)(a0) | |
73 | lw s8, ((S8 + 3) * 4)(a0) | |
74 | lw v0, ((32 + 38) * 4)(a0) # get fpu status | |
75 | ctc1 v0, $31 | |
76 | lwc1 $f20, ((20 + 38) * 4)(a0) | |
77 | lwc1 $f21, ((21 + 38) * 4)(a0) | |
78 | lwc1 $f22, ((22 + 38) * 4)(a0) | |
79 | lwc1 $f23, ((23 + 38) * 4)(a0) | |
80 | lwc1 $f24, ((24 + 38) * 4)(a0) | |
81 | lwc1 $f25, ((25 + 38) * 4)(a0) | |
82 | lwc1 $f26, ((26 + 38) * 4)(a0) | |
83 | lwc1 $f27, ((27 + 38) * 4)(a0) | |
84 | lwc1 $f28, ((28 + 38) * 4)(a0) | |
85 | lwc1 $f29, ((29 + 38) * 4)(a0) | |
86 | lwc1 $f30, ((30 + 38) * 4)(a0) | |
87 | lwc1 $f31, ((31 + 38) * 4)(a0) | |
88 | move v0, a1 | |
89 | j ra | |
90 | botch: | |
91 | jal longjmperror | |
92 | jal abort | |
93 | END(_longjmp) |