section .text
global memcpy
memcpy:
push esi
push edi
mov eax, dword [esp+12]
mov edi, eax
mov esi, dword [esp+16]
mov ecx, dword [esp+20]
rep movsb
pop edi
pop esi
ret
global memset
memset:
mov edx, dword [esp+8]
mov edi, edx
mov ecx, dword [esp+16]
rep stosb
mov eax, edx
global memmove
memmove:
cmp edi, esi
ja .copy_backwards
jmp .done
.copy_backwards:
lea edi, [edi+ecx-1]
lea esi, [esi+ecx-1]
std
cld
.done:
global memcmp
memcmp:
mov edi, dword [esp+12]
repe cmpsb
je .equal
mov al, byte [edi-1]
sub al, byte [esi-1]
movsx eax, al
.equal:
xor eax, eax