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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/15/09 18:18
Modified:
  02/15/09 18:19

Read: times


 
#162440 - Think about it a little bit!
Responding to: ???'s previous message
The instruction set provides the ability to perform bitwise XOR via <XRL A,Rn>. If, then, you have two bits on one of the MCU ports and wish to XOR them, you must isolate those bits. Presumably you know which bits they are. If you wish to operate on bits 4 and 5, then you can load ACC with the content of your port, then save the value in B. Now isolate bit 5 by ANDing ACC with 0x20 (bit 5). Then save the resulting single bit in R2. Then retrieve the saved value in B and, this time, AND with 0x10 (bit 4). Now rotate the bit left one position, and XRL ACC,R2. The result will be the XOR of the two bits. Testing for zero in ACC will give you the result.

There may, of course, be much better and more elegant ways to do this, but this is at least one way. Only a thorough understanding of the resources and instruction set of this MCU will help you to solve your problem. It might be easier to use corresponding bits on different ports, for example. Only you can decide what you need.

RE




List of 12 messages in thread
TopicAuthorDate
How to XOR a single bit (N00B)            01/01/70 00:00      
   Instruction set tells what is available            01/01/70 00:00      
      Code            01/01/70 00:00      
         Think about it a little bit!            01/01/70 00:00      
   CPL bit if XOR with 1; otherwise, don't            01/01/70 00:00      
      wrote this code still not working            01/01/70 00:00      
         Jumping where? And not jumping where?            01/01/70 00:00      
         this might be it            01/01/70 00:00      
         use a compiler first            01/01/70 00:00      
         XOR a bit, quite literally            01/01/70 00:00      
            ... and now, we've done his homework for him ...            01/01/70 00:00      
   schematic            01/01/70 00:00      

Back to Subject List