1 /* $Id: setjmp.s,v 1.2 2004/11/27 00:46:24 chorns Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * PURPOSE: Implementation of _setjmp/longjmp
6 * FILE: lib/msvcrt/i386/setjmp.s
7 * PROGRAMMER: Ge van Geldorp (ge@gse.nl)
8 * NOTES: Implementation is not complete, see Wine source for a more
9 * complete implementation
25 * _setjmp(jmp_buf env);
28 * [ESP+04h] - jmp_buf env
39 movl JMPBUF(%esp), %edx
42 movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */
43 movl %ebx, (JB_BX*4)(%edx)
44 movl %edi, (JB_DI*4)(%edx)
45 movl %esi, (JB_SI*4)(%edx)
46 leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
47 movl %ecx, (JB_SP*4)(%edx)
48 movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
49 movl %ecx, (JB_IP*4)(%edx)
54 * _setjmp3(jmp_buf env, int nb_args, ...);
57 * [ESP+04h] - jmp_buf env
68 movl JMPBUF(%esp), %edx
71 movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */
72 movl %ebx, (JB_BX*4)(%edx)
73 movl %edi, (JB_DI*4)(%edx)
74 movl %esi, (JB_SI*4)(%edx)
75 leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
76 movl %ecx, (JB_SP*4)(%edx)
77 movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
78 movl %ecx, (JB_IP*4)(%edx)
85 * longjmp(jmp_buf env, int value);
88 * [ESP+04h] - jmp_buf setup by _setjmp
89 * [ESP+08h] - int value to return
99 movl JMPBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
101 movl VAL(%esp), %eax /* Second argument is return value. */
102 /* Save the return address now. */
103 movl (JB_IP*4)(%ecx), %edx
104 /* Restore registers. */
105 movl (JB_BP*4)(%ecx), %ebp
106 movl (JB_BX*4)(%ecx), %ebx
107 movl (JB_DI*4)(%ecx), %edi
108 movl (JB_SI*4)(%ecx), %esi
109 movl (JB_SP*4)(%ecx), %esp
110 /* Jump to saved PC. */