-----Original Message----- >From: Josh Koffman >Sent: Mar 11, 2015 11:28 PM >To: "Microcontroller discussion list - Public." >Subject: Re: [PIC] Setting Multiple Bits in C > >On Wed, Mar 11, 2015 at 11:21 PM, Lyle Hazelwood wrot= e: >> If you want to set both bits, only the OR operand is needed. >> >> If you want to clear the bits, only the AND operator is needed. >> >> If the target bits may be going either way, then you're right on track >> with your examples. > >Hi Lyle, > >I wasn't very clear in my original question. I'm assuming an unknown >initial state of "target" and an unknown modification. I'll be looking >values up in a table to modify the target. Hopefully. > If you have the space, why not put all eight bits in the table? or Would if be easier to read if you combine your mask and value into one vari= able then AND that with "target"? or define "target" with bit fields and set the field equal to value? http://en.wikipedia.org/wiki/Bit_field >Josh >--=20 >A common mistake that people make when trying to design something >completely foolproof is to underestimate the ingenuity of complete >fools. > -Douglas Adams >--=20 >http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .