memcpystack proc dest,src,cnt;cnt is a count of dwords
;this function has a granularity of dwords
mov edx,src
mov eax,dest
sub eax,edx
sub eax,4
mov ecx,cnt
xchg esp,edx
.repeat
pop dword ptr[esp+eax]
dec ecx
.until zero?
xchg esp,edx
retmemcpystack endp
memcpy1 proc dest,src,cnt
mov edx,src
mov ebx,dest
mov ecx,cnt
.repeat
mov eax,dword ptr[edx]
mov dword ptr[ebx],eax
add edx,4
add eax,4
dec ecx
.until zero?
retmemcpy1 endp
memcpy2 proc dest,src,cnt
mov edx,src
mov ebx,dest
mov ecx,cnt
.repeat
push dword ptr[edx]
pop dword ptr[ebx]
add edx,4
add ebx,4
dec ecx
.until zero?
retmemcpy2 endp
memcpy3 proc dest,src,cnt
mov esi,src
mov edi,dest
mov ecx,cnt
rep movsd
retmemcpy3 endp
汇编-memcpy的实现