Hello Jean-Michel. As far as I understand you need I can see two ways to do it. 1. You only need to shift single one register. rlf byte1,W ;get new bit from carry xorwf byte1,W ;get difference andlw B'00011111' ;0's will mask unchanged bits xorwf byte1,F ;update only required bits 2. You need to shift in such way through many registers. rlf byte1,W ;get new bit from carry andlw B'00111111' ;mask msb's but last addlw B'11100000' ;copy last to carry xorwf byte1,W andlw B'00011111' ;see explanation of xorwf byte1,F ;this in example above ;then ; rlf byte2,W andlw B'00111111' addlw B'11100000' ; ;and so on as many bytes as you need ;) WBR Dmitry. > I need to shift a 5 bit number in, through and out of a byte using bit0 to > bit4 and not affect bit5 - bit7. > > The best way I can think of an example is if you had two 8 bit wide > registers next to each other like the following. The 5 bit value in byte 2 > is shifted left throughout byte 1 and out. > > byte1 byte2 > > XXX00000 xxx11111 start state > XXX00001 xxx11110 > XXX00011 xxx11100 > XXX00111 xxx11000 > XXX01111 xxx10000 > XXX11111 xxx00000 > XXX11110 xxx00000 > XXX11100 xxx00000 > XXX11000 xxx00000 > XXX10000 xxx00000 > XXX00000 xxx00000 end state > > Only byte 1 is important, byte 2 is just for my example. > > X = can not be changed, x = not used -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.