;
; A hand-written "memcpy()"
;

LEA ESI [src]           ; ESI = &src
LEA EDI [dest]          ; EDI = &dest

MOV ECX, length         ; ECX = length
MOV EDX, ECX            ; EDX = ECX

SHR ECX, 3              ; ECX = length (ECX, qwords)
AND EDX, 7              ; EDX = remainder (EDX, bytes)

CLD                     ; Clear direction flag
REP MOVSQ               ; Copy qwords (from left to right)

MOV ECX, EDX            ; ECX = EDX
REP MOVSB               ; Copy remaining bytes

