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

bitwise operation

hello,
i m implementing a pc keyboard logic.
pc keboard signals are transmitted serially to port pin.
i want to know how to do bitwise shifting in 'c' for reception as well as for transmission to get the data present on port pin.
i did it in assembly using RRC A.
can i used accumulator and carry flag directly in 'c'?
my code is proper but i hav problem in data management
thank u all.

Parents
  • Keil C51 has intrinsic library functions for rotate. See _crol_, _cror_, _iror/l_, _lror/l_.

    Take another look at your 8051 architecture manual. Port pins are generally bit-addressable. (SFRs whose addresses end in x0 or x8 are bit-addressable.) You can test and set the bits directly, without having to rotate a byte into the carry. Instead of doing a rotate, branch if carry, simply do an "if (bit)".

    It's possible, but unwise, to directly access CPU registers such as the ACC or CY from C. The code generator allocates and uses those registers for its own purposes, and you have no guarantees on its behavior. Even if you peek at the generated code, there's no assurance the pattern will remain exactly the same in the next version of the compiler, or even if you change the source.

    On the bright side, you generally don't need to access those registers from C anyway.

Reply
  • Keil C51 has intrinsic library functions for rotate. See _crol_, _cror_, _iror/l_, _lror/l_.

    Take another look at your 8051 architecture manual. Port pins are generally bit-addressable. (SFRs whose addresses end in x0 or x8 are bit-addressable.) You can test and set the bits directly, without having to rotate a byte into the carry. Instead of doing a rotate, branch if carry, simply do an "if (bit)".

    It's possible, but unwise, to directly access CPU registers such as the ACC or CY from C. The code generator allocates and uses those registers for its own purposes, and you have no guarantees on its behavior. Even if you peek at the generated code, there's no assurance the pattern will remain exactly the same in the next version of the compiler, or even if you change the source.

    On the bright side, you generally don't need to access those registers from C anyway.

Children
No data