汇编高手帮帮忙!急。。。正确的追加50分

设计一个时钟程序,由键盘输入当前时、分、秒值,随即显示时间并不停计时,当有键盘按下时,返回DOS。设计一个程序。

;太长了
code segment
assume cs:code,ds:code
org 100h
start:
push cs
pop ds
mov ax,3
int 10h
mov ax,0b800h
mov es,ax
cld
Q0:lea dx,Tips ;提示输入时间
mov ah,9
int 21h
;输入当前时、分、秒值
call input_bcd
mov HH,al
mov ax,0e3ah ;':'
int 10h
call input_bcd
mov MM,al
mov ax,0e3ah ;':'
int 10h
call input_bcd
mov dh,al
mov ch,HH
cmp ch,23H
ja Q1
mov cl,MM
cmp cl,59H
ja Q1
cmp dh,59H
jbe Q2
Q1:lea dx,Err
mov ah,9
int 21h
jmp Q0
Q2:mov ah,3
int 1ah
call xssj
mov ah,4ch
int 21h

input_bcd:
mov cl,4
call key
shl al,cl
mov dl,al
call key
add al,dl
ret

key:
mov ah,0
int 16h
cmp al,'0'
jb key
cmp al,'9'
ja key
mov ah,0eh
int 10h
sub al,'0'
ret

xssj:
mov di,(80*10+30)*2
T1:mov ah,04 ;CX=2009 DX=0222
int 1ah;读取日期
;出口参数:CX=年,DX=月/日
mov al,ch;显示年
call disp
mov al,cl
call disp
mov al,'-'
stosb
mov al,0ah;绿色
stosb
mov al,dh;显示月
call disp
mov al,'-'
stosb
mov al,0ah;绿色
stosb
mov al,dl;显示日
call disp
mov al,20h
stosb
mov al,0ah;绿色
stosb
mov ah,02 ;CX=1252 DX=0300
int 1ah;读取当前时间
;出口参数:CX=时/分;DH=秒
mov al,ch;显示时
call disp
mov al,':'
stosb
mov al,0ah;绿色
stosb
mov al,cl;显示分
call disp
mov al,':'
stosb
mov al,0ah;绿色
stosb
mov al,dh;显示秒
call disp
mov ah,01
int 16h;读键盘
jz xssj ;无字符输入,继续显示时间
mov ah,0
int 16h
cmp al,1bh
jnz xssj
ret

disp:
push cx
mov ah,al
mov cx,4
shr al,cl
and al,0fh
or al,30h
stosb
mov al,0ah;绿色
stosb
mov al,ah
and al,0fh
or al,30h
stosb
mov al,0ah;绿色
stosb
pop cx
ret

Tips db ' Input Current Time'
db 0dh,0ah,' HH:MM:SS $'
Err db 0dh,0ah,'Input Error!',0dh,0ah,'$'

HH db 0
MM db 0

code ends
end start
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-05-23
我的思路是用死循环在端口读写时间并显示,一输入完数字除了用端口改写时间之外,再立即修改键盘中断。等按下去退出就恢复原键盘中断入口。
相似回答