Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / i386-all / clib / longjmp.s
blobbd8b4bdc41652bd6cd9b44f10bd881ece105f99b
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
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/i386/asm.h"
64 .text
65 _ALIGNMENT
66 .globl AROS_CDEFNAME(longjmp)
67 _FUNCTION(AROS_CDEFNAME(longjmp))
69 .set FirstArg, 4 /* Skip Return-Adress */
70 .set env, FirstArg
71 .set val, env+4
72 .set retaddr, 0
74 AROS_CDEFNAME(longjmp):
75 /* Fetch the address of the env-structure off the stack.
76 The address is stored in %eax which is not preserved
77 because it's contents are overwritten anyway by the
78 return code */
79 movl env(%esp),%eax
81 /* Read return value into %ebx and make sure it's not 0 */
82 movl val(%esp),%ebx
83 cmpl $0,%ebx
84 jne 1f
86 movl $1,%ebx
88 /* Restore stack pointer and all registers from env */
89 movl 28(%eax),%esp /* Restore original stack */
91 movl 0(%eax),%ecx
92 movl %ecx,retaddr(%esp) /* Restore return address */
94 pushl %ebx /* Save return value on new stack */
96 /* Restore all registers */
97 movl 4(%eax),%ebx /* %ebx */
98 movl 8(%eax),%ecx /* %ecx */
99 movl 12(%eax),%edx /* %edx */
100 movl 16(%eax),%esi /* %esi */
101 movl 20(%eax),%edi /* %edi */
102 movl 24(%eax),%ebp /* %ebp */
104 popl %eax /* Fetch return value */