mirror of
https://github.com/reactos/reactos.git
synced 2025-08-01 18:53:05 +00:00
- Write new, optimized, small, working and clean functions (fixes booting, last few commits broke it for me):
- RtlCompareMemory - RtlCompareMemoryUlong - RtlFillMemory - RtlFillMemoryUlong - RtlFillMemoryUlongUlong - RtlMoveMemory - RtlZeroMemory - RtlPrefetchMemoryNonTemporal - RtlUshortByteSwap - RtlUlongByteSwap - RtlUlonglongByteSwap svn path=/trunk/; revision=23830
This commit is contained in:
parent
5b8d955fb7
commit
e4e58dde50
14 changed files with 367 additions and 587 deletions
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: comparememory_asm.S
|
||||
* PURPOSE: Memory functions
|
||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||
* Alex Ionescu (alex@relsoft.net)
|
||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||
*/
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* GLOBALS ****************************************************************/
|
||||
|
||||
.globl _RtlCompareMemory@12 // [4] (no bug)
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
_RtlCompareMemory@12:
|
||||
xor eax,eax // count = 0
|
||||
mov ecx, dword [esp + 12 ] // ecx = Length
|
||||
cmp ecx,0 // if (Length==0) goto .zero
|
||||
je 3f
|
||||
|
||||
push edi// register that does not to be save eax,ecx,edx to
|
||||
push ebx// the stack for protetion
|
||||
|
||||
mov edi, dword [esp + (4 + 8)] // edi = Destination
|
||||
mov edx, dword [esp + (8 + 8)] // edx = Source
|
||||
|
||||
1:
|
||||
mov bl,byte [edi + eax ] // if (src[count]!=des[count]) goto .pop_zero
|
||||
cmp byte [edx + eax ],bl
|
||||
jne 2f
|
||||
|
||||
inc eax // count = count + 1
|
||||
dec ecx // Length = Length - 1
|
||||
jnz 1b // if (Length!=0) goto .loop_1byte
|
||||
|
||||
2:
|
||||
pop ebx // restore regiester
|
||||
pop edi
|
||||
3:
|
||||
ret 12 // return count
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: comparememory_ulong_asm.S
|
||||
* PURPOSE: Memory functions
|
||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||
* Alex Ionescu (alex@relsoft.net)
|
||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||
*/
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* GLOBALS ****************************************************************/
|
||||
|
||||
.globl _RtlCompareMemoryUlong@12 // [5] (no bug)
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
_RtlCompareMemoryUlong@12:
|
||||
xor eax,eax
|
||||
mov ecx, dword [esp + 8 ] // ecx = Length
|
||||
shr ecx,2 // Length / sizeof(ULONG)
|
||||
jz 1f // if (Length==0) goto .zero
|
||||
|
||||
push edi// register that does not to be save eax,ecx,edx to
|
||||
push ebx// the stack for protetion
|
||||
|
||||
mov edi, dword [esp + (4 + 8)] // edx = Destination
|
||||
mov eax, dword [esp + (12 + 8)] // ebx = value
|
||||
mov ebx,ecx
|
||||
cld
|
||||
repe scasd
|
||||
|
||||
inc ecx
|
||||
mov eax,ebx
|
||||
|
||||
sub eax,ecx
|
||||
shl eax,2
|
||||
|
||||
pop ebx
|
||||
pop edi
|
||||
|
||||
1:
|
||||
ret 12
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: fillmemory_asm.S
|
||||
* PURPOSE: Memory functions
|
||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||
* Alex Ionescu (alex@relsoft.net)
|
||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||
*/
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* GLOBALS ****************************************************************/
|
||||
|
||||
.globl _RtlFillMemory@12 //[4] (no bug)
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
_RtlFillMemory@12:
|
||||
mov ecx,dword [esp + 8 ] // ecx = Length
|
||||
cmp ecx,0// if (Length==0) goto .zero
|
||||
je 2f
|
||||
|
||||
mov edx, dword [esp + 4] // edx = Destination
|
||||
mov eax, dword [esp + 12] // eax = fill
|
||||
1:
|
||||
mov byte [edx + ecx -1],al // src[Length - 1] = fill
|
||||
dec ecx // Length = Length - 1
|
||||
jnz 1b // if (Length!=0) goto .loop
|
||||
2:
|
||||
ret 12 // return
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: fillmemory_ulong_asm.S
|
||||
* PURPOSE: Memory functions
|
||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||
* Alex Ionescu (alex@relsoft.net)
|
||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||
*/
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* GLOBALS ****************************************************************/
|
||||
|
||||
.globl _RtlFillMemoryUlong@12 // (no bug) (max optimze code)
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
_RtlFillMemoryUlong@12:
|
||||
mov ecx, dword [esp + 8 ] // Length
|
||||
shr ecx,2// Length = Length / sizeof(ULONG)
|
||||
jz 1f // if (Length==0) goto .zero
|
||||
|
||||
push edi
|
||||
mov edi, dword [esp + (4 + 4)] // Destination
|
||||
mov eax, dword [esp + (12 + 4)] // Fill
|
||||
cld
|
||||
rep stosd// while (Length>0) {Destination[Length-1]=Fill// Length = Length - 1}
|
||||
pop edi
|
||||
1:
|
||||
ret 12
|
|
@ -1,75 +0,0 @@
|
|||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/rtl/mem.c
|
||||
* PURPOSE: Memory functions
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <rtl.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#undef RtlUlonglongByteSwap
|
||||
#undef RtlUlongByteSwap
|
||||
#undef RtlUshortByteSwap
|
||||
|
||||
USHORT UshortByteSwap (IN USHORT Source);
|
||||
ULONG UlongByteSwap (IN ULONG Source);
|
||||
ULONGLONG UlonglongByteSwap (IN ULONGLONG Source);
|
||||
|
||||
/*************************************************************************
|
||||
* RtlUshortByteSwap
|
||||
*
|
||||
* Swap the bytes of an unsigned short value.
|
||||
*
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
USHORT FASTCALL
|
||||
RtlUshortByteSwap (IN USHORT Source)
|
||||
{
|
||||
return UshortByteSwap (Source);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* RtlUlongByteSwap [NTDLL.@]
|
||||
*
|
||||
* Swap the bytes of an unsigned int value.
|
||||
*
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
ULONG
|
||||
FASTCALL
|
||||
RtlUlongByteSwap(
|
||||
IN ULONG Source
|
||||
)
|
||||
{
|
||||
return UlongByteSwap(Source);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* RtlUlonglongByteSwap
|
||||
*
|
||||
* Swap the bytes of an unsigned long long value.
|
||||
*
|
||||
* PARAMS
|
||||
* i [I] Value to swap bytes of
|
||||
*
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
ULONGLONG FASTCALL
|
||||
RtlUlonglongByteSwap (IN ULONGLONG Source)
|
||||
{
|
||||
return UlonglongByteSwap(Source);
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: prefetchmemory_asm.S
|
||||
* PURPOSE: Memory functions
|
||||
* PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
|
||||
* Alex Ionescu (alex@relsoft.net)
|
||||
* Magnus Olsen (magnusolsen@greatlord.com)
|
||||
*/
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* GLOBALS ****************************************************************/
|
||||
|
||||
.globl @RtlPrefetchMemoryNonTemporal@8
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
@RtlPrefetchMemoryNonTemporal@8:
|
||||
ret /* Overwritten by ntoskrnl/ke/i386/kernel.c if SSE is supported (see Ki386SetProcessorFeatures() ) */
|
||||
|
||||
mov eax, [_Ke386CacheAlignment] // Get cache line size
|
||||
|
||||
// This is fastcall, so ecx = address, edx = size
|
||||
fetch_next_line:
|
||||
prefetchnta byte ptr [ecx] // prefechnta(address)
|
||||
add ecx, eax // address = address + cache_line_size
|
||||
sub edx, eax // count = count - cache_line_size
|
||||
ja fetch_next_line // goto fetch_next_line
|
||||
ret
|
312
reactos/lib/rtl/i386/rtlmem.s
Normal file
312
reactos/lib/rtl/i386/rtlmem.s
Normal file
|
@ -0,0 +1,312 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS Run-Time Library
|
||||
* PURPOSE: Memory functions
|
||||
* FILE: lib/rtl/i386/rtlswap.S
|
||||
* PROGRAMER: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
.globl _RtlCompareMemory@12
|
||||
.globl _RtlCompareMemoryUlong@12
|
||||
.globl _RtlFillMemory@12
|
||||
.globl _RtlFillMemoryUlong@12
|
||||
.globl _RtlMoveMemory@12
|
||||
.globl _RtlZeroMemory@8
|
||||
.globl @RtlPrefetchMemoryNonTemporal@8
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
.func RtlCompareMemory@12
|
||||
_RtlCompareMemory@12:
|
||||
|
||||
/* Save volatiles */
|
||||
push esi
|
||||
push edi
|
||||
|
||||
/* Clear direction flag and load pointers and size in ULONGs */
|
||||
cld
|
||||
mov esi, [esp+12]
|
||||
mov edi, [esp+16]
|
||||
mov ecx, [esp+20]
|
||||
shr ecx, 2
|
||||
jz NoUlongs
|
||||
|
||||
/* Compare the ULONGs */
|
||||
repe cmpsd
|
||||
jnz NotEqual
|
||||
|
||||
NoUlongs:
|
||||
|
||||
/* Compare what's left */
|
||||
mov ecx, [esp+20]
|
||||
and ecx, 3
|
||||
jz NoneLeft
|
||||
repe cmpsb
|
||||
jnz NotEqual2
|
||||
|
||||
NoneLeft:
|
||||
|
||||
/* We're done, return full count */
|
||||
mov eax, [esp+20]
|
||||
pop edi
|
||||
pop esi
|
||||
ret 12
|
||||
|
||||
NotEqual:
|
||||
/* Compare the last ULONG */
|
||||
sub esi, 4
|
||||
sub edi, 4
|
||||
mov ecx, 5
|
||||
repe cmpsb
|
||||
|
||||
NotEqual2:
|
||||
|
||||
/* Remember how many mathced */
|
||||
dec esi
|
||||
sub esi, [esp+20]
|
||||
|
||||
/* Return count */
|
||||
mov eax, esi
|
||||
pop edi
|
||||
pop esi
|
||||
ret 12
|
||||
.endfunc
|
||||
|
||||
.func RtlCompareMemoryUlong@12
|
||||
_RtlCompareMemoryUlong@12:
|
||||
|
||||
/* Get pointers and size in ULONGs */
|
||||
push edi
|
||||
mov edi, [esp+8]
|
||||
mov ecx, [esp+12]
|
||||
mov eax, [esp+16]
|
||||
shr ecx, 2
|
||||
|
||||
/* Do the compare and check result */
|
||||
repe scasd
|
||||
jz Done
|
||||
sub esi, 4
|
||||
|
||||
/* Return count */
|
||||
Done:
|
||||
sub edi, [esp+8]
|
||||
mov eax, edi
|
||||
pop edi
|
||||
ret 12
|
||||
.endfunc
|
||||
|
||||
.func RtlFillMemory@12
|
||||
_RtlFillMemory@12:
|
||||
|
||||
/* Get pointers and size */
|
||||
push edi
|
||||
mov edi, [esp+8]
|
||||
mov ecx, [esp+12]
|
||||
|
||||
/* Get pattern */
|
||||
mov al, [esp+16]
|
||||
mov ah, al
|
||||
shr eax, 16
|
||||
mov al, [esp+16]
|
||||
mov ah, al
|
||||
|
||||
/* Clear direction flag and set ULONG size and UCHAR remainder */
|
||||
cld
|
||||
mov edx, ecx
|
||||
and edx, 3
|
||||
shr ecx, 2
|
||||
|
||||
/* Do the fill */
|
||||
rep stosd
|
||||
or ecx, ecx
|
||||
jnz ByteFill
|
||||
|
||||
/* Return */
|
||||
pop edi
|
||||
ret 12
|
||||
|
||||
ByteFill:
|
||||
/* Fill what's left */
|
||||
rep stosb
|
||||
pop edi
|
||||
ret 12
|
||||
.endfunc
|
||||
|
||||
.func RtlFillMemoryUlong@12
|
||||
_RtlFillMemoryUlong@12:
|
||||
|
||||
/* Get pointer, size and pattern */
|
||||
push edi
|
||||
mov edi, [esp+8]
|
||||
mov ecx, [esp+12]
|
||||
mov eax, [esp+16]
|
||||
shr ecx, 2
|
||||
|
||||
/* Do the fill and return */
|
||||
rep stosd
|
||||
pop edi
|
||||
ret 12
|
||||
.endfunc
|
||||
|
||||
.func RtlFillMemoryUlonglong@16
|
||||
_RtlFillMemoryUlonglong@16:
|
||||
|
||||
/* Save volatiles */
|
||||
push edi
|
||||
push esi
|
||||
|
||||
/* Get pointer, size and pattern */
|
||||
mov ecx, [esp+16]
|
||||
mov esi, [esp+12]
|
||||
mov eax, [esp+20]
|
||||
shr ecx, 2
|
||||
sub ecx, 2
|
||||
|
||||
/* Save the first part */
|
||||
mov [esi], eax
|
||||
|
||||
/* Read second part */
|
||||
mov eax, [esp+24]
|
||||
lea edi, [esi+8]
|
||||
mov [esi+4], eax
|
||||
|
||||
/* Do the fill and return */
|
||||
rep movsd
|
||||
pop esi
|
||||
pop edi
|
||||
ret 16
|
||||
.endfunc
|
||||
|
||||
.func RtlZeroMemory@8
|
||||
_RtlZeroMemory@8:
|
||||
|
||||
/* Get pointers and size */
|
||||
push edi
|
||||
mov edi, [esp+8]
|
||||
mov ecx, [esp+12]
|
||||
|
||||
/* Get pattern */
|
||||
xor eax, eax
|
||||
|
||||
/* Clear direction flag and set ULONG size and UCHAR remainder */
|
||||
cld
|
||||
mov edx, ecx
|
||||
and edx, 3
|
||||
shr ecx, 2
|
||||
|
||||
/* Do the fill */
|
||||
rep stosd
|
||||
or ecx, ecx
|
||||
jnz ByteZero
|
||||
|
||||
/* Return */
|
||||
pop edi
|
||||
ret 8
|
||||
|
||||
ByteZero:
|
||||
/* Fill what's left */
|
||||
rep stosb
|
||||
pop edi
|
||||
ret 8
|
||||
.endfunc
|
||||
|
||||
.func RtlMoveMemory@12
|
||||
_RtlMoveMemory@12:
|
||||
|
||||
/* Save volatiles */
|
||||
push esi
|
||||
push edi
|
||||
|
||||
/* Get pointers and size */
|
||||
mov esi, [esp+16]
|
||||
mov edi, [esp+12]
|
||||
mov ecx, [esp+20]
|
||||
cld
|
||||
|
||||
/* Check for overlap */
|
||||
cmp esi, edi
|
||||
jbe Overlap
|
||||
|
||||
/* Set ULONG size and UCHAR remainder */
|
||||
DoMove:
|
||||
mov edx, ecx
|
||||
and edx, 3
|
||||
shr ecx, 2
|
||||
|
||||
/* Do the move */
|
||||
rep movsd
|
||||
or ecx, ecx
|
||||
jnz ByteMove
|
||||
|
||||
/* Return */
|
||||
pop edi
|
||||
pop esi
|
||||
ret 12
|
||||
|
||||
ByteMove:
|
||||
/* Move what's left */
|
||||
rep stosb
|
||||
|
||||
DoneMove:
|
||||
pop edi
|
||||
pop esi
|
||||
ret 12
|
||||
|
||||
Overlap:
|
||||
/* Avoid full overlap */
|
||||
jz DoneMove
|
||||
|
||||
/* Remove overlap */
|
||||
mov eax, edi
|
||||
sub eax, esi
|
||||
cmp ecx, eax
|
||||
jbe DoMove
|
||||
|
||||
/* Set direction flag for backward move */
|
||||
std
|
||||
|
||||
/* Can only move some bytes, calculate how many */
|
||||
add esi, ecx
|
||||
add edi, ecx
|
||||
dec esi
|
||||
dec edi
|
||||
|
||||
/* Do the move, reset flag and return */
|
||||
rep movsb
|
||||
cld
|
||||
jmp DoneMove
|
||||
.endfunc
|
||||
|
||||
.func @RtlPrefetchMemoryNonTemporal@8, @RtlPrefetchMemoryNonTemporal@8
|
||||
@RtlPrefetchMemoryNonTemporal@8:
|
||||
|
||||
/*
|
||||
* Overwritten by ntoskrnl/ke/i386/kernel.c if SSE is supported
|
||||
* (see Ki386SetProcessorFeatures())
|
||||
*/
|
||||
ret
|
||||
|
||||
/* Get granularity */
|
||||
mov eax, [_Ke386CacheAlignment]
|
||||
|
||||
FetchLine:
|
||||
|
||||
/* Prefetch this line */
|
||||
prefetchnta byte ptr [ecx]
|
||||
|
||||
/* Update address and count */
|
||||
add ecx, eax
|
||||
sub edx, eax
|
||||
|
||||
/* Keep looping for the next line, or return if done */
|
||||
ja FetchLine
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
/* FIXME: HACK */
|
||||
_Ke386CacheAlignment:
|
||||
.long 0x40
|
53
reactos/lib/rtl/i386/rtlswap.S
Normal file
53
reactos/lib/rtl/i386/rtlswap.S
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS Run-Time Library
|
||||
* PURPOSE: Byte swap functions
|
||||
* FILE: lib/rtl/i386/rtlswap.S
|
||||
* PROGRAMER: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl @RtlUshortByteSwap@4
|
||||
.globl @RtlUlongByteSwap@4
|
||||
.globl @RtlUlonglongByteSwap@8
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
.func @RtlUshortByteSwap@4, @RtlUshortByteSwap@4
|
||||
@RtlUshortByteSwap@4:
|
||||
|
||||
/* Swap high and low bits */
|
||||
mov ah, cl
|
||||
mov al, ch
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func @RtlUlongByteSwap@4, @RtlUlongByteSwap@4
|
||||
@RtlUlongByteSwap@4:
|
||||
|
||||
/* Swap high and low bits */
|
||||
mov eax, ecx
|
||||
bswap eax
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func @RtlUlonglongByteSwap@8, @RtlUlonglongByteSwap@8
|
||||
@RtlUlonglongByteSwap@8:
|
||||
|
||||
/* Get 64-bit integer */
|
||||
mov edx, [esp+8]
|
||||
mov eax, [esp+4]
|
||||
|
||||
/* Swap it */
|
||||
bswap edx
|
||||
bswap eax
|
||||
|
||||
/* Return it */
|
||||
mov ecx, eax
|
||||
mov eax, edx
|
||||
mov edx, ecx
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Run-Time Library
|
||||
* FILE: lib/rtl/i386/RtlUlongByteSwap.S
|
||||
* PROGRAMER: Magnus Olsen (magnus@greatlord.com)
|
||||
*/
|
||||
|
||||
.globl _UlongByteSwap
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
_UlongByteSwap:
|
||||
push ebp // save base
|
||||
mov ebp,esp // move stack to base
|
||||
mov eax,[ebp+8] // load the ULONG
|
||||
bswap eax // swap the ULONG
|
||||
pop ebp // restore the base
|
||||
ret
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Run-Time Library
|
||||
* FILE: lib/rtl/i386/RtlUlonglongByteSwap.S
|
||||
* PROGRAMER: Magnus Olsen (magnus@greatlord.com)
|
||||
*/
|
||||
|
||||
.globl _UlonglongByteSwap
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
_UlonglongByteSwap:
|
||||
push ebp // save base
|
||||
mov ebp,esp // move stack to base
|
||||
mov edx,[ebp+8] // load the higher part of ULONGLONG
|
||||
mov eax,[ebp+12] // load the lower part of ULONGLONG
|
||||
bswap edx // swap the higher part
|
||||
bswap eax // swap the lower part
|
||||
pop ebp // restore the base
|
||||
ret
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Run-Time Library
|
||||
* FILE: lib/rtl/i386/RtlUlongByteSwap.S
|
||||
* PROGRAMER: Magnus Olsen (magnus@greatlord.com)
|
||||
*/
|
||||
|
||||
.globl _UshortByteSwap
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
_UshortByteSwap:
|
||||
push ebp // save base
|
||||
mov ebp,esp // move stack to base
|
||||
mov eax,[ebp+8] // load the USHORT
|
||||
bswap eax // swap the USHORT, xchg is slow so we use bswap with rol
|
||||
rol eax,16 // make it USHORT
|
||||
pop ebp // restore the base
|
||||
ret
|
|
@ -1,173 +0,0 @@
|
|||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/rtl/mem.c
|
||||
* PURPOSE: Memory functions
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <rtl.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* RtlCompareMemory [NTDLL.@]
|
||||
*
|
||||
* Compare one block of memory with another
|
||||
*
|
||||
* PARAMS
|
||||
* Source1 [I] Source block
|
||||
* Source2 [I] Block to compare to Source1
|
||||
* Length [I] Number of bytes to fill
|
||||
*
|
||||
* RETURNS
|
||||
* The length of the first byte at which Source1 and Source2 differ, or Length
|
||||
* if they are the same.
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
SIZE_T NTAPI
|
||||
RtlCompareMemory(IN const VOID *Source1,
|
||||
IN const VOID *Source2,
|
||||
IN SIZE_T Length)
|
||||
{
|
||||
SIZE_T i;
|
||||
for(i=0; (i<Length) && (((PUCHAR)Source1)[i]==((PUCHAR)Source2)[i]); i++)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlCompareMemoryUlong (
|
||||
PVOID Source,
|
||||
ULONG Length,
|
||||
ULONG Value
|
||||
)
|
||||
/*
|
||||
* FUNCTION: Compares a block of ULONGs with an ULONG and returns the number of equal bytes
|
||||
* ARGUMENTS:
|
||||
* Source = Block to compare
|
||||
* Length = Number of bytes to compare
|
||||
* Value = Value to compare
|
||||
* RETURNS: Number of equal bytes
|
||||
*/
|
||||
{
|
||||
PULONG ptr = (PULONG)Source;
|
||||
ULONG len = Length / sizeof(ULONG);
|
||||
ULONG i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (*ptr != Value)
|
||||
break;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
return (ULONG)((PCHAR)ptr - (PCHAR)Source);
|
||||
}
|
||||
|
||||
|
||||
#undef RtlFillMemory
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
NTAPI
|
||||
RtlFillMemory (
|
||||
PVOID Destination,
|
||||
ULONG Length,
|
||||
UCHAR Fill
|
||||
)
|
||||
{
|
||||
memset(Destination, Fill, Length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
NTAPI
|
||||
RtlFillMemoryUlong (
|
||||
PVOID Destination,
|
||||
ULONG Length,
|
||||
ULONG Fill
|
||||
)
|
||||
{
|
||||
PULONG Dest = Destination;
|
||||
ULONG Count = Length / sizeof(ULONG);
|
||||
|
||||
while (Count > 0)
|
||||
{
|
||||
*Dest = Fill;
|
||||
Dest++;
|
||||
Count--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#undef RtlMoveMemory
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
NTAPI
|
||||
RtlMoveMemory (
|
||||
PVOID Destination,
|
||||
CONST VOID * Source,
|
||||
ULONG Length
|
||||
)
|
||||
{
|
||||
memmove (
|
||||
Destination,
|
||||
Source,
|
||||
Length
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
FASTCALL
|
||||
RtlPrefetchMemoryNonTemporal(
|
||||
IN PVOID Source,
|
||||
IN SIZE_T Length
|
||||
)
|
||||
{
|
||||
/* By nature of prefetch, this is non-portable. */
|
||||
(void)Source;
|
||||
(void)Length;
|
||||
}
|
||||
|
||||
|
||||
#undef RtlZeroMemory
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
NTAPI
|
||||
RtlZeroMemory (
|
||||
PVOID Destination,
|
||||
ULONG Length
|
||||
)
|
||||
{
|
||||
RtlFillMemory (
|
||||
Destination,
|
||||
Length,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,77 +0,0 @@
|
|||
/* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/rtl/mem.c
|
||||
* PURPOSE: Memory functions
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <rtl.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#undef RtlUlonglongByteSwap
|
||||
#undef RtlUlongByteSwap
|
||||
#undef RtlUshortByteSwap
|
||||
|
||||
/*************************************************************************
|
||||
* RtlUshortByteSwap
|
||||
*
|
||||
* Swap the bytes of an unsigned short value.
|
||||
*
|
||||
* NOTES
|
||||
* Based on the inline versions in Wine winternl.h
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
USHORT FASTCALL
|
||||
RtlUshortByteSwap (IN USHORT Source)
|
||||
{
|
||||
return (Source >> 8) | (Source << 8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* RtlUlongByteSwap [NTDLL.@]
|
||||
*
|
||||
* Swap the bytes of an unsigned int value.
|
||||
*
|
||||
* NOTES
|
||||
* Based on the inline versions in Wine winternl.h
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
ULONG
|
||||
FASTCALL
|
||||
RtlUlongByteSwap(
|
||||
IN ULONG Source
|
||||
)
|
||||
{
|
||||
return ((ULONG)RtlUshortByteSwap((USHORT)Source) << 16) | RtlUshortByteSwap((USHORT)(Source >> 16));
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* RtlUlonglongByteSwap
|
||||
*
|
||||
* Swap the bytes of an unsigned long long value.
|
||||
*
|
||||
* PARAMS
|
||||
* i [I] Value to swap bytes of
|
||||
*
|
||||
* RETURNS
|
||||
* The value with its bytes swapped.
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
ULONGLONG FASTCALL
|
||||
RtlUlonglongByteSwap (IN ULONGLONG Source)
|
||||
{
|
||||
return ((ULONGLONG) RtlUlongByteSwap (Source) << 32) | RtlUlongByteSwap (Source>>32);
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
|
@ -22,37 +22,24 @@
|
|||
<file>aullshr_asm.s</file>
|
||||
<file>ceil_asm.s</file>
|
||||
<file>chkstk_asm.s</file>
|
||||
<file>comparememory_asm.s</file>
|
||||
<file>comparememory_ulong_asm.s</file>
|
||||
<file>cos_asm.s</file>
|
||||
<file>debug_asm.S</file>
|
||||
<file>except_asm.s</file>
|
||||
<file>exception.c</file>
|
||||
<file>fabs_asm.s</file>
|
||||
<file>fillmemory_asm.s</file>
|
||||
<file>fillmemory_ulong_asm.s</file>
|
||||
<file>floor_asm.s</file>
|
||||
<file>ftol_asm.s</file>
|
||||
<file>log_asm.s</file>
|
||||
<file>random_asm.S</file>
|
||||
<file>memgeni386.c</file>
|
||||
<file>rtlushortbyteswap.s</file>
|
||||
<file>rtlulongbyteswap.s</file>
|
||||
<file>rtlulonglongbyteswap.s</file>
|
||||
<file>rtlswap.S</file>
|
||||
<file>rtlmem.S</file>
|
||||
<file>pow_asm.s</file>
|
||||
<file>prefetchmemory_asm.s</file>
|
||||
<file>res_asm.s</file>
|
||||
<file>sin_asm.s</file>
|
||||
<file>sqrt_asm.s</file>
|
||||
<file>tan_asm.s</file>
|
||||
<file>zeromemory_asm.s</file>
|
||||
</directory>
|
||||
</if>
|
||||
|
||||
<ifnot property="ARCH" value="i386">
|
||||
<file>memgen.c</file>
|
||||
</ifnot>
|
||||
|
||||
<file>access.c</file>
|
||||
<file>acl.c</file>
|
||||
<file>atom.c</file>
|
||||
|
@ -73,7 +60,6 @@
|
|||
<file>handle.c</file>
|
||||
<file>heap.c</file>
|
||||
<file>image.c</file>
|
||||
<file>mem.c</file>
|
||||
<file>message.c</file>
|
||||
<file>largeint.c</file>
|
||||
<file>luid.c</file>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue