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

>> convert to RR not RRC

Hi,

I need to put a statement in a interrupt routine to shift a variable right one-bit. Like this:

dat >>=1;

It generated assembly code like this:

MOV A,dat
CLR C
RRC A
MOV dat,A

What statement in C language sould be written to complete the shift operation but not effect the "C,carry" bit?

This is to save the "PUSH PSW", "POP PSW" instruction in my ISR. The inline assembly statement is not good to me, since I am not familar with it.

Thanks, John

Parents
  • I'm forced to find a way to save the time as more as I can.

    In that case, you'll have to dive into assembly.

    The compiler does several things that usually don't mix well with tight timing constraints in interrupts.

    For example, it always locates the ISR somewhere in program memory, and performs a LJMP from the interrupt vector table to the start address of the ISR, even though there are 8 bytes available in the vector table that can hold a complete (yet short) interrupt service routine.

Reply
  • I'm forced to find a way to save the time as more as I can.

    In that case, you'll have to dive into assembly.

    The compiler does several things that usually don't mix well with tight timing constraints in interrupts.

    For example, it always locates the ISR somewhere in program memory, and performs a LJMP from the interrupt vector table to the start address of the ISR, even though there are 8 bytes available in the vector table that can hold a complete (yet short) interrupt service routine.

Children