Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/12/03 15:19
Read: times


 
#52488 - RE: update pins on a port on the byte level
Responding to: ???'s previous message
Using this shadow register method compiles down nicely, usually to around 6 instructions, depending on whether "val" and "mask" are constant integers (i.e., literal, not const integer) or variables. From my previous example, the line PORT_WR(P2, i, 0x0F) results in:

    MOV  A,P2_OLR
    XRL  A,R7
    ANL  A,#0FH
    XRL  A,P2_OLR
    MOV  P2_OLR,A
    MOV  P2,A

This is using Keil's C51, with a different compiler YMMV, so check the compiler output to learn which way is more efficient (if you care), the AND-XOR method or the AND-CPL-OR method of updating the shadow register. The nice thing about preprocessor macros is that you can change the macro body in one place only.


List of 11 messages in thread
TopicAuthorDate
update pins on a port on the byte level            01/01/70 00:00      
   RE: update pins on a port on the byte level            01/01/70 00:00      
   RE: update pins on a port on the byte level            01/01/70 00:00      
      RE: update pins on a port on the byte level            01/01/70 00:00      
      RE: update pins on a port on the byte level            01/01/70 00:00      
         RE: update pins on a port on the byte level            01/01/70 00:00      
            RE: update pins on a port on the byte level            01/01/70 00:00      
               RE: update pins on a port on the byte level            01/01/70 00:00      
   RE: update pins on a port on the byte level            01/01/70 00:00      
   RE: update pins on a port on the byte level            01/01/70 00:00      
   RE: update pins on a port on the byte level            01/01/70 00:00      

Back to Subject List