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 always flinch when I see the statement "for efficiency,i have to use inline assembly".

    The truth is that the C51 compiler will generate better code than most assembly programmers. Yes the code routines must be written more general than a tightly defined assembly code but I normally see most coders can't write tight assembly code better than the C51 compiler.

    This seems to be the case because the OP says he MUST use in-line assembly. He appears not to know the best way is to let the compiler generate SRC code and then edit if necessary.

    Bradford

Reply
  • I always flinch when I see the statement "for efficiency,i have to use inline assembly".

    The truth is that the C51 compiler will generate better code than most assembly programmers. Yes the code routines must be written more general than a tightly defined assembly code but I normally see most coders can't write tight assembly code better than the C51 compiler.

    This seems to be the case because the OP says he MUST use in-line assembly. He appears not to know the best way is to let the compiler generate SRC code and then edit if necessary.

    Bradford

Children