From: Maciej Hrebien <m_hrebien@wp.pl>
To: linux-assembly@vger.kernel.org
Subject: Re: atomic_add_and_test
Date: Fri, 20 Jun 2003 13:51:48 +0200 [thread overview]
Message-ID: <3EF2F554.56611A01@wp.pl> (raw)
In-Reply-To: Law11-F123JwM21tVHd000a4bf1@hotmail.com
Mark Lobo wrote:
>
> static __inline__ int32_t atomic_add_and_test(atomic_t * p_plValue, int32_t
> p_lAdd)
> {
> int32_t l_lResult;
> __asm__ __volatile__ (
> "push %%EBX;"
> "movl %1, %%EBX;"
> "movl %2, %%EAX;"
> "lock; xadd %%EAX, (%%EBX);"
> "inc %%EAX;"
> "mov %%EAX, %0;"
> "pop %%EBX"
> : "=g"(l_lResult) : "g"(p_plValue), "g"(p_lAdd):"%eax", "ebx" );
> return l_lResult;
> }
Can't you just:
inline int add_and_test(int* value, int to_add)
{
int old_result;
asm volatile("
lock
xadd %%eax,(%%ebx)
" : "=eax" (old_result) : "a" (to_add), "b" (value) );
return old_result;
}
? Do you have to push %ebx on stack? Why do you inc %eax after xadd?
Regards,
--
Maciej Hrebien
prev parent reply other threads:[~2003-06-20 11:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-16 19:40 atomic_add_and_test Mark Lobo
2003-06-20 11:51 ` Maciej Hrebien [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3EF2F554.56611A01@wp.pl \
--to=m_hrebien@wp.pl \
--cc=linux-assembly@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).