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

rewriting _crol_ as inline assembly

This line:

thresBits = _crol_(thresBits, 2);


generates this SRC:

   MOV     R7,thresBits?1282
        MOV     R0,#02H
        MOV     A,R7
        INC     R0
        SJMP    ?C0198
?C0197:
        RL      A
?C0198:
        DJNZ    R0,?C0197
        MOV     thresBits?1282,A

I have added a "#pragma asm" to manually change the assembly to this:

#pragma asm
          MOV A, thresBits
          RL    A               ;rotate once
          RL    A               ;rotate the 2nd time
          MOV thresBits, A
#pragma endasm


but I get "error A45: UNDEFINED SYMBOL". How do I access the local C thresBits variable in my inline assembly code?

Parents
  • Thanks for your answers guys. I did consider pushing that snippet into a function, but if I did that, I think the code would take about as long as the library code.

    I've ended up reverting to the library code, as it's a bit more of a hassle to debug using the SRC file.

    My request wasn't so much of a necessity as a inquiry into what was possible with Keil and inline assembly, and also how to go about it.

    That line of code is part of a loop in a much larger time-critical function, but I've optimised other parts such that the difference between compiler generated code and my assembly didn't really matter for that particular line.

Reply
  • Thanks for your answers guys. I did consider pushing that snippet into a function, but if I did that, I think the code would take about as long as the library code.

    I've ended up reverting to the library code, as it's a bit more of a hassle to debug using the SRC file.

    My request wasn't so much of a necessity as a inquiry into what was possible with Keil and inline assembly, and also how to go about it.

    That line of code is part of a loop in a much larger time-critical function, but I've optimised other parts such that the difference between compiler generated code and my assembly didn't really matter for that particular line.

Children