This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to access local variable in C51 inline-assembly

For efficiency,i have to use inline assembly in my code, but I failed to access local variables
My code is something like this:

void func(void)
{
       unsigned int i;
       i=0;

        #pragma asm
        MOV A,i
        #pragma endasm

}

but i get a error : error A45: UNDEFINED SYMBOL (PASS-2)

So i there and way to solve this problem

Parents
  • I know what you mean, but the truth is :

    R1 = (bit)(*buffer1 & i);
    

    will generate code like this

    MOV      A,0x08
    ANL      A,R5
    
    MOV      R7,A
    MOV      A,R7
    
    ADD      A,#0xFF
    MOV      R1(0xA0.1),C
    

    I know KEIL always generate codes better than me most of time.but this ,i'm really confused about the redundant two instructions

    
    MOV      R7,A
    MOV      A,R7
    
    

    I want to elimate this two instruction, so that's why i need to use inline assembly.

Reply
  • I know what you mean, but the truth is :

    R1 = (bit)(*buffer1 & i);
    

    will generate code like this

    MOV      A,0x08
    ANL      A,R5
    
    MOV      R7,A
    MOV      A,R7
    
    ADD      A,#0xFF
    MOV      R1(0xA0.1),C
    

    I know KEIL always generate codes better than me most of time.but this ,i'm really confused about the redundant two instructions

    
    MOV      R7,A
    MOV      A,R7
    
    

    I want to elimate this two instruction, so that's why i need to use inline assembly.

Children