summaryrefslogtreecommitdiffstats
path: root/usr/klibc/arch/ppc/setjmp.S
blob: e02b7da7659229a48a705966062c5caed8f0c750 (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
#
# arch/ppc/setjmp.S
#
# Basic setjmp/longjmp implementation
# This file was derived from the equivalent file in NetBSD
#

	.text
	.align 4
	.type setjmp,@function
	.globl setjmp
setjmp:
        mflr    %r11                    /* save return address */
        mfcr    %r12                    /* save condition register */
        mr      %r10,%r1                /* save stack pointer */
        mr      %r9,%r2                 /* save GPR2 (not needed) */
        stmw    %r9,0(%r3)              /* save r9..r31 */
        li      %r3,0                   /* indicate success */
        blr                             /* return */

	.size setjmp,.-setjmp

	.type longjmp,@function
	.globl longjmp
longjmp:
        lmw     %r9,0(%r3)              /* save r9..r31 */
        mtlr    %r11                    /* restore LR */
        mtcr    %r12                    /* restore CR */
        mr      %r2,%r9                 /* restore GPR2 (not needed) */
        mr      %r1,%r10                /* restore stack */
        mr      %r3,%r4                 /* get return value */
        blr                             /* return */

	.size longjmp,.-longjmp