Andreas Nyholm wrote: > > Hi!! > Can anyone tell me what's wrong with this part of my program?? > > ; Wait for doors closed AND doors locked. WAIT2 MOVF PORTA, W ; get port A into W andlw b'00000111' SUBLW B'OOOOO100' BTFSS STATUS,Z ; skip when result is zero GOTO WAIT2 > If W= 00000100 and you 'AND' it with 00000100 the result will be 00000100, not 0. Use AND for masking, the way I did it, is that it will only leave RA0, RA1, RA2 bits in W, then you subtract b'00000100' from it. Zero flag will be SET if the result of the subtract is zero, so you test for set and skip. Hope it helps Quentin