John Albers wrote: > I know that I could use the BSF and BSC instructions to selectively > change bits 3-0 on PORTB. You could ... but given that things don't always happen as you want them/ thought they would, this is unwise. > But suppose that I want to use movlw b'????????' followed by movwf > PORTB to set things up. For a port, that is *always* the way you want to do it. > I know that I need movlw b'????1100' but I don't know what to put for > ???? since bits 7-4 are inputs. I have a feeling that I can use > anything for ???? and the PIC will ignore it because bits 7-4 are > inputs. Indeed it will "ignore" it - unless some peculiar glitch occurs and bits 7-4 are suddenly no longer inputs. For which reason you should set up the values that would cause the least trouble if that happened. > In general what happens if anything, when a pin is set for input and a > BSF, BSC, or MOVWF command tries to change the value of that pin to a > 1 or 0? The value you set is set up in the port latch, ready to be the value output should that pin be re-defined as an output at any time. The "gotcha" is that if you use BSF or BCF to do *anything* on the port, then the port latch for every bit *other* than the one you set/ cleared, is set to match whatever the voltage on its particular pin happens to define at that instant. And for outputs, that instantaneous voltage may just be (overloading, inductive "spikes", capacitor on pin) something you didn't bargain for, but is now the "official" output. That's why you *don't* use BSF/ BCF on port registers. -- Cheers, Paul B.