Messages in this thread | | | From | (Erik Mouw) | Subject | Re: for a help | Date | Wed, 8 Sep 1999 23:33:18 +0200 (CEST) |
| |
> During my reading the code of Linux,I always encouter the programming like > this" > __asm__ __volatile__( > "movl %%esp,%%esi\n\t" > "int $0x80\n\t" /* Linux/i386 system call */ > "cmpl %%esp,%%esi\n\t" /* child or parent? */ > "je 1f\n\t" /* parent - jump */ > /* Load the argument into eax, and push it. That way, it does > * not matter whether the called function is compiled with > * -mregparm or not. */ > "movl %4,%%eax\n\t" > "pushl %%eax\n\t" > "call *%5\n\t" /* call fn */ > "movl %3,%0\n\t" /* exit */ > "int $0x80\n" > "1:\t" > :"=&a" (retval), "=&S" (d0) > :"0" (__NR_clone), "i" (__NR_exit), > "r" (arg), "r" (fn), > "b" (flags | CLONE_VM) > : "memory");
Spooky inline assembly code, isn't it? :-)
> If you like, can you explain the > :"=&a" (retval), "=&S" (d0) > :"0" (__NR_clone), "i" (__NR_exit), > "r" (arg), "r" (fn), > "b" (flags | CLONE_VM) > : "memory"); > for me,just the Language grammer,what does it mean?
This is to tell the C compiler which registers and variables are used, which are clobbered by the assembly, and which are used for input or output. I do not understand it completely (read: I only understand the parts I needed), but you can find it in the gcc and as documentation. Look in /usr/info on your Linux system, gcc.info* and as.info* are the files you're looking for. Use info, tkinfo or emacs to read info files.
Hope this helps, Erik
-- J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department of Electrical Engineering, Faculty of Information Technology and Systems, Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2785859 Fax: +31-15-2781843 Email J.A.K.Mouw@its.tudelft.nl WWW: http://www-ict.its.tudelft.nl/~erik/
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |