public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* sorry again:)->extended asm problem
@ 2004-08-09 15:20 Ankit Jain
  2004-08-09 16:05 ` Paweł Sikora
  0 siblings, 1 reply; 3+ messages in thread
From: Ankit Jain @ 2004-08-09 15:20 UTC (permalink / raw)
  To: gcc

sorry again. i generally dont make such mistyakes
while asking questiuons. but yes it should %0.

and i want it through pointers. earlier my program was
having all these things correct but somewhat later i
have done all these mistakes in the code and while
sending the problem i pasted this error code.
i guess the code below is correct and i have to
understand why array b is not initialised with the
value
1 #include<inttypes.h>
      2
      3
      4 int main()
      5 {
      6   uint8_t
a[8]={1,2,3,4,5,6,7,8},b[8]={0,0,0,0,0,0},i;
      7   uint8_t *m,*m1;
      8 
      9   m=a;
     10   m1=b;         //i have pointed m1 to b
     11   for(i=0;i<8;i++)
     12      printf("%d ",a[i]);
     13   printf("\n");
     14   asm("movq (%1), %%mm0 \n"
     15       "movq %%mm0, (%0) \n"
     16       :"=r"(m1)
     17       :"r"(m)
     18       );
     19 
     20   for(i=0;i<8;i++)
     21      printf("%d ",b[i]);
     22   return 0;
     23 }
so i expect that b should be initialised
the problem in this code is it is printing array b as
00000000
it is not moving the values
WHY?

thanks a lot
ankit

________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sorry again:)->extended asm problem
  2004-08-09 15:20 sorry again:)->extended asm problem Ankit Jain
@ 2004-08-09 16:05 ` Paweł Sikora
  2004-08-09 17:23   ` Ankit Jain
  0 siblings, 1 reply; 3+ messages in thread
From: Paweł Sikora @ 2004-08-09 16:05 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

# gcc -s -O2 mmx.c

# ./a.out
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8


-- 
/* Copyright (C) 2003, SCO, Inc. This is valuable Intellectual Property. */

                           #define say(x) lie(x)

[-- Attachment #2: mmx.c --]
[-- Type: text/x-csrc, Size: 435 bytes --]

#include <inttypes.h>
#include <stdio.h>

uint8_t a[8] = { 1, 2, 3, 4, 5, 6, 7, 8},
	b[8] = { 0, 0, 0, 0, 0, 0, 0, 0};

int main()
{
    int i;
    for(i = 0; i < 8; i++)
	printf("%d ",a[i]);
    printf("\n");

    asm volatile (
	"movq	(%0), %%mm0	\n\t"
	"movq	%%mm0, (%1)	\n\t"
	:			// outputs
	: "r"(a), "r" (b)	// inputs
	: "mm0"			// clobbers
	);

    for(i = 0; i < 8; i++)
	printf("%d ",b[i]);
    printf("\n");
    return 0;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sorry again:)->extended asm problem
  2004-08-09 16:05 ` Paweł Sikora
@ 2004-08-09 17:23   ` Ankit Jain
  0 siblings, 0 replies; 3+ messages in thread
From: Ankit Jain @ 2004-08-09 17:23 UTC (permalink / raw)
  To: Paweł_Sikora; +Cc: gcc-help

hi

thanks a lot :) but i wanted to do it through
pointers? 

i am not able to understand why it cant happen with
pointers?

what u told is fine except i could not understand
"volaitle"?

thanks

ankit
 --- Paweł_Sikora <pluto@pld-linux.org> wrote: 
> # gcc -s -O2 mmx.c
> 
> # ./a.out
> 1 2 3 4 5 6 7 8
> 1 2 3 4 5 6 7 8
> 
> 
> -- 
> /* Copyright (C) 2003, SCO, Inc. This is valuable
> Intellectual Property. */
> 
>                            #define say(x) lie(x)
> > #include <inttypes.h>
> #include <stdio.h>
> 
> uint8_t a[8] = { 1, 2, 3, 4, 5, 6, 7, 8},
> 	b[8] = { 0, 0, 0, 0, 0, 0, 0, 0};
> 
> int main()
> {
>     int i;
>     for(i = 0; i < 8; i++)
> 	printf("%d ",a[i]);
>     printf("\n");
> 
>     asm volatile (
> 	"movq	(%0), %%mm0	\n\t"
> 	"movq	%%mm0, (%1)	\n\t"
> 	:			// outputs
> 	: "r"(a), "r" (b)	// inputs
> 	: "mm0"			// clobbers
> 	);
> 
>     for(i = 0; i < 8; i++)
> 	printf("%d ",b[i]);
>     printf("\n");
>     return 0;
> }
>  

________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-08-09 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-09 15:20 sorry again:)->extended asm problem Ankit Jain
2004-08-09 16:05 ` Paweł Sikora
2004-08-09 17:23   ` Ankit Jain

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).