STSWAP EQU 30H ; Holds LED condition
ORG 0H
SJMP START ; Always make room
START: MOV A,#0 ; P2 output
MOV P2,A
MOV A,#0FFH ; P1 input
MOV P1,A
MOV A,#0FH ;
MOV STSWAP,A ; Set first LED condition
MAIN: MOV A,P1 ; Check switches
CLR C ; Clear carry BEFORE sub
SUBB A,#255 ; If all switches OK it will be zero
JNZ ON
MOV A,#18H ; Not in alarm
MOV P2,A ; Display
SJMP MAIN ; Go again..
ON: MOV A,STSWAP ; In alarm
MOV P2,A ; Display
SWAP A ; Change LED condition for next sweep
MOV STSWAP,A
CALL SDELAY ; Wait to view
JMP MAIN ; Go again..
DELAY: MOV R3,#15
OUTER: MOV R2,#240
INNER: DJNZ R2,INNER
DJNZ R3,OUTER
RET
SDELAY: MOV R5,#5
H3: MOV R4,#242
H2: MOV R3,#255
H1: DJNZ R3,H1
DJNZ R4,H2
DJNZ R5,H3
RET
END