public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* arm gcc help in programming
@ 2009-12-02  8:48 abhilash abraham
  2009-12-02  9:44 ` Andrew Haley
  0 siblings, 1 reply; 2+ messages in thread
From: abhilash abraham @ 2009-12-02  8:48 UTC (permalink / raw)
  To: gcc-help

hello...i'm abhilash..i've typed a code to add 2 64bit numbers.the
code iis not successfully compiled..errors are not shown in the .c
file but in a .s file whose location cant be traced out.
my code is given below...
........................................................
#include<stdio.h>

unsigned long value1[2]={0x12a2e670,0xa2435649};
unsigned long value2[2]={0x12a2e670,0xa2435649};
unsigned long result[2];

unsigned long *a=&value1;
unsigned long *b=&value2;
unsigned long *c=&result;


main()
{
asm("ldr r0,%[v]\n\t"
                "ldr r1,[r0]\n\t"
                "ldr r2,[r0,#4]\n\t"
                ::[v] "r" (a));
asm volatile( "ldr r0,%0\n\t"
                "ldr r3,[r0]\n\t"
                "ldr r4,[r0,#4]\n\t"
                ::"r" (b):"memory");
asm volatile( "adds r6,r2,r4\n\t"
                "adc r5,r1,r3\n\t"
                "ldr r0,%0\n\t"
                "str r5,[r0]\n\t"
                "str r6,[r0,#4]\n\t"
                ::"r" (c):"memory");
asm volatile("mrs r7,cpsr\n\t"
                "swi &11");
}

.........................................................

after this i did "gcc filename" and errors came...please help me sort
the issue...

Abhilash

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

* Re: arm gcc help in programming
  2009-12-02  8:48 arm gcc help in programming abhilash abraham
@ 2009-12-02  9:44 ` Andrew Haley
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Haley @ 2009-12-02  9:44 UTC (permalink / raw)
  To: abhilash abraham; +Cc: gcc-help

abhilash abraham wrote:
> hello...i'm abhilash..i've typed a code to add 2 64bit numbers.the
> code iis not successfully compiled..errors are not shown in the .c
> file but in a .s file whose location cant be traced out.
> my code is given below...
> ........................................................
> #include<stdio.h>
> 
> unsigned long value1[2]={0x12a2e670,0xa2435649};
> unsigned long value2[2]={0x12a2e670,0xa2435649};
> unsigned long result[2];
> 
> unsigned long *a=&value1;
> unsigned long *b=&value2;
> unsigned long *c=&result;
> 
> 
> main()
> {
> asm("ldr r0,%[v]\n\t"
>                 "ldr r1,[r0]\n\t"
>                 "ldr r2,[r0,#4]\n\t"
>                 ::[v] "r" (a));
> asm volatile( "ldr r0,%0\n\t"
>                 "ldr r3,[r0]\n\t"
>                 "ldr r4,[r0,#4]\n\t"
>                 ::"r" (b):"memory");
> asm volatile( "adds r6,r2,r4\n\t"
>                 "adc r5,r1,r3\n\t"
>                 "ldr r0,%0\n\t"
>                 "str r5,[r0]\n\t"
>                 "str r6,[r0,#4]\n\t"
>                 ::"r" (c):"memory");
> asm volatile("mrs r7,cpsr\n\t"
>                 "swi &11");
> }
> 
> .........................................................
> 
> after this i did "gcc filename" and errors came...please help me sort
> the issue...

Why do you want this?  Is this homework?

There are many, many errors in this code.  In particular you clobber
fixed registers without including them in the clobber list.

Andrew.

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

end of thread, other threads:[~2009-12-02  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-02  8:48 arm gcc help in programming abhilash abraham
2009-12-02  9:44 ` Andrew Haley

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