哪位懂行的大哥能否帮小弟解释下下面这个电子时钟的程序
哪位懂行的大哥能否帮小弟解释下下面这个电子时钟的程序:使用SW1-SW6键盘分别设定时,分,秒,按键时伴有提示音!
BUFF_KEY EQU 21H ;键盘键
BUFF_LED1 EQU 22H ;数码管显示缓存
BUFF_LED2 EQU 23H
BUFF_LED3 EQU 24H
BUFF_LED4 EQU 25H
BUFF_LED5 EQU 26H
BUFF_LED6 EQU 27H
BUFF_LED_LP EQU 28H ;T0键盘显示扫描缓存
HOR EQU 30H ;小时值缓存
MIN EQU 31H ;分钟值缓存
SEC EQU 32H ;秒值缓存
F_BEEP BIT 01H
LED_PORT EQU P0
DIG_PORT EQU P2
KEY_PORT EQU P2
SW1 BIT P2.7
SW2 BIT P2.6
SW3 BIT P2.5
SW4 BIT P2.4
SW5 BIT P2.3
SW6 BIT P2.2
BEEP BIT P2.0
KEY BIT P3.3
org 000h
JMP main
ORG 00BH
JMP T0_INT
ORG 100H
MAIN: MOV SP ,#40H
MOV PSW,#00H
MOV R0,#7FH ;初始化RAM区,
CLR_RAM:MOV A,#00H
MOV @R0,A
DJNZ R0,CLR_RAM
MOV P1,0FFH ;INIT
MOV P2,0FFH
MOV P0,0FFH
MOV P3,0FFH
MOV TMOD,#21h
MOV TH0,#240 ;T0=4MS
MOV TL0,#96
SETB TR0
SETB ET0
SETB EA
WAIT_KEY:JB KEY,$ ;等候按键!
JNB SW1,SW1_OK
JNB SW2,SW2_OK
JNB SW3,SW3_OK
JNB SW4,SW4_OK
JNB SW5,SW5_OKA
JNB SW6,SW6_OKA
JMP WAIT_KEY
SW5_OKA: JMP SW5_OK
SW6_OKA: JMP SW6_OK
SW1_OK: MOV A,HOR
CJNE A,#24,SW1_OVER
MOV HOR,#00H
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW1_OVER:INC HOR ;时加1
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW2_OK: MOV A,HOR
CJNE A,#00,SW2_OVER
MOV HOR,#23
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW2_OVER:DEC HOR ;时减1
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
JMP WAIT_KEY
SW3_OK: MOV A,MIN
CJNE A,#59,SW3_OVER
MOV MIN,#00H
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW3_OVER:INC MIN ;分加1
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW4_OK: MOV A,MIN
CJNE A,#00,SW4_OVER
MOV MIN,#59
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW4_OVER:DEC MIN ;分减1
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW5_OK: MOV A,SEC
CJNE A,#59,SW5_OVER
MOV SEC,#00H
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW5_OVER:INC SEC ;秒加1
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW6_OK: MOV A,SEC
CJNE A,#00,SW6_OVER
MOV HOR,#59
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
SW6_OVER:DEC SEC ;时减1
SETB F_BEEP
CLR BEEP
LCALL DEL
SETB BEEP
CLR F_BEEP
JMP WAIT_KEY
DEL: MOV R5,#02 ;为演示方便,人为插入的延时
DEL01: MOV R6,#200
DEL02: MOV R7,#200
DJNZ R7,$
DJNZ R6,DEL02
DJNZ R5,DEL01
RET
BIN_BCD: MOV B,#10
DIV AB
RET
;------------- T0 INTRRUPT 数码管扫描定时中断---------------------------
T0_INT: PUSH ACC
PUSH PSW
MOV TH0,#240 ;T0=4MS
MOV TL0,#96
INC BUFF_LED_LP
MOV A,BUFF_LED_LP
CJNE A,#250,CONT_SCAN ;250*4MS=1S
MOV BUFF_LED_LP,#00H
INC SEC
MOV A,SEC
CJNE A,#60,CONT_SCAN
MOV SEC,#00H
INC MIN
MOV A,MIN
CJNE A,#60,CONT_SCAN
MOV MIN,#00H
INC HOR
MOV A,HOR
CJNE A,#24,CONT_SCAN
MOV HOR,#00H
clr beep
clr p1.0
lcall del
setb beep
setb p1.0
CONT_SCAN:MOV A,SEC
LCALL BIN_BCD
MOV BUFF_LED6,B
MOV BUFF_LED5,A
MOV A,MIN
LCALL BIN_BCD
MOV BUFF_LED4,B
MOV BUFF_LED3,A
MOV A,HOR
LCALL BIN_BCD
MOV BUFF_LED2,B
MOV BUFF_LED1,A
MOV A,BUFF_LED_LP
MOV B,#06
DIV AB
MOV A,B
RL A
MOV DPTR,#TAB_SCAN
JMP @A+DPTR
TAB_SCAN: AJMP SCAN_L1
AJMP SCAN_L2
AJMP SCAN_L3
AJMP SCAN_L4
AJMP SCAN_L5
AJMP SCAN_L6
SCAN_L1: MOV DIG_PORT,#01111111B
MOV A,BUFF_LED1
JMP END_SCAN
SCAN_L2: MOV DIG_PORT,#10111111B
MOV A,BUFF_LED2
JMP END_SCAN
SCAN_L3: MOV DIG_PORT,#11011111B
MOV A,BUFF_LED3
JMP END_SCAN
SCAN_L4: MOV DIG_PORT,#11101111B
MOV A,BUFF_LED4
JMP END_SCAN
SCAN_L5: MOV DIG_PORT,#11110111B
MOV A,BUFF_LED5
JMP END_SCAN
SCAN_L6: MOV DIG_PORT,#11111011B
MOV A,BUFF_LED6
END_SCAN: MOV DPTR,#TAB_LED
MOVC A,@A+DPTR
MOV LED_PORT,A
JNB F_BEEP,EXIT_T0
CLR BEEP
EXIT_T0: POP PSW
POP ACC
RETI
TAB_LED: DB 0C0H,0F9H,0A4H,0B0H,99H,92H ;数码管显示字型表
DB 82H,0F8H,80H,90H,88H,83H,0A7H
DB 0A1H,86H,8EH
END
要是能越详细越好