- Make all x86assembly ML compatible
- Remove memcpy, it was duplicated from memmove, copy the label instead
- Guard some code against compilation on msvc, as these functions are intrinsics on MSVC and cannot be implemented
- Fix some x64 assembly (don't modify stack below rsp)

svn path=/branches/cmake-bringup/; revision=49421
This commit is contained in:
Timo Kreuzer 2010-11-02 00:06:33 +00:00
parent 0d7a1c46a0
commit a3623f23de
49 changed files with 912 additions and 918 deletions

View file

@ -9,6 +9,9 @@
* complete implementation
*/
#include <reactos/asm.h>
#include <ndk/asm.h>
#define JB_BP 0
#define JB_BX 1
#define JB_DI 2
@ -20,6 +23,7 @@
#define JMPBUF 4
.code
/*
* int
* _setjmp(jmp_buf env);
@ -33,20 +37,20 @@
* 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
/*
@ -62,24 +66,22 @@ __setjmp:
* 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);
@ -94,18 +96,20 @@ __setjmp3:
* 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