At 07:36 PM 5/1/2014, John J. McDonough wrote: >I'm kind of surprised nobody compared the generated code. The code >produced by XC16 is identical: > > if ( myBits & 0x0002 ) > myTestWord =3D 87; > > if (myBitfield.b1) > myTestWord =3D 83; > >I would argue that the mask code is only clearer if 1) You are doing=20 >some bogus example like this or 2) You are an assembler programmer > >With the bitfield you can give the bits names, so for example you could >say something like: > > if ( LCDstatus.LCDisBusy ) > > rather than > > if ( LCDstatus & 0b0000000000100000 ) This has been an informative thread for me. I'm a diehard assembler=20 programmer and my brain simply refuses to grok "C". But I keep=20 poking at it, hoping that the AH HA moment will occur. One of the many things I learned from PIC assembler guru Andrew=20 Warren was to define all of my bit fields with names that are used=20 later in my program. Your example above would be done as: #define LCDisBusy LCDstatus,1 where LCDstatus has previously been defined in exactly the same=20 way. In use, I simply reference the defined name: btfsc LCDisBusy do something One of the things that really bugs me about C programs is that there=20 didn't appear to be any easy way to do this simple function. This=20 thread has shown me that there is something relatively close. Many thanks! dwayne --=20 Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax www.trinity-electronics.com Custom Electronics Design and Manufacturing --=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 .