- 论坛徽章:
- 0
|
就是效率吧
src[off]版的汇编片段:
- my_strcpy:
- pushl %ebp
- movl %esp, %ebp
- subl $16, %esp
- movl 8(%ebp), %edx
- movl 12(%ebp), %eax
- movl %edx, %ecx
- subl %eax, %ecx
- movl %ecx, %eax
- subl $1, %eax
- movl %eax, -4(%ebp)
- .L2:
- movl 12(%ebp), %eax
- movzbl (%eax), %edx
- addl $1, 12(%ebp)
- movl -4(%ebp), %eax
- addl 12(%ebp), %eax
- movb %dl, (%eax)
- testb %dl, %dl
- jne .L2
- movl 8(%ebp), %eax
- leave
- ret
复制代码
*dest++=*src++版的汇编:
- my_strcpy:
- pushl %ebp
- movl %esp, %ebp
- jmp .L2
- .L3:
- movl 12(%ebp), %eax
- movzbl (%eax), %edx
- movl 8(%ebp), %eax
- movb %dl, (%eax)
- addl $1, 8(%ebp)
- addl $1, 12(%ebp)
- .L2:
- cmpl $0, 12(%ebp)
- jne .L3
- movl 8(%ebp), %eax
- popl %ebp
- ret
复制代码
编译器是gcc4.1
不是很懂汇编(以后再学...)
[ 本帖最后由 imonyse 于 2007-11-21 14:21 编辑 ] |
|