闹钟怎么加进去。闹钟的端口是P3.7~
ORG 0000HAJMP START
ORG 000BH
LJMP INT_0
ORG 001BH
LJMP INT_1
ORG 0100H
START:LCALL QING
MAIN:MOV P3,#0FFH
JNB P3.2,KEY
AJMP MAIN
QING: ;初始化
MOV 7EH,#0 ;时十位
MOV 7DH,#0 ;时个位
MOV 7CH,#0 ;分十位
MOV 7BH,#0 ;分个位
MOV 7AH,#0 ;秒十位
MOV 79H,#0 ;秒个位
MOV 32H,#0 ;秒
MOV 31H,#0 ;分
MOV 30H,#0 ;时
MOV 39H,#20
MOV 40H,#0
MOV 41H,#0
MOV TMOD,#11H
MOV TH0,#3CH
MOV TL0,#0B4H
MOV TH1,#09EH
MOV TL1,#0D0H
SETB TR0
SETB TR1
SETB EA
SETB ET0
SETB ET1
SETB PT0
CLR PT1
RET
INT_0: ;中断0初始化
MOV TH0,#4BH
MOV TL0,#0EAH
DJNZ 39H,EXIT
MOV 39H,#20
MOV A,41H ; 41H控制是否计时
CJNE A,#1,INT_01
INT_01:
INC 30H
MOV A,30H
CJNE A,#60,EXIT
MOV 30H,#0
INC 31H
MOV A,31H
CJNE A,#60,EXIT
MOV 31H,#0
INC 32H
MOV A,32H
CJNE A,#24,EXIT
MOV 32H,#0
EXIT:
RETI
INT_1:
MOV TH1,#9EH ;定时1中断
MOV TL1,#0D0H
INT_13: ;数据转换 “时”“分”“秒”
MOV A,32H
MOV B,#10
DIV AB
MOV 7EH,A
MOV 7DH,B
MOV A,31H
MOV B,#10
DIV AB
MOV 7CH,A
MOV 7BH,B
MOV A,30H
MOV B,#10
DIV AB
MOV 7AH,A
MOV 79H,B
ACALL X1
KEY:JNB P3.2,KEY
MOV 41H,#1
CLR TR0
LJMP KEY1
K3:JNB P3.3,K3
KEY3:JNB P3.4,K2_0
JNB P3.2,SHI_0
AJMP KEY3
SHI_0:JNB P3.2,SHI_0
SHI:JNB P3.3,JIA_SHI
JNB P3.4,JIAN_SHI
JNB P3.2,KEY0
AJMP SHI
JIA_SHI:JNB P3.3,JIA_SHI
INC 32H
MOV R0,32H
CJNE @R0,#24,SHI
MOV 32H,#0
AJMP SHI
JIAN_SHI:JNB P3.4,JIAN_SHI
DEC 32H
MOV R0,32H
CJNE @R0,#-1,SHI
MOV 32H,#23
AJMP SHI
KEY0: JNB P3.2,KEY0
MOV 41H,#0
MOV TH0,#3CH
MOV TL0,#0B4H
SETB TR0
AJMP MAIN
K1: JNB P3.4,K1
KEY1:
JNB P3.3,K2
JNB P3.2,S_0
AJMP KEY1
K2: JNB P3.3,K2
K2_0: JNB P3.4,K2_0
KEY2: JNB P3.3,K3
JNB P3.4,K1
JNB P3.2,F_0
AJMP KEY2
S_0: JNB P3.2,S_0
S: JNB P3.2,KEY0
JNB P3.3,JIA_S
JNB P3.4,JIAN_S
AJMP S
JIA_S:JNB P3.3,JIA_S
INC 30H
MOV R0,30H
CJNE @R0,#61,S
MOV 30H,#0
AJMP S
JIAN_S:JNB P3.4,JIAN_S
DEC 30H
MOV R0,30H
CJNE @R0,#-1,S
MOV 30H,#59
AJMP S
F_0:JNB P3.2,F_0
F: JNB P3.3,JIA_F
JNB P3.4,JIAN_F
JNB P3.2,KEY0
AJMP F
JIA_F:JNB P3.3,JIA_F
INC 31H
MOV R0,31H
CJNE @R0,#60,F
MOV 31H,#0
AJMP F
JIAN_F:JNB P3.4,JIAN_F
DEC 31H
MOV R0,31H
CJNE @R0,#-1,F
MOV 31H,#59
AJMP F
GUAN: ;数码管
MOV DPTR,#TAB
MOV A,79H ; ”秒“ 个位
MOVC A,@A+DPTR
MOV P0,A
MOV P2,#80H
ACALL DELAY
MOV DPTR,#TAB
MOV A,7AH ; ”秒“十位
MOVC A,@A+DPTR
MOV P0,A
MOV P2,#40H
ACALL DELAY
MOV DPTR,#TAB
MOV A,7BH ; ”分“个位
MOVC A,@A+DPTR
MOV P0,A
MOV P2,#20H
ACALL DELAY
MOV DPTR,#TAB
MOV A,7CH ; ”分“十位
MOVC A,@A+DPTR
MOV P0,A
MOV P2,#10H
ACALL DELAY
MOV P0,#7FH ;小数点
MOV P2,#20H
ACALL DELAY
JNB P3.5,LOOP ;转为” 时分“显示
LJMP EXIT2
LOOP:
JNB P3.5,LOOP
MOV 40H,#1
AJMP EXIT2
DELAY:
MOV R3,#50 ;延时约为50MS
D0:
MOV R2,#50
DJNZ R2,$
DJNZ R3,D0
RET
GUAN_1:
MOV DPTR,#TAB
MOV A,7BH ; ”分“个位
MOVC A,@A+DPTR
MOV P0,A
MOV P2,#80H
ACALL DELAY
MOV DPTR,#TAB
MOV A,7CH ; ”分“十位
MOVC A,@A+DPTR
MOV P0,A
MOV P2,#40H
ACALL DELAY
MOV DPTR,#TAB
MOV A,7DH ;“ 时”个位
MOVC A,@A+DPTR
MOV P0,A
MOV P2,#20H
ACALL DELAY
MOV DPTR,#TAB
MOV A,7EH ; “时“十位
MOVC A,@A+DPTR
MOV P0,A
MOV P2,#10H
ACALL DELAY
MOV P0,#7FH ;小数点闪烁
MOV P2,#20H
ACALL DELAY
JNB P3.5,LOOP1 ;转为”分秒“显示
LJMP EXIT2
LOOP1:
JNB P3.5,LOOP1
MOV 40H,#0
LJMP EXIT2
EXIT1:
RETI
EXIT2:
RETI
X1: MOV A,40H ;分秒转换
CJNE A,#1,X2
LJMP GUAN_1
X2: LJMP GUAN
RET
TAB: ;数据调用
DB 0C0H ,0F9H ,0A4H ,0B0H ,99H
DB 92H ,82H ,0F8H,80H ,90H
END