Carter Brock wrote: > The problem is I have 76 bits in 8 consecutive bytes that have been > interleaved in the following pattern: It's real big problem because 76 bits overflow 8 bytes ;) I think you are talk about 9.5 bytes ? > (1,20,39,58,2,21,40,59....) So you have sequence above and you need to rearrange it to 1,2,3,4,5,....,73,74,75,76 ? I think it will be easy read bit by bit sequency from input to fill 4 3-bytes arrays like example below . ; bytes A0 | A1 | A2 = x,x,x,x,x,1,2,3 | 4,5,6,7,8,9,10,11 | 12,13,14,15,16,17,18,19 ; B0 | B1 | B2 = x,x,x,x,x,20,21,22 | 23,24,25,26,27,28,29,30 | 31,32,33,34,35,36,37,38 ; C0 | C1 | C2 = x,x,x,x,x,39,40,41 | 42,43,44,45,46,47,48,49 | 50,51,52,53,54,55,56,57 ; D0 | D1 | D2 = x,x,x,x,x,58,59,60 | 61,62,63,64,65,66,67,68 | 69,70,71,72,73,74,75,76 ;Let suppose you read from port PORT from input pin with number IN_BIT PORT EQU PORTC IN_BIT EQU 5 ;PORTC.5 MOVLW D'19' MOVWF COUNT READ_LOOP: MOVFW PORT,IN_BIT ;copy IN_BIT to Carry ANDLW (1< Now if there was such an animal in the PIC world as a bit array, code that > looked something like this would do it: > > for (i=0;i<20,i++) { > for(j=0;j<3;j++) { > deinterleaved_array[k++]=interleaved_array[(j*19)+i]; ????? ^^^^ deinterleaved_array[k++]=interleaved_array[(j*4)+i]; > } > } > > Any suggestions on the best way of testing, setting and clearing bits in an > array of bytes? > > TIA, > > Carter Brock WBR Dmitry.