2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * PURPOSE: Implementation of _setjmp/longjmp
5 * FILE: lib/sdk/crt/setjmp/i386/setjmp.s
6 * PROGRAMMER: Ge van Geldorp (ge@gse.nl)
7 * NOTES: Implementation is not complete, see Wine source for a more
8 * complete implementation
27 * _setjmp(jmp_buf env);
30 * [ESP+04h] - jmp_buf env
44 mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */
45 mov [edx + JB_BX*4], ebx
46 mov [edx + JB_DI*4], edi
47 mov [edx + JB_SI*4], esi
48 lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */
49 mov [edx + JB_SP*4], ecx
50 mov ecx, PCOFF[esp] /* Save PC we are returning to now. */
51 mov [edx + JB_IP*4], ecx
56 * _setjmp3(jmp_buf env, int nb_args, ...);
59 * [ESP+04h] - jmp_buf env
73 mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */
74 mov [edx + JB_BX*4], ebx
75 mov [edx + JB_DI*4], edi
76 mov [edx + JB_SI*4], esi
77 lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */
78 mov [edx + JB_SP*4], ecx
79 mov ecx, PCOFF[esp] /* Save PC we are returning to now. */
80 mov [edx + JB_IP*4], ecx
85 * longjmp(jmp_buf env, int value);
88 * [ESP+04h] - jmp_buf setup by _setjmp
89 * [ESP+08h] - int value to return
99 mov ecx, JMPBUF[esp] /* User's jmp_buf in %ecx. */
101 mov eax, [esp + 8] /* Second argument is return value. */
102 /* Save the return address now. */
103 mov edx, [ecx + JB_IP*4]
104 /* Restore registers. */
105 mov ebp, [ecx + JB_BP*4]
106 mov ebx, [ecx + JB_BX*4]
107 mov edi, [ecx + JB_DI*4]
108 mov esi, [ecx + JB_SI*4]
109 mov esp, [ecx + JB_SP*4]
110 /* Jump to saved PC. */