* hi about C and asm
@ 2013-05-29 1:02 lx
2013-05-29 1:27 ` Augusto Mecking Caringi
2013-05-29 15:33 ` Jonathan Neuschäfer
0 siblings, 2 replies; 3+ messages in thread
From: lx @ 2013-05-29 1:02 UTC (permalink / raw)
To: kernelnewbies
hi all:
They are some asm codes in the kernel like:
#define set_bit(nr,addr) ({\
register int res __asm__("ax"); \
__asm__ __volatile__("btsl %2,%3\n\tsetb %%al": \
"=a" (res):"0" (0),"r" (nr),"m" (*(addr))); \
res;})
But, almost I can't understand this. So I want to understand asm in C,
which book or website I should learn ?
Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130529/6b24ba0a/attachment.html
^ permalink raw reply [flat|nested] 3+ messages in thread* hi about C and asm
2013-05-29 1:02 hi about C and asm lx
@ 2013-05-29 1:27 ` Augusto Mecking Caringi
2013-05-29 15:33 ` Jonathan Neuschäfer
1 sibling, 0 replies; 3+ messages in thread
From: Augusto Mecking Caringi @ 2013-05-29 1:27 UTC (permalink / raw)
To: kernelnewbies
On Tue, May 28, 2013 at 10:02 PM, lx <lxlenovostar@gmail.com> wrote:
> hi all:
> They are some asm codes in the kernel like:
>
> #define set_bit(nr,addr) ({\
> register int res __asm__("ax"); \
> __asm__ __volatile__("btsl %2,%3\n\tsetb %%al": \
> "=a" (res):"0" (0),"r" (nr),"m" (*(addr))); \
> res;})
>
>
> But, almost I can't understand this. So I want to understand asm in C,
> which book or website I should learn ?
Hi,
This is a C (preprocessor) macro called set_bit which use GCC
inline assembly in its body.
http://gcc.gnu.org/onlinedocs/cpp/Macros.html
http://wiki.osdev.org/Inline_Assembly
--
Augusto Mecking Caringi
^ permalink raw reply [flat|nested] 3+ messages in thread* hi about C and asm
2013-05-29 1:02 hi about C and asm lx
2013-05-29 1:27 ` Augusto Mecking Caringi
@ 2013-05-29 15:33 ` Jonathan Neuschäfer
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Neuschäfer @ 2013-05-29 15:33 UTC (permalink / raw)
To: kernelnewbies
On Wed, May 29, 2013 at 09:02:22AM +0800, lx wrote:
> hi all:
> They are some asm codes in the kernel like:
>
> #define set_bit(nr,addr) ({\
> register int res __asm__("ax"); \
> __asm__ __volatile__("btsl %2,%3\n\tsetb %%al": \
> "=a" (res):"0" (0),"r" (nr),"m" (*(addr))); \
> res;})
>
>
> But, almost I can't understand this. So I want to understand asm in C,
> which book or website I should learn ?
Google "asm in c", first link is:
http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
HTH,
Jonathan Neusch?fer
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-29 15:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-29 1:02 hi about C and asm lx
2013-05-29 1:27 ` Augusto Mecking Caringi
2013-05-29 15:33 ` Jonathan Neuschäfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).