七段码电子表显示程序.docx
《七段码电子表显示程序.docx》由会员分享,可在线阅读,更多相关《七段码电子表显示程序.docx(20页珍藏版)》请在冰豆网上搜索。
七段码电子表显示程序
1.题目及要求``````````````````````````````````````````2
2.功能设计`````````````````````````````````````````````2
3.详细设计`````````````````````````````````````````````2
3.1设计方法``````````````````````````````````````````````````````````2
3.2流程图`````````````````````````````````````````````````````````````2
3.3重点,难点``````````````````````````````````````````````````````6
4.总结心得体会```````````````````````````````````````````7
5.参考文献````````````````````````````````````````````````7
6.附:
源程序```````````````````````````````````````````````7
1.题目及要求
1.1题目:
七段码电子表显示程序
1.2要求
1.七段码电子表显示程序
2.菜单选择:
设置时,分,秒,开始,退出等
3.模拟七段码管显示时,分,秒
4.要求界面美
2.功能设计
说明:
esc键退出s键设置时间
数据段
(1)Disptime,showtime显示时钟
(2)定义定义0-9十个图形数字,以便模拟七段码显示时钟
宏定义
(1)Clear定义清屏宏
(2)rowcol定义光标定位宏
(3)crlf回车换行宏
(4)display显示字符串宏
(5)change计算时间宏
函数
(1)main主函数
(2)play主要完成显示七段码电子表显示
(3)prog0到prog10完成七段码到一般显示的转换
(4)moveshape显示七段码电子表
(4)delay延迟函数
(5)exit返回DOS函数
3.设计详细
3.1设计方法
(1)Clears清屏宏用到了BIOS中断06H。
(2)rowcol光标定位宏用到了BIOS中断02H。
(3)crlf回车换行宏用到了DOS中断的0ah,0dh
(4)display显示字符串宏用到了DOS中断的09h
(5)change计算时间宏用户自己定义的宏,方便以后使用
(6)main主函数主要调用子函数实现功能
(7)delayr延迟函数用双重循环实现,根据不同机子设置不同的参数
(8)exit返回DOS函数,也就是结束函数。
调用int21h中的04h
(9)moveshape显示七段码电子表函数。
利用int21h中的09h
3.2流程图
Play函数
Delay函数
3.3重点,难点
本程序的重点是怎么把系统时间转化成七段码显示出来,先把吧0到9十个数字,利用相对坐标表示出来。
然后在依依和系统时间的时、分、秒对比,相等则输出,这样就把系统时间的显示方式,改变成七段码表显示方式了。
然而要实现以上功能实在不容易,经过多番努力,最后才实现了系统时间到七段码的转化。
接下来设置时间,取DOS中断的2DH,把输入的时间转化成七段码。
再下来是加上窗口,优化程序,整理界面,使程序更加好理解。
4.总结
心得体会
学习了汇编语言这门课程,对它有了基本的了解和认识。
以为可以对付一些简单的程序的,但是拿到题目还是无从下手。
幸好得到了同学的帮助,才一点点起步,到后面完成。
最后运行自己程序的时候,喜悦真是难以言表。
很感谢帮助过我的同学和老师,没有他们的帮助,我真不知道课程设计能否按时完成。
对于所学的这个专业,编写程序是基本技能,可是自己却不能独立完成课程设计,自责的感觉油然而生,我相信在今后的学习中,自己能够吸取教训。
5.参考文献
1.东扬生等编著:
“宏汇编语言MASM6实用大全”,科学,1993
2.求伯军主编:
“新编深入DOS编程”,学苑,1994
3.沈美明温冬婵主编:
“IBM-PC汇编语言程序设计”,清华大学,2001
6.附:
源程序
datasegment
DisptimeDB00,00,":
",00,00,":
",00,00,"$"
showtimedwA10,A11,A12,A13,A14,A15,A16,A17,A18,A19
escapeequ1bh;按键ESC退出
zhaodb0dh,0ah,'Press's'tosettime.$'
db0dh,0ah,'Press'esc'toend!
$'
bingdb0dh,0ah,'CLOCK$'
stimedb9,(?
),9dup(?
)
signdb0
;*****定义0-9十个图形数字*****
s0db6
db5fh,0ah,0,0
db7ch,0ah,1,-1
db7ch,0ah,1,0
db5fh,0ah,0,1
db7ch,0ah,0,1
db7ch,0ah,-1,0
s1db2
db7ch,0ah,1,0
db7ch,0ah,1,0
s2db5
db5fh,0ah,0,0
db7ch,0ah,1,1
db5fh,0ah,0,-1
db7ch,0ah,1,-1
db5fh,0ah,0,1
s3db5
db5fh,0ah,0,0
db7ch,0ah,1,1
db5fh,0ah,0,-1
db7ch,0ah,1,1
db5fh,0ah,0,-1
s4db4
db7ch,0ah,1,0
db5fh,0ah,0,1
db7ch,0ah,1,1
db7ch,0ah,-1,0
s5db5
db5fh,0ah,0,0
db7ch,0ah,1,-1
db5fh,0ah,0,1
db7ch,0ah,1,1
db5fh,0ah,0,-1
s6db6
db5fh,0ah,0,0
db7ch,0ah,1,-1
db5fh,0ah,0,1
db7ch,0ah,1,1
db5fh,0ah,0,-1
db7ch,0ah,0,-1
s7db3
db5fh,0ah,0,0
db7ch,0ah,1,1
db7ch,0ah,1,0
s8db7
db7ch,0ah,1,0
db5fh,0ah,-1,1
db7ch,0ah,1,1
db5fh,0ah,0,-1
db7ch,0ah,1,1
db5fh,0ah,0,-1
db7ch,0ah,0,-1
s9db6
db7ch,0ah,1,0
db5fh,0ah,-1,1
db7ch,0ah,1,1
db5fh,0ah,0,-1
db7ch,0ah,1,1
db5fh,0ah,0,-1
s10db2
db03h,0ah,1,0
db03h,0ah,1,0
dataends
;...................
codesegment
crlfMACRO
pushax
pushbx
pushcx
pushdx
movah,02h
movdl,0ah
int21h
movah,02h
movdl,0dh
int21h
popdx
popcx
popbx
popax
ENDM
;....................
clearmacroala,ulrow,ulcol,lrrow,lrcol,att
pushax
pushbx
pushcx
pushdx
movah,6
moval,ala;属性
movbh,ulrow;页号
movch,ulcol;左上角行号
movcl,lrrow;左上角列号
movdh,lrcol;右下角行号
movdl,att;右下角列号
int10h
popdx
popcx
popbx
popax
endm
;........................
rowcolmacrorow,col;光标定位
pushax
pushbx
pushcx
pushdx
pushdi
movbh,0
movdh,row
movdl,col
movah,02h
int10h
popdi
popdx
popcx
popbx
popax
endm
changemacroc1,c2,c3;系统时间
moval,c1
cbw
divbh
addal,'0'
movDisptime[c2],al
addah,'0'
movDisptime[c3],ah
endm
change_1macroc1,c2,c3;设定时间
movbh,10
moval,stime[c2]
subal,'0'
mulbh
addal,stime[c3]
subal,'0'
movc1,al
endm
;...............................................................................
assumecs:
code,ds:
data
;---------------------------------------------------------------------------------
;主函数
start:
movax,data
movds,ax
next:
calldelay
moval,sign
cmpal,1bh
jeA1_1
cmpal,'s'
jesettime
jmpA1_2
A1_1:
jmpexit
settime:
rowcol18,22
leadx,stime
movah,0ah;接受键盘输入
int21h
movah,2
movbh,0
movdh,18
movdl,22
int21h
change_1ch,2,3
change_1cl,5,6
change_1dh,8,9
movdl,00
movah,2dh;置系统时间
int21h
cmpal,0
jneA1_1
jmpA1_2
A1_2:
clear0,07h,0,0,24,79
clear0,44h,4,19,23,60
clear0,07h,6,20,7,59
clear0,07h,9,20,13,59;从第四行,20列开始
clear0,07h,16,20,22,59
movah,2
movbh,0
movdh,6;确定“clock”的输出行
movdl,25;确定的"clock"的输出列
int10h
movah,9;显示字符串
leadx,bing
int21h
movah,2ch;取系统时间
int21h
movbh,10
changech,0,1
changecl,3,4
changedh,6,7
movdl,00
movbx,0
movdh,10
movdl,25
show:
pushdx
movax,dx
rowcolah,al
moval,Disptime[bx]
cmpal,':
'
jeA20
subal,'0'
shlal,1
CBW
MOVSI,AX
JMPshowtime[SI]
next1:
popdx
adddx,0004h
incbx
cmpbx,8
jaenext2
jmpshow
next2:
jmpnext
A10:
callprog0
jmpnext1
A11:
callprog1
jmpnext1
A12:
callprog2
jmpnext1
A13:
callprog3
jmpnext1
A14:
callprog4
jmpnext1
A15:
callprog5
jmpnext1
A16:
callprog6
jmpnext1
A17:
callprog7
jmpnext1
A18:
callprog8
jmpnext1
A19:
callprog9
jmpnext1
A20:
callprog10
jmpnext1
;............................
prog0proc
leadi,s0
callmoveshape
ret
prog0endp
prog1proc
leadi,s1
callmoveshape
ret
prog1endp
prog2proc
leadi,s2
callmoveshape
ret
prog2endp
prog3proc
leadi,s3
callmoveshape
ret
prog3endp
prog4proc
leadi,s4
callmoveshape
ret
prog4endp
prog5proc
leadi,s5
callmoveshape
ret
prog5endp
prog6proc
leadi,s6
callmoveshape
ret
prog6endp
prog7proc
leadi,s7
callmoveshape
ret
prog7endp
prog8proc
leadi,s8
callmoveshape
ret
prog8endp
prog9proc
leadi,s9
callmoveshape
ret
prog9endp
prog10proc
leadi,s10
callmoveshape
ret
prog10endp
moveshapeprocnear;对字符的输出
pushax
pushbx
pushcx
pushdx
pushdi
movah,0fh
int10h
subch,ch
movcl,[di]
incdi
plotnext:
adddh,[di+2]
adddl,[di+3]
movah,2
int10h
moval,[di]
movbl,[di+1]
pushcx
movcx,1
movah,09
int10h
popcx
adddi,4
loopplotnext
popdi
popdx
popcx
popbx
popax
ret
moveshapeendp
delayprocnear
pushax
pushcx
pushdx
movcx,10000
b1:
pushcx
b2:
loopb2
popcx
movdl,0ffh
movah,06h
int21h
cmpal,1bh
jeC11
cmpal,'s'
jeC11
loopb1
C11:
movsign,al
popdx
popcx
popax
ret
delayendp
exit:
movah,4ch
int21h
codeends
endstart