2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id: setjmp.s 12741 2001-12-08 18:16:08Z chodorowski $
5 Desc: ANSI C function setjmp()
9 /******************************************************************************
14 int setjmp (jmp_buf env);
17 Save the current context so that you can return to it later.
20 env - The context/environment is saved here for later restoring
23 0 if it returns from setjmp() and 1 when it returns from longjmp().
34 ... this code is executed after setjmp() returns ...
36 // This is no good example on how to use this function
37 // You should not do that
45 ... this code is executed if you call longjmp(env) ...
57 ******************************************************************************/
59 #include "aros/x86_64/asm.h"
63 .globl AROS_CDEFNAME(setjmp)
64 _FUNCTION
(AROS_CDEFNAME
(setjmp
))
68 AROS_CDEFNAME
(setjmp
):
69 /* Save stack pointer and all registers into env */
70 mov
%rbx
,8(%rdi
) /* %ebx */
71 mov
%rcx
,16(%rdi
) /* %ecx */
72 mov
%rdx
,24(%rdi
) /* %edx */
73 mov
%rsi
,32(%rdi
) /* %esi */
74 mov
%rdi
,40(%rdi
) /* %edi */
75 mov
%rbp
,48(%rdi
) /* %ebp */
84 mov
%rsp
,120(%rdi
) /* %esp */
86 mov retaddr
(%rsp
),%rax
/* Save return address (%esp has changed) */
89 xor %rax
,%rax
/* Return 0 */