请教copy_user宏
#define __copy_user(to,from,size) \256 do { \
257 int __d0, __d1; \
258 __asm__ __volatile__( \
259 "0: rep; movsl\n" \
260 " movl %3,%0\n" \
261 "1: rep; movsb\n" \
262 "2:\n" \
263 ".section .fixup,\"ax\"\n" \
264 "3: lea 0(%3,%0,4),%0\n" \
265 " jmp 2b\n" \
266 ".previous\n" \
267 ".section __ex_table,\"a\"\n" \
268 " .align 4\n" \
269 " .long 0b,3b\n" \
270 " .long 1b,2b\n" \
271 ".previous" \
272 : "=&c"(size), "=&D" (__d0), "=&S" (__d1) \
273 : "r"(size & 3), ""(size / 4), "1"(to), "2"(from) \
274 : "memory"); \
275 } while (0)
宏里的asm看大不懂,可否转成汇编代码给我,谢谢 这个已经是汇编了
#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)
"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 这些都知道,可movsb需要指定reg的
主要是不是很懂
: "=&c"(size), "=&D" (__d0), "=&S" (__d1) \
: "r"(size & 3), "0"(size / 4), "1"(to), "2"(from)\
: "memory");
d0,d1,to,from如何被指定了? : "=&c"(size), "=&D" (__d0), "=&S" (__d1)
: "r"(size & 3), "0"(size / 4), "1"(to), "2"(from)
依次分别是:%0,%1......
在输入部中,"0"代表输入到%0,"1"代表输入到%1......
"=&D" 代表di或edi是%1,具体是哪个取决于__d0的位数 3x
页:
[1]