1bits 32 2section .text 3;extern "C" int asm_memcpy 4; (unsigned char *dest, unsigned char *src, int len); 5 6global asm_memcpy 7 8times ($$-$) & 3 db 0 9 10asm_memcpy: 11 12pushad ; save registers 13mov edi,[esp+36] ; get 1st argument 14mov esi,[esp+40] ; ...2nd 15mov eax,[esp+44] ; ...3rd 16 17mov edx, eax 18shr eax, 2 ; figure out how many 4 byte chunks we have 19and edx, 3 ; also figure out slack 20test eax, eax ; Do we have any big chunks? 21push edx 22jz .slack ; If not, just do slack 23 24mov ecx,eax 25 26rep movsd ; move 4 byte chunks 27 28.slack: 29pop ecx 30rep movsb ; move 1 byte slack 31 32popad ; clean up 33ret 34 35; -------------------------------------- 36 37%ifdef NASM_STACK_NOEXEC 38section .note.GNU-stack noalloc noexec nowrite progbits 39%endif 40