[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: [thanks] what followin code is doin?



hi
   thanks for the solution .
   yes i am the same guy who met u in meetin at sarai and asked abt beowulf cluster
    
manish arya
--

On Fri, 20 Jul 2001 22:04:09  
 Ankur wrote:
>
>>     pls tell me what is the meaning of this code
>>
>> -------------------------------------------------------
>> int exec_interrupt(const char *filename, const arg[], const char *envp[])
>>
>> {
>>       long __res;
>>       __asm__ volatile("int $0x80" :a" (__res): "0"
>(__NE_exec_call),"b"((long)(filename),"c" ((long)(argv)),"d"((long)(envp)));
>>
>>        return (int __res);
>> }
>>
>
>After a few corrections(more or less trivial ones), the code is:
>
>int exec_interrupt(const char *filename, const argv[], const char *envp[]) {
>long __res;
> __asm__ volatile("int $0x80" : "=a" (__res) : "0" (__NR_execve),
>                            "b" ((long)(filename)), "c" ((long)(argv)),
>                           "d"((long)(envp)));
>       return (int) __res;
>}
>There is no such thing as __NE_exec_call(unless you've
>defined them yourselves). <asm/unistd.h> defines __NR_execve.
>
>This seems to be doing is calling interrupt 0x80(Linux system call
>interrupt) with the following arguments :
>. The value __NR_execve(system call number) in whatever "0"
>  specifies [ register EAX on x86]
>. The filename pointer in EBX ("b")
>. argv in ECX("c")
>. envp in EDX("d")
>. output on returning would be in the whatever "=a" specifies [EAX]
>
>This, btw, is the syntax for Extended Asm of gcc. Basically gcc
>doesn't parse through whatever code is present in the __asm__ block.
>It just emits code from this block into the asm it generates. But this
>causes a major problem wrt compiler optimizations. So this is a way to
>let the compiler know as to what the __asm__ block is changing.
>
>You can check out <asm/unistd.h> and the Linux kernel source for a lot more
>similar
>examples. Also take a look at info gcc.C Extensions.Extended Asm.
>
>Regards,
>ankur
>PS: Are you the same guy, who was very interested in the Beowulf
>architecture?
>
>------------------------------------------------
>The mailing list archives are available at
>http://lists.linux-india.org/cgi-bin/wilma/linux-delhi
>


Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/