> > 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 This is a problem right here. Since you are sending the result to W, only bit 0 of port A will be transferred to the carry bit. > 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. Two ways to solve it: 1. Copy portA to a temp register, then rotate that. 2. Skip the rotate completely and simply poll each bit with a bit test. The reason that a lot of uControllers used rotate for this type of operation ius simply because they couldn't test a bit directly. PIC's can so why not use it. 3. You can mask out the bits in port A you're interested in and loop until a switch is actually pressed. Then do a bit test to figure out which switch was pressed. Just a couple of thoughts. I think PIC's code set has other ways of solving the problem. BAJ