I am using a 12C509 to read four switches. I have /MCLR enabled so that GP3 is not an input. I also have GP0 as an output and I am running off of the internal R/C oscillator (freeing up GP4,5). Thus I have GP1,2,4,5 as inputs reading the switches. I want to take the four inputs and place them in the high nybble of W so that: GP1 = Bit4 = Switch A GP2 = Bit5 = Switch B GP4 = Bit6 = Switch C GP5 = Bit7 = Switch D Here's what I wrote: ; READ THE SWITCHES MOVF GPIO,W ; W = 00DC0BA0 ; ; SHIFT BITS TO ALIGN WITH THE HIGH NYBBLE BTFSC W,5 ; is GP5 (pin 2) HI? BSF W,7 ; if it is, then Bit7=HI BTFSC W,4 ; is GP4 (pin 3) HI? BSF W,6 ; if it is, then Bit6=HI ANDLW 0x0C6 ; W = DC000BA0 BTFSC W,2 ; is GP2 (pin 5) HI? BSF W,5 ; if it is, then Bit5=HI BTFSC W,1 ; is GP1 (pin 6) HI? BSF W,4 ; if it is, then Bit4=HI ; W = DCBA0BA0 ; ; MASK OFF LOW NYBBLE ANDLW 0x0F0 ; W = DCBA0000 It looks right to me but I am getting flakey results and I am suspicious of the bit manipulation. It is late Sunday night in California and of course I have a demo in twelve hours... Can anyone see a flaw here? Is there a better way of shifting the bits? My read of the datasheet says that bits 0,3,6,7 of GPIO (all non-inputs) should read as 0's right? I mean I don't need an ANDLW 0x036 after the read of GPIO or something? Any help appreciated, Michael * TAKE THE '.NOSPAM' OUT OF MY ADDRESS TO REPLY ********************************************** Outside of a dog, a book is man's best friend. Inside of a dog, it's too hard to read anyway! Groucho Marx **********************************************