2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
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/i386/asm.h"
63 .globl AROS_CDEFNAME(setjmp)
64 _FUNCTION
(AROS_CDEFNAME
(setjmp
))
66 .set FirstArg, 4 /* Skip Return-Adress */
69 AROS_CDEFNAME
(setjmp
):
70 /* Fetch the address of the env-structure off the stack.
71 The address is stored in %eax which is not preserved
72 because it's contents are overwritten anyway by the
76 /* Save stack pointer and all registers into env */
77 movl
%ebx
,4(%eax
) /* %ebx */
78 movl
%ecx
,8(%eax
) /* %ecx */
79 movl
%edx
,12(%eax
) /* %edx */
80 movl
%esi
,16(%eax
) /* %esi */
81 movl
%edi
,20(%eax
) /* %edi */
82 movl
%ebp
,24(%eax
) /* %ebp */
83 movl
%esp
,28(%eax
) /* %esp */
87 movl retaddr+
4(%esp
), %ebx
/* Save return address (%esp has changed) */
92 xorl
%eax
,%eax
/* Return 0 */