* inline asm problem
@ 2002-03-18 0:59 TWISTI
2002-03-18 1:30 ` Ian Lance Taylor
0 siblings, 1 reply; 11+ messages in thread
From: TWISTI @ 2002-03-18 0:59 UTC (permalink / raw)
To: binutils
I've already posted this in `gcc@gcc.gnu.org'. But maybe this is the
_more_ correct list. Here it goes:
Can anyone tell me how the at&t syntax is for this small intel asm?
short filt_cos[] = { 141, ... };
pmaddwd mm1, [filt_cos + 8]
I've tried it this way:
__asm__ __volatile__ ("pmaddwd 8(%0), %%mm1" : : "m" (filt_cos));
but:
/tmp/cctukwBb.s: Assembler messages:
/tmp/cctukwBb.s:1753: Error: junk `(.LC13)' after expression
Then i tried this:
__asm__ __volatile__ ("pmaddwd 8 + %0(,1), %%mm1" : : "m" (filt_cos));
works, but give wrong result.
Is there an _one_liner_ solution?
Regards.
TWISTI
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: inline asm problem
2002-03-18 0:59 inline asm problem TWISTI
@ 2002-03-18 1:30 ` Ian Lance Taylor
2002-03-18 4:32 ` Hans-Peter Nilsson
0 siblings, 1 reply; 11+ messages in thread
From: Ian Lance Taylor @ 2002-03-18 1:30 UTC (permalink / raw)
To: TWISTI; +Cc: binutils
TWISTI <twisti@fusion.at> writes:
> I've already posted this in `gcc@gcc.gnu.org'. But maybe this is the
> _more_ correct list. Here it goes:
>
> Can anyone tell me how the at&t syntax is for this small intel asm?
>
> short filt_cos[] = { 141, ... };
>
> pmaddwd mm1, [filt_cos + 8]
>
> I've tried it this way:
>
> __asm__ __volatile__ ("pmaddwd 8(%0), %%mm1" : : "m" (filt_cos));
>
> but:
> /tmp/cctukwBb.s: Assembler messages:
> /tmp/cctukwBb.s:1753: Error: junk `(.LC13)' after expression
>
> Then i tried this:
>
> __asm__ __volatile__ ("pmaddwd 8 + %0(,1), %%mm1" : : "m" (filt_cos));
>
> works, but give wrong result.
>
> Is there an _one_liner_ solution?
It looks to me like you are trying to add 8 within the inline
assembler. But you've told gcc to use an arbitrary memory address.
There is no reason to expect that gcc will expect you something to
which you can add 8. You could try using a constraint of "o". But
why not just do this:
__asm__ __volatile__ ("pmaddwd %0, %%mm1" : : "m" (filt_cos + 8));
Ian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: inline asm problem
2002-03-18 1:30 ` Ian Lance Taylor
@ 2002-03-18 4:32 ` Hans-Peter Nilsson
2002-03-18 9:38 ` TWISTI
0 siblings, 1 reply; 11+ messages in thread
From: Hans-Peter Nilsson @ 2002-03-18 4:32 UTC (permalink / raw)
To: TWISTI; +Cc: binutils
On 18 Mar 2002, Ian Lance Taylor wrote:
> why not just do this:
> __asm__ __volatile__ ("pmaddwd %0, %%mm1" : : "m" (filt_cos + 8));
But don't forget to cast to char * so you're not surprised by
address arithmetic on the short-sized items (often two bytes):
__asm__ __volatile__ ("pmaddwd %0, %%mm1" : : "m" ((char *) filt_cos + 8));
or just say filt_cos + 4.
brgds, H-P
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: inline asm problem
2002-03-18 4:32 ` Hans-Peter Nilsson
@ 2002-03-18 9:38 ` TWISTI
2002-03-18 9:46 ` DJ Delorie
0 siblings, 1 reply; 11+ messages in thread
From: TWISTI @ 2002-03-18 9:38 UTC (permalink / raw)
To: Hans-Peter Nilsson, amodra, ian; +Cc: binutils
On Mon, 2002-03-18 at 13:31, Hans-Peter Nilsson wrote:
> On 18 Mar 2002, Ian Lance Taylor wrote:
>
> > why not just do this:
> > __asm__ __volatile__ ("pmaddwd %0, %%mm1" : : "m" (filt_cos + 8));
>
> But don't forget to cast to char * so you're not surprised by
> address arithmetic on the short-sized items (often two bytes):
> __asm__ __volatile__ ("pmaddwd %0, %%mm1" : : "m" ((char *) filt_cos + 8));
> or just say filt_cos + 4.
>
> brgds, H-P
Thanks, that did help very much. I've another related problem:
Let's say i would like to address it like this: filt_cos + %eax * 8
Can i do this without
"movl %0, %%ebx" : : "m" (filt_cos)
"movl (%ebx, %eax, 8), %mm1"
Obviously
"movl (%0, %eax, 8), %%mm1" : : "m" (filt_cos)
does not work. Maybe another oneliner?
TWISTI
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: inline asm problem
2002-03-18 9:38 ` TWISTI
@ 2002-03-18 9:46 ` DJ Delorie
2002-03-18 10:13 ` TWISTI
0 siblings, 1 reply; 11+ messages in thread
From: DJ Delorie @ 2002-03-18 9:46 UTC (permalink / raw)
To: twisti; +Cc: binutils
> Let's say i would like to address it like this: filt_cos + %eax * 8
>
> Can i do this without
>
> "movl %0, %%ebx" : : "m" (filt_cos)
> "movl (%ebx, %eax, 8), %mm1"
>
> Obviously
>
> "movl (%0, %eax, 8), %%mm1" : : "m" (filt_cos)
>
> does not work. Maybe another oneliner?
Why not this?
asm("mov %0, %%mm1" : : "m" (filt_cos[n]));
You don't have to be *that* clever, as gcc *does* know how to handle
things like this on its own.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: inline asm problem
2002-03-18 9:46 ` DJ Delorie
@ 2002-03-18 10:13 ` TWISTI
2002-03-18 10:53 ` Ian Lance Taylor
[not found] ` <200203181816.g2IIGnO07978@envy.delorie.com>
0 siblings, 2 replies; 11+ messages in thread
From: TWISTI @ 2002-03-18 10:13 UTC (permalink / raw)
To: DJ Delorie; +Cc: binutils
On Mon, 2002-03-18 at 18:46, DJ Delorie wrote:
> Why not this?
> asm("mov %0, %%mm1" : : "m" (filt_cos[n]));
>
> You don't have to be *that* clever, as gcc *does* know how to handle
> things like this on its own.
>
Would be possible, but counter is in %eax and i need fastest execution
possible. Assignment to `n' isn't that clever i think.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: inline asm problem
2002-03-18 10:13 ` TWISTI
@ 2002-03-18 10:53 ` Ian Lance Taylor
[not found] ` <200203181816.g2IIGnO07978@envy.delorie.com>
1 sibling, 0 replies; 11+ messages in thread
From: Ian Lance Taylor @ 2002-03-18 10:53 UTC (permalink / raw)
To: TWISTI; +Cc: DJ Delorie, binutils
TWISTI <twisti@fusion.at> writes:
> On Mon, 2002-03-18 at 18:46, DJ Delorie wrote:
> > Why not this?
> > asm("mov %0, %%mm1" : : "m" (filt_cos[n]));
> >
> > You don't have to be *that* clever, as gcc *does* know how to handle
> > things like this on its own.
> >
>
> Would be possible, but counter is in %eax and i need fastest execution
> possible. Assignment to `n' isn't that clever i think.
You need to read up about gcc constraints, which is a subject for the
gcc list, not for here. You can use constraints to force gcc to put a
value into a particular set of registers, which I think is what you
want. See
http://gcc.gnu.org/onlinedocs/gcc-3.0.3/gcc_20.html#SEC216
with particular attention to the i386 section in
http://gcc.gnu.org/onlinedocs/gcc-3.0.3/gcc_20.html#SEC221
Ian
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <200203181816.g2IIGnO07978@envy.delorie.com>]
* Re: inline asm problem
[not found] ` <200203181816.g2IIGnO07978@envy.delorie.com>
@ 2002-03-18 11:04 ` TWISTI
2002-03-18 11:10 ` DJ Delorie
0 siblings, 1 reply; 11+ messages in thread
From: TWISTI @ 2002-03-18 11:04 UTC (permalink / raw)
To: DJ Delorie; +Cc: binutils
On Mon, 2002-03-18 at 19:16, DJ Delorie wrote:
> Did you use inline asm to put the counter in %eax? Wherever you got
> the count value from, tell gcc about that, and it should figure out to
> use %eax anyway.
It's something like this:
%edx = n
%eax = %edx
%eax >> 22
It's completely modified in assembler.
>
> Have you tried using &filt_cos instead of just filt_cos? You'd need
> an "i" constraint.
Like this: "pmaddwd (%0, %%eax, 8), %%mm3" : : "i" (&cosin64)?
Results in: pmaddwd ($cosin64, %eax, 8), %mm3
/tmp/ccNuWzdA.s:1827: Error: missing ')'
/tmp/ccNuWzdA.s:1827: Error: junk `,%eax,8)' after expression
>
> At some point, it becomes worthwhile to switch to plain old assembler
> (*.S) instead of inline assembler. The whole advantage of inline
> assembler is to let gcc keep track of where everything is.
Hmm.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: inline asm problem
2002-03-18 11:04 ` TWISTI
@ 2002-03-18 11:10 ` DJ Delorie
2002-03-18 13:19 ` TWISTI
0 siblings, 1 reply; 11+ messages in thread
From: DJ Delorie @ 2002-03-18 11:10 UTC (permalink / raw)
To: twisti; +Cc: binutils
> > Have you tried using &filt_cos instead of just filt_cos? You'd need
> > an "i" constraint.
>
> Like this: "pmaddwd (%0, %%eax, 8), %%mm3" : : "i" (&cosin64)?
> Results in: pmaddwd ($cosin64, %eax, 8), %mm3
> /tmp/ccNuWzdA.s:1827: Error: missing ')'
> /tmp/ccNuWzdA.s:1827: Error: junk `,%eax,8)' after expression
This seems to work:
long long filt_cos[100];
int foo(int n)
{
asm("mov %0(,%%eax,8), %%mm1" : : "m" (filt_cos[0]));
}
mov filt_cos(,%eax,8), %mm1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: inline asm problem
2002-03-18 11:10 ` DJ Delorie
@ 2002-03-18 13:19 ` TWISTI
2002-03-18 13:21 ` DJ Delorie
0 siblings, 1 reply; 11+ messages in thread
From: TWISTI @ 2002-03-18 13:19 UTC (permalink / raw)
To: DJ Delorie; +Cc: binutils
On Mon, 2002-03-18 at 20:10, DJ Delorie wrote:
> This seems to work:
>
> long long filt_cos[100];
>
> int foo(int n)
> {
> asm("mov %0(,%%eax,8), %%mm1" : : "m" (filt_cos[0]));
> }
>
> mov filt_cos(,%eax,8), %mm1
>
Yes works. Thanks very much. But more obvious for me:
asm("movq %0(, %%eax, 8), %%mm1" : : "m" (*filt_cos));
As i experimented with this, i found a solution for my very first
problem:
__asm__ __volatile__ ("pmaddwd (%0 + 8), %%mm1" : : "m" (*filt_cos));
But i haven't found this documented. Or am i overlooking something...
Anyway.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2002-03-18 21:21 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-18 0:59 inline asm problem TWISTI
2002-03-18 1:30 ` Ian Lance Taylor
2002-03-18 4:32 ` Hans-Peter Nilsson
2002-03-18 9:38 ` TWISTI
2002-03-18 9:46 ` DJ Delorie
2002-03-18 10:13 ` TWISTI
2002-03-18 10:53 ` Ian Lance Taylor
[not found] ` <200203181816.g2IIGnO07978@envy.delorie.com>
2002-03-18 11:04 ` TWISTI
2002-03-18 11:10 ` DJ Delorie
2002-03-18 13:19 ` TWISTI
2002-03-18 13:21 ` DJ Delorie
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 read-only IMAP folder(s) and NNTP newsgroup(s).