reactos/lib/rtl/amd64/rtlmem.S
Amine Khaldi c424146e2c Create a branch for cmake bringup.
svn path=/branches/cmake-bringup/; revision=48236
2010-07-24 18:52:44 +00:00

88 lines
1.6 KiB
ArmAsm

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Run-Time Library
* PURPOSE: Memory functions for amd64
* FILE: lib/rtl/i386/rtlswap.S
* PROGRAMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <reactos/asm.h>
#include <ndk/amd64/asm.h>
/* FUNCTIONS *****************************************************************/
.code64
/* SIZE_T
* RtlCompareMemory(
* IN CONST VOID *Source1, <rcx>
* IN CONST VOID *Source2, <rdx>
* IN SIZE_T Length <r8>
* );
*/
.proc RtlCompareMemory
/* Save registers */
push rsi
.pushreg rsi
push rdi
.pushreg rdi
.ENDPROLOG
/* Setup registers for compare */
mov rsi, rcx
mov rdi, rdx
/* Clear direction flag */
cli
/* Get number of qwords */
mov rcx, r8
shr rcx, 3
jz RtlCompareMemory2
/* Compare qwords */
repe cmpsq
jnz RtlCompareMemory4
RtlCompareMemory2:
/* Compare rest */
mov rcx, r8
and rcx, 7
jz RtlCompareMemory3
repe cmpsb
jnz RtlCompareMemory5
RtlCompareMemory3:
/* All equal */
/* Return the full count */
mov rax, rcx
jmp RtlCompareMemory6
RtlCompareMemory4:
/* Not equal after comparing qwords */
/* Compare the last qword */
sub rsi, 8
sub rdi, 8
mov rcx, 8
repe cmpsb
RtlCompareMemory5:
/* Not equal after comparing bytes */
/* Return difference */
sub rdi, rdx
dec rdi
mov rax, rdi
RtlCompareMemory6:
/* Cleanup and return */
pop rdi
pop rsi
ret
.endp RtlCompareMemory
END