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()
9 /******************************************************************************
14 void longjmp (jmp_buf env, int val);
17 Save the current context so that you can return to it later.
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.
26 This function doesn't return.
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
48 ... this code is executed if you call longjmp(env) ...
60 ******************************************************************************/
62 #include "aros/x86_64/asm.h"
66 .globl AROS_CDEFNAME(longjmp)
67 _FUNCTION
(AROS_CDEFNAME
(longjmp
))
69 .set FirstArg, 8 /* Skip Return-Adress */
74 AROS_CDEFNAME
(longjmp
):
77 /* Make sure return value is not 0 */
83 /* Restore stack pointer and all registers from env */
84 mov
120(%rax
),%rsp
/* Restore original stack */
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 */
107 pop
%rax
/* Fetch return value */