2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
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 ******************************************************************************/
61 #define FirstArg 4 /* Skip Return-Address */
67 .globl AROS_CDEFNAME(setjmp)
68 .type AROS_CDEFNAME(setjmp),@function
69 AROS_CDEFNAME
(setjmp
):
71 move.
l env
(%sp
),%a0
/* save area pointer */
72 move.
l retaddr
(%sp
),(%a0
)+ /* save old PC */
73 lea.
l env
(%sp
),%a1
/* adjust saved SP since we won't rts */
74 move.
l %a1
,(%a0
)+ /* save old SP */
75 movem.
l %d2-
%d7
/%a2-
%a6
,(%a0
) /* save remaining non-scratch regs */
76 clr.
l %d0
/* return 0 */
79 move.
l env
(%sp
),%a0
/* get address of jmp_buf */
80 move.
l (%sp
),(%a0
)+ /* store return address */
81 movem.
l %d2-
%d7
/%a2-
%a6
/%sp
,(%a0
) /* store all registers except scratch */
82 moveq.
l #0,%d0 /* return 0 */
87 The jmp_buf is filled as follows (d0/d1/a0/a1 are not saved):
89 _jmp_buf offset contents