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 get the C-compiler to use RLC and ACC.x

Hello,

I would like to know if there's any way I can write C code that will use the assembly instructions RLC and ACC.x efficiently. I would like to some C code that will result in:

MOV A,byBuffer
MOV c,bInput
RLC A
MOV byBuffer,A

The closest I could get was this:

byBuffer=(byBuffer<<1)&bInput;

Which results in:

MOV A,byBuffer
ADD A,ACC
MOV R7,A
MOV C,bInput
CLR A
RLC A
ANL A,R7
MOV byBuffer,A

The same thing happens when I want to use a specific bit from a byte. I have never seen the C-compiler use the ACC.x instruction. It uses solutions like this:

MOV A,R6
MOV R0,AR5
INC R0
SJMP ?C0078
?C0077:
CLR C
RLC A
?C0078:
DJNZ R0,?C0077

Any ideas ????

Parents
  • Sorry, forgot to use the pre and /pre....

    //--------------------------------------//

    Hello,

    I would like to know if there's any way I can write C code that will use the assembly instructions RLC and ACC.x efficiently. I would like to some C code that will result in:

    MOV A,byBuffer
    MOV c,bInput
    RLC A
    MOV byBuffer,A
    
    The closest I could get was this:
    byBuffer=(byBuffer<<1)&bInput;
    
    Which results in:
    MOV A,byBuffer
    ADD A,ACC
    MOV R7,A
    MOV C,bInput
    CLR A
    RLC A
    ANL A,R7
    MOV byBuffer,A
    
    The same thing happens when I want to use a specific bit from a byte. I have never seen the C-compiler use the ACC.x instruction. It uses solutions like this:
    MOV A,R6
    MOV R0,AR5
    INC R0
    SJMP ?C0078
    ?C0077:
    CLR C
    RLC A
    ?C0078:
    DJNZ R0,?C0077
    
    Any ideas ????

Reply
  • Sorry, forgot to use the pre and /pre....

    //--------------------------------------//

    Hello,

    I would like to know if there's any way I can write C code that will use the assembly instructions RLC and ACC.x efficiently. I would like to some C code that will result in:

    MOV A,byBuffer
    MOV c,bInput
    RLC A
    MOV byBuffer,A
    
    The closest I could get was this:
    byBuffer=(byBuffer<<1)&bInput;
    
    Which results in:
    MOV A,byBuffer
    ADD A,ACC
    MOV R7,A
    MOV C,bInput
    CLR A
    RLC A
    ANL A,R7
    MOV byBuffer,A
    
    The same thing happens when I want to use a specific bit from a byte. I have never seen the C-compiler use the ACC.x instruction. It uses solutions like this:
    MOV A,R6
    MOV R0,AR5
    INC R0
    SJMP ?C0078
    ?C0077:
    CLR C
    RLC A
    ?C0078:
    DJNZ R0,?C0077
    
    Any ideas ????

Children