接口课程设计出租车计价器.docx
《接口课程设计出租车计价器.docx》由会员分享,可在线阅读,更多相关《接口课程设计出租车计价器.docx(27页珍藏版)》请在冰豆网上搜索。
接口课程设计出租车计价器
信息科学与技术学院
微机原理与接口技术课程设计报告
1.方案选择1
1.1题目:
1
1.2要求:
1
2.程序设计与分析1
2.1功能设计1
2.1.1输出字符串宏(str)1
2.1.2定义光标定位宏1
2.1.3清屏宏(clearscreen)1
2.1.4延时模块1
2.1.5数字显示模块2
2.1.6数字自增模块2
2.1.7设置单价模块2
2.2主程序设计2
2.2.1主函数2
2.3字符串宏模块3
2.3.1本设计的方法,计算公式3
2.3.2本模块的流程图:
3
2.3.3本设计的重点、难点和解决方法3
2.4字显示成数的形式的disp子程序4
2.5自加功能:
5
3.程序运行界面6
5.总结6
6.参考文献:
7
7.附原程序:
8
1.方案选择
1.1题目:
出租车计价器
1.2要求:
1.计价功能
2.手动设计单价
3.显示里程、单价与总价
4.据时间设定单价
2.程序设计与分析
2.1功能设计
2.1.1输出字符串宏(str)
功能:
将字符串定义在宏里面,然后输出。
2.1.2定义光标定位宏
功能:
指定光标的位置。
2.1.3清屏宏(clearscreen)
功能:
设置开始和结尾的行列数以及属性。
2.1.4延时模块
功能:
延缓每次显示的时间,使之能够准确的输出。
2.1.5数字显示模块
功能:
显示所有的数字内容,其中包括行驶过程中的价格,和里程的显示。
在数据段中定义数字的格式,通过中断显示出数字能容。
光标定位,使数字显示在指定的位置。
2.1.6数字自增模块
功能:
设计程车每走100m,总价格增加0.2元,起步价为5元。
此时在行驶的里程中,不断的加100m,当达到3km的时候,通过cx的判断,使价格从5元开始,每走100m加0.2元。
需要用到延时程序,和跳转功能。
2.1.7设置单价模块
功能:
手动设置单价,设定每公里要走的单价。
在数据段定义后,每输入一次,通过取数据段的数据,完成定价的功能。
2.2主程序设计
2.2.1主函数
2.3字符串宏模块
2.3.1本设计的方法,计算公式
显示字符串是本模块的功能,方法是将字符串传送到’dx’中,然后用’09’中断输出。
2.3.2本模块的流程图:
2.3.3本设计的重点、难点和解决方法
我认为本设计的重点和难点在于字符串的传送,解决方法在于用09输出和字符串的定义一起搭配使用。
2.4字显示成数的形式的disp子程序
2.5自加功能:
3.程序运行界面
5.总结
在这次的课程设计中,学到的知识有很多,收获也不小。
可以从理论结合实际,可以把身边的一些所涉及到的编程工具自己也能够体会和学习一下。
比如这次所做的计程车计价器。
由于能力有限不能拿单片机或仿真的工具来做,只是用汇编基础的模拟了一下,其中也了解到了最基本的原理,锻炼了自己的基础知识水平。
可以用到将来的实际应用当中。
能够体会到其中的乐趣。
但是这次也有许多的问题,首先是自己的编程水平不好,所以做起来速度很慢,需要以后多多练习,实验。
有些功能还没有能够实现,所以还需要进一步的学习,要学的知识还有很多,还应该花更多的精力在这些方面,这样才能够提高自己的专业水平。
汇编语言和微机接口原理也是最基层的计算机语言和最接近硬件的,只有了解了这里的本质,才能更有效准确的运用其他工具。
6.参考文献:
[1]《IBM-PC汇编语言程序设计》沈美明清华大学出版社2001年8月第2版
[2]《IBM-PC汇编语言程序设计例题习题集》沈美明清华大学出版社1991年6月第1版
[3]《微机系统和接口应用技术》朱世鸿著清华大学出版社2006年9月第1版
7.附原程序:
datasegment
valuenumdb00,00,00,".",00,"$";distance
valuenum3db00,00,05,".",00,"$";price
num1db"totalvalue","$"
num2db"distance","$"
num3db"km","$"
num4db"yuan","$"
stopdb"*pressstostop!
","$"
go_ondb"*pressgtogoon","$"
shuzidb"_",0dh,0ah,"$"
db"||",0dh,0ah,"$"
db"|_|",0dh,0ah,"$"
db"",0dh,0ah,"$"
db"|",0dh,0ah,"$"
db"|",0dh,0ah,"$"
db"_",0dh,0ah,"$"
db"_|",0dh,0ah,"$"
db"|_",0dh,0ah,"$"
db"_",0dh,0ah,"$"
db"_|",0dh,0ah,"$"
db"_|",0dh,0ah,"$"
db"",0dh,0ah,"$"
db"|_|",0dh,0ah,"$"
db"|",0dh,0ah,"$"
db"_",0dh,0ah,"$"
db"|_",0dh,0ah,"$"
db"_|",0dh,0ah,"$"
db"_",0dh,0ah,"$"
db"|_",0dh,0ah,"$"
db"|_|",0dh,0ah,"$"
db"_",0dh,0ah,"$"
db"|",0dh,0ah,"$"
db"|",0dh,0ah,"$"
db"_",0dh,0ah,"$"
db"|_|",0dh,0ah,"$"
db"|_|",0dh,0ah,"$"
db"_",0dh,0ah,"$"
db"|_|",0dh,0ah,"$"
db"_|",0dh,0ah,"$"
dataends
poscursemacrodh1,dl1;定义光标定位宏
pushax
pushbx
pushdx
movah,2h
movbh,0h
movdh,dh1;光标行坐标位置
movdl,dl1;光标列坐标位置
int10h;movah,2hint10h是10号中断的2号功能,设置光标位置
popdx
popbx
popax
endm
codesegment
assumecS:
code,ds:
data
mainprocfar
movax,data
movds,ax
clearmacroaL1,bh1,ch1,cl1,dh1,dl1
MOVAH,06H;初始化屏幕,10号中断的6号功能
movaL,aL1
movbh,bh1
movch,ch1
movcl,cl1
movdh,dh1
movdl,dl1
INT10H
endm
clear0,01000000b,2,3,20,75
clear0,00011110b,5,5,18,73
movcx,0
B:
inccx
cmpcx,32
jzc;不相等则跳转到c
calldisp3
calldelay
calldisp2
calldelay
calldelay
callinc_2
calldelay
movah,0bh
int21h
incal
jnzb
movah,01h
int21h
cmpal,'s'
jnzb
jmpa
c:
clear0,01000000b,2,3,20,75
clear0,00011110b,5,5,18,73
calldisp1;显示价格
calldelay
callinc_1;价格加2
calldelay
calldisp2;显示里程
calldelay
callinc_2;里程加2
calldelay
movah,0bh
int21h
incal
jnzc
movah,01h
int21h
cmpal,'s'
jnzc
jmpa
m:
jmpb
a:
movah,0bh
int21h
incal
jnza
movah,01h
int21h
cmpal,'g'
jnza
moval,[valuenum]
cmpal,0
jac
moval,[valuenum+1]
cmpal,0
jac
moval,[valuenum+2]
cmpal,3
jac
cmpal,3
jnzm
jmpc
RET
mainendp
;-----output子程序-----
outputprocnear
pushax
movah,09h
int21h
popax
ret
outputendp
;inc_1子程序
inc_1procnear
pushax
moval,[valuenum3+4]
incal
incal
mov[valuenum3+4],al
cmpal,0ah
jnzreturn3
mov[valuenum3+4],00h
moval,[valuenum3+2]
incal
mov[valuenum3+2],al
cmpal,0ah
jnzreturn3
mov[valuenum3+2],00h
moval,[valuenum3+1]
incal
mov[valuenum3+1],al
cmpal,0ah
jnzreturn3
mov[valuenum3+1],00h
moval,[valuenum]
incal
mov[valuenum3],al
cmpal,0ah
jnzreturn3
mov[valuenum3],00h
return3:
popax
ret
inc_1endp
;inc_2子程序
inc_2procnear
pushax
moval,[valuenum+4]
incal
mov[valuenum+4],al
cmpal,0ah
jnzreturn
mov[valuenum+4],00h
moval,[valuenum+2]
incal
mov[valuenum+2],al
cmpal,0ah
jnzreturn
mov[valuenum+2],00h
moval,[valuenum+1]
incal
mov[valuenum+1],al
cmpal,0ah
jnzreturn
mov[valuenum+1],00h
moval,[valuenum]
incal
mov[valuenum],al
cmpal,0ah
jnzreturn
mov[valuenum],00h
return:
popax
ret
inc_2endp
;-----delay子程序-----
delayprocnear
pushbx
pushax
pushcx
movbl,75d
waitf2:
movcx,1000d
waitf1:
inal,61h
andal,10h
cmpal,ah
jewaitf1
movah,al
loopwaitf1
decbl
cmpbl,0
jnzwaitf2
popcx
popax
popbx
ret
delayendp
;-----disp1子程序,从5开始显示-----
disp1procnear
leadx,num1
poscurse09h,6h;坐标位置
calloutput;输出num1里面的字符串
leadx,num2
poscurse0ch,08h
calloutput
leadx,num3
poscurse0ch,23h
calloutput
leadx,num4
poscurse09h,23h
calloutput
leadx,stop
poscurse12h,06h
calloutput
leadx,go_on
poscurse12h,30h
movah,09h;显示dx寄存器地址中的字符串
int21h
moval,[valuenum3]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse07h,13h
adddx,ax
calloutput
poscurse08h,13h
adddx,06h
calloutput
poscurse09h,13h
adddx,06h
calloutput
poscurse07h,16h
moval,[valuenum3+1]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse07h,16h
adddx,ax
calloutput
poscurse08h,16h
adddx,06h
calloutput
poscurse09h,16h
adddx,06h
calloutput
poscurse07h,19h
moval,[valuenum3+2]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse07h,19h
adddx,ax
calloutput
poscurse08h,19h
adddx,06h
calloutput
poscurse09h,19h
adddx,06h
calloutput
poscurse09h,1ch
movdl,2eh
movah,02h;调用系统时间
int21h
poscurse07h,1eh
moval,[valuenum3+4]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse07h,1eh
adddx,ax
calloutput
poscurse08h,1eh
adddx,06h
calloutput
poscurse09h,1eh
adddx,06h
calloutput
ret
disp1endp
;-----disp2子程序-----
disp2procnear
pushax
moval,[valuenum]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse0ah,13h
adddx,ax
calloutput
poscurse0bh,13h
adddx,06h
calloutput
poscurse0ch,13h
adddx,06h
calloutput
poscurse0ah,16h
moval,[valuenum+1]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse0ah,16h
adddx,ax
calloutput
poscurse0bh,16h
adddx,06h
calloutput
poscurse0ch,16h
adddx,06h
calloutput
poscurse0ah,19h
moval,[valuenum+2]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse0ah,19h
adddx,ax
calloutput
poscurse0bh,19h
adddx,06h
calloutput
poscurse0ch,19h
adddx,06h
calloutput
poscurse0ch,1ch
movdl,2eh
movah,02h
int21h
poscurse0ah,1eh
moval,[valuenum+4]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse0ah,1eh
adddx,ax
calloutput
poscurse0bh,1eh
adddx,06h
calloutput
poscurse0ch,1eh
adddx,06h
calloutput
popax
ret
disp2endp
;-----disp3子程序-----
disp3procnear
leadx,num1;取num的地址送dx
poscurse09h,6h
movah,09h
int21h
leadx,num2
poscurse0ch,8h
movah,09h
int21h
leadx,num3
poscurse0ch,23h
calloutput
leadx,num4
poscurse09h,23h
calloutput
leadx,stop
poscurse12h,06h
movah,09h
int21h
leadx,go_on
poscurse12h,30h
calloutput
moval,[valuenum3]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse07h,13h
adddx,ax
calloutput
poscurse08h,13h
adddx,06h
calloutput
poscurse09h,13h
adddx,06h
calloutput
poscurse07h,16h
moval,[valuenum3+1]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse07h,16h
adddx,ax
calloutput
poscurse08h,16h
adddx,06h
calloutput
poscurse09h,16h
adddx,06h
calloutput
poscurse07h,19h
moval,[valuenum3+2]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse07h,19h
adddx,ax
calloutput
poscurse08h,19h
adddx,06h
calloutput
poscurse09h,19h
adddx,06h
calloutput
poscurse09h,1ch
movdl,2eh
movah,02h
int21h
poscurse07h,1eh
moval,[valuenum3+4]
movbl,12h
mulbl
movdx,offsetshuzi
poscurse07h,1eh
adddx,ax
calloutput
poscurse08h,1eh
adddx,06h
calloutput
poscurse09h,1eh
adddx,06h
calloutput
ret
disp3endp
codeends
endmain