cmp stop,0
mov al,00h
mov dx,portb4
out dx,al
skip: cmp sec,60
jl exit
mov sec,0
inc min
cmp min,60
jl exit
mov min,0
mov al,0ffh
mov dx,portb4
out dx,al
inc hour
cmp hour,24
jl exit
mov hour,0
exit:mov al,00100000b; 中断结束EOI
mov dx,3a0h
out dx,al
pop dx
pop cx
pop bx
pop ax
iret
interupt endp
DELY proc
PUSH CX
MOV CX,0ffffH
LOOP $
POP CX
REt
dely endp
;//////////////////////////////////////////////////////////////////////////键盘
input proc
push ax
push bx
push cx
push dx
wt1:
MOV AL,00H
MOV DX,PORT2
OUT DX,AL ;使数码管全灭的同时,列线输出0判断是否有键按下
MOV DX,PORT2
IN AL,DX ;是否有键按下
NOT AL
AND AL,0FH
JNZ lk11 ;有,转
JMP wt1 ;无键,继续查询等待
lk11:
CALL DELY
MOV AL,00H
MOV DX,PORT2
OUT DX,AL
;再次确认是否有键按下
MOV DX,PORT2
IN AL,DX
NOT AL
AND AL,0FH
JZ wt1
MOV CL,00H ;有键,识别按键,CL为列计数器
MOV BL,0feH ;第0列
lk44: MOV AL,BL
MOV DX,PORT2
OUT DX,AL
MOV DX,PORT2
IN AL,DX
NOT AL
AND AL,0FH ;结果为行值
JNZ KEYDOWN1 ;此列有键按下,计算键值
next1: INC CL ;扫描下一列
TEST BL,08H
JZ wt1
ROL BL,1
JMP lk44
KEYDOWN1:
MOV BX,0 ;BX为行计数器,判断哪一行有按键
CMPROW1:CMP AL,ROW[BX]
JZ KEY1
INC BX
JMP CMPROW1
KEY1: IMUL BX,3
mov ah,0
ADD CL,BL
mov al,cl
mov time,ax
pop dx
pop cx
pop bx
pop ax
ret
input endp
CODE ENDS
END beg