Tony I did not expect to get a response so fast, thanks. However the code that you supplied executed in exactly the same way as my original code. It seems that when I rrf the a register the first bit is sent to the carry. When the instruction comes around a second time it again shifts the first bit into the carry instead of the second bit. Scott Tony Nixon wrote: > Scott wrote: > > > > I want to use portA to read two switches for one project and four > > switches for another. How do I make each bit rotate through the carry > > flag consecutivly. I have been using the following code, but it only > > reads the first bit. I am using a 16c56 > > > > movlw 0x0F > > tris PORTA > > movlw 0x00 > > tris PORTB > > > > input bcf STATUS, C > > rrf PORTA, W > > btfsc STATUS, C > > goto code_1 > > rrf PORTA, W > > btfsc STATUS, C > > goto code_2 > > goto input > > > > I was able to write the rest of this program and simulate it with > > success and I have been stareing at this part for four hours with no > > luck. > > > > Scott > > Try this > > input movf portA,w > movwf Temp > rrf Temp > btfsc status,C > goto code_1 > rrf Temp > btfsc status,C > goto code_2 > > etc.... > goto input > > You don't need to preclear the carry bit because it will be overwritten > on the first rrf instruction anyway. > > -- > Best regards > > Tony > > http://www.picnpoke.com > Email sales@picnpoke.com