Problem with increment in inline ARM assembly
        Posted  
        
            by tech74
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by tech74
        
        
        
        Published on 2010-04-25T14:43:28Z
        Indexed on 
            2010/04/25
            15:13 UTC
        
        
        Read the original article
        Hit count: 240
        
Hi , i have the following bit of inline ARM assembly, it works in a debug build but crashes in a release build of iphone sdk 3.1. The problem is the add instructions where i am incrementing the address of the C variables output and x by 4 bytes, this is supposed to increment by the size of a float. I think when i increment at some such stage i am overwriting something, can anyone say which is the best way to handle this
Thanks
C code that the asm is replacing, sum,output and x are all floats
for(int i = 0; i< count; i++)
 sum+= output[i]* (*x++)
 asm volatile(
    ".align 4 \n\t"
    "mov r4,%3    \n\t"  
    "flds s0,[%0]           \n\t"
    "0:                   \n\t"
    "flds s1,[%2]           \n\t"
    //"add %3,%3,#4         \n\t"
    "flds s2,[%1]           \n\t"
    //"add %2,%2,#4         \n\t"
    "subs r4,r4, #1         \n\t"
    "fmacs s0, s1, s2        \n\t"
    "bne 0b                 \n\t"
    "fsts s0,[%0]               \n\t"
    :
    : "r" (&sum), "r" (output), "r" (x),"r" (count)
    : "r0","r4","cc", "memory", 
        "s0","s1","s2"                         
    );
© Stack Overflow or respective owner