Simple question...I hope. How do I access a function local variable with the inline assembler using ldw?
Example of the code below:
Code: Select all
long nGlobalVar ;
void MyFunction (int a)
{
    int b ;
    // This is global access
    asm("ldw r0, dp[nGlobalVar]") ;
   
    // How do I correctly do local access?
    // This will not compile correctly
    asm("ldw r0, sp[a]") ;
   
    // I can get the following to work, and avoid
    // the clobber registers, but I really want to simply
    // use a syntax similar to the line above
    asm("add r0, %0, 0" : : "r"(a) : "r0","r1","r2") ;
    // The above code will expand to 
    //     ldw r11, sp[1]
    //     add r0, r11, 0
    // I want tight code    : (
}