|
发表于 2004-4-21 08:45:28
|
显示全部楼层
[code:1]
#define __copy_user(to,from,size) \
do { \
int __d0, __d1; \
__asm__ __volatile__( \
"0: rep; movsl\n" \
" movl %3,%0\n" \
"1: rep; movsb\n" \
"2:\n" \
".section .fixup,\"ax\"\n" \
"3: lea 0(%3,%0,4),%0\n" \
" jmp 2b\n" \
".previous\n" \
".section __ex_table,\"a\"\n" \
" .align 4\n" \
" .long 0b,3b\n" \
" .long 1b,2b\n" \
".previous" \
: "=&c"(size), "=&D" (__d0), "=&S" (__d1) \
: "r"(size & 3), "0"(size / 4), "1"(to), "2"(from)\
: "memory"); \
} while (0)
[/code:1]
"0: rep; movsl\n" ;以4byte为单位拷贝
" movl %3,%0\n" ;更改ecx
"1: rep; movsb\n" ;以1byte为单位拷贝
".section __ex_table,\"a\"\n" ;异常表
" .align 4\n" ;4byte对齐
" .long 0b,3b\n" ;如果label 0处发生异常,跳转到label 3
" .long 1b,2b\n" ;如果label 1处发生异常,跳转到label 2
".section .fixup,\"ax\"\n" ;处理异常
"3: lea 0(%3,%0,4),%0\n" ;计算尚未拷贝的字节数,等价于%ecx=(size%4)+%ecx*4.
" jmp 2b\n" ;跳转到label 2 |
|