使用单片机汇编语言设计的双按键流水灯,按下开关K2,灯从D8到D1依次亮。按下开关K1,全部灯同时闪烁。已用proteus仿真。
ORG 0000H
AJMP START
ORG 0003H
AJMP INTR0
ORG 0013H
AJMP INTR1
START:MOV IE,#85H
MOV IP,#01H
MOV TCON,#00H
MOV SP,#60H
MOV P0,#0FFH
MOV P3,#0FFH
MOV A,#0FEH
LP1:MOV P0,A
RL A
LCALL DELAY
SJMP LP1
INTR0:PUSH ACC
PUSH PSW
MOV R1,#10
MOV A,#00H
XH: MOV P0,A
LCALL DELAY
CPL A
DJNZ R1,XH
POP PSW
POP ACC
RETI
INTR1:PUSH ACC
PUSH PSW
MOV A,#7FH
MOV R2,#16
XH1:MOV P0,A
LCALL DELAY
RR A
DJNZ R2,XH1
POP PSW
POP ACC
RETI
DELAY: MOV R7,#20
DELAY1:MOV R6,#20
DELAY2:MOV R5,#248
DJNZ R5,$