From: mycroft@hal.gnu.ai.mit.edu (Charles Hannum) Subject: Re: GNU __asm__ Date: 2 May 1993 08:48:51 -0400
This really is all documented, but the documentation is not very clear.
In article <C6CGny.LM@oea.hobby.nl> dan@oea.hobby.nl (Dan Naas) writes:
>
>__asm__ volatile ("movl %2,%%ebx\n\t" \
The `%2' is replaced by a specification of argument #2, which is `arg'.
(The arguments are numbered from 0, not 1.)
> "int $0x80" \
> : "=a" (__res) \
This says that `__res' is output (=) in register eax (a). (Look in the
manual section on `constraints' for more information on this.)
> : "0" (__NR_##name), "g" ((long) (arg)) \
This says that `__NR_##name' is input in the same register as argument
0 (the output above); i.e. eax. `arg' is input in any general-purpose
register or directly accessible memory location.
> : "bx" ); \
This just says that ebx is clobbered.
i.e. It's conceptually equivalent to:
movl arg, %ebx
movl __NR_##name, %eax
int $0x80
movl %eax, __res
FWIW, the above construct could have been written as:
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name), "b" ((long) (arg)));
BTW, this is a simple example. B-)
-- \ / Charles Hannum, mycroft@ai.mit.edu /\ \ PGP public key available on request. MIME, AMS, NextMail accepted. Scheme White heterosexual atheist male (WHAM) pride!