_setjmp.S revision 1.2 1 1.2 matt /* $NetBSD: _setjmp.S,v 1.2 2002/07/30 06:07:57 matt Exp $ */
2 1.1 thorpej
3 1.1 thorpej #include <machine/asm.h>
4 1.1 thorpej
5 1.1 thorpej #if defined(LIBC_SCCS)
6 1.1 thorpej .text
7 1.2 matt .asciz "$NetBSD: _setjmp.S,v 1.2 2002/07/30 06:07:57 matt Exp $"
8 1.1 thorpej #endif
9 1.1 thorpej
10 1.1 thorpej /*
11 1.1 thorpej * C library -- _setjmp, _longjmp
12 1.1 thorpej *
13 1.1 thorpej * _longjmp(a,v)
14 1.1 thorpej * will generate a "return(v?v:1)" from the last call to
15 1.1 thorpej * _setjmp(a)
16 1.1 thorpej * by restoring registers from the stack.
17 1.1 thorpej * The previous signal state is NOT restored.
18 1.1 thorpej */
19 1.1 thorpej
20 1.1 thorpej ENTRY(_setjmp)
21 1.2 matt mflr %r11 /* save return address */
22 1.2 matt mfcr %r12 /* save condition register */
23 1.2 matt mr %r10,%r1 /* save stack pointer */
24 1.2 matt mr %r9,%r2 /* save GPR2 (not needed) */
25 1.2 matt stmw %r9,8(%r3) /* save r9..r31 */
26 1.2 matt li %r3,0 /* indicate success */
27 1.2 matt blr /* return */
28 1.1 thorpej
29 1.1 thorpej ENTRY(_longjmp)
30 1.2 matt lmw %r9,8(%r3) /* save r9..r31 */
31 1.2 matt mtlr %r11 /* restore LR */
32 1.2 matt mtcr %r12 /* restore CR */
33 1.2 matt mr %r2,%r9 /* restore GPR2 (not needed) */
34 1.2 matt mr %r1,%r10 /* restore stack */
35 1.2 matt or. %r3,%r4,%r4 /* get return value */
36 1.2 matt bnelr /* return if not 0 */
37 1.2 matt li %r3,1 /* what's the point? */
38 1.2 matt blr /* return */
39