arm gcc help in programming

Andrew Haley aph@redhat.com
Wed Dec 2 09:44:00 GMT 2009


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.



More information about the Gcc-help mailing list