ORG 000H
KS: JB P3.5,$; 测按键
ACALL DELAY; 按键延时去抖动
JB P3.5,KS;再次测按键
JNB P3.5,$; 按键松开否
ACALL DELAY;
MOV A,P1; 读取P口值
ANL A,#001H;取P1.0位
JNZ MD; 测试P1.0口非0否,非零跳至MD点灯
SETB P1.0; 是0关灯
ACALL DELAY2; 延时200毫秒再测按键
SJMP KS
MD: CLR P1.0
ACALL DELAY2; 延时200毫秒再测按键
DELAY: MOV R1,#2
LOOP: MOV R2,#255
DJNZ R2,$
DJNZ R1,LOOP
RET
DELAY2: MOV R3,#2
LOOP3: MOV R4,#36
LOOP2: MOV R5,#255
DJNZ R5,$
DJNZ R4,LOOP2
DJNZ R3,LOOP3
RET
END
|