* complete implementation
*/
+#include <reactos/asm.h>
+#include <ndk/asm.h>
+
#define JB_BP 0
#define JB_BX 1
#define JB_DI 2
#define JMPBUF 4
+.code
/*
* int
* _setjmp(jmp_buf env);
* Notes:
* Sets up the jmp_buf
*/
-.globl __setjmp
+PUBLIC __setjmp
__setjmp:
- xorl %eax, %eax
- movl JMPBUF(%esp), %edx
+ xor eax, eax
+ mov edx, JMPBUF[esp]
/* Save registers. */
- movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */
- movl %ebx, (JB_BX*4)(%edx)
- movl %edi, (JB_DI*4)(%edx)
- movl %esi, (JB_SI*4)(%edx)
- leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
- movl %ecx, (JB_SP*4)(%edx)
- movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
- movl %ecx, (JB_IP*4)(%edx)
+ mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */
+ mov [edx + JB_BX*4], ebx
+ mov [edx + JB_DI*4], edi
+ mov [edx + JB_SI*4], esi
+ lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */
+ mov [edx + JB_SP*4], ecx
+ mov ecx, PCOFF[esp] /* Save PC we are returning to now. */
+ mov [edx + JB_IP*4], ecx
ret
/*
* Notes:
* Sets up the jmp_buf
*/
-.globl __setjmp3
+PUBLIC __setjmp3
__setjmp3:
- xorl %eax, %eax
- movl JMPBUF(%esp), %edx
+ xor eax, eax
+ mov edx, JMPBUF[esp]
/* Save registers. */
- movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */
- movl %ebx, (JB_BX*4)(%edx)
- movl %edi, (JB_DI*4)(%edx)
- movl %esi, (JB_SI*4)(%edx)
- leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
- movl %ecx, (JB_SP*4)(%edx)
- movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
- movl %ecx, (JB_IP*4)(%edx)
+ mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */
+ mov [edx + JB_BX*4], ebx
+ mov [edx + JB_DI*4], edi
+ mov [edx + JB_SI*4], esi
+ lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */
+ mov [edx + JB_SP*4], ecx
+ mov ecx, PCOFF[esp] /* Save PC we are returning to now. */
+ mov [edx + JB_IP*4], ecx
ret
-#define VAL 8
-
/*
* void
* longjmp(jmp_buf env, int value);
* Notes:
* Non-local goto
*/
-.globl _longjmp
+PUBLIC _longjmp
_longjmp:
- movl JMPBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
+ mov ecx, JMPBUF[esp] /* User's jmp_buf in %ecx. */
- movl VAL(%esp), %eax /* Second argument is return value. */
+ mov eax, [esp + 8] /* Second argument is return value. */
/* Save the return address now. */
- movl (JB_IP*4)(%ecx), %edx
+ mov edx, [edx + JB_IP*4]
/* Restore registers. */
- movl (JB_BP*4)(%ecx), %ebp
- movl (JB_BX*4)(%ecx), %ebx
- movl (JB_DI*4)(%ecx), %edi
- movl (JB_SI*4)(%ecx), %esi
- movl (JB_SP*4)(%ecx), %esp
+ mov ebp, [edx + JB_BP*4]
+ mov ebx, [edx + JB_BX*4]
+ mov edi, [edx + JB_DI*4]
+ mov esi, [edx + JB_SI*4]
+ mov esp, [edx + JB_SP*4]
/* Jump to saved PC. */
- jmp *%edx
+ jmp dword ptr [edx]
+
+END