谁有时间帮我加个注释啊 呵呵 看了很久 看不太懂 ORG 0000H
AJMP MAIN
ORG 000BH
LJMP CONT
ORG 0100H
SECBIT EQU 08H
MINBIT EQU 09H
HOURBIT EQU 0AH
ASECBIT EQU 0BH
AMINBIT EQU 0CH
AHOURBIT EQU 0DH
DISP0 EQU 30H
DISP1 EQU 31H
DISP2 EQU 32H
DISP3 EQU 33H
DISP4 EQU 34H
DISP5 EQU 35H
TDATA EQU 36H
ATDATA EQU 37H
HOUR EQU 3CH
MIN EQU 3DH
SEC EQU 3EH
MSEC EQU 3FH
AHOUR EQU 40H
AMIN EQU 41H
ASEC EQU 42H
F1 BIT PSW.1
MAIN:MOV SP,#60H ;主程序初始化
MOV P3,#0FFH
MOV R7,#13H
MOV R0,#30H
CLR A
LOOP:MOV @R0,A
INC R0
DJNZ R7,LOOP
MOV 21H,#00H
CLR F1
MOV TMOD,#01H
MOV TL0,#0B0H
MOV TH0,#3CH
SETB TR0
SETB EA
SETB ET0
MOV B,#HOUR
BEGIN:LCALL KS
JNZ RTEST
LCALL DISPLAY
JNB F1,BEGIN
LCALL ALARM
AJMP BEGIN
RTEST:LCALL DISPLAY
LCALL KS
JZ BEGIN
LCALL SERCH
CJNE A,#00H,N1 ;五个功能键,第一个是设置时钟
LCALL PR0
AJMP BEGIN
N1:CJNE A,#01H,N2 ;是设置闹钟键
LCALL PR1
AJMP BEGIN
N2:CJNE A,#02H,N3 ;是加一功能键
LCALL PR2
AJMP BEGIN
N3:CJNE A,#03H,N4 ;是确定按钮吗?
LCALL PR3
AJMP BEGIN
N4:CJNE A,#04H,N5 ;是清闹钟到时的二极管
LCALL PR4
N5:SJMP BEGIN
--------------------------------------------------------------------------------
DISPLAY:PUSH PSW ;显示子程序
PUSH ACC
SETB RS0
MOV R0,#DISP0
MOV R7,#03H MOV R1,B SEPA1:MOV A,@R1 ; 拆字子程序 LCALL SEPA INC R1 DJNZ R7,SEPA1 MOV R0,#DISP0 MOV R7,#06H MOV R6,#20H MOV R5,#00H DISP:MOV DPTR,#TAB MOV A,@R0 MOVC A,@A+DPTR MOV P0,A MOV A,R6 MOV P2,A SETB P2.7 HERE:DJNZ R5,HERE HERE1:DJNZ R5,HERE1 RR A MOV R6,A INC R0 DJNZ R7,DISP CLR RS0 POP ACC POP PSW RET SEPA:MOV 44H,A ANL A,#0F0H SWAP A MOV @R0,A INC R0 MOV A,44H ANL A,#0FH MOV @R0,A INC R0 RET
--------------------------------------------------------------------------------
TAB:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
--------------------------------------------------------------------------------
ALARM:MOV A,ASEC ;闹钟判别程序 CJNE A,SEC,DONT MOV A,AMIN CJNE A,MIN,DONT MOV A,AHOUR CJNE A,HOUR,DONT CLR P1.0 CLR F1 DONT:RET
--------------------------------------------------------------------------------
KS:MOV A,P3 ;键盘测试程序 CPL A ANL A,#1FH RET
--------------------------------------------------------------------------------
SERCH:JNB ACC.0,L1 ;寻找键值 MOV A,#00H AJMP NEXT L1:JNB ACC.1,L2 MOV A,#01H AJMP NEXT L2:JNB ACC.2,L3 MOV A,#02H AJMP NEXT L3:JNB ACC.3,L4 MOV A,#03H AJMP NEXT L4:JNB ACC.4,BACK MOV A,#04H NEXT:PUSH ACC LK:LCALL KS ACALL DISPLAY JNZ LK LCALL KS JNZ LK POP ACC RET
--------------------------------------------------------------------------------
BACK:AJMP BEGIN PR0: CLR TR0 ;功能子程序 CLR ASECBIT CLR AMINBIT CLR AHOURBIT MOV B,#HOUR MOV ATDATA,#00H SETB SECBIT RET
--------------------------------------------------------------------------------
PR1: CLR SECBIT CLR MINBIT CLR HOURBIT MOV B,#AHOUR MOV TDATA,#00H SETB ASECBIT RET
--------------------------------------------------------------------------------
PR2: JNB SECBIT,CUM0 MOV A,SEC ADD A,#01H DA A MOV SEC,A CJNE A,#60H,CUMEND MOV SEC,#00H LJMP CUMEND CUM0:JNB MINBIT,CUM1 MOV A,MIN ADD A,#01H DA A MOV MIN,A CJNE A,#60H,CUMEND MOV MIN,#00H LJMP CUMEND CUM1:JNB HOURBIT,CUM2 MOV A,HOUR ADD A,#01H DA A MOV HOUR,A CJNE A,#24H,CUMEND MOV HOUR,#00H LJMP CUMEND CUM2:JNB ASECBIT,CUM3 MOV A,ASEC ADD A,#01H DA A MOV ASEC,A CJNE A,#60H,CUMEND MOV ASEC,#00H LJMP CUMEND CUM3:JNB AMINBIT,CUM4 MOV A,AMIN ADD A,#01H DA A MOV AMIN,A CJNE A,#60H,CUMEND MOV AMIN,#00H LJMP CUMEND CUM4:JNB AHOURBIT,CUMEND MOV A,AHOUR ADD A,#01H DA A MOV AHOUR,A CJNE A,#24H,CUMEND MOV AHOUR,#00H LJMP CUMEND CUMEND:RET
--------------------------------------------------------------------------------
PR3:JB TR0,PPR3 INC TDATA MOV A,TDATA CJNE A,#01H,TWO1 CLR SECBIT SETB MINBIT LJMP BK0 TWO1:CJNE A,#02H,BK1 CLR MINBIT SETB HOURBIT LJMP BK0 BK1:MOV TDATA,#00H CLR HOURBIT SETB TR0 LJMP BK0 PPR3:INC ATDATA MOV A,ATDATA CJNE A,#01H,TWO2 CLR ASECBIT SETB AMINBIT LJMP BK0 TWO2:CJNE A,#02H,BK2 CLR AMINBIT SETB AHOURBIT LJMP BK0 BK2:MOV ATDATA,#00H CLR AHOURBIT SETB F1 MOV B,#HOUR BK0:RET
--------------------------------------------------------------------------------
PR4:SETB P1.0 CLR F1 RET
--------------------------------------------------------------------------------
CONT:MOV TL0,#0B7H ;中断服务程序,即秒修改程序 MOV TH0,#3CH PUSH PSW PUSH ACC INC MSEC MOV A,MSEC CJNE A,#13H,DONE MOV MSEC,#00H MOV A,SEC ADD A,#01H DA A MOV SEC,A CJNE A,#60H,DONE MOV SEC,#00H MOV A,MIN ADD A,#01H DA A MOV MIN,A CJNE A,#60H,DONE MOV MIN,#00H MOV A,HOUR ADD A,#01H DA A MOV HOUR,A CJNE A,#24H,DONE MOV HOUR,#00H DONE:POP ACC POP PSW RETI END
|