汇编小闹钟.docx
《汇编小闹钟.docx》由会员分享,可在线阅读,更多相关《汇编小闹钟.docx(12页珍藏版)》请在冰豆网上搜索。
汇编小闹钟
实验题目
小闹钟程序
教师评语
评价指标:
题目内容完成情况优□良□中□差□
对原理的理解程度优□良□中□差□
程序设计水平优□良□中□差□
实验报告结构清晰优□良□中□差□
实验总结和分析详尽优□良□中□差□
实验报告
一、实验目的
通过本综合性、设计性实验使学生进一步巩固课堂所学,全面熟悉、掌握8088宏汇编语言程序设计的基本方法和技巧,进一步提高编写程序、阅读分析程序及上机操作、调试程序的能力。
二、实验要求
1从键盘输入闹铃时间
2程序开始记时,并在屏幕上显示时间(如00:
00:
01)并实时刷新
3时间到,则发出闹铃声,声音维持数秒;同时时间停止刷新
三、实验原理分析
1由键盘输入十进制字符,转化为二进制数值,并保存作为响铃时间
2调用2ch中断获取系统时间,在循环中并用回车返回刷新时间
3将系统实时时间与保存的时间比较,相等则响铃
四、流程图
五、源程序
datasegment
line1db'===========AlarmClock===========','$'
setdb'*Pleaseinputtheringbelltime:
','$'
hdb'*Hour:
','$'
mdb'*Munite:
','$'
sdb'*Second:
','$'
crfdb0ah,0ah,'$'
nowdb'*Thestarttime:
','$'
curdb'=current=','$'
nhdw0
nmdw0
nsdw0
crdb0dh,0ah,'$'
brdb0dh,'$'
rindb'*Thetimeisreach!
','$'
errdb'*quitinput"0":
','$'
line2db'===========ClockClose===========','$'
line3db'===========ClockStart===========','$'
dataends
;*****************************************************************
codesegment
mainprocfar
assumecs:
code,ds:
data
start:
pushds
subax,ax
pushax
movax,data
movds,ax
;输出'===========AlarmClock==========='
movah,9
leadx,line1
int21h
calldropline
;输出'Pleaseinputtheringbelltime:
'
movah,9
leadx,now
int21h
;2ch号功能调用,取系统时间:
ch,cl,dh中分别存放时分秒
movah,2ch
int21h
calldisplayTime
calldropline
;输入响铃时间
callinput
;输出'===========ClockStart==========='
leadx,line3
movah,9
int21h
calldropline
;若输入出错,可输入“0”退出
leadx,err
movah,9
int21h
movah,1
int21h
cmpal,'0'
jzexit
calldropline
;输出'=current='
leadx,cur
movah,9
int21h
calldropline
;实时刷新时间,并检查响铃时间是否到了
s0:
calldisplayTime
;消除光标
movcx,2000h
movah,01h
int10h
;回车刷新
movah,9
leadx,br
int21h
movah,2ch
int21h
;比较时
moval,ch
cbw
cmpax,nh
jnzs0
;比较分
moval,cl
cbw
cmpax,nm
jnzs0
;比较秒
moval,dh
cbw
cmpax,ns
jnzs0
calldropline
;响铃
callringbell
calldropline
;结束输出'===========ClockClose==========='
movah,9
leadx,line2
int21h
exit:
ret
mainendp
;*****************************************************************
;响铃控制
ringbellprocnear
pushbx
pushcx
movah,9
leadx,rin
int21h
movbx,30000
movcx,30000
callsound
popcx
popbx
ret
ringbellendp
;*****************************************************************
;发声子程序,参数为BX,CX
soundprocnear
pushdx
pushax
movdx,cx
inal,61h
andal,10101010b
trig:
xoral,2
out61h,al
movcx,bx
delay:
loopdelay
decdx
jnetrig
popax
popdx
ret
soundendp
;*****************************************************************
;接收输入的时分秒,存入nh,nm,ns
inputprocnear
pushdx
pushax
;输出'Pleaseinputtheringbelltime:
'
movah,9
leadx,set
int21h
calldropline
;接收时
movah,9
leadx,h
int21h
calltansfer
calldropline
movnh,ax
;接收分
movah,9
leadx,m
int21h
calltansfer
calldropline
movnm,ax
;接收秒
movah,9
leadx,s
int21h
calltansfer
calldropline
movns,ax
popdx
popax
ret
inputendp
;*****************************************************************
;输出参数ax存放接受的十进制数实际大小
tansferprocnear
pushbx
movax,0
movah,1
int21h
subal,30h
movbl,al
movah,1
int21h
subal,30h
movbh,al
moval,bl
movbl,10
mulbl
movbl,bh
movbh,0
addax,bx
popbx
ret
tansferendp
;*****************************************************************
displayTimeprocnear
moval,ch;小时的值赋给al
cbw;al扩展成ax,用做除法的被除数
callbindec
movdl,':
';显示":
"
movah,02h
int21h
moval,cl;分
cbw
callbindec
movdl,':
';显示":
"
movah,02h
int21h
moval,dh;秒
cbw
callbindec
ret
displayTimeendp
;*****************************************************************
bindecprocnear
pushax
pushcx
pushdx
movdx,0
movcx,10d
divcx
movbx,dx;先保存余数
movdl,al;显示商(即十进制二位数的十位)
ordl,30h
movah,02h
int21h
movdx,bx;恢复余数的值(十进制二位数的个位)
adddl,30h
movah,02h
int21h
popdx
popcx
popax
ret
bindecendp
;*****************************************************************
;输出空行
droplineprocnear
pushax
pushdx
movah,9
leadx,cr
int21h
popdx
popax
ret
droplineendp
;*****************************************************************
codeends
endstart
六、程序测试
1.输入响铃时间,选择“0”可以退出
2.current处动态刷新时间
3.时间到响铃