> -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of PICdude > Sent: 13 February 2012 02:20 > To: piclist@mit.edu > Subject: Re: [PIC] Bit operations in C -- shift? >=20 > Ack!! I meant 70 *BITS* (hence my use of 9 bytes in assembly to hold > the data). I see replies, so will get to them in a couple hours when > I get home. >=20 > Cheers, > -Neil 70 bits is more manageable, but even in this case shifting all those bytes = is inefficient unless you actually NEED to shift them (e.g. some kind of LF= SR). If you simply need to spit these out as a serial stream then using a = bit mask which you shift 8 times and then move onto the next byte makes far= more sense. Something like this should do it, and would be very simple to modify should= you ever need to send a variable number of bits etc. #define BIT_ARRAY_SIZE 70 void ShiftOut( uint8_t *buff ) { uint8_t bitcount =3D BIT_ARRAY_SIZE + 1; uint8_t bitmask =3D 0x01; while( bitcount-- ) { if( bitmask & *buff ) { SendHiBit(); } else { SendLowBit(); } /* Move to next bit to send */ bitmask <<=3D 1; /* If bit mask is zero we need to move to the next byte */ if( bitmask =3D=3D 0 ) { bitmask=3D 0x01; buff++; } } } Cheers Mike =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .