用汇编语言编一道题。
按下按键S1后,开始倒计时
按下按键S2后,停止运行
按下按键S3后,数码管十位加1,从0-9循环
按下按键S4后,数码管个位加1,从0-9循环
计时计到0,重新计时。 展开
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TH0,#HIGH(65536-10000)
MOV TL0,#LOW(65536-10000)
SETB ET0
SETB EA
MOV R0,#9
MOV R1,#9
MOV R2,#0
MOV R3,#9
CLR 00H
CLR 01H
LOOP:
JB P1.0,LP01
JNB P1.0,$
SETB TR0
CLR 01H
SJMP LOOP0
LP01:
JB P1.1,LP02
JNB P1.1,$
SETB 01H
SJMP LOOP0
LP02:
JB P1.2,LP03
JNB P1.2,$
SETB 01H
INC R0
CJNE R0,#10,LOOP0
MOV R0,#0
SJMP LOOP0
LP03:
JB P1.3,LOOP0
JNB P1.3,$
SETB 01H
INC R1
CJNE R1,#10,LOOP0
MOV R1,#0
LOOP0:
JB 00H,LOOP1
MOV A,R0
SJMP LOOP2
LOOP1:
MOV A,R1
LOOP2:
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV R3,A
SJMP LOOP
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-10000)
MOV TL0,#LOW(65536-10000)
SETB TR0
JB 01H,T0C
INC R2
T0C:
CPL 00H
MOV A,R3
JB 00H,T001
MOV P3,#0FDH
MOV P2,A
SJMP T002
T001:
MOV P3,#0FEH
MOV P2,A
T002:
MOV A,R2
CJNE A,#100,T0E
MOV R2,#0
MOV A,R0
JZ T003
DEC R0
SJMP T0E
T003:
MOV A,R1
JZ T004
DEC R1
MOV R0,#9
T0E:
RETI
T004:
CLR TR0
RETI
TABLE: ; 共阴极数码管显示代码表
DB 3FH,06H,5BH,4FH,66H ;01234
DB 6DH,7DH,07H,7FH,6FH ;56789
END