- 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

@ -21,12 +21,12 @@
#define _tlods lodsw
#define _tstos stosw
#define _tsize $2
#define _tsize 2
#define _treg(_O_) _O_ ## x
#define _tdec(_O_) sub $2, _O_
#define _tinc(_O_) add $2, _O_
#define _tdec(_O_) sub _O_, 2
#define _tinc(_O_) add _O_, 2
#else
@ -45,7 +45,7 @@
#define _tlods lodsb
#define _tstos stosb
#define _tsize $1
#define _tsize 1
#define _treg(_O_) _O_ ## l

View file

@ -2,31 +2,34 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcscat
PUBLIC _tcscat
.code
_tcscat:
push %esi
push %edi
mov 0x0C(%esp), %edi
mov 0x10(%esp), %esi
push esi
push edi
mov edi, [esp + 12]
mov esi, [esp + 16]
xor %eax, %eax
mov $-1, %ecx
cld
xor eax, eax
mov ecx, -1
cld
repne _tscas
_tdec(%edi)
repne _tscas
_tdec(edi)
.L1:
_tlods
_tstos
test %_treg(a), %_treg(a)
jnz .L1
_tlods
_tstos
test _treg(a), _treg(a)
jnz .L1
mov 0x0C(%esp), %eax
pop %edi
pop %esi
ret
mov eax, [esp + 12]
pop edi
pop esi
ret
END
/* EOF */

View file

@ -2,29 +2,31 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcschr
PUBLIC _tcschr
.code
_tcschr:
push %esi
mov 0x8(%esp), %esi
mov 0xC(%esp), %edx
cld
push esi
mov esi, [esp + 8]
mov edx, [esp + 12]
cld
.L1:
_tlods
cmp %_treg(a), %_treg(d)
je .L2
test %_treg(a), %_treg(a)
jnz .L1
mov _tsize, %esi
_tlods
cmp _treg(d), _treg(a)
je .L2
test _treg(a), _treg(a)
jnz .L1
mov esi, _tsize
.L2:
mov %esi, %eax
_tdec(%eax)
mov eax, esi
_tdec(eax)
pop %esi
ret
pop esi
ret
END
/* EOF */

View file

@ -2,33 +2,36 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcscmp
PUBLIC _tcscmp
.code
_tcscmp:
push %esi
push %edi
mov 0x0C(%esp), %esi
mov 0x10(%esp), %edi
xor %eax, %eax
cld
push esi
push edi
mov esi, [esp + 12]
mov edi, [esp + 16]
xor eax, eax
cld
.L1:
_tlods
_tscas
jne .L2
test %eax, %eax
jne .L1
xor %eax, %eax
jmp .L3
_tlods
_tscas
jne .L2
test eax, eax
jne .L1
xor eax, eax
jmp .L3
.L2:
sbb %eax, %eax
or $1, %al
sbb eax, eax
or al, 1
.L3:
pop %edi
pop %esi
ret
pop edi
pop esi
ret
END
/* EOF */

View file

@ -2,26 +2,29 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcscpy
PUBLIC _tcscpy
.code
_tcscpy:
push %esi
push %edi
mov 0x0C(%esp), %edi
mov 0x10(%esp), %esi
cld
push esi
push edi
mov edi, [esp + 12]
mov esi, [esp + 16]
cld
.L1:
_tlods
_tstos
test %_treg(a), %_treg(a)
jnz .L1
_tlods
_tstos
test _treg(a), _treg(a)
jnz .L1
mov 0x0C(%esp), %eax
mov eax, [esp + 12]
pop %edi
pop %esi
ret
pop edi
pop esi
ret
END
/* EOF */

View file

@ -2,28 +2,31 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcslen
PUBLIC _tcslen
.code
_tcslen:
push %edi
mov 0x8(%esp), %edi
xor %eax, %eax
test %edi,%edi
jz _tcslen_end
push edi
mov edi, [esp + 8]
xor eax, eax
test edi, edi
jz _tcslen_end
mov $-1, %ecx
cld
mov ecx, -1
cld
repne _tscas
repne _tscas
not %ecx
dec %ecx
not ecx
dec ecx
mov %ecx, %eax
mov eax, ecx
_tcslen_end:
pop %edi
ret
pop edi
ret
END
/* EOF */

View file

@ -2,41 +2,44 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcsncat
PUBLIC _tcsncat
.code
_tcsncat:
push %esi
push %edi
mov 0x0C(%esp), %edi
mov 0x10(%esp), %esi
cld
push esi
push edi
mov edi, [esp + 12]
mov esi, [esp + 16]
cld
xor %eax, %eax
mov $-1, %ecx
repne _tscas
_tdec(%edi)
xor eax, eax
mov ecx, -1
repne _tscas
_tdec(edi)
mov 0x14(%esp),%ecx
mov ecx, [esp + 20]
.L1:
dec %ecx
js .L2
_tlods
_tstos
test %_treg(a), %_treg(a)
jne .L1
jmp .L3
dec ecx
js .L2
_tlods
_tstos
test _treg(a), _treg(a)
jne .L1
jmp .L3
.L2:
xor %eax, %eax
_tstos
xor eax, eax
_tstos
.L3:
mov 0x0C(%esp), %eax
pop %edi
pop %esi
mov eax, [esp + 12]
pop edi
pop esi
ret
ret
END
/* EOF */

View file

@ -2,39 +2,42 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcsncmp
PUBLIC _tcsncmp
.code
_tcsncmp:
push %esi
push %edi
mov 0x0C(%esp), %esi /* s1 */
mov 0x10(%esp), %edi /* s2 */
mov 0x14(%esp), %ecx /* n */
push esi
push edi
mov esi, [esp + 12] /* s1 */
mov edi, [esp + 16] /* s2 */
mov ecx, [esp + 20] /* n */
xor %eax,%eax
cld
xor eax, eax
cld
.L1:
dec %ecx
js .L2
_tlods
_tscas
jne .L3
test %eax, %eax
jne .L1
dec ecx
js .L2
_tlods
_tscas
jne .L3
test eax, eax
jne .L1
.L2:
xor %eax, %eax
jmp .L4
xor eax, eax
jmp .L4
.L3:
sbb %eax, %eax
or $1, %al
sbb eax, eax
or al, 1
.L4:
pop %edi
pop %esi
ret
pop edi
pop esi
ret
END
/* EOF */

View file

@ -2,33 +2,36 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcsncpy
PUBLIC _tcsncpy
.code
_tcsncpy:
push %esi
push %edi
mov 0x0C(%esp), %edi /* s1 */
mov 0x10(%esp), %esi /* s2 */
mov 0x14(%esp), %ecx /* n */
push esi
push edi
mov edi, [esp + 12] /* s1 */
mov esi, [esp + 16] /* s2 */
mov ecx, [esp + 20] /* n */
xor %eax, %eax
cld
xor eax, eax
cld
.L1:
dec %ecx
js .L2
_tlods
_tstos
test %_treg(a), %_treg(a)
jnz .L1
rep _tstos
dec ecx
js .L2
_tlods
_tstos
test _treg(a), _treg(a)
jnz .L1
rep _tstos
.L2:
mov 0x0C(%esp), %eax
mov eax, [esp + 12]
pop %edi
pop %esi
ret
pop edi
pop esi
ret
END
/* EOF */

View file

@ -2,29 +2,32 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcsnlen
PUBLIC _tcsnlen
.code
_tcsnlen:
push %edi
mov 0x8(%esp), %edi
mov 0xC(%esp), %ecx
xor %eax, %eax
test %ecx, %ecx
jz .L1
mov %ecx, %edx
push edi
mov edi, [esp + 8]
mov ecx, [esp + 12]
xor eax, eax
test ecx, ecx
jz .L1
mov edx, ecx
cld
cld
repne _tscas
repne _tscas
sete %al
sub %ecx, %edx
sub %eax, %edx
mov %edx, %eax
sete al
sub edx, ecx
sub edx, eax
mov eax, edx
.L1:
pop %edi
ret
pop edi
ret
END
/* EOF */

View file

@ -2,30 +2,33 @@
*/
#include "tchar.h"
#include <reactos/asm.h>
.globl _tcsrchr
PUBLIC _tcsrchr
.code
_tcsrchr:
push %esi
mov 0x8(%esp), %esi
mov 0xC(%esp), %edx
push esi
mov esi, [esp + 8]
mov edx, [esp + 12]
cld
mov _tsize, %ecx
cld
mov ecx, _tsize
.L1:
_tlods
cmp %_treg(a), %_treg(d)
jne .L2
mov %esi, %ecx
_tlods
cmp _treg(d), _treg(a)
jne .L2
mov ecx, esi
.L2:
test %_treg(a), %_treg(a)
jnz .L1
test _treg(a), _treg(a)
jnz .L1
mov %ecx, %eax
_tdec(%eax)
pop %esi
ret
mov eax, ecx
_tdec(eax)
pop esi
ret
END
/* EOF */