Article View: comp.lang.asm.x86
Article #165inline ASM: SSE
From: Christoph Brunner
Date: Sun, 25 May 2003 18:59
Date: Sun, 25 May 2003 18:59
38 lines
2716 bytes
2716 bytes
Hi,
I'm currently trying to get into extended inline ASM in gcc (gcc version
3.2.2, gas 2.13.90.0.18).
However, I'm having some trouble: The following code, using SSE
instructions, segfaults, and I don't really know why.
Perhaps someone could give me a hint?
void add_asm(float *a, float *b, float *c, int n)
{
// a,b,c properly aligned; (n % 4) = 0
int iter = 0;
__asm__ __volatile__
(
"calc:\n"
"subl $4, %%ecx\n"
// perform package load/addition/store
"movaps (%3), %%xmm0\n"
"addps (%4), %%xmm0\n"
"movaps %%xmm0, (%0)\n"
// increment number of iterations
"addl $1, %1\n"
// advance pointers
// removing the following lines prevents the segfault
"addl $16, %3\n"
"addl $16, %4\n"
"addl $16, %0\n"
"jnz calc\n"
: "+r"(c), "+r"(iter), "+c" (n)
: "r"(a), "r"(b)
);
printf("iter:%d\n", iter); // STRANGE: always prints "0"
}
Technical Details
Message-ID:
<Ko8Aa.20426$Kn1.264902@news.chello.at>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,11e8a07eb4e4bb6f,start X-Google-Attributes: gid11318c,public X-Google-Thread: 114917,11e8a07eb4e4bb6f,start X-Google-Attributes: gid114917,public X-Google-ArrivalTime: 2003-05-25 14:52:00 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mail From: Christoph Brunner <cb100@gmx.net> Newsgroups: comp.lang.asm.x86,gnu.gcc.help Subject: inline ASM: SSE Approved: CLAX86 Moderators <ccrayne@crayne.org> Date: Sun, 25 May 2003 18:59:54 GMT Organization: Customers chello Austria Message-ID: <Ko8Aa.20426$Kn1.264902@news.chello.at> X-CLAX86-Policy: http://www.pacificsites.com/~ccrayne/clax86.html X-CLAX86-Faq: http://www2.dgsys.com/~raymoon/x86faqs.html X-CLAX86-Info-1: Send submissions to comp-lang-asm-x86@moderators.isc.org X-CLAX86-Info-2: Send technical complaints to ccrayne@crayne.org X-CLAX86-Info-3: Send complaints about policy to ccrayne@crayne.org X-Comment: moderators do not necessarily agree or disagree with this article. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030506 X-Accept-Language: en-us, en MIME-Version: 1.0 X-Enigmail-Version: 0.73.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-MailScanner: Found to be clean X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (score=0.2, required 5, FROM_ENDS_IN_NUMS, NOSPAM_INC, SPAM_PHRASE_00_01, USER_AGENT, USER_AGENT_MOZILLA_UA, X_ACCEPT_LANG) X-UIDL: 9P&!!F^)#!/gY"!D9)#! X-Complaints-To: abuse@supernews.com Lines: 39