From: Dan Naas (dan@oea.hobby.nl)
Date: 05/01/93


From: dan@oea.hobby.nl (Dan Naas)
Subject: GNU __asm__
Date: Sat, 1 May 1993 10:47:57 GMT

Hi all,
        I am making an effort to understand the source code for the
LINUX kernel but I'm frustrated by the GNU __asm__ construct. I've
read the GCC info files a couple of times but I find their explanation
inadequate. Let me give you an example of what I mean:

#define _syscall1(type,name,atype,arg) \
type name(atype arg) \
{
long __res;
__asm__ volatile ("movl %2,%%ebx\n\t" \
                  "int $0x80" \
                  : "=a" (__res) \
                  : "0" (__NR_##name), "g" ((long) (arg)) \
                  : "bx" ); \
if (__res >= 0) \
        return (type) __res; \
errno = -__res; \
return -1; \
}

My questions are:
        What gets substituted for %2 in the movl statement?
        Where does the output (__res) come from? Is it taken
                from a register? eax? Is the value put there
                by the int 0x80 service routine?
        Where do the inputs (__NR_##name and arg) go? Again,
                do they go into registers to be used by the
                isr? If so which registers? How do you figure
                out where every thing goes?
Anybody out there willing and able to help solve these and maybe
other mystries?

Thanks in advance!

-- 
+---------------------------------------+
| Dan Naas                              |
| uucp: ...!hobbynet!oea!dan            |
| inet: dan@oea.hobbynet.nl             |