public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* problem with pointers in asm
@ 2004-08-11  8:52 Ankit Jain
  0 siblings, 0 replies; 2+ messages in thread
From: Ankit Jain @ 2004-08-11  8:52 UTC (permalink / raw)
  To: gcc; +Cc: linux

hi

well i want to understand how assembler treats
pointers?

my code is:

      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 }
well this problem is not solved yet. because when i
display b array then it prints all 0's. according to
me since i have initialised this m1 pointer then by b
then b whould have all the values which i have moved

some have advised me to use arrays here as constraint
but i want to use pointers. i am using r constraint
and it says it says that m1 will use a register (i
guess there is no problem in that)

what is the complete problem HOW THIS ASSEMBLER IS
TREATING THIS POINTER m1?

thanks 

ankit jain

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

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

* problem with pointers in asm
       [not found] <20040811080658.GA10320@login-4.efd.lth.se>
@ 2004-08-11  9:04 ` Ankit Jain
  0 siblings, 0 replies; 2+ messages in thread
From: Ankit Jain @ 2004-08-11  9:04 UTC (permalink / raw)
  To: Fredrik Olofsson, gcc

thanks but still i am not clear how m1 is input to
asm()?
and if u can explain this " "memory" since your asm()
changes memory."

thanks

ankit
 --- Fredrik Olofsson <frol@linux.nu> wrote: 
> On Wed, Aug 11, 2004 at 07:35:56AM +0100, Ankit Jain
> wrote:
> >      14   asm("movq (%1), %%mm0 \n"
> >      15       "movq %%mm0, (%0) \n"
> >      16       :"=r"(m1)
> >      17       :"r"(m)
> >      18       );
> 
> m1 is used as an input to the asm(), so adding
> "r"(m1) to line 17 and removing it from line 16
> fixes the problem. Probably you should also add a
> line 17.5 : "memory" since your asm() changes
> memory.
> 
> asm("movq (%1), %%mm0 \n"
>     "movq %%mm0, (%0) \n"
>     :
>     : "r"(m1), "r"(m)
>     : "memory"
>     );
> 
> Cheers,
> /Fredrik
>  

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

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

end of thread, other threads:[~2004-08-11  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-11  8:52 problem with pointers in asm Ankit Jain
     [not found] <20040811080658.GA10320@login-4.efd.lth.se>
2004-08-11  9:04 ` 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).