+ -
当前位置:首页 → 问答吧 → 有谁可以帮我看一下这个程序么。

有谁可以帮我看一下这个程序么。

时间:2011-06-09

来源:互联网

assume cs:code,ds:data
;******************************************************************************
data segment
message1 db "please input the time to alarm(eg.11/06/07 12:36:56):",0ah,0dh,'$'
time db "00/00/00 00:00:00",0ah,0dh,'$'
buffer db "00/00/00 00:00:00",0ah,0dh,'$'
clear db " ",0ah,0dh,'$'
message2 db "---good bye!---",0ah,0dh,'$'
data ends
;******************************************************************************
code segment
start:
mov ax,data
mov ds,ax

lea dx,message1
mov ah,9
int 21h

mov si,0
mov cx,17
set:
mov ah,1
int 21h
mov buffer[si],al ;设定时间响铃
inc si
loop set


mov cx,1
endless: ;无限循环

call main
;call compare_alarm

mov bh,0
mov dh,3
mov dl,0 ;将光标移动到第0页第3行第0列
mov ah,2
int 10h
lea dx,time
mov ah,9 ;显示时间
int 21h

call compare_alarm

mov bl,2
back:
mov cx,33144
call waitf
dec bl ;时间延迟一秒
jnz back 

mov ah,1
int 16h ;检测键盘状态,若有输入则程序中止
jnz exit

call clearscreen

mov cx,2 ;无限循环

loop endless

exit:
lea dx,message2
mov ah,9
int 21h
mov ax,4c00h ;结束
int 21h
;******************************************************************************
main:
mov cx,3
mov di,0
mov bl,9 ;bl表示CMOS RAM中的单元号
;******************************************************************************
s1:
push cx ;循环次数入栈

mov al,bl
out 70h,al
in al,71h

mov ah,al ;从71号端口的第9、8、7号单元分别获取年、月、日
mov cl,4
shr ah,cl ;ah代表十位数
and al,00001111b ;al代表个位数

add ah,30h ;BCD码转化成十进制数对应的ASCII码
add al,30h

mov time[di],ah
mov time[di+1],al ;数据放入time中
add di,3

pop cx ;循环次数出栈
dec bl
loop s1
;******************************************************************************
mov cx,3
sub bl,2 ;使bl置成4
s2:
push cx ;循环次数入栈

mov al,bl
out 70h,al
in al,71h

mov ah,al
mov cl,4 ;从71号端口的第4、2、0号单元分别获取时、分、秒
shr ah,cl
and al,00001111b

add ah,30h
add al,30h

mov time[di],ah
mov time[di+1],al ;时间数据写入time中
add di,3

pop cx ;循环次数出栈
sub bl,2
loop s2
;******************************************************************************
ret
;******************************************************************************
clearscreen:

mov bh,0
mov dh,3
mov dl,0 ;将光标移动到第0页第3行第0列
mov ah,2
int 10h  

lea dx,clear
mov ah,9 ;清屏
int 21h

ret
;******************************************************************************
waitf proc near
push ax
waitf1:
in al,61h
and al,10h
cmp al,ah
je waitf1 ;延迟0.5秒
mov ah,al
loop waitf1
pop ax
ret 
waitf endp
;******************************************************************************
compare_alarm:

mov cx,17
mov si,0

cp:
mov dh,buffer[si]
mov dl,time[si] ;比较预定时间和当前时间是否相同
cmp dh,dl
jnz point
inc si 
loop cp

call alarm

point:
ret
;******************************************************************************
alarm:
mov cx,20
a:
mov dl,7
mov ah,2 ;响铃20次
int 21h
loop a
ret  
;******************************************************************************
code ends
end start

在设定时间的时候,为什么第17个字符始终无法输入。。

作者: BIN_413799245   发布时间: 2011-06-09

很急,请各位大侠帮帮忙。

作者: BIN_413799245   发布时间: 2011-06-09