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

Write R7 register directly from C

I use KeilC uVision4 for 89C51 MCU.
By "Inline ASM", i can easily direct write value to R7 register, like this :

    #pragma ASM
        MOV R7, #10
    #pragma ENDASM


But now, there are some reason that i have to write to R7 register direct from C (not from inline ASM), eg:

    R7 = 10;


Of course, the C compiler does not understand R7 as MCU Register (not Inline ASM).

-> Is there anyway to solve this problem. Please help me if anyone know, thanks a lot !

Parents
  • When it comes to programming, there is not always a clear right or wrong.

    However, some methods have clear advantages and some clear disadvantages. I can see no advantage in what you're trying to do - And I think others here would concur. It is simply cumbersome and potentially error prone.

    A piece of complicated looking code does not mean that author is a genius. On the contrary, quite often it is the simple elegant pieces of code that are written by the smarter people.

    There's nothing much simpler than a software delay loop - Why try to complicate it?

Reply
  • When it comes to programming, there is not always a clear right or wrong.

    However, some methods have clear advantages and some clear disadvantages. I can see no advantage in what you're trying to do - And I think others here would concur. It is simply cumbersome and potentially error prone.

    A piece of complicated looking code does not mean that author is a genius. On the contrary, quite often it is the simple elegant pieces of code that are written by the smarter people.

    There's nothing much simpler than a software delay loop - Why try to complicate it?

Children