This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using the Intel's MMX Instruction Set in gcc3.2


Hi All,

I have got the solution for this..Thought of putting it across.
We have to use the Intrinsic library provided by gcc here.

The below is a program to test the PMADDWD(Packed Multiply and Add) of the MMX Instruction Set.

NOTE: compile like this>gcc  -mmmx testmac.c
(-mmmx option is important here.)

------------------------TESTMAC.C-----------------------------------
#include <mmintrin.h>


int main() { __m64 m1 = 0x00ff00a300bc00ae; __m64 m2 = 0x0001000100010001; __m64 m3;

   unsigned char *data;
   unsigned char ch;
   int i;


//asm ("pmaddwd m1,m2\n\t"); m3 =_mm_madd_pi16 (m1, m2);

   printf("value is %x%x\n", m1);
   printf("value is %x%x\n", m2);
   printf("value is %x%x\n", m3);

data = (char *)&m3;

   for ( i = 0; i < 8; i++)
        {
        printf("Element %d value is %x\n", i, data[i]);
        }


return; }


Thanks for the pointers and the individual mails sent to me which gave me an insight of doing this.
I guess that there is a scarcity of material on this subject in the Net.


Regards,
Prakash.
~

At 20.18 05/03/2003 +0530, Ulrich Prakash wrote:
Hi,

I tried this piece of code.


-----testmac.c----------- #include <mmintrin.h>


int main() { __m64 m1 = 12; __m64 m2 = 24; __m64 m3;

asm ("pmaddwd m1,m2\n\t");

m3 = m1;


return; }


and tried compiling using> gcc -mmmx testmac.c I get the foll ERROR: /tmp/cc0rnlnq.s: Assembler messages: /tmp/cc0rnlnq.s:18: Error: too many memory references for `pmaddwd'

though i could find nothing wrong in usage of asm ("pmaddwd m1,m2\n\t");

Please help me if I am missing something.


Thanks, Prakash.

At 02:06 PM 3/5/03 +0100, Andrea 'fwyzard' Bocci wrote:
At 16.32 05/03/2003 +0530, Ulrich Prakash wrote:
Hi,


I am using gcc version3.2,which supports the MMX Instruction Set. Can anyone tell me how to use this Instruction Set in my C program?

Is there a particular way that GCC provides to use the MMX Instruction Set directly?(If so,how?)
(OR)
Is it through an assembly function(.s file) in which I would have to use these Instruction Sets,and which I would have to call in my C program?


I don't recall now, I think there should be some intrinsics for that, or whatever. Have a look into the GCC manual, looking for MMX.

.fwyzard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]