Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / x86_64-all / clib / longjmp.s
blob1dbc538366db5a0903507fd26fd8d7d4e4178b0c
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id: longjmp.s 12741 2001-12-08 18:16:08Z chodorowski $
5 Desc: ANSI C function longjmp()
6 Lang: english
7 */
9 /******************************************************************************
11 NAME
12 #include <setjmp.h>
14 void longjmp (jmp_buf env, int val);
16 FUNCTION
17 Save the current context so that you can return to it later.
19 INPUTS
20 env - The context/environment to restore
21 val - This value is returned by setjmp() when you return to the
22 saved context. You cannot return 0. If val is 0, then
23 setjmp() returns with 1.
25 RESULT
26 This function doesn't return.
28 NOTES
30 EXAMPLE
31 jmp_buf env;
33 ... some code ...
35 if (!setjmp (env))
37 ... this code is executed after setjmp() returns ...
39 // This is no good example on how to use this function
40 // You should not do that
41 if (error)
42 longjmp (env, 5);
44 ... some code ...
46 else
48 ... this code is executed if you call longjmp(env) ...
51 BUGS
53 SEE ALSO
54 setjmp()
56 INTERNALS
58 HISTORY
60 ******************************************************************************/
62 #include "aros/x86_64/asm.h"
64 .text
65 _ALIGNMENT
66 .globl AROS_CDEFNAME(longjmp)
67 _FUNCTION(AROS_CDEFNAME(longjmp))
69 .set FirstArg, 8 /* Skip Return-Adress */
70 .set env, FirstArg
71 .set val, env+8
72 .set retaddr, 0
74 AROS_CDEFNAME(longjmp):
76 mov %rdi, %rax
77 /* Make sure return value is not 0 */
78 cmp $0,%rsi
79 jne 1f
81 mov $1,%rsi
83 /* Restore stack pointer and all registers from env */
84 mov 120(%rax),%rsp /* Restore original stack */
86 mov 0(%rax),%rcx
87 mov %rcx,retaddr(%rsp) /* Restore return address */
89 push %rsi /* Save return value on new stack */
91 /* Restore all registers */
92 mov 8(%rax),%rbx /* %ebx */
93 mov 16(%rax),%rcx /* %ecx */
94 mov 24(%rax),%rdx /* %edx */
95 mov 32(%rax),%rsi /* %esi */
96 mov 40(%rax),%rdi /* %edi */
97 mov 48(%rax),%rbp /* %ebp */
98 mov 56(%rax),%r8
99 mov 64(%rax),%r9
100 mov 72(%rax),%r10
101 mov 80(%rax),%r11
102 mov 88(%rax),%r12
103 mov 96(%rax),%r13
104 mov 104(%rax),%r14
105 mov 112(%rax),%r15
107 pop %rax /* Fetch return value */