char *my_strcpy(char *dest, char *src) { char *cpy = dest; while(*src) { *dest = *src; ++src; ++dest; } *dest = *src; return(cpy); } .file "strcpy.c" .text .globl my_strcpy .type my_strcpy, @function my_strcpy: pushl %ebp movl %esp, %ebp subl $4, %esp movl 8(%ebp), %eax movl %eax, -4(%ebp) .L2: movl 12(%ebp), %eax cmpb $0, (%eax) jne .L4 jmp .L3 .L4: movl 8(%ebp), %edx movl 12(%ebp), %eax movb (%eax), %al movb %al, (%edx) leal 12(%ebp), %eax incl (%eax) incl 8(%ebp) jmp .L2 .L3: movl 8(%ebp), %edx movl 12(%ebp), %eax movb (%eax), %al movb %al, (%edx) movl -4(%ebp), %eax leave ret .size my_strcpy, .-my_strcpy .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)" .file "strcpy.c" .text .p2align 2,,3 .globl my_strcpy .type my_strcpy, @function my_strcpy: pushl %ebp movl %esp, %ebp movl 12(%ebp), %ecx pushl %ebx movb (%ecx), %dl movl 8(%ebp), %eax testb %dl, %dl movl %eax, %ebx je .L7 .p2align 2,,3 .L5: movb %dl, (%eax) incl %ecx movb (%ecx), %dl incl %eax testb %dl, %dl jne .L5 .L7: movb %dl, (%eax) movl %ebx, %eax popl %ebx leave ret .size my_strcpy, .-my_strcpy .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)"