linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jack Andrews" <effbiae@gmail.com>
To: linux-assembly@vger.kernel.org
Subject: inline asm mmx: how to movq from memory to %mmX
Date: Tue, 17 Apr 2007 23:28:50 +1000	[thread overview]
Message-ID: <2cf50a010704170628r3f4229c3lad2b58743c63462e@mail.gmail.com> (raw)

hi lin-asm,

i am trying to do some vector addition using MMX and inline assembly
in GCC.  my code follows.

i want the function 'simd' to do the same as 'sisd'

i get these errors when i try to compile:

[jack@fedora i]$ gcc -mmmx v.c
/tmp/ccWXntVc.s: Assembler messages:
/tmp/ccWXntVc.s:19: Error: suffix or operands invalid for `movq'
/tmp/ccWXntVc.s:20: Error: junk `%mm0' after register

[jack@fedora i]$ gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/u
sr/share/info --enable-shared --enable-threads=posix --enable-checking=release -
-with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-
libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable
-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.
0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.0 20060304 (Red Hat 4.1.0-3)


[jack@fedora i]$ cat v.c
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

typedef long I;
typedef char C;
#define IZ sizeof(I)
#define W 2

simd(n, is)
I *is;
{   I i;
    asm("pxor %mm0,%mm0");
    for (i=0; i < n; i += W) {
        asm("movq %0 %%mm1\n\t"
            "paddq %%mm1 %%mm0"
            :
            :"m"(is[i])           );
    }
    return 0;
}

sisd(n, is)
I *is;
{
    I i = 0, j = 0;
    for (i = 0; i < n; i++)
        j += is[i];
    return j;
}

main(c, v)
C **v;
{
    I n = atol(v[1]),
        z = atol(v[2]), m = atol(v[3]), *is = malloc(IZ * (z *= W));
    I result;
    printf("IZ=%d, %s\n",IZ,m?"SIMD":"SISD");
    while (n--)
        result=m?simd(z, is):sisd(z, is);
    printf("%d\n",result);

             reply	other threads:[~2007-04-17 13:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-17 13:28 Jack Andrews [this message]
2007-04-17 14:58 ` inline asm mmx: how to movq from memory to %mmX Robert Plantz

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=2cf50a010704170628r3f4229c3lad2b58743c63462e@mail.gmail.com \
    --to=effbiae@gmail.com \
    --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 read-only IMAP folder(s) and NNTP newsgroup(s).